Commit 84d25f0e authored by nextime's avatar nextime

Clima gui is complete.

parent ca75628c
<? <?
//$GUIDEBUG=FALSE; $GUIDEBUG=FALSE;
$GUIDEBUG=TRUE; //$GUIDEBUG=TRUE;
function getBaseGuiPath() function getBaseGuiPath()
......
...@@ -147,6 +147,10 @@ if(f[a]("text")){for(g.text=f.text;h.firstChild;)h.removeChild(h.firstChild);for ...@@ -147,6 +147,10 @@ if(f[a]("text")){for(g.text=f.text;h.firstChild;)h.removeChild(h.firstChild);for
// scroller: $('#content')[0] // scroller: $('#content')[0]
//}) //})
if (!Date.now) {
Date.now = function() { return new Date().getTime(); };
}
var audioTagSupport = !!(document.createElement('audio').canPlayType); var audioTagSupport = !!(document.createElement('audio').canPlayType);
/* /*
function DoFullScreen() { function DoFullScreen() {
......
...@@ -46,6 +46,10 @@ ...@@ -46,6 +46,10 @@
// scroller: $('#content')[0] // scroller: $('#content')[0]
//}) //})
if (!Date.now) {
Date.now = function() { return new Date().getTime(); };
}
var audioTagSupport = !!(document.createElement('audio').canPlayType); var audioTagSupport = !!(document.createElement('audio').canPlayType);
/* /*
function DoFullScreen() { function DoFullScreen() {
......
...@@ -27,7 +27,7 @@ if($GUISUBSECTION=="") ...@@ -27,7 +27,7 @@ if($GUISUBSECTION=="")
foreach($thermostats as $t) foreach($thermostats as $t)
{ {
$panels[]=array('panel_title'=>$t['button_name'],'panel_sections'=>$t['sensor_type'], 'panel_websections'=>'clima', $panels[]=array('panel_title'=>$t['button_name'],'panel_sections'=>$t['sensor_type'], 'panel_websections'=>'clima',
'panel_type'=>'thermostat', 'panel_content'=>$t['sensor_domain'],'panel_cols'=>5, 'panel_height'=>'80%')+$PANELDEFAULTS; 'panel_type'=>'thermostat', 'panel_content'=>$t['name'],'panel_cols'=>5, 'panel_height'=>'80%')+$PANELDEFAULTS;
$panels[]=array('panel_title'=>'programmazione '.$t['button_name'],'panel_sections'=>$t['sensor_type'], 'panel_websections'=>'clima', $panels[]=array('panel_title'=>'programmazione '.$t['button_name'],'panel_sections'=>$t['sensor_type'], 'panel_websections'=>'clima',
'panel_type'=>'thermostat_program', 'panel_content'=>$t['name'],'panel_cols'=>5, 'panel_height'=>'80%')+$PANELDEFAULTS; 'panel_type'=>'thermostat_program', 'panel_content'=>$t['name'],'panel_cols'=>5, 'panel_height'=>'80%')+$PANELDEFAULTS;
......
<? @include_once("../../includes/common.php"); ?> <? @include_once("../../includes/common.php"); ?>
<? <?
if($panel && is_array($panel)) { if($panel && is_array($panel)) {
$buttonar=getPanelButtons($_DOMOTIKA['username'],$panel['panel_content'],$panel['panel_sections'],$panel['panel_websections'],$panel['panel_selector'],true); $thermo=DB::queryFirstRow("SELECT * from thermostats WHERE name=%s AND active='yes'", $panel['panel_content']);
$buttonar=getPanelButtons($_DOMOTIKA['username'],$thermo['sensor_domain'],$panel['panel_sections'],$panel['panel_websections'],$panel['panel_selector'],true);
$climastatus=DB::queryOneField("value", "SELECT * FROM uniques WHERE name='climastatus'"); $climastatus=DB::queryOneField("value", "SELECT * FROM uniques WHERE name='climastatus'");
if(!$climastatus) { if(!$climastatus) {
DB::insert('uniques', array('name'=>'climastatus','value'=>'WINTER')); DB::insert('uniques', array('name'=>'climastatus','value'=>'WINTER'));
...@@ -77,13 +79,13 @@ if($panel && is_array($panel)) { ...@@ -77,13 +79,13 @@ if($panel && is_array($panel)) {
<div id="gauge-<?=$button['id']."-".$panel['id']?>" data-domotika-type="gauge" <div id="gauge-<?=$button['id']."-".$panel['id']?>" data-domotika-type="gauge"
data-dmval-min="<?=floatval($button['minval'])?>" data-dmval-min="<?=floatval($button['minval'])?>"
data-dmval-max="<?=floatval($button['maxval'])?>" data-dmval-max="<?=floatval($button['maxval'])?>"
data-dmval-low="<?=floatval($button['lowval'])?>" data-dmval-low="0.0"
data-dmval-high="<?=floatval($button['highval'])?>" data-dmval-high="<?=floatval($thermo['setval'])*floatval($button['divider'])?>"
data-dmval-divider="<?=floatval($button['divider'])?>" data-dmval-divider="<?=floatval($button['divider'])?>"
data-dmcolor-min="<?=$button['color_min']?>" data-dmcolor-min="blue"
data-dmcolor-low="<?=$button['color_low']?>" data-dmcolor-low="blue"
data-dmcolor-medium="<?=$button['color_medium']?>" data-dmcolor-medium="blue"
data-dmcolor-high="<?=$button['color_high']?>" data-dmcolor-high="red"
data-domotika-name="<?=$button['button_name']?>" data-domotika-name="<?=$button['button_name']?>"
data-dmval="<?=floatval($button['status'])?>" data-dmval="<?=floatval($button['status'])?>"
data-domotika-label="<?=$button['unit']?>" data-domotika-label="<?=$button['unit']?>"
...@@ -92,17 +94,34 @@ if($panel && is_array($panel)) { ...@@ -92,17 +94,34 @@ if($panel && is_array($panel)) {
</div> </div>
<div style="display:inline-block;width:20%;min-width:68px;height:250px;margin:0 auto;text-align:center;"> <div style="display:inline-block;width:20%;min-width:68px;height:250px;margin:0 auto;text-align:center;">
<div><button type="button" id="thermo-showset-<?=$button['id']."-".$panel['id']?>" class="btn btn-gray">--.-</button></div> <div><button type="button" id="thermo-showset-<?=$button['id']."-".$panel['id']?>" class="btn btn-gray">--.-</button></div>
<div style="margin:0 auto;text-align:center;height:150px;margin-top:25px;margin-bottom:25px;" <div style="margin:0 auto;text-align:center;height:150px;margin-top:25px;margin-bottom:25px;"
data-domotika-maxval="<?=$thermo['maxslide']?>"
data-domotika-minval="<?=$thermo['minslide']?>"
data-domotika-setval="<?=$thermo['setval']?>"
id="thermo-level-<?=$button['id']."-".$panel['id']?>" data-domotika-type="thermo-level"> id="thermo-level-<?=$button['id']."-".$panel['id']?>" data-domotika-type="thermo-level">
</div> </div>
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-primary btn-small"><i class="glyphicon glyphicon-chevron-down"></i></button> <button type="button" class="btn btn-primary btn-small"
<button type="button" class="btn btn-danger btn-small"><i class="glyphicon glyphicon-chevron-up"></i></button> id="thermo-minus-<?=$button['id']."-".$panel['id']?>">
<i class="glyphicon glyphicon-chevron-down"></i></button>
<button type="button" class="btn btn-danger btn-small"
id="thermo-plus-<?=$button['id']."-".$panel['id']?>">
<i class="glyphicon glyphicon-chevron-up"></i></button>
</div> </div>
</div> </div>
<div style="margin-top:45px;"> <div style="margin-top:45px;">
<button type="button" class="btn btn-gray " style="width:150px;height:40px;"><b>Manual</b></button> <button type="button" class="btn btn-gray "
<button type="button" class="btn btn-primary " style="width:150px;height:40px;"><b>Program</b></button> id="thermo-btnmanual-<?=$button['id']."-".$panel['id']?>"
data-dmcolor-on="btn-primary"
data-dmcolor-off="btn-gray"
data-domotika-type="btnmanual"
style="width:150px;height:40px;"><b>Manual</b></button>
<button type="button" class="btn btn-primary "
id="thermo-btnprogram-<?=$button['id']."-".$panel['id']?>"
data-dmcolor-on="btn-primary"
data-dmcolor-off="btn-gray"
data-domotika-type="btnprogram"
style="width:150px;height:40px;"><b>Program</b></button>
</div> </div>
</div> </div>
<? <?
......
<? @include_once("../../includes/common.php"); ?> <? @include_once("../../includes/common.php"); ?>
<script> <script>
function thermoResetGaugeLevel(g,l) {
var gau=gaugeArray[g];
gau.config.customSectors[2]={color: gau.config.customSectors[2].color,
lo: gau.config.customSectors[2].lo,
hi: l}
gau.config.customSectors[3]={color: gau.config.customSectors[3].color,
lo: l,
hi: gau.config.customSectors[3].hi};
gau.refresh(gau.config.value);
}
function checkSliderSet(slider){
if(slider.data('lastchanged'))
{
if(Date.now()-slider.data('lastchanged')>1000)
{
console.debug(slider.data('lastchanged'));
console.debug(Date.now());
console.debug('------------------------');
slider.data('lastchanged', false);
}
}
if(slider.val()!=slider.data('oldval'))
{
slider.data('lastchanged', Date.now());
slider.data('oldval', slider.val());
}
setTimeout(function(){checkSliderSet(slider)}, 500);
}
$("[data-domotika-type=thermo-level]").each( $("[data-domotika-type=thermo-level]").each(
function(){ function(){
$(this).noUiSlider({ $(this).noUiSlider({
range: [-10, 50], range: [parseFloat($(this).attr('data-domotika-minval')), parseFloat($(this).attr('data-domotika-maxval'))],
start: 20, start: parseFloat($(this).attr('data-domotika-setval')),
handles: 1, handles: 1,
connect: 'lower', connect: 'lower',
orientation: 'vertical', orientation: 'vertical',
...@@ -13,8 +46,23 @@ $("[data-domotika-type=thermo-level]").each( ...@@ -13,8 +46,23 @@ $("[data-domotika-type=thermo-level]").each(
slide: function() { slide: function() {
var parts=$(this).attr('id').split("-"); var parts=$(this).attr('id').split("-");
$("#thermo-showset-"+parts[2]+'-'+parts[3]).text(parseFloat($(this).val()).toFixed(1)); $("#thermo-showset-"+parts[2]+'-'+parts[3]).text(parseFloat($(this).val()).toFixed(1));
thermoResetGaugeLevel('gauge-'+parts[2]+'-'+parts[3], parseFloat($(this).val()));
var program=$("#thermo-btnprogram-"+parts[2]+'-'+parts[3]);
var manual=$("#thermo-btnmanual-"+parts[2]+'-'+parts[3]);
program.alterClass(program.attr('data-dmcolor-on'), program.attr('data-dmcolor-off'));
manual.alterClass(manual.attr('data-dmcolor-off'), manual.attr('data-dmcolor-on'));
}, },
/*
set: function() {
$(this).data('lastchanged', Date.now());
}
*/
}); });
$(this).data('oldval', $(this).val());
$(this).data('lastchanged', false);
slider=$(this);
setTimeout(function(){checkSliderSet(slider)}, 1000);
var parts=$(this).attr('id').split('-'); var parts=$(this).attr('id').split('-');
var btn=$("#thermo-showset-"+parts[2]+'-'+parts[3]); var btn=$("#thermo-showset-"+parts[2]+'-'+parts[3]);
btn.text(parseFloat($(this).val()).toFixed(1)); btn.text(parseFloat($(this).val()).toFixed(1));
...@@ -27,9 +75,42 @@ $("[data-domotika-type=thermo-level]").each( ...@@ -27,9 +75,42 @@ $("[data-domotika-type=thermo-level]").each(
if(event.deltaY!=0) if(event.deltaY!=0)
{ {
$('#'+$(this).attr('id').replace('thermo-level-','thermo-showset-')).text(parseFloat($(this).val()).toFixed(1)); $('#'+$(this).attr('id').replace('thermo-level-','thermo-showset-')).text(parseFloat($(this).val()).toFixed(1));
thermoResetGaugeLevel('gauge-'+parts[2]+'-'+parts[3], parseFloat($(this).val()));
var program=$("#thermo-btnprogram-"+parts[2]+'-'+parts[3]);
var manual=$("#thermo-btnmanual-"+parts[2]+'-'+parts[3]);
program.alterClass(program.attr('data-dmcolor-on'), program.attr('data-dmcolor-off'));
manual.alterClass(manual.attr('data-dmcolor-off'), manual.attr('data-dmcolor-on'));
//$(this).data('lastchanged', Date.now());
} }
}); });
var plus=$('#'+$(this).attr('id').replace('thermo-level-','thermo-plus-'));
var minus=$('#'+$(this).attr('id').replace('thermo-level-','thermo-minus-'));
minus.continouoshold(function(){
var slide=$('#'+$(this).attr('id').replace('thermo-minus-','thermo-level-'));
slide.val(parseFloat(slide.val())-0.5);
$('#'+$(this).attr('id').replace('thermo-minus-','thermo-showset-')).text(parseFloat(slide.val()).toFixed(1));
var parts=$(this).attr('id').split("-");
var program=$("#thermo-btnprogram-"+parts[2]+'-'+parts[3]);
var manual=$("#thermo-btnmanual-"+parts[2]+'-'+parts[3]);
program.alterClass(program.attr('data-dmcolor-on'), program.attr('data-dmcolor-off'));
manual.alterClass(manual.attr('data-dmcolor-off'), manual.attr('data-dmcolor-on'));
//slide.data('lastchanged', Date.now());
}, 200, 700, true);
plus.continouoshold(function(){
var slide=$('#'+$(this).attr('id').replace('thermo-plus-','thermo-level-'));
slide.val(parseFloat(slide.val())+0.5);
$('#'+$(this).attr('id').replace('thermo-plus-','thermo-showset-')).text(parseFloat(slide.val()).toFixed(1));
var parts=$(this).attr('id').split("-");
var program=$("#thermo-btnprogram-"+parts[2]+'-'+parts[3]);
var manual=$("#thermo-btnmanual-"+parts[2]+'-'+parts[3]);
program.alterClass(program.attr('data-dmcolor-on'), program.attr('data-dmcolor-off'));
manual.alterClass(manual.attr('data-dmcolor-off'), manual.attr('data-dmcolor-on'));
//slide.data('lastchanged', Date.now());
}, 200, 700, true);
} }
); );
...@@ -57,6 +138,27 @@ $("[data-domotika-type=statusselect]").each( ...@@ -57,6 +138,27 @@ $("[data-domotika-type=statusselect]").each(
} }
); );
$("[data-domotika-type=btnprogram]").each(
function(){$(this).fastClick(
function() {
var parts=$(this).attr('id').split("-");
var other=$("#thermo-btnmanual-"+parts[2]+'-'+parts[3]);
other.alterClass(other.attr('data-dmcolor-on'), other.attr('data-dmcolor-off'));
$(this).alterClass($(this).attr('data-dmcolor-off'), $(this).attr('data-dmcolor-on'));
});
}
);
$("[data-domotika-type=btnmanual]").each(
function(){$(this).fastClick(
function() {
var parts=$(this).attr('id').split("-");
var other=$("#thermo-btnprogram-"+parts[2]+'-'+parts[3]);
other.alterClass(other.attr('data-dmcolor-on'), other.attr('data-dmcolor-off'));
$(this).alterClass($(this).attr('data-dmcolor-off'), $(this).attr('data-dmcolor-on'));
});
}
);
</script> </script>
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