Skip to content

Commit

Permalink
Kommastellen bei Zahlen ( Numbers - 4) bei Systemvariablen ermöglicht
Browse files Browse the repository at this point in the history
Über "kommastellen":"Anzahl" kann bestimmt werden auf wie viele Kommastellen ein Wert begrenzt/aufgefüllt wird.
  • Loading branch information
christian1180 committed Feb 2, 2025
1 parent e2f0620 commit 1ec914b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
21 changes: 20 additions & 1 deletion components/SysVar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'])) {
Expand All @@ -60,7 +79,7 @@ function SysVar($component) {
.$ShowTime
. '<span class="info';
if ($component['indicator'] == '-1') $content = $content.' lheight';
$content = $content.'" data-id="' . $component['ise_id'] . '" data-component="' . $component['component'] . '" data-datapoint="4" data-unit="' . htmlentities($component['unit']) . '" data-indicator="' . $component['indicator'] . '"></span>'
$content = $content.'" data-id="' . $component['ise_id'] . '" data-component="' . $component['component'] . '" data-datapoint="4" data-unit="' . htmlentities($component['unit']) . '" data-indicator="' . $component['indicator'] . '" '.$kommastellen.'></span>'
. '</div>';
if ($component['operate'] == 'true') $content = $content.'<div class="clearfix"></div></div><div class="hh2 collapse" id="' . $modalId . '">'
. '<div class="row text-center">'
Expand Down
15 changes: 13 additions & 2 deletions js/script.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 1ec914b

Please sign in to comment.