Created
April 6, 2022 08:04
-
-
Save boxalljohn/d8445c26db675df628c45311432a9ba2 to your computer and use it in GitHub Desktop.
WFH messaging system front end HTML
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
<html> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/particle-api-js@8/dist/particle.min.js"></script> | |
<script> | |
var particle = new Particle(); | |
// This is incredibly insecure, and only ideal for local tasks of no consequence if things go wrong. | |
const accessToken = 'ENTER YOUR ACCESS TOKEN HERE'; | |
const deviceId = 'ENTER YOUR DEVICE ID HERE'; | |
function ledControl(cmd) { | |
// Used to turn on or off the LED by using the Particle.function "led" | |
document.getElementById("statusSpan").innerHTML = ''; | |
particle.callFunction({deviceId, name:'led', argument: cmd, auth:accessToken}).then( | |
function(data) { | |
document.getElementById("statusSpan").innerHTML = 'Message sent.'; | |
}, | |
function(err) { | |
document.getElementById("statusSpan").innerHTML = 'Error calling device: ' + err; | |
} | |
); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="mainDiv"> | |
<h3>WFH Messaging System</h3> | |
<p><button id="ledOnButton" onclick="ledControl('D1On')">Working Alone.</button> | |
<button id="ledOffButton" onclick="ledControl('D0On')">In a meeting - DND.</button></p> | |
<button id="ledOnButton" onclick="ledControl('D2On')">I need coffee!</button> | |
<button id="ledOffButton" onclick="ledControl('D3On')">Please bring me some water.</button></p> | |
<button id="ledOnButton" onclick="ledControl('D4On')">Finished for the day.</button> | |
<p> </p> | |
<p><span id="statusSpan"></span></p> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment