Browse Source

Small fixes to custom and gulpfile js

softuart
Xose Pérez 6 years ago
parent
commit
21fb8d8b59
4 changed files with 688 additions and 681 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +634
    -633
      code/espurna/static/index.html.gz.h
  3. +5
    -8
      code/gulpfile.js
  4. +49
    -40
      code/html/custom.js

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


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


+ 5
- 8
code/gulpfile.js View File

@ -42,16 +42,11 @@ const csslint = require('gulp-csslint');
const dataFolder = 'espurna/data/';
const staticFolder = 'espurna/static/';
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.split(search).join(replacement);
};
var toHeader = function(filename) {
var source = dataFolder + filename;
var destination = staticFolder + filename + '.h';
var safename = filename.replaceAll('.', '_');
var safename = filename.split('.').join('_');
var wstream = fs.createWriteStream(destination);
wstream.on('error', function (err) {
@ -64,7 +59,9 @@ var toHeader = function(filename) {
wstream.write('const uint8_t ' + safename + '[] PROGMEM = {');
for (var i=0; i<data.length; i++) {
if (i % 20 == 0) wstream.write('\n');
if (0 === (i % 20)) {
wstream.write('\n');
}
wstream.write('0x' + ('00' + data[i].toString(16)).slice(-2));
if (i<data.length-1) {
wstream.write(',');
@ -76,7 +73,7 @@ var toHeader = function(filename) {
};
function htmllintReporter(filepath, issues) {
var htmllintReporter = function(filepath, issues) {
if (issues.length > 0) {
issues.forEach(function (issue) {
gutil.log(gutil.colors.cyan('[gulp-htmllint] ') + gutil.colors.white(filepath + ' [' + issue.line + ',' + issue.column + ']: ') + gutil.colors.red('(' + issue.code + ') ' + issue.msg));


+ 49
- 40
code/html/custom.js View File

@ -166,8 +166,10 @@ function getData(form) {
// Populate data
$("input,select", form).each(function() {
var name = $(this).attr("name");
if (name) {
var value = "";
// Do not report these fields
@ -179,7 +181,9 @@ function getData(form) {
if ($(this).attr("type") === "checkbox") {
value = $(this).is(":checked") ? 1 : 0;
} else if ($(this).attr("type") === "radio") {
if (!$(this).is(":checked")) {return;}
if (!$(this).is(":checked")) {
return;
}
value = $(this).val();
} else {
value = $(this).val();
@ -187,7 +191,9 @@ function getData(form) {
// Build the object
if (name in data) {
if (!Array.isArray(data[name])) data[name] = [data[name]];
if (!Array.isArray(data[name])) {
data[name] = [data[name]];
}
data[name].push(value);
} else if (is_group.indexOf(name) >= 0) {
data[name] = [value];
@ -196,6 +202,7 @@ function getData(form) {
}
}
});
// Post process
@ -249,12 +256,9 @@ function resetOriginals() {
}
function doReload(milliseconds) {
milliseconds = (typeof milliseconds == "undefined") ?
0 :
parseInt(milliseconds, 10);
setTimeout(function() {
window.location.reload();
}, milliseconds);
}, parseInt(milliseconds, 10));
}
/**
@ -363,19 +367,19 @@ function doReboot(ask) {
var response;
ask = (typeof ask == "undefined") ? true : ask;
ask = (typeof ask === "undefined") ? true : ask;
if (numChanged > 0) {
response = window.confirm("Some changes have not been saved yet, do you want to save them first?");
if (response === true) {
return doUpdate();
return doUpdate();
}
}
if (ask) {
response = window.confirm("Are you sure you want to reboot the device?");
if (response === false) {
return false;
return false;
}
}
@ -386,21 +390,22 @@ function doReboot(ask) {
}
function doReconnect(ask) {
var response;
ask = (typeof ask == "undefined") ? true : ask;
ask = (typeof ask === "undefined") ? true : ask;
if (numChanged > 0) {
response = window.confirm("Some changes have not been saved yet, do you want to save them first?");
if (response === true) {
return doUpdate();
return doUpdate();
}
}
if (ask) {
response = window.confirm("Are you sure you want to disconnect from the current WIFI network?");
if (response === false) {
return false;
return false;
}
}
@ -439,7 +444,7 @@ function doUpdate() {
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(); }
if (response === true) { doReload(0); }
}
resetOriginals();
@ -460,7 +465,7 @@ function doBackup() {
function onFileUpload(event) {
var inputFiles = this.files;
if (inputFiles === undefined || inputFiles.length === 0) {
if (typeof inputFiles === "undefined" || inputFiles.length === 0) {
return false;
}
var inputFile = inputFiles[0];
@ -800,10 +805,20 @@ function initChannels(num) {
var max = num;
if (colors) {
max = num % 3;
if ((max > 0) & useWhite) max--;
if ((max > 0) & useWhite) {
max--
};
}
var start = num - max;
var onChannelSliderChange = function() {
var id = $(this).attr("data");
var value = $(this).val();
var parent = $(this).parents(".pure-g");
$("span", parent).html(value);
websock.send(JSON.stringify({"action": "channel", "data" : { "id": id, "value": value }}));
}
// add templates
var template = $("#channelTemplate").children();
for (var i=0; i<max; i++) {
@ -811,13 +826,7 @@ function initChannels(num) {
var channel_id = start + i;
var line = $(template).clone();
$("span.slider", line).attr("data", channel_id);
$("input.slider", line).attr("data", channel_id).on("change", function() {
var id = $(this).attr("data");
var value = $(this).val();
var parent = $(this).parents(".pure-g");
$("span", parent).html(value);
websock.send(JSON.stringify({"action": "channel", "data" : { "id": id, "value": value }}));
});
$("input.slider", line).attr("data", channel_id).on("change", onChannelSliderChange);
$("label", line).html("Channel " + (channel_id + 1));
line.appendTo("#channels");
@ -830,6 +839,24 @@ function initChannels(num) {
// RFBridge
// -----------------------------------------------------------------------------
function rfbLearn() {
var parent = $(this).parents(".pure-g");
var input = $("input", parent);
websock.send(JSON.stringify({"action": "rfblearn", "data" : {"id" : input.attr("data-id"), "status": input.attr("data-status")}}));
}
function rfbForget() {
var parent = $(this).parents(".pure-g");
var input = $("input", parent);
websock.send(JSON.stringify({"action": "rfbforget", "data" : {"id" : input.attr("data-id"), "status": input.attr("data-status")}}));
}
function rfbSend() {
var parent = $(this).parents(".pure-g");
var input = $("input", parent);
websock.send(JSON.stringify({"action": "rfbsend", "data" : {"id" : input.attr("data-id"), "status": input.attr("data-status"), "data": input.val()}}));
}
function addRfbNode() {
var numNodes = $("#rfbNodes > legend").length;
@ -851,24 +878,6 @@ function addRfbNode() {
return line;
}
function rfbLearn() {
var parent = $(this).parents(".pure-g");
var input = $("input", parent);
websock.send(JSON.stringify({"action": "rfblearn", "data" : {"id" : input.attr("data-id"), "status": input.attr("data-status")}}));
}
function rfbForget() {
var parent = $(this).parents(".pure-g");
var input = $("input", parent);
websock.send(JSON.stringify({"action": "rfbforget", "data" : {"id" : input.attr("data-id"), "status": input.attr("data-status")}}));
}
function rfbSend() {
var parent = $(this).parents(".pure-g");
var input = $("input", parent);
websock.send(JSON.stringify({"action": "rfbsend", "data" : {"id" : input.attr("data-id"), "status": input.attr("data-status"), "data": input.val()}}));
}
// -----------------------------------------------------------------------------
// Processing
// -----------------------------------------------------------------------------


Loading…
Cancel
Save