1
1
define ( [ 'app' ] , function ( app ) {
2
- app . controller ( 'TemperatureController' , [ '$scope' , '$rootScope' , '$location' , '$http' , '$interval' , 'permissions' , function ( $scope , $rootScope , $location , $http , $interval , permissions ) {
2
+ app . controller ( 'TemperatureController' , [ '$scope' , '$rootScope' , '$location' , '$http' , '$interval' , '$window' , ' permissions', function ( $scope , $rootScope , $location , $http , $interval , $window , permissions ) {
3
3
4
4
var ctrl = this ;
5
5
@@ -436,6 +436,7 @@ define(['app'], function (app) {
436
436
$ ( '#tempcontent' ) . html ( GetBackbuttonHTMLTable ( 'ShowTemps' ) + htmlcontent ) ;
437
437
$ ( '#tempcontent' ) . i18n ( ) ;
438
438
$ ( '#tempwidgets' ) . hide ( ) ;
439
+ $ ( '#temptophtm' ) . hide ( ) ;
439
440
440
441
$ . content = "#tempcontent" ;
441
442
@@ -626,93 +627,14 @@ define(['app'], function (app) {
626
627
}
627
628
$ ( '#modal' ) . show ( ) ;
628
629
629
- var bShowRoomplan = false ;
630
- $ . RoomPlans = [ ] ;
631
- $ . ajax ( {
632
- url : "json.htm?type=plans" ,
633
- async : false ,
634
- dataType : 'json' ,
635
- success : function ( data ) {
636
- if ( typeof data . result != 'undefined' ) {
637
- var totalItems = data . result . length ;
638
- if ( totalItems > 0 ) {
639
- bShowRoomplan = true ;
640
- // if (window.myglobals.ismobile==true) {
641
- // bShowRoomplan=false;
642
- // }
643
- if ( bShowRoomplan == true ) {
644
- $ . each ( data . result , function ( i , item ) {
645
- $ . RoomPlans . push ( {
646
- idx : item . idx ,
647
- name : item . Name
648
- } ) ;
649
- } ) ;
650
- }
651
- }
652
- }
653
- }
654
- } ) ;
655
-
656
- var bHaveAddedDevider = false ;
657
- var tophtm = "" ;
658
- if ( $ . RoomPlans . length == 0 ) {
659
- tophtm +=
660
- '\t<table class="bannav" id="bannav" border="0" cellpadding="0" cellspacing="0" width="100%">\n' +
661
- '\t<tr>\n' +
662
- '\t <td align="left" valign="top" id="timesun"></td>\n' +
663
- '\t <td align="right">\n' ;
664
- if ( window . myglobals . ismobile == false ) {
665
- tophtm +=
666
- '\t<table class="bannav" border="0" cellpadding="0" cellspacing="0" width="100%">\n' +
667
- '\t<tr>\n' +
668
- '\t <td align="left"></td>\n' +
669
- '\t <td align="right">\n' +
670
- '\t <a class="btnstyle" onclick="ShowCustomTempLog();" data-i18n="Custom Graph">Custom Graph</a>\n' ;
671
- if ( $scope . config . Latitude != "" ) {
672
- tophtm +=
673
- '\t <a id="Forecast" class="btnstyle" onclick="ShowForecast();" data-i18n="Forecast">Forecast</a>\n' ;
674
- }
675
- tophtm +=
676
- '\t </td>\n' +
677
- '\t</tr>\n' +
678
- '\t</table>\n' ;
679
- }
680
- tophtm +=
681
- '</td>' +
682
- '\t</tr>\n' +
683
- '\t</table>\n' ;
684
- }
685
- else {
686
- tophtm +=
687
- '\t<table border="0" cellpadding="0" cellspacing="0" width="100%">\n' +
688
- '\t<tr>\n' +
689
- '\t <td align="left" valign="top" id="timesun"></td>\n' +
690
- '<td align="right" valign="top">' +
691
- '<span data-i18n="Room">Room</span>: <select id="comboroom" style="width:160px" class="combobox ui-corner-all">' +
692
- '<option value="0" data-i18n="All">All</option>' +
693
- '</select>' +
694
- '</td>' +
695
- '\t</tr>\n' +
696
- '\t</table>\n' ;
697
- if ( window . myglobals . ismobile == false ) {
698
- tophtm +=
699
- '\t<table class="bannav" border="0" cellpadding="0" cellspacing="0" width="100%">\n' +
700
- '\t<tr>\n' +
701
- '\t <td align="left"></td>\n' +
702
- '\t <td align="right">\n' +
703
- '\t <a class="btnstyle" onclick="ShowCustomTempLog();" data-i18n="Custom Graph">Custom Graph</a>\n' ;
704
- if ( $scope . config . Latitude != "" ) {
705
- tophtm +=
706
- '\t <a id="Forecast" class="btnstyle" onclick="ShowForecast();" data-i18n="Forecast">Forecast</a>\n' ;
707
- }
708
- tophtm +=
709
- '\t </td>\n' +
710
- '\t</tr>\n' +
711
- '\t</table>\n' ;
712
- }
713
- }
630
+ // TODO should belong to a global controller
631
+ ctrl . isNotMobile = function ( ) {
632
+ return $window . myglobals . ismobile == false ;
633
+ } ;
634
+
635
+ var bHaveAddedDevider = false ; // TODO remove ?
714
636
715
- var i = 0 ;
637
+ var i = 0 ; // TODO remove ?
716
638
717
639
$ . ajax ( {
718
640
url : "json.htm?type=devices&filter=temp&used=true&order=Name&plan=" + window . myglobals . LastPlanSelected ,
@@ -731,25 +653,12 @@ define(['app'], function (app) {
731
653
}
732
654
} ) ;
733
655
$ ( '#modal' ) . hide ( ) ;
734
- $ ( '#tempcontent' ) . html ( tophtm ) ;
656
+ $ ( '#temptophtm' ) . show ( ) ;
657
+ $ ( '#temptophtm' ) . i18n ( ) ;
735
658
$ ( '#tempwidgets' ) . show ( ) ;
736
659
$ ( '#tempwidgets' ) . i18n ( ) ;
660
+ $ ( '#tempcontent' ) . html ( "" ) ;
737
661
$ ( '#tempcontent' ) . i18n ( ) ;
738
- if ( bShowRoomplan == true ) {
739
- $ . each ( $ . RoomPlans , function ( i , item ) {
740
- var option = $ ( '<option />' ) ;
741
- option . attr ( 'value' , item . idx ) . text ( item . name ) ;
742
- $ ( "#tempcontent #comboroom" ) . append ( option ) ;
743
- } ) ;
744
- if ( typeof window . myglobals . LastPlanSelected != 'undefined' ) {
745
- $ ( "#tempcontent #comboroom" ) . val ( window . myglobals . LastPlanSelected ) ;
746
- }
747
- $ ( "#tempcontent #comboroom" ) . change ( function ( ) {
748
- var idx = $ ( "#tempcontent #comboroom option:selected" ) . val ( ) ;
749
- window . myglobals . LastPlanSelected = idx ;
750
- ShowTemps ( ) ;
751
- } ) ;
752
- }
753
662
754
663
$rootScope . RefreshTimeAndSun ( ) ;
755
664
@@ -1061,7 +970,37 @@ define(['app'], function (app) {
1061
970
$interval . cancel ( $scope . mytimer ) ;
1062
971
$scope . mytimer = undefined ;
1063
972
}
1064
- } ) ;
973
+ } ) ;
974
+
975
+ ctrl . RoomPlans = [ { idx :0 , name :$ . t ( "All" ) } ] ;
976
+ $ . ajax ( {
977
+ url : "json.htm?type=plans" ,
978
+ async : false ,
979
+ dataType : 'json' ,
980
+ success : function ( data ) {
981
+ if ( typeof data . result != 'undefined' ) {
982
+ var totalItems = data . result . length ;
983
+ if ( totalItems > 0 ) {
984
+ $ . each ( data . result , function ( i , item ) {
985
+ ctrl . RoomPlans . push ( {
986
+ idx : item . idx ,
987
+ name : item . Name
988
+ } ) ;
989
+ } ) ;
990
+ }
991
+ }
992
+ }
993
+ } ) ;
994
+
995
+ if ( typeof window . myglobals . LastPlanSelected != 'undefined' ) {
996
+ ctrl . roomSelected = window . myglobals . LastPlanSelected ;
997
+ }
998
+ ctrl . changeRoom = function ( ) {
999
+ var idx = ctrl . roomSelected ;
1000
+ window . myglobals . LastPlanSelected = idx ;
1001
+ ShowTemps ( ) ;
1002
+ } ;
1003
+
1065
1004
} ] )
1066
1005
. directive ( 'dztemperaturewidget' , function ( ) {
1067
1006
return {
@@ -1201,6 +1140,7 @@ define(['app'], function (app) {
1201
1140
1202
1141
ctrl . ShowTempLog = function ( divId , fn ) {
1203
1142
$ ( '#tempwidgets' ) . hide ( ) ; // TODO delete when multiple views implemented
1143
+ $ ( '#temptophtm' ) . hide ( ) ;
1204
1144
return ShowTempLog ( divId , fn , ctrl . item . idx , escape ( ctrl . item . Name ) ) ;
1205
1145
} ;
1206
1146
@@ -1214,11 +1154,13 @@ define(['app'], function (app) {
1214
1154
1215
1155
ctrl . ShowNotifications = function ( divId , fn ) {
1216
1156
$ ( '#tempwidgets' ) . hide ( ) ; // TODO delete when multiple views implemented
1157
+ $ ( '#temptophtm' ) . hide ( ) ;
1217
1158
return ShowNotifications ( ctrl . item . idx , escape ( ctrl . item . Name ) , divId , fn ) ;
1218
1159
} ;
1219
1160
1220
1161
ctrl . ShowForecast = function ( divId , fn ) {
1221
1162
$ ( '#tempwidgets' ) . hide ( ) ; // TODO delete when multiple views implemented
1163
+ $ ( '#temptophtm' ) . hide ( ) ;
1222
1164
return ShowForecast ( atob ( ctrl . item . forecast_url ) , escape ( ctrl . item . Name ) , divId , fn ) ;
1223
1165
} ;
1224
1166
0 commit comments