Created
August 22, 2013 03:19
-
-
Save SeanJA/6302851 to your computer and use it in GitHub Desktop.
check if you are connected and you don't have a dead battery.
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 characters
$('.my-form').submit(function(){ | |
var battery = window.navigator.battery.level <= 0.05; | |
var connectivity = window.navigator.onLine; | |
var msg = ''; | |
if(!battery){ | |
msg = "you should probably plug in your computer"; | |
} | |
if(!battery && !connectivity){ | |
msg += ", " | |
} | |
if(!connectivity){ | |
msg += " you don't seem to be online"; | |
} | |
if(msg){ | |
alert("Bugger... " + msg); | |
return false; | |
} | |
return true; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment