Last active
August 9, 2018 22:28
-
-
Save lkatney/9c58e9cb5f8bb610c8389c25d7c47943 to your computer and use it in GitHub Desktop.
Visualforce page to detect wifi signal of machine - Salesforce
This file contains 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
<apex:page controller="DetectWifiSignalController"> | |
<style> | |
body{ | |
text-align:center; | |
} | |
h1{ | |
font-size : 20px | |
} | |
#status-section{ | |
font-size : 18px; | |
} | |
</style> | |
<body> | |
<h1>Detect Wifi Signal</h1> | |
<div id="status-section"> | |
Status: <span id="status"></span> | |
</div> | |
<script> | |
function checkWifiStatus(){ | |
Visualforce.remoting.Manager.invokeAction( | |
'{!$RemoteAction.DetectWifiSignalController.checkWifiStatus}', | |
function(result, event){ | |
if (event.status) { | |
console.log('online'); | |
document.getElementById("status").style.color = 'green'; | |
document.getElementById("status").innerHTML = 'Online'; | |
} else if (event.type === 'exception') { | |
console.log('offline', event.message); | |
document.getElementById("status").style.color = 'red'; | |
document.getElementById("status").innerHTML = 'Offline'; | |
} else { | |
console.log('offline',event.message); | |
document.getElementById("status").style.color = 'red'; | |
document.getElementById("status").innerHTML = 'Offline'; | |
} | |
}, | |
{escape: true} | |
); | |
} | |
setInterval(function(){checkWifiStatus()}, 3000); | |
</script> | |
</body> | |
</apex:page> |
This file contains 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
global class DetectWifiSignalController { | |
@RemoteAction | |
global static void checkWifiStatus(){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment