diff --git a/web_server/html/js/apscan.js b/web_server/html/js/apscan.js index 4d8b434..e9dd4c5 100644 --- a/web_server/html/js/apscan.js +++ b/web_server/html/js/apscan.js @@ -32,7 +32,15 @@ function getEncryption(num) { function getResults() { toggleScan(true); getResponse("APScanResults.json", function(responseText) { - var res = JSON.parse(responseText); + var res; + try { + res = JSON.parse(responseText); + } catch(e) { + // wut + showMessage("JSON Parsing failed :-(", 2500); + return; + } + // TODO: more sanity checks on res && res.aps res.aps = res.aps.sort(compare); networkInfo.innerHTML = res.aps.length; apMAC.innerHTML = ""; diff --git a/web_server/html/js/attack.js b/web_server/html/js/attack.js index 936fb71..74a4c20 100644 --- a/web_server/html/js/attack.js +++ b/web_server/html/js/attack.js @@ -14,7 +14,15 @@ var data = {}; function getResults() { getResponse("attackInfo.json", function(responseText) { - var res = JSON.parse(responseText); + var res; + try { + res = JSON.parse(responseText); + } catch(e) { + // wut + showMessage("JSON Parsing failed :-(", 2500); + return; + } + // TODO: more sanity checks on res && res.aps var aps = ""; var clients = ""; var tr = "AttackStatusStart/Stop"; diff --git a/web_server/html/js/functions.js b/web_server/html/js/functions.js index 8f2c73c..f2916c4 100644 --- a/web_server/html/js/functions.js +++ b/web_server/html/js/functions.js @@ -28,10 +28,12 @@ function showMessage(msg, closeAfter){ } } + function getResponse(adr, callback, timeoutCallback, timeout, method){ + if(timeoutCallback === undefined) { timeoutCallback = function(){ - showMessage("error loading "+adr); + showMessage("Timeout loading "+adr); }; } if(timeout === undefined) timeout = 8000; @@ -49,4 +51,12 @@ function getResponse(adr, callback, timeoutCallback, timeout, method){ xmlhttp.send(); xmlhttp.timeout = timeout; xmlhttp.ontimeout = timeoutCallback; + + xmlhttp.onabort = function(e) { + showMessage("ABORT "+adr); + }; + xmlhttp.onerror = function(e) { + showMessage("ERROR loading "+adr +" :: "+ this.statusText); + }; + } \ No newline at end of file