-
Notifications
You must be signed in to change notification settings - Fork 0
/
onoff.js
executable file
·106 lines (101 loc) · 1.85 KB
/
onoff.js
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
function turnonoff()
{
$(".onoff").unbind();
$(".onoff").mousedown(function()
{
if ($(this).html() == "Åben")
{
$(this).html("Låst");
$(this).css("background-color", "red");
$(this).css("text-align", "center");
switch($(this).attr("type"))
{
case "work":
onOffWork($(this).attr("name"), false);
return;
case "home":
onOffHome($(this).attr("name"), false);
return;
case "free":
onOffFree($(this).attr("name"), false);
return;
case "lockedSwitch":
onOffFree($(this).attr("name"), false);
return;
}
}
else
{
$(this).html("Åben");
$(this).css("background-color", "green");
$(this).css("text-align", "left");
switch($(this).attr("type"))
{
case "work":
onOffWork($(this).attr("name"), true);
return;
case "home":
onOffHome($(this).attr("name"), true);
return;
case "free":
onOffFree($(this).attr("name"), true);
return;
case "lockedSwitch":
onOffFree($(this).attr("name"), true);
return;
}
}
});
};
(function start()
{
turnonoff();
})();
$(".onsettingsoff").mousedown(function()
{
if ($(this).html() == "Til")
{
$(this).html("Fra");
$(this).css("background-color", "red");
$(this).css("text-align", "center");
}
else
{
$(this).html("Til");
$(this).css("background-color", "green");
$(this).css("text-align", "left");
}
});
function onOffWork(names, value)
{
$.each(doorsWork, function(i)
{
if (doorsWork[i].name == names)
{
doorsWork[i].locked = value;
displayWork();
}
});
}
function onOffHome(names, value)
{
$.each(doorsHome, function(i)
{
if (doorsHome[i].name == names)
{
doorsHome[i].locked = value;
displayHome();
}
});
}
function onOffFree(names, value)
{
$.each(doorsFree, function(i)
{
if (doorsFree[i].name == names)
{
doorsFree[i].locked = value;
displayFree();
}
});
}