Browse Source

Remove code

softuart
Xose Pérez 6 years ago
parent
commit
14509efacb
3 changed files with 729 additions and 744 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +671
    -676
      code/espurna/static/index.html.gz.h
  3. +58
    -68
      code/html/custom.js

BIN
code/espurna/data/index.html.gz View File


+ 671
- 676
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 58
- 68
code/html/custom.js View File

@ -12,7 +12,6 @@ var numReconnect = 0;
var numReload = 0; var numReload = 0;
var useWhite = false; var useWhite = false;
var manifest;
var now = 0; var now = 0;
var ago = 0; var ago = 0;
@ -116,7 +115,7 @@ function loadTimeZones() {
]; ];
for (var i in time_zones) { for (var i in time_zones) {
var value = parseInt(time_zones[i], 10);
var value = time_zones[i];
var offset = value >= 0 ? value : -value; var offset = value >= 0 ? value : -value;
var text = "GMT" + (value >= 0 ? "+" : "-") + var text = "GMT" + (value >= 0 ? "+" : "-") +
zeroPad(parseInt(offset / 60, 10), 2) + ":" + zeroPad(parseInt(offset / 60, 10), 2) + ":" +
@ -360,7 +359,7 @@ function doUpgrade() {
function doUpdatePassword() { function doUpdatePassword() {
var form = $("#formPassword"); var form = $("#formPassword");
if (validateForm(form)) { if (validateForm(form)) {
sendConfig(getData(form))
sendConfig(getData(form));
} }
return false; return false;
} }
@ -537,7 +536,7 @@ function createRelayList(data, container, template_name) {
if (current > 0) { return; } if (current > 0) { return; }
var template = $("#" + template_name + " .pure-g")[0]; var template = $("#" + template_name + " .pure-g")[0];
for (var i=0; i<data.length; i++) {
for (var i in data) {
var line = $(template).clone(); var line = $(template).clone();
$("label", line).html("Switch #" + i); $("label", line).html("Switch #" + i);
$("input", line).attr("tabindex", 40 + i).val(data[i]); $("input", line).attr("tabindex", 40 + i).val(data[i]);
@ -552,7 +551,7 @@ function createMagnitudeList(data, container, template_name) {
if (current > 0) { return; } if (current > 0) { return; }
var template = $("#" + template_name + " .pure-g")[0]; var template = $("#" + template_name + " .pure-g")[0];
for (var i=0; i<data.length; i++) {
for (var i in data) {
var magnitude = data[i]; var magnitude = data[i];
var line = $(template).clone(); var line = $(template).clone();
$("label", line).html(magnitudeType(magnitude.type) + " #" + parseInt(magnitude.index, 10)); $("label", line).html(magnitudeType(magnitude.type) + " #" + parseInt(magnitude.index, 10));
@ -672,7 +671,7 @@ function initRelayConfig(data) {
if (current > 0) { return; } if (current > 0) { return; }
var template = $("#relayConfigTemplate").children(); var template = $("#relayConfigTemplate").children();
for (var i=0; i < data.length; i++) {
for (var i in data) {
var relay = data[i]; var relay = data[i];
var line = $(template).clone(); var line = $(template).clone();
$("span.gpio", line).html(relay.gpio); $("span.gpio", line).html(relay.gpio);
@ -699,7 +698,7 @@ function initMagnitudes(data) {
// add templates // add templates
var template = $("#magnitudeTemplate").children(); var template = $("#magnitudeTemplate").children();
for (var i=0; i<data.length; i++) {
for (var i in data) {
var magnitude = data[i]; var magnitude = data[i];
var line = $(template).clone(); var line = $(template).clone();
$("label", line).html(magnitudeType(magnitude.type) + " #" + parseInt(magnitude.index, 10)); $("label", line).html(magnitudeType(magnitude.type) + " #" + parseInt(magnitude.index, 10));
@ -710,15 +709,6 @@ function initMagnitudes(data) {
} }
function getManifest(sensor_id) {
for (var i in manifest) {
if (manifest[i].sensor_id === sensor_id) {
return manifest[i];
}
}
return null;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Lights // Lights
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -866,8 +856,6 @@ function addRfbNode() {
function processData(data) { function processData(data) {
console.log(data);
// title // title
if ("app_name" in data) { if ("app_name" in data) {
var title = data.app_name; var title = data.app_name;
@ -884,13 +872,14 @@ function processData(data) {
Object.keys(data).forEach(function(key) { Object.keys(data).forEach(function(key) {
var i; var i;
var value = data[key];
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Web mode // Web mode
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
if (key === "webMode") { if (key === "webMode") {
password = (1 === data.webMode);
password = (1 === value);
$("#layout").toggle(!password); $("#layout").toggle(!password);
$("#password").toggle(password); $("#password").toggle(password);
} }
@ -921,7 +910,7 @@ function processData(data) {
var nodes = data.rfb; var nodes = data.rfb;
for (i in nodes) { for (i in nodes) {
var node = nodes[i]; var node = nodes[i];
$("input[name='rfbcode'][data-id='" + node["id"] + "'][data-status='" + node["status"] + "']").val(node["data"]);
$("input[name='rfbcode'][data-id='" + node.id + "'][data-status='" + node.status + "']").val(node.data);
} }
return; return;
} }
@ -932,14 +921,14 @@ function processData(data) {
if (key === "rgb") { if (key === "rgb") {
initColorRGB(); initColorRGB();
$("input[name='color']").wheelColorPicker("setValue", data[key], true);
$("input[name='color']").wheelColorPicker("setValue", value, true);
return; return;
} }
if (key === "hsv") { if (key === "hsv") {
initColorHSV(); initColorHSV();
// wheelColorPicker expects HSV to be between 0 and 1 all of them // wheelColorPicker expects HSV to be between 0 and 1 all of them
var chunks = data[key].split(",");
var chunks = value.split(",");
var obj = {}; var obj = {};
obj.h = chunks[0] / 360; obj.h = chunks[0] / 360;
obj.s = chunks[1] / 100; obj.s = chunks[1] / 100;
@ -949,23 +938,24 @@ function processData(data) {
} }
if (key === "brightness") { if (key === "brightness") {
$("#brightness").val(data[key]);
$("span.brightness").html(data[key]);
$("#brightness").val(value);
$("span.brightness").html(value);
return; return;
} }
if (key === "channels") { if (key === "channels") {
var len = data[key].length;
var len = value.length;
initChannels(len); initChannels(len);
for (i=0; i<len; i++) {
$("input.slider[data=" + i + "]").val(data[key][i]);
$("span.slider[data=" + i + "]").html(data[key][i]);
for (i in value) {
var ch = value[i];
$("input.slider[data=" + i + "]").val(ch);
$("span.slider[data=" + i + "]").html(ch);
} }
return; return;
} }
if (key === "useWhite") { if (key === "useWhite") {
useWhite = data[key];
useWhite = value;
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -973,34 +963,31 @@ function processData(data) {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
if (key === "magnitudes") { if (key === "magnitudes") {
initMagnitudes(data[key]);
for (i=0; i<data[key].length; i++) {
var error = data[key][i].error || 0;
var text = (error === 0) ?
data[key][i].value + data[key][i].units :
initMagnitudes(value);
for (i in value) {
var magnitude = value[i];
var error = magnitude.error || 0;
var text = (0 === error) ?
magnitude.value + magnitude.units :
magnitudeError(error); magnitudeError(error);
$("input[name='magnitude'][data='" + i + "']").val(text); $("input[name='magnitude'][data='" + i + "']").val(text);
} }
return; return;
} }
if (key === "manifest") {
manifest = data[key];
}
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// WiFi // WiFi
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
if (key === "maxNetworks") { if (key === "maxNetworks") {
maxNetworks = parseInt(data.maxNetworks, 10);
maxNetworks = parseInt(value, 10);
return; return;
} }
if (key === "wifi") { if (key === "wifi") {
for (i in data.wifi) {
for (i in value) {
var wifi = value[i];
var nwk_line = addNetwork(); var nwk_line = addNetwork();
var wifi = data.wifi[i];
Object.keys(wifi).forEach(function(key) { Object.keys(wifi).forEach(function(key) {
$("input[name='" + key + "']", nwk_line).val(wifi[key]); $("input[name='" + key + "']", nwk_line).val(wifi[key]);
}); });
@ -1017,18 +1004,21 @@ function processData(data) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
if (key === "maxSchedules") { if (key === "maxSchedules") {
maxSchedules = parseInt(data.maxSchedules, 10);
maxSchedules = parseInt(value, 10);
return; return;
} }
if (key === "schedule") { if (key === "schedule") {
for (i in data.schedule) {
for (i in value) {
var schedule = value[i];
var sch_line = addSchedule(); var sch_line = addSchedule();
var schedule = data.schedule[i];
Object.keys(schedule).forEach(function(key) { Object.keys(schedule).forEach(function(key) {
$("input[name='" + key + "']", sch_line).val(schedule[key]);
$("select[name='" + key + "']", sch_line).prop("value", schedule[key]);
$(":checkbox", sch_line).prop("checked", schedule[key]);
var sch_value = schedule[key];
$("input[name='" + key + "']", sch_line).val(sch_value);
$("select[name='" + key + "']", sch_line).prop("value", sch_value);
$(":checkbox[name='" + key + "']", sch_line).
prop("checked", sch_value).
iphoneStyle("refresh");
}); });
} }
return; return;
@ -1039,12 +1029,12 @@ function processData(data) {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
if (key === "relayStatus") { if (key === "relayStatus") {
initRelays(data[key]);
for (i in data[key]) {
initRelays(value);
for (i in value) {
// Set the status for each relay // Set the status for each relay
$("input.relayStatus[data='" + i + "']"). $("input.relayStatus[data='" + i + "']").
prop("checked", data[key][i]).
prop("checked", value[i]).
iphoneStyle("refresh"); iphoneStyle("refresh");
} }
@ -1053,7 +1043,7 @@ function processData(data) {
// Relay configuration // Relay configuration
if (key === "relayConfig") { if (key === "relayConfig") {
initRelayConfig(data[key]);
initRelayConfig(value);
return; return;
} }
@ -1063,13 +1053,13 @@ function processData(data) {
// Domoticz - Relays // Domoticz - Relays
if (key === "dczRelays") { if (key === "dczRelays") {
createRelayList(data[key], "dczRelays", "dczRelayTemplate");
createRelayList(value, "dczRelays", "dczRelayTemplate");
return; return;
} }
// Domoticz - Magnitudes // Domoticz - Magnitudes
if (key === "dczMagnitudes") { if (key === "dczMagnitudes") {
createMagnitudeList(data[key], "dczMagnitudes", "dczMagnitudeTemplate");
createMagnitudeList(value, "dczMagnitudes", "dczMagnitudeTemplate");
return; return;
} }
@ -1079,13 +1069,13 @@ function processData(data) {
// Thingspeak - Relays // Thingspeak - Relays
if (key === "tspkRelays") { if (key === "tspkRelays") {
createRelayList(data[key], "tspkRelays", "tspkRelayTemplate");
createRelayList(value, "tspkRelays", "tspkRelayTemplate");
return; return;
} }
// Thingspeak - Magnitudes // Thingspeak - Magnitudes
if (key === "tspkMagnitudes") { if (key === "tspkMagnitudes") {
createMagnitudeList(data[key], "tspkMagnitudes", "tspkMagnitudeTemplate");
createMagnitudeList(value, "tspkMagnitudes", "tspkMagnitudeTemplate");
return; return;
} }
@ -1095,7 +1085,7 @@ function processData(data) {
// Messages // Messages
if (key === "message") { if (key === "message") {
window.alert(messages[data.message]);
window.alert(messages[value]);
return; return;
} }
@ -1108,32 +1098,32 @@ function processData(data) {
} }
if (key === "now") { if (key === "now") {
now = data[key];
now = value;
ago = 0; ago = 0;
return; return;
} }
if (key == "free_size") { if (key == "free_size") {
free_size = parseInt(data[key], 10);
free_size = parseInt(value, 10);
} }
// Pre-process // Pre-process
if (key === "network") { if (key === "network") {
data.network = data.network.toUpperCase();
data.network = value.toUpperCase();
} }
if (key === "mqttStatus") { if (key === "mqttStatus") {
data.mqttStatus = data.mqttStatus ? "CONNECTED" : "NOT CONNECTED";
data.mqttStatus = value ? "CONNECTED" : "NOT CONNECTED";
} }
if (key === "ntpStatus") { if (key === "ntpStatus") {
data.ntpStatus = data.ntpStatus ? "SYNC'D" : "NOT SYNC'D";
data.ntpStatus = value ? "SYNC'D" : "NOT SYNC'D";
} }
if (key === "uptime") { if (key === "uptime") {
var uptime = parseInt(data[key], 10);
var uptime = parseInt(value, 10);
var seconds = uptime % 60; uptime = parseInt(uptime / 60, 10); var seconds = uptime % 60; uptime = parseInt(uptime / 60, 10);
var minutes = uptime % 60; uptime = parseInt(uptime / 60, 10); var minutes = uptime % 60; uptime = parseInt(uptime / 60, 10);
var hours = uptime % 24; uptime = parseInt(uptime / 24, 10); var hours = uptime % 24; uptime = parseInt(uptime / 24, 10);
var days = uptime; var days = uptime;
data[key] = days + "d " + zeroPad(hours, 2) + "h " + zeroPad(minutes, 2) + "m " + zeroPad(seconds, 2) + "s";
data.key = days + "d " + zeroPad(hours, 2) + "h " + zeroPad(minutes, 2) + "m " + zeroPad(seconds, 2) + "s";
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -1148,14 +1138,14 @@ function processData(data) {
if (input.length > 0) { if (input.length > 0) {
if (input.attr("type") === "checkbox") { if (input.attr("type") === "checkbox") {
input. input.
prop("checked", data[key]).
prop("checked", value).
iphoneStyle("refresh"); iphoneStyle("refresh");
} else if (input.attr("type") === "radio") { } else if (input.attr("type") === "radio") {
input.val([data[key]]);
input.val([value]);
} else { } else {
pre = input.attr("pre") || ""; pre = input.attr("pre") || "";
post = input.attr("post") || ""; post = input.attr("post") || "";
input.val(pre + data[key] + post);
input.val(pre + value + post);
} }
} }
@ -1164,13 +1154,13 @@ function processData(data) {
if (span.length > 0) { if (span.length > 0) {
pre = span.attr("pre") || ""; pre = span.attr("pre") || "";
post = span.attr("post") || ""; post = span.attr("post") || "";
span.html(pre + data[key] + post);
span.html(pre + value + post);
} }
// Look for SELECTs // Look for SELECTs
var select = $("select[name='" + key + "']"); var select = $("select[name='" + key + "']");
if (select.length > 0) { if (select.length > 0) {
select.val(data[key]);
select.val(value);
} }
}); });


Loading…
Cancel
Save