Browse Source

Process checkboxes data before sending to device

fastled
Xose Pérez 7 years ago
parent
commit
60e8446d1b
3 changed files with 948 additions and 957 deletions
  1. +920
    -917
      code/espurna/static/index.html.gz.h
  2. +1
    -40
      code/espurna/web.ino
  3. +27
    -0
      code/html/custom.js

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


+ 1
- 40
code/espurna/web.ino View File

@ -198,18 +198,7 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
bool changed = false;
bool changedMQTT = false;
bool changedNTP = false;
bool apiEnabled = false;
bool dstEnabled = false;
bool mqttUseJson = false;
bool useColor = false;
bool useWhite = false;
bool useGamma = false;
#if ENABLE_FAUXMO
bool fauxmoEnabled = false;
#endif
#if ENABLE_DOMOTICZ
bool dczEnabled = false;
#endif
unsigned int network = 0;
unsigned int dczRelayIdx = 0;
String adminPass;
@ -291,20 +280,6 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
key = String("adminPass");
}
// Checkboxes
if (key == "apiEnabled") { apiEnabled = true; continue; }
if (key == "ntpDST") { dstEnabled = true; continue; }
if (key == "mqttUseJson") { mqttUseJson = true; continue; }
if (key == "useColor") { useColor = true; continue; }
if (key == "useWhite") { useWhite = true; continue; }
if (key == "useGamma") { useGamma = true; continue; }
#if ENABLE_FAUXMO
if (key == "fauxmoEnabled") { fauxmoEnabled = true; continue; }
#endif
#if ENABLE_DOMOTICZ
if (key == "dczEnabled") { dczEnabled = true; continue; }
#endif
if (key == "ssid") {
key = key + String(network);
}
@ -337,20 +312,6 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
if (webMode == WEB_MODE_NORMAL) {
// Checkboxes
setBoolSetting("apiEnabled", apiEnabled, ENABLE_API);
setBoolSetting("ntpDST", dstEnabled, NTP_DAY_LIGHT);
setBoolSetting("mqttUseJson", mqttUseJson, MQTT_USE_JSON);
setBoolSetting("useColor", useColor, LIGHT_USE_COLOR);
setBoolSetting("useWhite", useWhite, LIGHT_USE_WHITE);
setBoolSetting("useGamma", useGamma, LIGHT_USE_GAMMA);
#if ENABLE_FAUXMO
setBoolSetting("fauxmoEnabled", fauxmoEnabled, FAUXMO_ENABLED);
#endif
#if ENABLE_DOMOTICZ
setBoolSetting("dczEnabled", dczEnabled, DOMOTICZ_ENABLED);
#endif
// Clean wifi networks
int i = 0;
while (i < network) {


+ 27
- 0
code/html/custom.js View File

@ -32,18 +32,45 @@ function validateForm(form) {
}
function valueSet(data, name, value) {
for (var i in data) {
if (data[i]['name'] == name) {
data[i]['value'] = value;
return;
}
}
data.push({'name': name, 'value': value});
}
function doUpdate() {
var form = $("#formSave");
if (validateForm(form)) {
// Get data
var data = form.serializeArray();
// Post-process
delete(data['filename']);
$("input[type='checkbox']").each(function() {
var name = $(this).attr("name");
if (name) {
valueSet(data, name, $(this).is(':checked') ? 1 : 0);
}
});
websock.send(JSON.stringify({'config': data}));
$(".powExpected").val(0);
$("input[name='powExpectedReset']")
.prop("checked", false)
.iphoneStyle("refresh");
}
return false;
}
function doUpgrade() {


Loading…
Cancel
Save