kopia lustrzana https://github.com/botheredbybees/kilnController
Minor JS refactoring
rodzic
30b450c9d3
commit
8f5967479d
|
@ -33,6 +33,7 @@ border-color: #000000;
|
|||
|
||||
.ds-num {
|
||||
font-family: "LCDN";
|
||||
line-height: 38px;
|
||||
}
|
||||
|
||||
#main_status {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var state = "IDLE";
|
||||
var state_last = "";
|
||||
var graph = [ 'profile', 'live'];
|
||||
var points = [];
|
||||
var profiles = [];
|
||||
|
@ -257,8 +258,8 @@ $(document).ready(function()
|
|||
});
|
||||
};
|
||||
|
||||
ws_status.onclose = function()
|
||||
{
|
||||
ws_status.onclose = function()
|
||||
{
|
||||
$.bootstrapGrowl("<span class=\"glyphicon glyphicon-exclamation-sign\"></span> <b>ERROR 1:</b><br/>Status Websocket not available", {
|
||||
ele: 'body', // which element to append to
|
||||
type: 'error', // (null, 'info', 'error', 'success')
|
||||
|
@ -269,11 +270,7 @@ ws_status.onclose = function()
|
|||
allow_dismiss: true,
|
||||
stackup_spacing: 10 // spacing between consecutively stacked growls.
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
eta=0;
|
||||
|
||||
};
|
||||
|
||||
ws_status.onmessage = function(e)
|
||||
{
|
||||
|
@ -298,6 +295,7 @@ ws_status.onclose = function()
|
|||
|
||||
updateProgress(parseFloat(x.runtime)/parseFloat(x.totaltime)*100);
|
||||
$('#state').html(parseInt(parseFloat(x.runtime)/parseFloat(x.totaltime)*100) + '% ' + eta);
|
||||
$('#target_temp').html(parseInt(x.target) + ' \xB0C');
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -307,47 +305,36 @@ ws_status.onclose = function()
|
|||
$('#state').html(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('#act_temp').html(parseInt(x.temperature) + ' \xB0C');
|
||||
$('#heat').css("background-color", (x.heat > 0.5 ? "rgba(233, 28, 0, 0.84)" : "rgba(46, 12, 12, 0.62") );
|
||||
$('#air').css("background-color", (x.air > 0.5 ? "rgba(240, 199, 67, 0.84)" : "rgba(46, 38, 12, 0.62)") );
|
||||
$('#cool').css("background-color", (x.cool > 0.5 ? "rgba(74, 159, 255, 0.84)" : "rgba(12, 28, 46, 0.62)") );
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (x.target == 0)
|
||||
|
||||
// Control Socket ////////////////////////////////
|
||||
|
||||
|
||||
ws_control.onopen = function()
|
||||
{
|
||||
$('#target_temp').html('OFF');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#target_temp').html(parseInt(x.target) + ' \xB0C');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Control Socket ////////////////////////////////
|
||||
|
||||
|
||||
ws_control.onopen = function()
|
||||
{
|
||||
ws_control.onmessage = function(e)
|
||||
{
|
||||
console.log (e.data);
|
||||
}
|
||||
|
||||
console.log("Control Socket has been opened");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Storage Socket ///////////////////////////////
|
||||
// Storage Socket ///////////////////////////////
|
||||
|
||||
ws_storage.onopen = function()
|
||||
{
|
||||
ws_storage.send('GET');
|
||||
};
|
||||
|
||||
ws_storage.onopen = function()
|
||||
{
|
||||
console.log("Storage Socket has been opened");
|
||||
|
||||
ws_storage.onmessage = function(e)
|
||||
{
|
||||
|
@ -357,24 +344,26 @@ ws_storage.onopen = function()
|
|||
{
|
||||
if(message.resp == "FAIL")
|
||||
{
|
||||
if (confirm('Overwrite?')) {
|
||||
if (confirm('Overwrite?'))
|
||||
{
|
||||
message.force=true;
|
||||
console.log("Sending: " + JSON.stringify(message));
|
||||
ws_storage.send(JSON.stringify(message));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//the message is an array of profiles
|
||||
//FIXME: this should be better, maybe a {"profiles": ...} container?
|
||||
profiles = message;
|
||||
//delete old options in select
|
||||
$('#e2')
|
||||
.find('option')
|
||||
.remove()
|
||||
.end();
|
||||
$('#e2').find('option').remove().end();
|
||||
|
||||
// fill select with new options from websocket
|
||||
for (var i=0; i<profiles.length; i++)
|
||||
|
@ -392,25 +381,19 @@ ws_storage.onopen = function()
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log('Requesting stored profiles');
|
||||
ws_storage.send('GET');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$("#e2").select2({
|
||||
$("#e2").select2(
|
||||
{
|
||||
placeholder: "Select Profile",
|
||||
allowClear: false
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#e2").on("change", function(e) {
|
||||
$("#e2").on("change", function(e)
|
||||
{
|
||||
update_profile(e.val);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<div class="pull-left" style="margin: 14px">
|
||||
<span id="act_temp" class="display ds-num" style="color: #75890c">25 °C</span>
|
||||
<span id="target_temp" class="display ds-num">OFF</span>
|
||||
<span id="state" class="display" style="font-size: 14px; text-align: center; padding-right:0">Idle</span>
|
||||
<span id="state" class="display ds-num" style="text-align: center; padding-right:0">Idle</span>
|
||||
<span id="heat" class="display" style="width: 35px; background: rgba(46, 12, 12, 0.62)"> </span>
|
||||
<span id="air" class="display" style="width: 35px; background: rgba(46, 38, 12, 0.62)"> </span>
|
||||
<span id="cool" class="display" style="width: 35px; background: rgba(12, 28, 46, 0.62)"> </span>
|
||||
|
|
Ładowanie…
Reference in New Issue