mirror of
https://github.com/shouptech/tempgopher.git
synced 2026-02-03 16:49:42 +00:00
Add form to UI
This commit is contained in:
parent
b4c4ce8650
commit
9aadc2007a
1 changed files with 23 additions and 9 deletions
|
|
@ -35,7 +35,7 @@ function renderThermostats() {
|
||||||
var statustext = "Idle"
|
var statustext = "Idle"
|
||||||
}
|
}
|
||||||
var statusp = $("<p></p>").html(statustext);
|
var statusp = $("<p></p>").html(statustext);
|
||||||
var statusdiv = $("<div></div>").addClass("three columns").append(statusp);
|
var statusdiv = $("<div></div>").addClass("two columns").append(statusp);
|
||||||
rowdiv.append(statusdiv);
|
rowdiv.append(statusdiv);
|
||||||
|
|
||||||
// Display sensor config
|
// Display sensor config
|
||||||
|
|
@ -43,23 +43,37 @@ function renderThermostats() {
|
||||||
url: jsconfig.baseurl + "/api/config/sensors/" + data[key].alias
|
url: jsconfig.baseurl + "/api/config/sensors/" + data[key].alias
|
||||||
}).then(function(configData){
|
}).then(function(configData){
|
||||||
if (jsconfig.fahrenheit) {
|
if (jsconfig.fahrenheit) {
|
||||||
var hightemp = celsiusToFahrenheit(parseFloat(configData.hightemp)).toFixed(1) + "°F";
|
var degUnit = "°F";
|
||||||
var lowtemp = celsiusToFahrenheit(parseFloat(configData.lowtemp)).toFixed(1) + "°F";
|
var hightemp = celsiusToFahrenheit(parseFloat(configData.hightemp)).toFixed(1);
|
||||||
|
var lowtemp = celsiusToFahrenheit(parseFloat(configData.lowtemp)).toFixed(1);
|
||||||
} else {
|
} else {
|
||||||
var hightemp = parseFloat(configData.hightemp).toFixed(1) + "°C";
|
var hightemp = parseFloat(configData.hightemp).toFixed(1);
|
||||||
var lowtemp = parseFloat(configData.lowtemp).toFixed(1) + "°C";
|
var lowtemp = parseFloat(configData.lowtemp).toFixed(1);
|
||||||
}
|
}
|
||||||
configText = "Chills for " + configData.coolminutes + " minutes when > " + hightemp + ".<br />";
|
|
||||||
configText += "Heats for " + configData.heatminutes + " minutes when < " + lowtemp + ".";
|
rp = '[0-9]+(\.[0-9]+)?'
|
||||||
|
|
||||||
|
configText = "Chills for " +
|
||||||
|
"<input id=\"cm" + configData.alias + "\" value=\"" + configData.coolminutes + "\" size=\"2\" pattern=\"" + rp +"\"> minutes when > " +
|
||||||
|
"<input id=\"ht" + configData.alias + "\" value=\"" + hightemp + "\" size=\"4\" pattern=\"" + rp +"\">" + degUnit + ".<br />";
|
||||||
|
|
||||||
|
configText += "Heats for " +
|
||||||
|
"<input id=\"hm" + configData.alias + "\" value=\"" + configData.heatminutes + "\" size=\"2\" pattern=\"" + rp +"\"> minutes when < " +
|
||||||
|
"<input id=\"lt" + configData.alias + "\" value=\"" + lowtemp + "\" size=\"4\" pattern=\"" + rp +"\">" + degUnit + ".<br />";
|
||||||
|
|
||||||
var configp = $("<p></p>").html(configText);
|
var configp = $("<p></p>").html(configText);
|
||||||
var configdiv = $("<div></div>").addClass("seven columns").append(configp);
|
var configdiv = $("<div></div>").addClass("five columns").append(configp);
|
||||||
rowdiv.append(configdiv);
|
rowdiv.append(configdiv);
|
||||||
|
|
||||||
|
var yesButton = $("<button></button>").attr("type", "submit").addClass("button button-primary").text("✔").css("margin-right", "5px");
|
||||||
|
var noButton = $("<button></button>").addClass("button").text("✘");
|
||||||
|
var buttonDiv = $("<div></div>").addClass("three columns").append(yesButton).append(noButton);
|
||||||
|
rowdiv.append(buttonDiv);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add things back to the thermostat list
|
// Add things back to the thermostat list
|
||||||
$("#thermostats").append(titlediv);
|
$("#thermostats").append(titlediv);
|
||||||
$("#thermostats").append(rowdiv);
|
$("#thermostats").append($("<form></form>").append(rowdiv));
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue