Last active
January 10, 2021 11:56
-
-
Save bwaidelich/2b8f58d9cceb7f763bd1d539832dd8db to your computer and use it in GitHub Desktop.
Powered*
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
yep |
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
Powered* | |
power failed -> Unpowered | |
Green* | |
tick -> Yellow | |
Yellow | |
tick -> Red | |
Red | |
tick -> Green | |
Unpowered | |
power restored -> Powered | |
Red On* | |
tick -> Red Off | |
Red Off | |
tick -> Red On |
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
function light(color, is_illuminated){ | |
return $('div', {style: {backgroundColor: color, | |
width: '20px', | |
height: '20px', | |
opacity: is_illuminated ? 1 : 0.2}}); | |
} | |
//A function that draws all of our lights, based on the current state | |
function render(model){ | |
var active_light = model.active_states[0].name; | |
return $('div', | |
light('Red', active_light === 'Red' || active_light === 'Red On'), | |
light('Yellow', active_light === 'Yellow'), | |
light('Green', active_light === 'Green'), | |
$('button', {style: {position: "relative", left: 50, top: 30}, | |
onClick: function(){ model.emit("tick") }}, | |
"Tick"), | |
$('button', {style: {position: "relative", left: 50, top: 30}, | |
onClick: function(){ model.emit("power failed") }}, | |
"Outage") | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment