Commit ee6d082a authored by nextime's avatar nextime

Make analog progress bar show color and value in ajax

parent 4a1431a7
...@@ -34,8 +34,9 @@ $perc=(floatval($button['status'])-floatval($button['minval']))*100/(floatval($b ...@@ -34,8 +34,9 @@ $perc=(floatval($button['status'])-floatval($button['minval']))*100/(floatval($b
data-dmcolor-med="<?=$pbcoln.$dmcolors[$button['color_medium']]?>" data-dmcolor-high="<?=$pbcoln.$dmcolors[$button['color_high']]?>" data-dmcolor-med="<?=$pbcoln.$dmcolors[$button['color_medium']]?>" data-dmcolor-high="<?=$pbcoln.$dmcolors[$button['color_high']]?>"
data-dmval-min="<?=floatval($button['minval'])?>" data-dmval-low="<?=floatval($button['lowval'])?>" data-dmval-min="<?=floatval($button['minval'])?>" data-dmval-low="<?=floatval($button['lowval'])?>"
data-dmval-high="<?=floatval($button['highval'])?>" data-dmval-max="<?=floatval($button['maxval'])?>" data-dmval-high="<?=floatval($button['highval'])?>" data-dmval-max="<?=floatval($button['maxval'])?>"
data-dmval-divider="<?=floatval($button['divider'])?>" data-domotika-anaprog="<?=$button['id']?>"> data-domotika-anaprog="<?=$button['id']?>">
<span class="sr-only"><?=floatval($button['status'])/$button['divider']?></span> <span class="sr-only" data-domotika-anat="<?=$button['id']?>"
data-dmval-divider="<?=floatval($button['divider'])?>"><?=floatval($button['status'])/$button['divider']?></span>
</div> </div>
</div> </div>
</div> </div>
...@@ -43,7 +44,10 @@ $perc=(floatval($button['status'])-floatval($button['minval']))*100/(floatval($b ...@@ -43,7 +44,10 @@ $perc=(floatval($button['status'])-floatval($button['minval']))*100/(floatval($b
<button class="btn devlist-button <?=$btncol?>" data-domotika-anaid="<?=$button['id']?>" <button class="btn devlist-button <?=$btncol?>" data-domotika-anaid="<?=$button['id']?>"
data-dmcolor-min="btn-<?=$dmcolors[$button['color_min']]?>" data-dmcolor-low="btn-<?=$dmcolors[$button['color_low']]?>" data-dmcolor-min="btn-<?=$dmcolors[$button['color_min']]?>" data-dmcolor-low="btn-<?=$dmcolors[$button['color_low']]?>"
data-dmcolor-med="btn-<?=$dmcolors[$button['color_medium']]?>" data-dmcolor-high="btn-<?=$dmcolors[$button['color_high']]?>" data-dmcolor-med="btn-<?=$dmcolors[$button['color_medium']]?>" data-dmcolor-high="btn-<?=$dmcolors[$button['color_high']]?>"
><span><?=$button['unit']?>:</span> <span><?=floatval($button['status'])/$button['divider']?></span></button> data-dmval-min="<?=floatval($button['minval'])?>" data-dmval-low="<?=floatval($button['lowval'])?>"
data-dmval-high="<?=floatval($button['highval'])?>" data-dmval-max="<?=floatval($button['maxval'])?>"
><span><?=$button['unit']?>:</span> <span data-dmval-divider="<?=floatval($button['divider'])?>"
data-domotika-anab="<?=$button['id']?>" ><?=floatval($button['status'])/$button['divider']?></span></button>
</div> <!-- devlist-rightpart--> </div> <!-- devlist-rightpart-->
</div> <!-- devlist-row --> </div> <!-- devlist-row -->
</div> <!-- devlist item --> </div> <!-- devlist item -->
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -478,9 +478,45 @@ ...@@ -478,9 +478,45 @@
); );
$("[data-domotika-anaid="+val[0]+"]").each( $("[data-domotika-anaid="+val[0]+"]").each(
function() { function() {
console.debug("anaid"); if(val[1]<=$(this).attr('data-dmval-min')) {
$(this).alterClass('btn-*', $(this).attr('data-dmcolor-min'));
} else if(val[1]<=$(this).attr('data-dmval-low')) {
$(this).alterClass('btn-*', $(this).attr('data-dmcolor-low'));
} else if(val[1]<$(this).attr('data-dmval-high')) {
$(this).alterClass('btn-*', $(this).attr('data-dmcolor-med'));
} else if(val[1]>=$(this).attr('data-dmval-high')) {
$(this).alterClass('btn-*', $(this).attr('data-dmcolor-high'));
}
}
);
$("[data-domotika-anaprog="+val[0]+"]").each(
function() {
if(val[1]<=$(this).attr('data-dmval-min')) {
$(this).alterClass('progress-bar-*', $(this).attr('data-dmcolor-min'));
} else if(val[1]<=$(this).attr('data-dmval-low')) {
$(this).alterClass('progress-bar-*', $(this).attr('data-dmcolor-low'));
} else if(val[1]<$(this).attr('data-dmval-high')) {
$(this).alterClass('progress-bar-*', $(this).attr('data-dmcolor-med'));
} else if(val[1]>=$(this).attr('data-dmval-high')) {
$(this).alterClass('progress-bar-*', $(this).attr('data-dmcolor-high'));
}
} }
); );
$("[data-domotika-anat="+val[0]+"]").each(
function() {
v=val[1]/$(this).attr('data-dmval-divider');
$(this).text(v);
}
);
$("[data-domotika-anab="+val[0]+"]").each(
function() {
v=val[1]/$(this).attr('data-dmval-divider');
$(this).text(v);
}
);
break; break;
case 'action': case 'action':
......
...@@ -42,7 +42,7 @@ if($panel && is_array($panel)) { ...@@ -42,7 +42,7 @@ if($panel && is_array($panel)) {
//print_r($chart); //print_r($chart);
$_SESSION['PANELS_CHARTS'][$chart['name']."-".$panel['id']]=$chart; $_SESSION['PANELS_CHARTS'][$chart['name']."-".$panel['id']]=$chart;
?> ?>
<div id="<?=$chart['name']."-".$panel['id']?>" style="height:200px;width:550px"><?=$chart['name']?></div> <div id="<?=$chart['name']."-".$panel['id']?>" style="height:200px;width:550px"></div>
<? <?
}?> }?>
</div> </div>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
$.fn.alterClass = function ( removals, additions ) { $.fn.alterClass = function ( removals, additions ) {
var self = this; var self = this;
if ( typeof(removals)!='undefined') {
if ( removals.indexOf( '*' ) === -1 ) { if ( removals.indexOf( '*' ) === -1 ) {
// Use native jQuery methods if there is no wildcard matching // Use native jQuery methods if there is no wildcard matching
self.removeClass( removals ); self.removeClass( removals );
...@@ -34,6 +34,7 @@ $.fn.alterClass = function ( removals, additions ) { ...@@ -34,6 +34,7 @@ $.fn.alterClass = function ( removals, additions ) {
} }
it.className = $.trim( cn ); it.className = $.trim( cn );
}); });
}
return !additions ? self : self.addClass( additions ); return !additions ? self : self.addClass( additions );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment