-
Notifications
You must be signed in to change notification settings - Fork 0
/
preventsleep.html
84 lines (77 loc) · 2.19 KB
/
preventsleep.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
<script src="NoSleep.min.js"></script>
<div id="prevent-sleep">
<br><h4 class="onoffswitch-text">Prevent my device from sleeping</h4>
<div class="onoffswitch">
<input type="checkbox" name="preventsleep" class="onoffswitch-checkbox" id="preventsleep">
<label class="onoffswitch-label" for="preventsleep">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
<script>
var noSleep = new NoSleep();
$('#prevent-sleep').mousedown(function() {
setTimeout(function(){
if ($('#preventsleep').is(':checked')) {
noSleep.enable();
console.log("NoSleep enabled.");
} else {
noSleep.disable();
console.log("NoSleep disabled.");
}
}, 1000);
});
$('#prevent-sleep').bind("touchstart",function(e) {
setTimeout(function(){
if ($('#preventsleep').is(':checked')) {
noSleep.enable();
console.log("NoSleep enabled.");
} else {
noSleep.disable();
console.log("NoSleep disabled.");
}
}, 1000);
});
</script>
<style>
.onoffswitch {
position: relative; width: 58px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
display: inline-block;
vertical-align: middle;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
height: 30px; padding: 0; line-height: 30px;
border: 2px solid #999999; border-radius: 30px;
background-color: #EEEEEE;
transition: background-color 0.3s ease-in;
}
.onoffswitch-label:before {
content: "";
display: block; width: 30px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 26px;
border: 2px solid #999999; border-radius: 30px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label {
background-color: #7F54A3;
}
.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before {
border-color: #7F54A3;
}
.onoffswitch-checkbox:checked + .onoffswitch-label:before {
right: 0px;
}
.onoffswitch-text {
display: inline-block;
vertical-align: middle;
padding-right: 10px;
}
</style>