-
-
Save jpsilvashy/5725579 to your computer and use it in GitHub Desktop.
Revisions
-
jpsilvashy revised this gist
Jun 6, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function hostReachable() { var status; // Open new request as a HEAD to the root hostname with a random param to bust the cache xhr.open( "HEAD", "//" + window.location.hostname + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000), false ); // Issue request and handle response try { -
jpsilvashy revised this gist
Jun 6, 2013 . 2 changed files with 18 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ function hostReachable() { // Handle IE and more capable browsers var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" ); var status; // Open new request as a HEAD to the root hostname with a random param to bust the cache xhr.open( "HEAD", "//" + window.location.hostname + "/?rand=" + Math.random(), false ); // Issue request and handle response try { xhr.send(); return ( xhr.status >= 200 && xhr.status < 300 || xhr.status === 304 ); } catch (error) { return false; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +0,0 @@ -
Louis-Rémi Babé revised this gist
Apr 22, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,8 +16,8 @@ function serverReachable() { s = x.status; // Make sure the server is reachable return ( s >= 200 && s < 300 || s === 304 ); // catch network & other problems } catch (e) { return false; } } -
Louis-Rémi Babé revised this gist
Apr 22, 2011 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,8 +5,9 @@ function serverReachable() { x.open( // requesting the headers is faster, and just enough "HEAD", // append a random string to the current hostname, // to make sure we're not hitting the cache "//" + window.location.hostname + "/?rand=" + Math.random(), // make a synchronous request false ); -
Louis-Rémi Babé revised this gist
Apr 22, 2011 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,22 @@ function serverReachable() { // IE vs. standard XHR creation var x = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" ), s; x.open( // requesting the headers is faster, and just enough "HEAD", // append a random string to the current hostname, to make sure we're not hitting the cache "//" + window.location.hostname + "/?rand=" + ( Math.random() * 1E9 ), // make a synchronous request false ); try { x.send(); s = x.status; // Make sure the server is reachable return ( s >= 200 && s < 300 || s === 304 ); } catch (e) { // throws NETWORK_ERR when... there is an problem with the network. return false; } } -
Louis-Rémi Babé created this gist
Apr 22, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ function serverReachable() { var x = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" ), s; x.open( "HEAD" , "//" + window.location.hostname + "/?rand=" + ( Math.random() * 1E9 ), 0); try { x.send(); s = x.status; return ( s >= 200 && s < 300 || s === 304 ); } catch (e) { return false; } }