mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 12:48:29 +00:00
Add per-browser temp unit selection
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -164,7 +164,6 @@ function initTheme() {
|
||||
|
||||
// The theme selector is only available on the settings page
|
||||
var theme_selector = $('#theme-selector');
|
||||
console.log(theme_selector);
|
||||
if (theme_selector !== null) {
|
||||
theme_selector.change(function(){
|
||||
themename = $(this).val();
|
||||
@@ -174,6 +173,45 @@ function initTheme() {
|
||||
}
|
||||
}
|
||||
|
||||
function initCPUtemp() {
|
||||
function setCPUtemp(unit) {
|
||||
var temperature = parseFloat($("#rawtemp").text());
|
||||
var displaytemp = $("#tempdisplay");
|
||||
if (temperature !== NaN) {
|
||||
switch (unit) {
|
||||
case "K":
|
||||
temperature = temperature + 273.15;
|
||||
displaytemp.html(temperature.toFixed(1) + " °K");
|
||||
break;
|
||||
|
||||
case "F":
|
||||
temperature = (temperature * 9/5) + 32;
|
||||
displaytemp.html(temperature.toFixed(1) + " °F");
|
||||
break;
|
||||
|
||||
default:
|
||||
displaytemp.html(temperature.toFixed(1) + " °C");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var tempunit = localStorage.getItem("tempunit");
|
||||
if (tempunit === null) {
|
||||
tempunit = "C";
|
||||
}
|
||||
setCPUtemp(tempunit);
|
||||
|
||||
// The theme selector is only available on the settings page
|
||||
var tempunit_selector = $('#tempunit-selector');
|
||||
if (tempunit_selector !== null) {
|
||||
tempunit_selector.change(function(){
|
||||
tempunit = $(this).val();
|
||||
localStorage.setItem("tempunit", tempunit);
|
||||
setCPUtemp(tempunit);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
var enaT = $("#enableTimer");
|
||||
var target = new Date(parseInt(enaT.html()));
|
||||
@@ -190,6 +228,7 @@ $(function () {
|
||||
applyCheckboxRadioStyle();
|
||||
applyBoxedLayout();
|
||||
initTheme();
|
||||
initCPUtemp();
|
||||
|
||||
// Run check immediately after page loading ...
|
||||
checkMessages();
|
||||
|
||||
Reference in New Issue
Block a user