Skip to content

Instantly share code, notes, and snippets.

@lkatney
Last active August 9, 2018 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkatney/9c58e9cb5f8bb610c8389c25d7c47943 to your computer and use it in GitHub Desktop.
Save lkatney/9c58e9cb5f8bb610c8389c25d7c47943 to your computer and use it in GitHub Desktop.
Visualforce page to detect wifi signal of machine - Salesforce
<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>
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