blob: 994bbdce1c16082cf6c2fc6f52503e0c328d87a9 (
plain)
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
|
<h2>Wake-up alert
<details style="display: inline-block;font-size:12px;">
<summary class="text-muted" style="opacity:.5;"></summary>
<label><input id="test-mode" type="checkbox"> Test Mode</label> · <label><input id="fake-requests" type="checkbox"> Fake Requests</label>
</details>
</h2>
<span data-bs-toggle="modal" data-bs-target="#turn-on" id="btn-on" style="background: #7f0000;font-size: 48px;padding: 10px 50px;border-radius: 10px;width: max-content;display: block;margin-left: auto;margin-right: auto;cursor: pointer;">Turn <b>ON</b></span>
<span onclick="disableAlert()" id="btn-off" style="display:none;background: #007f0b;font-size: 48px;padding: 10px 50px;border-radius: 10px;width: max-content;margin-left: auto;margin-right: auto;cursor: pointer;">Turn <b>OFF</b></span>
<p style="text-align:center;margin-top:10px;">Sending next notification <b><span id="next-notification">never</span></b></p>
<style>
<?php global $use2023UI; if (!$use2023UI): ?>
.modal-header {
border-bottom: 1px solid #353738;
}
.modal-content {
border: 1px solid rgba(255, 255, 255, .2);
background-color: #111;
}
.btn-close {
filter: invert(1);
}
<?php endif; ?>
#btn-on.disabled, #btn-off.disabled {
opacity: .5;
pointer-events: none;
}
</style>
<div class="modal" id="turn-on">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Somepony will be awoken.</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<button onclick="enableAlert();" data-bs-dismiss="modal" class="btn btn-success" style="font-size:20px;font-weight:bold;display:block;width:100%;">I wish to proceed.</button>
<hr>
<div class="alert alert-warning">
This alert system is designed to emit sudden alerts, and may surprise somepony if e.g. they are sleeping. Keep that in mind.
</div>
<p>
<b>Disclaimer:</b> This is NOT an emergency alert system, use the "Emergency alert" option is you need immediate help and comfort.
</p>
<p>
© <?= date('Y') ?> Equestria.dev
</p>
</div>
</div>
</div>
</div>
<script>
window.alertInterval = null;
window.alertIntervalAmount = 5;
window.alertIntervalCounter = window.alertIntervalAmount;
function sendNotification() {
window.alertIntervalCounter = -1;
if (document.getElementById("test-mode").checked) {
document.getElementById("next-notification").innerText = "now";
if (document.getElementById("fake-requests").checked) {
window.alertIntervalCounter = window.alertIntervalAmount;
document.getElementById("next-notification").innerText = "in " + window.alertIntervalAmount + " seconds";
} else {
window.fetch("/api/wakeup").then(() => {
window.alertIntervalCounter = window.alertIntervalAmount;
document.getElementById("next-notification").innerText = "in " + window.alertIntervalAmount + " seconds";
})
}
} else {
document.getElementById("next-notification").innerText = "now";
if (document.getElementById("fake-requests").checked) {
window.alertIntervalCounter = window.alertIntervalAmount;
document.getElementById("next-notification").innerText = "in " + window.alertIntervalAmount + " seconds";
} else {
window.fetch("/api/wakeup-real").then(() => {
window.alertIntervalCounter = window.alertIntervalAmount;
document.getElementById("next-notification").innerText = "in " + window.alertIntervalAmount + " seconds";
})
}
}
}
function enableAlert() {
sendNotification();
document.getElementById("btn-on").style.display = "none";
document.getElementById("btn-off").style.display = "block";
document.getElementById("test-mode").disabled = true;
document.getElementById("fake-requests").disabled = true;
window.alertInterval = setInterval(() => {
window.alertIntervalCounter--;
if (window.alertIntervalCounter === 0) {
sendNotification();
} else if (window.alertIntervalCounter > -1) {
document.getElementById("next-notification").innerText = "in " + window.alertIntervalCounter + " second" + (window.alertIntervalCounter > 1 ? "s" : "");
}
}, 1000);
}
function disableAlert() {
clearInterval(window.alertInterval);
document.getElementById("next-notification").innerText = "never";
document.getElementById("btn-on").style.display = "block";
document.getElementById("btn-off").style.display = "none";
document.getElementById("test-mode").disabled = false;
document.getElementById("fake-requests").disabled = false;
}
</script>
|