From cfb14d490d2d3ad1335434188f16e85b36520c1a Mon Sep 17 00:00:00 2001 From: Mike Shoup Date: Sun, 7 Oct 2018 21:30:34 -0600 Subject: [PATCH] Add ability to stop reloading whent yping in form --- html/js/thermostat.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/html/js/thermostat.js b/html/js/thermostat.js index 9220ff2..a9bc1a2 100644 --- a/html/js/thermostat.js +++ b/html/js/thermostat.js @@ -53,27 +53,32 @@ function renderThermostats() { rp = '[0-9]+(\.[0-9]+)?' - configText = "Chills for " + - " minutes when > " + - "" + degUnit + ".
"; + var cmIn = $("").attr("id", "cm" + configData.alias).val(configData.coolminutes).attr("size", "2").attr("pattern", rp).on('input', function(){window.clearInterval(rtHandle)}); + var htIn = $("").attr("id", "ht" + configData.alias).val(hightemp).attr("size", "4").attr("pattern", rp).on('input', function(){window.clearInterval(rtHandle)}); + var hmIn = $("").attr("id", "hm" + configData.alias).val(configData.heatminutes).attr("size", "2").attr("pattern", rp).on('input', function(){window.clearInterval(rtHandle)}); + var ltIn = $("").attr("id", "lt" + configData.alias).val(lowtemp).attr("size", "4").attr("pattern", rp).on('input', function(){window.clearInterval(rtHandle)}); - configText += "Heats for " + - " minutes when < " + - "" + degUnit + ".
"; + var configp = $("

").text("Chills for ").append(cmIn).append(" minutes when > ").append(htIn).append(degUnit).append($("
")); + configp.append("Heats for ").append(hmIn).append(" minutes when < ").append(ltIn).append(degUnit); - var configp = $("

").html(configText); var configdiv = $("
").addClass("five columns").append(configp); rowdiv.append(configdiv); var yesButton = $("").attr("type", "submit").addClass("button button-primary").text("✔").css("margin-right", "5px"); - var noButton = $("").addClass("button").text("✘"); + var noButton = $("").attr("id", "no" + configData.alias).addClass("button").text("✘"); var buttonDiv = $("
").addClass("three columns").append(yesButton).append(noButton); rowdiv.append(buttonDiv); - }); - // Add things back to the thermostat list - $("#thermostats").append(titlediv); - $("#thermostats").append($("
").append(rowdiv)); + // Add things back to the thermostat list + $("#thermostats").append(titlediv); + $("#thermostats").append($("
").append(rowdiv)); + + // Re-engage reload, and re-render the thermostat on clear + $("#no" + configData.alias).click(function() { + window.setInterval(renderThermostats, 60000); + renderThermostats(); + }); + }); }; }); }; @@ -89,4 +94,4 @@ function renderVersion() { $(document).ready(renderVersion); $(document).ready(renderThermostats); -setInterval(renderThermostats, 60000) +var rtHandle = window.setInterval(renderThermostats, 60000);