Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created December 24, 2018 20:29
Show Gist options
  • Save AndyNovo/7ae69ef9086709608a0787bc1e175fb2 to your computer and use it in GitHub Desktop.
Save AndyNovo/7ae69ef9086709608a0787bc1e175fb2 to your computer and use it in GitHub Desktop.
ZVyEpR
<div class="container">
<div class="led-box">
<div class="led-red on"></div>
<p>Red LED is <span class="status"></span></p>
</div>
</div>
$( function() {
var $winHeight = $( window ).height()
$( '.container' ).height( $winHeight );
var currentState = true;
let redHandler = firebase.database().ref('red');
redHandler.on('value', function(ss){
let data = ss.val();
if (data == 0){
$(".led-red").removeClass('on').addClass('off');
$(".status").html('OFF');
currentState = false;
} else {
$(".led-red").removeClass('off').addClass('on');
$(".status").html('ON');
currentState = true;
}
});
$(".led-box").click(function(evt){
redHandler.set(!currentState);
});
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
.container {
background-size: cover;
background: rgb(226,226,226);
background: -moz-linear-gradient(top, rgba(226,226,226,1) 0%, rgba(219,219,219,1) 50%, rgba(209,209,209,1) 51%, rgba(254,254,254,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(226,226,226,1)), color-stop(50%,rgba(219,219,219,1)), color-stop(51%,rgba(209,209,209,1)), color-stop(100%,rgba(254,254,254,1)));
background: -webkit-linear-gradient(top, rgba(226,226,226,1) 0%,rgba(219,219,219,1) 50%,rgba(209,209,209,1) 51%,rgba(254,254,254,1) 100%);
background: -o-linear-gradient(top, rgba(226,226,226,1) 0%,rgba(219,219,219,1) 50%,rgba(209,209,209,1) 51%,rgba(254,254,254,1) 100%);
background: -ms-linear-gradient(top, rgba(226,226,226,1) 0%,rgba(219,219,219,1) 50%,rgba(209,209,209,1) 51%,rgba(254,254,254,1) 100%);
background: linear-gradient(to bottom, rgba(226,226,226,1) 0%,rgba(219,219,219,1) 50%,rgba(209,209,209,1) 51%,rgba(254,254,254,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e2e2e2', endColorstr='#fefefe',GradientType=0 );
padding: 20px;
}
.led-box {
height: 30px;
width: 25%;
margin: 10px 0;
float: left;
}
.led-box p {
font-size: 12px;
text-align: center;
margin: 1em;
}
.led-red {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #F00;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 12px;
}
.led-red.off {
background-color: #A00;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.0) 0 2px 0;
}
@-webkit-keyframes blinkRed {
from { background-color: #F00; }
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
to { background-color: #F00; }
}
@-moz-keyframes blinkRed {
from { background-color: #F00; }
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
to { background-color: #F00; }
}
@-ms-keyframes blinkRed {
from { background-color: #F00; }
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
to { background-color: #F00; }
}
@-o-keyframes blinkRed {
from { background-color: #F00; }
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
to { background-color: #F00; }
}
@keyframes blinkRed {
from { background-color: #F00; }
50% { }
to { background-color: #F00; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment