Skip to content

Instantly share code, notes, and snippets.

@sarasantos
Created October 10, 2020 11:08
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 sarasantos/c00e585f557e8e2f25ec058069323b71 to your computer and use it in GitHub Desktop.
Save sarasantos/c00e585f557e8e2f25ec058069323b71 to your computer and use it in GitHub Desktop.
function onMessage(event) {
var state;
if (event.data == "1"){
state = "ON";
document.getElementById('button').style.backgroundColor = "COLOR_FOR_ON_BUTTON";
}
else{
state = "OFF";
document.getElementById('button').style.backgroundColor = "COLOR_FOR_OFF_BUTTON";
}
document.getElementById('state').innerHTML = state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment