From df9fecd16a3571138886cab6bd2c87bf0f3cfb80 Mon Sep 17 00:00:00 2001 From: userName Date: Sun, 22 Jul 2018 09:00:02 +0300 Subject: [PATCH] removed blind copy/paste console.log.... improved CSS to comply with CODACY rules --- code/html/custom.css | 19 +++++++++++++------ code/html/custom.js | 35 +++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/code/html/custom.css b/code/html/custom.css index df37d21b..5c4fae71 100644 --- a/code/html/custom.css +++ b/code/html/custom.css @@ -250,9 +250,11 @@ span.slider { position: absolute; left: -99em; } +label[for].toggle{ + margin: 0px; + padding: 0px; +} .toggle{ - margin: 0px !important; - padding: 0px!important; letter-spacing:normal; cursor: pointer; display: inline-block; @@ -277,10 +279,16 @@ span.slider { content: "NO"; left: 20px; } +input[name="relay"] + .toggle:before{ + content: "OFF"; +} .toggle:after{ content: "YES"; right: 20px; } +input[name="relay"] + .toggle:after{ + content: "ON"; +} .toggle__handler{ display: inline-block; position: relative; @@ -307,10 +315,6 @@ input:checked + .toggle:before { input + .toggle:before { color: #fff; } -input[disabled] + .toggle .toggle__handler{ - background: #CCC !important; -} - input:checked + .toggle .toggle__handler{ width: 50%; background: #00c000; @@ -322,6 +326,9 @@ input:checked + .toggle .toggle__handler{ border-top-right-radius: 4px; border-bottom-right-radius: 4px; } +input[disabled] + .toggle .toggle__handler{ + background: #ccc; +} /* ----------------------------------------------------------------------------- Loading diff --git a/code/html/custom.js b/code/html/custom.js index a3a719af..09346936 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -814,7 +814,6 @@ function initRelays(data) { $(":checkbox", line).prop('checked', data[i]).attr("data", i) .prop("id", "relay" + i) .on("change", function (event) { - console.log("sending message"); var id = parseInt($(event.target).attr("data"), 10); var status = $(event.target).prop("checked"); doToggle(id, status); @@ -1523,6 +1522,9 @@ function initUrls(root) { } else { urls.ws.protocol = "ws:"; } + + urls.ws.port = Number(urls.ws.port) + 1; + } @@ -1530,24 +1532,37 @@ function connectToURL(url) { initUrls(url); + + /* + $.ajax({ 'method': 'GET', 'crossDomain': true, 'url': urls.auth.href, 'xhrFields': { 'withCredentials': true } }).done(function(data) { - if (websock) { websock.close(); } - websock = new WebSocket(urls.ws.href); - websock.onmessage = function(evt) { - var data = getJson(evt.data.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t")); - if (data) { - processData(data); - } - }; + +*/ + + if (websock) { + websock.close(); + } + websock = new WebSocket(urls.ws.href); + websock.onmessage = function (evt) { + var data = getJson(evt.data.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t")); + if (data) { + processData(data); + } + }; + + /* + }).fail(function() { // Nothing to do, reload page and retry }); - + +*/ + } function connect(host) {