forked from marva/sumorobot-web
add battery indicator
This commit is contained in:
parent
1ff4ef120b
commit
3b3168203d
@ -14,8 +14,8 @@
|
||||
<script src="sumorobot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="bar">Battery: <span id="battery">0</span>%</div>
|
||||
<div id="stream">
|
||||
<!--<iframe width="100%" height="91%" allowfullscreen="true" src="https://mixer.com/embed/player/14551694"></iframe>-->
|
||||
<div class="btn-group btn-group-justified">
|
||||
<a href="#" class="btn btn-lg btn-danger btn-close">Close</a>
|
||||
</div>
|
||||
|
10
styles.css
10
styles.css
@ -71,6 +71,16 @@ input.has-error {
|
||||
.goog-menuitem-content {
|
||||
font-size: 2em !important;
|
||||
}
|
||||
#bar {
|
||||
right: 0px;
|
||||
z-index: 35;
|
||||
font-size: 2vw;
|
||||
color: #ee4d4d;
|
||||
position: absolute;
|
||||
}
|
||||
#bar.connected {
|
||||
color: #44CC00;
|
||||
}
|
||||
#panel {
|
||||
z-index: 35;
|
||||
width: 100%;
|
||||
|
@ -56,7 +56,12 @@ Sumorobot.prototype.connect = function() {
|
||||
workspace.highlightBlock(evt.data);
|
||||
highlighted = evt.data;
|
||||
} else {
|
||||
console.log(evt.data);
|
||||
var data = evt.data.replace(/'/g, '"').toLowerCase();
|
||||
console.log(data);
|
||||
var battery = JSON.parse(data)["battery_voltage"];
|
||||
battery = Math.round((((battery - 3.6) * 100) / (4.2 - 3.6)));
|
||||
$("#battery").html(battery + "");
|
||||
$("#bar").addClass("connected");
|
||||
}
|
||||
};
|
||||
/* when there is an WebSocket error */
|
||||
@ -434,6 +439,8 @@ window.onload = function() {
|
||||
$("#panel").hide();
|
||||
});
|
||||
|
||||
$("#stream").prepend('<iframe width="100%" height="91%" allowfullscreen="true" src="https://mixer.com/embed/player/14551694"></iframe>');
|
||||
|
||||
/* try to close if block bubble canvas */
|
||||
/*$(document).click(function(e) {
|
||||
var target = e.target;
|
||||
|
Loading…
Reference in New Issue
Block a user