-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.html
237 lines (212 loc) · 13.1 KB
/
button.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="css/dhive/jquery-ui.min.css" id="jqui_theme"/>
<link rel="stylesheet" href="css/backgrounds.css" type="text/css"/>
<link rel="stylesheet" href="css/hqWidgets.css" type="text/css"/>
<link rel="stylesheet" href="css/hqUtils.css" type="text/css"/>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/hqUtils.js"></script>
<script type="text/javascript" src="js/hqWidgets.js"></script>
<script type="text/javascript">
// Default body stle
var gBodyStyle = "hq-background-h-gradient-gray-0";
// Simulated image list. Normally this list must return server via some request
var aImages = new Array(
"flat.png",
"kde_folder.png",
"blind.png",
"DoorOpenedIcon.png",
"Lamp.png",
"Temperature.png",
"locked.png",
"LockOpened.png",
"LockOrange.png",
"unlocked.png");
// Request by server the image list in the pictures directory
function GetPicturesList (callback, param) {
// callback (list)
if (callback)
callback (aImages, param);
}
</script>
</head>
<body>
<div id='status' data-desc="Debug messages" style='z-index:1050; position:absolute; top: 100px; left: 100px; color:white'></div>
<div id='statusM' data-desc="Debug messages" style='z-index:1050; position:absolute; top: 50px; left: 100px; color:white'></div>
</body>
<script type="text/javascript">
// Apply current body style
$('body').addClass(gBodyStyle);
function onTimeoutChange (p) {
p.SetState ( p.dynStates.state == hqWidgets.gState.gStateOff ? hqWidgets.gState.gStateOn : hqWidgets.gState.gStateOff);
setTimeout (function (elem) {onTimeoutChange (elem);}, 5000, p);
}
// Init hqWidgets framework
hqWidgets.Init ({gGetFiles: GetPicturesList});
var isCtxMenu = true;
// ---------------- Create buttons --------------------------
// Create background image
var bg = hqWidgets.Create ({isContextMenu: isCtxMenu, x:10, y: 60, buttonType: hqWidgets.gButtonType.gTypeImage, iconName:'flat.png', zindex: -2});
// create dimmer 1
var b0 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:350, y:200, room: hqWidgets.Translate("Dimmer"), buttonType: hqWidgets.gButtonType.gTypeDimmer, iconName: 'Lamp.png', position: 100, hoursLastAction:-1});//, 'original/motion.png');
// create dimmer 2
var b01= hqWidgets.Create ({isContextMenu: isCtxMenu, x:350, y:260, room: hqWidgets.Translate("Dimmer1"), buttonType: hqWidgets.gButtonType.gTypeDimmer, iconName: 'Lamp.png', position: 100, hoursLastAction:-1});//, 'original/motion.png');
// create inside temperature (with valve state)
var b1 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:60, y:150, room: hqWidgets.Translate("Schlaffzimmer"),buttonType: hqWidgets.gButtonType.gTypeInTemp, iconName: 'Temperature.png'});//, 'original/motion.png');
var b2 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:70, y:70, room: hqWidgets.Translate("Balkon"), buttonType: hqWidgets.gButtonType.gTypeOutTemp, iconName: 'Temperature.png'});
var b3 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:140, y:70, room: hqWidgets.Translate("Wohzimmer"), iconName: 'Lamp.png', radius: 5, title: "Test", infoTextCss: {color: 'white'}});
var b4 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:210, y:70, room: hqWidgets.Translate("Wohzimmer"), buttonType: hqWidgets.gButtonType.gTypeBlind});
var b5 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:380, y:70, room: hqWidgets.Translate("Wohzimmer"), buttonType: hqWidgets.gButtonType.gTypeBlind});
var b6 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:120, y:180, room: hqWidgets.Translate("Wohzimmer"), buttonType: hqWidgets.gButtonType.gTypeDoor, width: 50, height:100, border:2, doorType: hqWidgets.gSwingType.gSwingRight});
var b7 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:110, y:170, room: hqWidgets.Translate("WC"), buttonType: hqWidgets.gButtonType.gTypeLock, width: 30, height:30, _noBackground: true, iconName: 'unlocked.png', doorType: hqWidgets.gSwingType.gSwingRight});
var b8 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:210, y:170, room: hqWidgets.Translate("KZ"), buttonType: hqWidgets.gButtonType.gTypeText, text: 'Sample text'});
// Create ip cam widget
var b9 = hqWidgets.Create ({isContextMenu: isCtxMenu, x:220, y:370, room: hqWidgets.Translate("KZ"), buttonType: hqWidgets.gButtonType.gTypeGong, /*radius:2,width:100, height:60, */ipCamImageURL: 'http://blog-imgs-55-origin.fc2.com/k/i/t/kitchencounterdesign/House-Photo-2.jpg', popUpDelay: 10000, gongQuestionImg: 'DoorOpen.png', gongActionBtn: true, ipCamActionBtn: true, title: 'KZ Camera', iconName: 'ringing-bell.png', gongMelody: 'door-bell.mp3'});
var b10 =hqWidgets.Create ({isContextMenu: isCtxMenu, x:20, y:330, room: hqWidgets.Translate("KZ"), buttonType: hqWidgets.gButtonType.gTypeCam, radius:2,width:100, height:60, ipCamImageURL: 'http://blog-imgs-55-origin.fc2.com/k/i/t/kitchencounterdesign/House-Photo-2.jpg', popUpDelay: 10000, /*gongActionBtn: true, ipCamActionBtn: true,*/ title: 'KZ Camera'});
onTimeoutChange(b3);
setTimeout (function (a) { a.SetStates({state: hqWidgets.gState.gStateOn});}, 1000, b9);
setTimeout (function (a) { a.SetStates({state: hqWidgets.gState.gStateOff});}, 15000, b9);
setTimeout (function (a) { a.SetStates({state: hqWidgets.gState.gStateOn});}, 3000, b6);
var editMode = hqWidgets.Create ({isContextMenu: isCtxMenu, x:300, y:300, title:hqWidgets.Translate("Edit mode"), divName: "edit_mode"});
// Simulate dynamic changes
b3.SetStates ({infoText: "130"});
b0.SetStates ({action: function (p, op, value){
if (op != "pos") {
p.SetState ( p.dynStates.state == hqWidgets.gState.gStateOff ? hqWidgets.gState.gStateOn : hqWidgets.gState.gStateOff);
console.log (p.settings.room + ": new status - " + p.dynStates.state);
}
else
console.log (p.settings.room + ": new value - " + value + "%");
}});
b01.SetStates ({action: function (p, op, value){
if (op != "pos")
console.log (p.settings.room + ": new status - " + p.dynStates.state);
else
console.log (p.settings.room + ": new value - " + value + "%");
}});
b1.SetStates ({action: function (p, op, value){
console.log (p.settings.room + ": new "+op+" - " + value);
}});
b7.SetStates ({action: function (p, op, value) {
console.log (p.settings.room + ": new status - " + value);
}});
b1.SetStates ({temperature: 5, setTemp: 10, humidity: 55, valve: 12});
b2.SetStates ({temperature: 5, setTemp: 10, humidity: 55, valve: 12});
b4.SetStates ({action: function (p, op, value) {
p.SetStates ({state: hqWidgets.gState.gStateOff, isWorking: true});
p.SetWindowState (0, hqWidgets.gWindowState.gWindowToggle);
p.SetWindowState (1, hqWidgets.gWindowState.gWindowToggle);
p.SetWindowState (2, hqWidgets.gWindowState.gWindowToggle);
console.log (p.settings.room + ": new value - " + value + "%");
p.SetStates({percentState: value});
}});
b5.SetStates ({action: function (p, op, value) {
p.SetStates ({state: hqWidgets.gState.gStateOff, isRefresh: true});
p.SetWindowState (0, hqWidgets.gWindowState.gWindowToggle);
p.SetWindowState (1, hqWidgets.gWindowState.gWindowToggle);
console.log (p.settings.room + ": new value - " + value + "%");
}});
b4.SetSettings ({width: 140, height: 70, windowConfig: hqWidgets.gSwingType.gSwingLeft+","+hqWidgets.gSwingType.gSwingLeft+","+hqWidgets.gSwingType.gSwingRight});
b4.SetStates ({handleState: "1,2,3"});
//b4.SetStates ({windowState: "2,2"});
// b6.SetState(hqWidgets.gState.gStateOn);
b4.SetStates ({lowBattery: true});
b4.SetStates ({lowBattery: false});
b4.SetStates ({lowBattery: true});
b3.SetStates ({isStrengthShow: true, strength: -64});
b9.SetStates({action: function (p, op, value) {
if (op == "state")
console.log (p.settings.title + ": play gong");
if (op == "open")
console.log (p.settings.title + ": open door");
}});
setTimeout (function () {b4.SetStates ({percentState: 80})}, 1000);
setTimeout (function () {b0.SetStates ({percentState: 20})}, 1000);
b3.SetStates ({action: function (p){p.SetRefresh(true); p.SetState ( p.dynStates.state == hqWidgets.gState.gStateOff ? hqWidgets.gState.gStateOn : hqWidgets.gState.gStateOff);}});
b2.SetStates ({action: function (p){p.SetRefresh(true); p.SetState ( p.dynStates.state == hqWidgets.gState.gStateOff ? hqWidgets.gState.gStateOn : hqWidgets.gState.gStateOff);}});
//b4.SetStates ({action: function (p){p.SetState ( p.dynStates.state == hqWidgets.gState.gStateOff ? hqWidgets.gState.gStateOn : hqWidgets.gState.gStateOff);}});
b2.SetStates({state: hqWidgets.gState.gStateOff});
b1.SetStates({state: hqWidgets.gState.gStateOff});
editMode.settings.isIgnoreEditMode=true;
editMode.SetTitle ("", "Switch edit mode on/off");
editMode.dynStates.action = function (p) { if (hqWidgets.SetEditMode()) p.SetState (hqWidgets.gState.gStateOn); else p.SetState (hqWidgets.gState.gStateOff); };
editMode.SetStates({state: hqWidgets.gState.gStateOff});
var first = hqStyleSelector.init ({ width: 150,
style: "menuElementHeader",
styles: {"Style": "hq-button-base-normal",
"AAA": "hq-button-base-normal-hover",
"Menu": "menuElementHeader",
}
});
hqStyleSelector.init ({ width: 200,
style: hqWidgets.gDynamics.gBodyStyle,
styles: {
"Blue marine lines": "hq-background-blue-marine-lines",
"Blue marine": "hq-background-blue-marine",
"Blue flowers": "hq-background-blue-flowers",
"Blue radial": "hq-background-radial-blue",
"Black hor. gradient 0": "hq-background-h-gradient-black-0",
"Black hor. gradient 1": "hq-background-h-gradient-black-1",
"Black hor. gradient 2": "hq-background-h-gradient-black-2",
"Black hor. gradient 3": "hq-background-h-gradient-black-3",
"Black hor. gradient 4": "hq-background-h-gradient-black-4",
"Black hor. gradient 5": "hq-background-h-gradient-black-5",
"Orange hor. gradient 0": "hq-background-h-gradient-orange-0",
"Orange hor. gradient 1": "hq-background-h-gradient-orange-1",
"Orange hor. gradient 2": "hq-background-h-gradient-orange-2",
"Orange hor. gradient 3": "hq-background-h-gradient-orange-3",
"Blue hor. gradient 0": "hq-background-h-gradient-blue-0",
"Blue hor. gradient 1": "hq-background-h-gradient-blue-1",
"Blue hor. gradient 2": "hq-background-h-gradient-blue-2",
"Blue hor. gradient 3": "hq-background-h-gradient-blue-3",
"Blue hor. gradient 4": "hq-background-h-gradient-blue-4",
"Blue hor. gradient 5": "hq-background-h-gradient-blue-5",
"Blue hor. gradient 6": "hq-background-h-gradient-blue-6",
"Blue hor. gradient 7": "hq-background-h-gradient-blue-7",
"Yellow hor. gradient 0": "hq-background-h-gradient-yellow-0",
"Yellow hor. gradient 1": "hq-background-h-gradient-yellow-1",
"Yellow hor. gradient 2": "hq-background-h-gradient-yellow-2",
"Yellow hor. gradient 3": "hq-background-h-gradient-yellow-3",
"Green hor. gradient 0": "hq-background-h-gradient-green-0",
"Green hor. gradient 1": "hq-background-h-gradient-green-1",
"Green hor. gradient 2": "hq-background-h-gradient-green-2",
"Green hor. gradient 3": "hq-background-h-gradient-green-3",
"Green hor. gradient 4": "hq-background-h-gradient-green-4",
"Gray flat 0": "hq-background-gray-0",
"Gray flat 1": "hq-background-gray-1",
"Gray hor. gradient 0": "hq-background-h-gradient-gray-0",
"Gray hor. gradient 1": "hq-background-h-gradient-gray-1",
"Gray hor. gradient 2": "hq-background-h-gradient-gray-2",
"Gray hor. gradient 3": "hq-background-h-gradient-gray-3",
"Gray hor. gradient 4": "hq-background-h-gradient-gray-4",
"Gray hor. gradient 5": "hq-background-h-gradient-gray-5",
"Gray hor. gradient 6": "hq-background-h-gradient-gray-6",
"Gray graident": "hq-background-gradient-box",
},
onchange: function (newStyle, obj) {
$('body').removeClass(gBodyStyle);
gBodyStyle = newStyle;
$('body').addClass(gBodyStyle);
},
});
hqStyleSelector.destroy (first);
// title
// titleIcon
// isClose - isCloseButton
// content
// isYes
// isNo
// isOk
// positionX: center, left, right
// positionY: middle, top, bottom
// x
// y
// width
// height
// modal
// timeout
//var d = new hqUtils.Dialog ({title: "Test window", positionX: 'center', positionY: 'middle', height: 200, modal: true, timeout: 5000});
//SetEditMode (true);
</script>
</html>