diff --git a/Frontend/server_selector.js b/Frontend/server_selector.js index 848891a..84f7e3b 100644 --- a/Frontend/server_selector.js +++ b/Frontend/server_selector.js @@ -1,12 +1,16 @@ /* - HTML5 Speedtest v4.6.1 MPOT - Server selector + HTML5 Speedtest v4.7 MPOT - Server selector by Federico Dossena https://github.com/adolfintel/speedtest/ GNU LGPLv3 License */ //pings the specified URL, then calls the function result. Result will receive a parameter which is either the time it took to ping the URL, or -1 if something went wrong. -//var PING_TIMEOUT=500; //disabled because it breaks IE11 +var PING_TIMEOUT=1000; +var USE_PING_TIMEOUT=true; //will be disabled on unsupported browsers +if(/MSIE.(\d+\.\d+)/i.test(navigator.userAgent)){ //IE11 doesn't support XHR timeout + USE_PING_TIMEOUT=false; +} function ping(url,result){ var xhr=new XMLHttpRequest(); var t=new Date().getTime(); @@ -29,9 +33,12 @@ function ping(url,result){ result(-1); }.bind(this); xhr.open("GET",url); - /*try{ //disabled because it breaks IE11 - xhr.timeout=PING_TIMEOUT; - }catch(e){}*/ + if(USE_PING_TIMEOUT){ + try{ + xhr.timeout=PING_TIMEOUT; + xhr.ontimeout=xhr.onerror; + }catch(e){} + } xhr.send(); } diff --git a/Frontend/server_selector.min.js b/Frontend/server_selector.min.js index d0e94ce..7aabfdc 100644 --- a/Frontend/server_selector.min.js +++ b/Frontend/server_selector.min.js @@ -1 +1 @@ -function ping(url,result){var xhr=new XMLHttpRequest,t=(new Date).getTime();xhr.onload=function(){if(0==xhr.responseText.length){var instspd=(new Date).getTime()-t;try{var p=performance.getEntries(),d=(p=p[p.length-1]).responseStart-p.requestStart;d<=0&&(d=p.duration),0