Merge branch 'master' into noisecouple

This commit is contained in:
Andrew de Quincey 2021-05-04 23:33:31 +01:00
commit 71ecd56499

View File

@ -14,7 +14,11 @@ var temp_scale_display = "C";
var kwh_rate = 0.26; var kwh_rate = 0.26;
var currency_type = "EUR"; var currency_type = "EUR";
var host = "ws://" + window.location.hostname + ":" + window.location.port; var protocol = 'ws:';
if (window.location.protocol == 'https:') {
protocol = 'wss:';
}
var host = "" + protocol + "//" + window.location.hostname + ":" + window.location.port;
var ws_status = new WebSocket(host+"/status"); var ws_status = new WebSocket(host+"/status");
var ws_control = new WebSocket(host+"/control"); var ws_control = new WebSocket(host+"/control");
var ws_config = new WebSocket(host+"/config"); var ws_config = new WebSocket(host+"/config");
@ -134,15 +138,15 @@ function updateProfileTable()
var fields = id.split("-"); var fields = id.split("-");
var col = parseInt(fields[1]); var col = parseInt(fields[1]);
var row = parseInt(fields[2]); var row = parseInt(fields[2]);
if (graph.profile.data.length > 0) { if (graph.profile.data.length > 0) {
if (col == 0) { if (col == 0) {
graph.profile.data[row][col] = timeProfileFormatter(value,false); graph.profile.data[row][col] = timeProfileFormatter(value,false);
} }
else { else {
graph.profile.data[row][col] = value; graph.profile.data[row][col] = value;
} }
graph.plot = $.plot("#graph_container", [ graph.profile, graph.live ], getOptions()); graph.plot = $.plot("#graph_container", [ graph.profile, graph.live ], getOptions());
} }
updateProfileTable(); updateProfileTable();
@ -157,7 +161,7 @@ function timeProfileFormatter(val, down) {
if (down) {rval = val / 60;} else {rval = val * 60;} if (down) {rval = val / 60;} else {rval = val * 60;}
break; break;
case "h": case "h":
if (down) {rval = val / 3600;} else {rval = val * 3600;} if (down) {rval = val / 3600;} else {rval = val * 3600;}
break; break;
} }
return Math.round(rval); return Math.round(rval);
@ -166,7 +170,7 @@ function timeProfileFormatter(val, down) {
function formatDPS(val) { function formatDPS(val) {
var tval = val; var tval = val;
if (time_scale_slope == "m") { if (time_scale_slope == "m") {
tval = val * 60; tval = val * 60;
} }
if (time_scale_slope == "h") { if (time_scale_slope == "h") {
tval = (val * 60) * 60; tval = (val * 60) * 60;
@ -175,10 +179,10 @@ function formatDPS(val) {
} }
function hazardTemp(){ function hazardTemp(){
if (temp_scale == "f") { if (temp_scale == "f") {
return (1500 * 9 / 5) + 32 return (1500 * 9 / 5) + 32
} }
else { else {
return 1500 return 1500
} }
@ -555,8 +559,8 @@ $(document).ready(function()
} }
$('#act_temp').html(parseInt(x.temperature)); $('#act_temp').html(parseInt(x.temperature));
if (x.heat > 0.0) { if (x.heat > 0.0) {
setTimeout(function() { $('#heat').addClass("ds-led-heat-active") }, 0 ) setTimeout(function() { $('#heat').addClass("ds-led-heat-active") }, 0 )
setTimeout(function() { $('#heat').removeClass("ds-led-heat-active") }, (x.heat*1000.0)-5) setTimeout(function() { $('#heat').removeClass("ds-led-heat-active") }, (x.heat*1000.0)-5)
} }
@ -571,7 +575,7 @@ $(document).ready(function()
}; };
// Config Socket ///////////////////////////////// // Config Socket /////////////////////////////////
ws_config.onopen = function() ws_config.onopen = function()
{ {
ws_config.send('GET'); ws_config.send('GET');
@ -586,9 +590,9 @@ $(document).ready(function()
time_scale_profile = x.time_scale_profile; time_scale_profile = x.time_scale_profile;
kwh_rate = x.kwh_rate; kwh_rate = x.kwh_rate;
currency_type = x.currency_type; currency_type = x.currency_type;
if (temp_scale == "c") {temp_scale_display = "C";} else {temp_scale_display = "F";} if (temp_scale == "c") {temp_scale_display = "C";} else {temp_scale_display = "F";}
$('#act_temp_scale').html('º'+temp_scale_display); $('#act_temp_scale').html('º'+temp_scale_display);
$('#target_temp_scale').html('º'+temp_scale_display); $('#target_temp_scale').html('º'+temp_scale_display);
@ -604,7 +608,7 @@ $(document).ready(function()
time_scale_long = "Hours"; time_scale_long = "Hours";
break; break;
} }
} }
// Control Socket //////////////////////////////// // Control Socket ////////////////////////////////
@ -665,12 +669,12 @@ $(document).ready(function()
// if not, update with first available profile name // if not, update with first available profile name
var valid_profile_names = profiles.map(function(a) {return a.name;}); var valid_profile_names = profiles.map(function(a) {return a.name;});
if ( if (
valid_profile_names.length > 0 && valid_profile_names.length > 0 &&
$.inArray(selected_profile_name, valid_profile_names) === -1 $.inArray(selected_profile_name, valid_profile_names) === -1
) { ) {
selected_profile = 0; selected_profile = 0;
selected_profile_name = valid_profile_names[0]; selected_profile_name = valid_profile_names[0];
} }
// fill select with new options from websocket // fill select with new options from websocket
for (var i=0; i<profiles.length; i++) for (var i=0; i<profiles.length; i++)