From 1ec914bb7664f2069b48f4d96622889dd35ab187 Mon Sep 17 00:00:00 2001 From: christian1180 <126362145+christian1180@users.noreply.github.com> Date: Sun, 2 Feb 2025 08:17:09 +0100 Subject: [PATCH] =?UTF-8?q?Kommastellen=20bei=20Zahlen=20(=20Numbers=20-?= =?UTF-8?q?=204)=20bei=20Systemvariablen=20erm=C3=B6glicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Über "kommastellen":"Anzahl" kann bestimmt werden auf wie viele Kommastellen ein Wert begrenzt/aufgefüllt wird. --- components/SysVar.php | 21 ++++++++++++++++++++- js/script.js.php | 15 +++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/components/SysVar.php b/components/SysVar.php index 063f293..58e3db2 100644 --- a/components/SysVar.php +++ b/components/SysVar.php @@ -5,6 +5,13 @@ //SysVar|Waschmaschine Status||ISE_ID=7284|VARIABLE=2|VALUE=2|VALUE_LIST=aus;läuft;fertig|MIN=|MAX=|UNIT=|TYPE=16|SUBTYPE=29|LOGGED=false|VISIBLE=true|TIMESTAMP=1443709817|VALUE_NAME_0=|VALUE_NAME_1=| //SysVar|CCU Boot Zeit||ISE_ID=5580|VARIABLE=14.09.2015 21:17:46 Uhr|VALUE=14.09.2015 21:17:46 Uhr|VALUE_LIST=|MIN=|MAX=|UNIT=|TYPE=20|SUBTYPE=11|LOGGED=false|VISIBLE=true|TIMESTAMP=1442258266|VALUE_NAME_0=|VALUE_NAME_1=| + +/* +2025-02-02 - Schappert: +Systemvariablen als Nummern unterstützen den Parameter "kommastellen":"x" +Damit wird die Zahl auf die Kommastellen reduziert bzw. aufgefüllt. +*/ + function SysVar($component) { if ($component['visible'] == 'true' && isset($component['ise_id'])) { if (!isset($component['operate'])) $component['operate'] = 'true'; @@ -46,6 +53,18 @@ function SysVar($component) { case '4': // Number $modalId = mt_rand(); + + if(isset($component['kommastellen'])) + { + if(is_numeric($component['kommastellen'])) + { + $kommastellen = ' data-kommastellen="'.$component['kommastellen'].'" '; + } + } + else + { + $kommastellen = ""; + } // Indikator anzeigen? if(!isset($component['indicator'])) { @@ -60,7 +79,7 @@ function SysVar($component) { .$ShowTime . '' + $content = $content.'" data-id="' . $component['ise_id'] . '" data-component="' . $component['component'] . '" data-datapoint="4" data-unit="' . htmlentities($component['unit']) . '" data-indicator="' . $component['indicator'] . '" '.$kommastellen.'>' . ''; if ($component['operate'] == 'true') $content = $content.'
' . '
' diff --git a/js/script.js.php b/js/script.js.php index 491d703..2eb0456 100644 --- a/js/script.js.php +++ b/js/script.js.php @@ -1427,10 +1427,21 @@ } } + var kommastellen = $('[data-id="' + ise_id + '"]').attr('data-kommastellen'); + if (kommastellen) + { + value = value.replace(",","."); + value = parseFloat(value) + value = value.toFixed(kommastellen) ; + } + else + { + value = parseFloat(value); + } if (unit !== '') { - $('[data-id="' + ise_id + '"]').html(parseFloat(value) + ' ' + unit); + $('[data-id="' + ise_id + '"]').html(value + ' ' + unit); } else { - $('[data-id="' + ise_id + '"]').html(parseFloat(value)); + $('[data-id="' + ise_id + '"]').html(value); } break; case '16':