Skip to content

Commit

Permalink
Codacy 2
Browse files Browse the repository at this point in the history
  • Loading branch information
omersiar committed Apr 2, 2018
1 parent 13f88a4 commit 210fc83
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions src/websrc/js/esprfid.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function handleReader() {
}

function handleDHCP() {
if (document.querySelector('input[name="dhcpenabled"]:checked').value === "1") {
if (document.querySelector("input[name=\"dhcpenabled\"]:checked").value === "1") {
$("#staticip").slideUp();
$("#staticip").show();
} else {
Expand Down Expand Up @@ -144,6 +144,11 @@ function listntp() {
deviceTime();
}

function revcommit() {
document.getElementById("jsonholder").innerText = JSON.stringify(config, null, 2);
$("#revcommit").modal("show");
}

function uncommited() {
$("#commit").fadeOut(200, function() {
$(this).css("background", "gold").fadeIn(1000);
Expand Down Expand Up @@ -189,7 +194,7 @@ function savegeneral() {

function savemqtt() {
config.mqtt.enabled = "0";
if ($("input[name=mqttenabled]:checked").val() === "1") {
if ($("input[name=\"mqttenabled\"]:checked").val() === "1") {
config.mqtt.enabled = "1";
}
config.mqtt.host = document.getElementById("mqtthost").value;
Expand Down Expand Up @@ -226,12 +231,12 @@ function savenetwork() {
if (document.getElementById("wmodeap").checked) {
wmode = "1";
config.network.bssid = document.getElementById("wifibssid").value = 0;
if (document.querySelector('input[name="hideapenable"]:checked').value === "1") {
if (document.querySelector("input[name=\"hideapenable\"]:checked").value === "1") {
config.network.hide = "1";
} else { config.network.hide = "0"; }
} else {
config.network.bssid = document.getElementById("wifibssid").value;
if (document.querySelector('input[name="dhcpenabled"]:checked').value === "1") {
if (document.querySelector("input[name=\"dhcpenabled\"]:checked").value === "1") {
config.network.dhcp = "1";
} else {

Expand Down Expand Up @@ -264,10 +269,8 @@ function savenetwork() {
uncommited();
}

function revcommit() {
document.getElementById("jsonholder").innerText = JSON.stringify(config, null, 2);
$("#revcommit").modal("show");
}
var formData = new FormData();


function inProgress(callback) {
$("body").load("esprfid.htm #progresscontent", function(responseTxt, statusTxt, xhr) {
Expand Down Expand Up @@ -349,17 +352,17 @@ function listnetwork() {
document.getElementById("wmodeap").checked = true;
if (config.network.hide === "1") {
var value = "1";
$("input[name=hideapenable][value=" + value + "]").prop('checked', true);
//$("input[name=hideapenable][value=\"1\"]").attr('checked', 'checked');
$("input[name=\"hideapenable\"][value=" + value + "]").prop("checked", true);
//$("input[name=hideapenable][value=\"1\"]").attr("checked", "checked");
}
handleAP();
} else {
document.getElementById("wmodesta").checked = true;
document.getElementById("wifibssid").value = config.network.bssid;
if (config.network.dhcp === "0") {
var value = "0";
$("input[name=dhcpenabled][value=" + value + "]").prop('checked', true);
//$("input[name=dhcpenabled][value=\"0\"]").attr('checked', 'checked');
$("input[name=\"dhcpenabled\"][value=" + value + "]").prop("checked", true);
//$("input[name=dhcpenabled][value=\"0\"]").attr("checked", "checked");
handleDHCP();
}
document.getElementById("ipaddress").value = config.network.ip;
Expand All @@ -384,8 +387,8 @@ function listgeneral() {
function listmqtt() {
if (config.mqtt.enabled === "1") {
var value = "1";
$("input[name=mqttenabled][value=" + value + "]").prop('checked', true);
//$("input[name=mqttenabled][value=\"1\"]").attr('checked', 'checked');
$("input[name=\"mqttenabled\"][value=" + value + "]").prop("checked", true);
//$("input[name=mqttenabled][value=\"1\"]").attr("checked", "checked");
}
document.getElementById("mqtthost").value = config.mqtt.host;
document.getElementById("mqttport").value = config.mqtt.port;
Expand Down Expand Up @@ -475,6 +478,12 @@ function testRelay() {
}


function colorStatusbar(ref) {
var percentage = ref.style.width.slice(0, -1);
if (percentage > 50) { ref.className = "progress-bar progress-bar-success"; } else if (percentage > 25) { ref.className = "progress-bar progress-bar-warning"; } else { ref.class = "progress-bar progress-bar-danger"; }
}


function listStats() {
document.getElementById("chip").innerHTML = ajaxobj.chipid;
document.getElementById("cpu").innerHTML = ajaxobj.cpu + " Mhz";
Expand Down Expand Up @@ -909,8 +918,8 @@ function initUserTable() {
uid = 10001;
$editor.on("submit", function(e) {
if (this.checkValidity && !this.checkValidity()) {
return
} ;
return;
}
e.preventDefault();
var row = $modal.data("row"),
values = {
Expand Down Expand Up @@ -946,10 +955,6 @@ function restartESP() {
inProgress("restart");
}

function colorStatusbar(ref) {
var percentage = ref.style.width.slice(0, -1);
if (percentage > 50) { ref.className = "progress-bar progress-bar-success"; } else if (percentage > 25) { ref.className = "progress-bar progress-bar-warning"; } else { ref.class = "progress-bar progress-bar-danger"; }
}


var nextIsNotJson = false;
Expand Down Expand Up @@ -1255,7 +1260,7 @@ $("#update").on("shown.bs.modal", function(e) {



var formData = new FormData();



function upload() {
Expand Down Expand Up @@ -1340,8 +1345,8 @@ function start() {
esprfidcontent.id = "mastercontent";
esprfidcontent.style.display = "none";
document.body.appendChild(esprfidcontent);
$('#signin').on('shown.bs.modal', function() {
$('#password').focus().select();
$("#signin").on("shown.bs.modal", function() {
$("#password").focus().select();
});
$("#mastercontent").load("esprfid.htm", function(responseTxt, statusTxt, xhr) {
if (statusTxt === "success") {
Expand Down

0 comments on commit 210fc83

Please sign in to comment.