Browse Source

More js fixes

i18n
Xose Pérez 6 years ago
parent
commit
a843698b9f
4 changed files with 656 additions and 656 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +589
    -589
      code/espurna/static/index.html.gz.h
  3. +2
    -4
      code/gulpfile.js
  4. +65
    -63
      code/html/custom.js

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


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


+ 2
- 4
code/gulpfile.js View File

@ -73,8 +73,7 @@ var toHeader = function(filename) {
wstream.write('\n};'); wstream.write('\n};');
wstream.end(); wstream.end();
}
};
function htmllintReporter(filepath, issues) { function htmllintReporter(filepath, issues) {
if (issues.length > 0) { if (issues.length > 0) {
@ -83,8 +82,7 @@ function htmllintReporter(filepath, issues) {
}); });
process.exitCode = 1; process.exitCode = 1;
} }
}
};
gulp.task('build_certs', function() { gulp.task('build_certs', function() {
toHeader('server.cer'); toHeader('server.cer');


+ 65
- 63
code/html/custom.js View File

@ -37,7 +37,7 @@ function sensorName(id) {
"SHT3X I2C", "BH1750" "SHT3X I2C", "BH1750"
]; ];
if (1 <= id && id <= names.length) { if (1 <= id && id <= names.length) {
return names[id-1];
return names[id-1];
} }
return null; return null;
} }
@ -51,7 +51,7 @@ function magnitudeType(type) {
"PM1.0", "PM2.5", "PM10", "CO2", "Lux" "PM1.0", "PM2.5", "PM10", "CO2", "Lux"
]; ];
if (1 <= type && type <= types.length) { if (1 <= type && type <= types.length) {
return types[type-1];
return types[type-1];
} }
return null; return null;
} }
@ -62,7 +62,7 @@ function magnitudeError(error) {
"CRC Error", "I2C Error", "GPIO Error" "CRC Error", "I2C Error", "GPIO Error"
]; ];
if (0 <= error && error < errors.length) { if (0 <= error && error < errors.length) {
return errors[error];
return errors[error];
} }
return "Error " + error; return "Error " + error;
} }
@ -81,7 +81,9 @@ function checkPassword(str) {
function zeroPad(number, positions) { function zeroPad(number, positions) {
var zeros = ""; var zeros = "";
for (var i = 0; i < positions; i++) zeros += "0";
for (var i = 0; i < positions; i++) {
zeros += "0";
}
return (zeros + number).slice(-positions); return (zeros + number).slice(-positions);
} }
@ -167,11 +169,11 @@ function getData(form) {
function randomString(length, chars) { function randomString(length, chars) {
var mask = ""; var mask = "";
if (chars.indexOf("a") > -1) mask += "abcdefghijklmnopqrstuvwxyz";
if (chars.indexOf("A") > -1) mask += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (chars.indexOf("#") > -1) mask += "0123456789";
if (chars.indexOf("@") > -1) mask += "ABCDEF";
if (chars.indexOf("!") > -1) mask += "~`!@#$%^&*()_+-={}[]:\";'<>?,./|\\";
if (chars.indexOf("a") > -1) { mask += "abcdefghijklmnopqrstuvwxyz"; }
if (chars.indexOf("A") > -1) { mask += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
if (chars.indexOf("#") > -1) { mask += "0123456789"; }
if (chars.indexOf("@") > -1) { mask += "ABCDEF"; }
if (chars.indexOf("!") > -1) { mask += "~`!@#$%^&*()_+-={}[]:\";'<>?,./|\\"; }
var result = ""; var result = "";
for (var i = length; i > 0; --i) { for (var i = length; i > 0; --i) {
result += mask[Math.round(Math.random() * (mask.length - 1))]; result += mask[Math.round(Math.random() * (mask.length - 1))];
@ -213,48 +215,6 @@ function doReload(milliseconds) {
}, milliseconds); }, milliseconds);
} }
function doUpdate() {
var form = $("#formSave");
if (validateForm(form)) {
// Get data
var data = getData(form);
websock.send(JSON.stringify({"config": data}));
// Empty special fields
$(".pwrExpected").val(0);
$("input[name='pwrResetCalibration']").
prop("checked", false).
iphoneStyle("refresh");
// Change handling
numChanged = 0;
setTimeout(function() {
var response;
if (numReboot > 0) {
response = window.confirm("You have to reboot the board for the changes to take effect, do you want to do it now?");
if (response === true) doReboot(false);
} else if (numReconnect > 0) {
response = window.confirm("You have to reconnect to the WiFi for the changes to take effect, do you want to do it now?");
if (response === true) doReconnect(false);
} else if (numReload > 0) {
response = window.confirm("You have to reload the page to see the latest changes, do you want to do it now?");
if (response === true) doReload();
}
resetOriginals();
}, 1000);
}
return false;
}
function doUpgrade() { function doUpgrade() {
var contents = $("input[name='upgrade']")[0].files[0]; var contents = $("input[name='upgrade']")[0].files[0];
@ -373,6 +333,48 @@ function doReconnect(ask) {
} }
function doUpdate() {
var form = $("#formSave");
if (validateForm(form)) {
// Get data
var data = getData(form);
websock.send(JSON.stringify({"config": data}));
// Empty special fields
$(".pwrExpected").val(0);
$("input[name='pwrResetCalibration']").
prop("checked", false).
iphoneStyle("refresh");
// Change handling
numChanged = 0;
setTimeout(function() {
var response;
if (numReboot > 0) {
response = window.confirm("You have to reboot the board for the changes to take effect, do you want to do it now?");
if (response === true) { doReboot(false); }
} else if (numReconnect > 0) {
response = window.confirm("You have to reconnect to the WiFi for the changes to take effect, do you want to do it now?");
if (response === true) { doReconnect(false); }
} else if (numReload > 0) {
response = window.confirm("You have to reload the page to see the latest changes, do you want to do it now?");
if (response === true) { doReload(); }
}
resetOriginals();
}, 1000);
}
return false;
}
function doBackup() { function doBackup() {
document.getElementById("downloader").src = webhost + "config"; document.getElementById("downloader").src = webhost + "config";
return false; return false;
@ -491,6 +493,16 @@ function createMagnitudeList(data, container, template_name) {
// Wifi // Wifi
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function delNetwork() {
var parent = $(this).parents(".pure-g");
$(parent).remove();
}
function moreNetwork() {
var parent = $(this).parents(".pure-g");
$(".more", parent).toggle();
}
function addNetwork() { function addNetwork() {
var numNetworks = $("#networks > div").length; var numNetworks = $("#networks > div").length;
@ -514,16 +526,6 @@ function addNetwork() {
} }
function delNetwork() {
var parent = $(this).parents(".pure-g");
$(parent).remove();
}
function moreNetwork() {
var parent = $(this).parents(".pure-g");
$(".more", parent).toggle();
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Relays scheduler // Relays scheduler
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -1111,8 +1113,8 @@ function hasChanged() {
var hasChanged = $(this).attr("hasChanged") || 0; var hasChanged = $(this).attr("hasChanged") || 0;
var action = $(this).attr("action"); var action = $(this).attr("action");
if (typeof originalValue === "undefined") {return;}
if (action === "none") {return;}
if (typeof originalValue === "undefined") { return; }
if (action === "none") { return; }
if (newValue !== originalValue) { if (newValue !== originalValue) {
if (hasChanged === 0) { if (hasChanged === 0) {


Loading…
Cancel
Save