mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01: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();
|
||||
|
||||
@@ -49,22 +49,6 @@
|
||||
$celsius *= 1e-3;
|
||||
}
|
||||
|
||||
$kelvin = $celsius + 273.15;
|
||||
$fahrenheit = ($celsius*9./5)+32.0;
|
||||
|
||||
if(isset($setupVars['TEMPERATUREUNIT']))
|
||||
{
|
||||
$temperatureunit = $setupVars['TEMPERATUREUNIT'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$temperatureunit = "C";
|
||||
}
|
||||
// Override temperature unit setting if it is changed via Settings page
|
||||
if(isset($_POST["tempunit"]))
|
||||
{
|
||||
$temperatureunit = $_POST["tempunit"];
|
||||
}
|
||||
// Get user-defined temperature limit if set
|
||||
if(isset($setupVars['TEMPERATURE_LIMIT']))
|
||||
{
|
||||
@@ -326,20 +310,7 @@ if($auth) {
|
||||
{
|
||||
echo "text-vivid-blue";
|
||||
}
|
||||
echo "\"></i> Temp: ";
|
||||
if($temperatureunit === "F")
|
||||
{
|
||||
echo round($fahrenheit,1) . " °F";
|
||||
}
|
||||
elseif($temperatureunit === "K")
|
||||
{
|
||||
echo round($kelvin,1) . " K";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo round($celsius,1) . " °C";
|
||||
}
|
||||
echo "</span>";
|
||||
?>"\"></i> Temp: <span id="rawtemp" hidden><?php echo $celsius;?></span><span id="tempdisplay"></span><?php
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+14
-15
@@ -1111,19 +1111,6 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "adlists", "
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4>CPU Temperature Unit</h4>
|
||||
<div>
|
||||
<input type="radio" name="tempunit" value="C" id="tempunit_C" <?php if ($temperatureunit === "C"){ ?>checked<?php } ?>>
|
||||
<label for="tempunit_C"><strong>Celsius</strong></label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" name="tempunit" value="K" id="tempunit_K" <?php if ($temperatureunit === "K"){ ?>checked<?php } ?>>
|
||||
<label for="tempunit_K"><strong>Kelvin</strong></label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" name="tempunit" value="F" id="tempunit_F" <?php if ($temperatureunit === "F"){ ?>checked<?php } ?>>
|
||||
<label for="tempunit_F"><strong>Fahrenheit</strong></label>
|
||||
</div>
|
||||
<h4>Administrator Email Address</h4>
|
||||
<input type="email" class="form-control" name="adminemail" value="<?php echo htmlspecialchars($adminemail); ?>">
|
||||
<input type="hidden" name="field" value="webUI">
|
||||
@@ -1152,7 +1139,7 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "adlists", "
|
||||
<div class="col-md-4">
|
||||
<p>Checkbox and radio buttons</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-8">
|
||||
<select id="iCheckStyle">
|
||||
<option>material-red</option>
|
||||
<option>material-pink</option>
|
||||
@@ -1180,13 +1167,25 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "adlists", "
|
||||
<div class="col-md-4">
|
||||
<p>Theme</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-8">
|
||||
<select id="theme-selector">
|
||||
<option value="default-light">Pi-hole default theme (light, default)</option>
|
||||
<option value="default-dark">Pi-hole midnight theme (dark)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>CPU Temperature Unit</p>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<select id="tempunit-selector">
|
||||
<option value="C">Celsius</option>
|
||||
<option value="K">Kelvin</option>
|
||||
<option value="F">Fahrenheit</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user