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
|
<h2>Emergency 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 data-bs-toggle="modal" data-bs-target="#turn-off" 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>
.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);
}
</style>
<div class="modal fade" id="turn-on">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">This is to be treated seriously.</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="alert alert-danger">
<b>WARNING:</b> This alert should be used IF AND ONLY IF you are in a situation that requires immediate help from a loved one. If your life is at immediate risk, please do not use this emergency system and call your local emergency services.
</div>
<div class="alert alert-danger">
Keep this page open until you receive help. If you close the page, alert notifications will not be sent.
</div>
<button onclick="enableAlert();" data-bs-dismiss="modal" class="btn btn-danger" style="font-size:20px;font-weight:bold;display:block;width:100%;">I understand the risk, enable the alert now.</button>
<hr>
<div class="alert alert-danger">
Once enabled, disable the alert system ONLY once you are safe. <b>Your mental health is more important than sleep.</b>
</div>
<div class="alert alert-warning">
This emergency alert system is designed to make sure a loved one can get in touch with you as soon as possible. Therefore, it will emit sudden alerts, and may surprise somecreature if e.g. they are sleeping. Keep that in mind.
</div>
<p>
<b>Disclaimer:</b> This emergency alert system MUST NOT be used in life-threatening situations. Although it has been extensively tested in multiple conditions, it may stop working correctly or stop working at all at any time and without warning. If your life is at immediate risk, call your local emergency services.
</p>
<p>
© <?= date('Y') ?> Equestria.dev
</p>
</div>
</div>
</div>
</div>
<div class="modal fade" id="turn-off">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Make sure you are safe.</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="alert alert-danger">
Make sure you are safe, and you got in touch with a loved one before disabling this alert system. It can be re-enabled later at any time. Remember, <b>your mental health is more important than sleep.</b>
</div>
<p class="text-muted">
Scroll until the bottom of the page to disable the alert.
</p>
<p>
<b>Read this if you want to disable the alert before receiving help:</b> Remember you are loved, cared for. Ponies rely on you, need you, love you. We never want to lose any of you, so please, keep the alert enabled until you are safe. If you are unsure, always keep the alert enabled.
</p>
<p>
<b>Disclaimer:</b> This emergency alert system MUST NOT be used in life-threatening situations. Although it has been extensively tested in multiple conditions, it may stop working correctly or stop working at all at any time and without warning. If your life is at immediate risk, call your local emergency services.
</p>
<p>
This service makes use of the ntfy platform, provided by a third party. Do note that their privacy policy applies when delivering the notifications; although they should not contain personal information in any way.
</p>
<p>
© <?= date('Y') ?> Equestria.dev
</p>
<button id="disable-button" onclick="disableAlert();" data-bs-dismiss="modal" class="btn btn-success disabled" style="display:block;width:100%;">I am safe, disable the alert now. <span id="disable-timer">(X)</span></button>
</div>
</div>
</div>
</div>
<script>
window.alertInterval = null;
window.alertIntervalCounter = 15;
window.alertDisablerCounter = 9;
window.alertDisablerEnabled = false;
window.alertDisablerCounterInterval = null;
setInterval(() => {
if (document.getElementById("turn-off").offsetWidth > 0 || document.getElementById("turn-off").offsetHeight > 0) {
if (!window.alertDisablerEnabled) {
window.alertDisablerEnabled = true;
window.alertDisablerCounter = 9;
document.getElementById("disable-timer").innerText = "(" + window.alertDisablerCounter + ")";
document.getElementById("disable-button").classList.add("disabled");
window.alertDisablerCounterInterval = setInterval(() => {
window.alertDisablerCounter--;
if (window.alertDisablerCounter > 0) {
document.getElementById("disable-timer").innerText = "(" + window.alertDisablerCounter + ")";
document.getElementById("disable-button").classList.add("disabled");
} else {
document.getElementById("disable-timer").innerText = "";
document.getElementById("disable-button").classList.remove("disabled");
}
}, 1000);
}
} else {
window.alertDisablerEnabled = false;
try { clearInterval(window.alertDisablerCounterInterval) } catch (e) {}
window.alertDisablerCounter = 9;
}
});
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 = 15;
document.getElementById("next-notification").innerText = "15 seconds";
} else {
window.fetch("/api/emergency").then(() => {
window.alertIntervalCounter = 15;
document.getElementById("next-notification").innerText = "15 seconds";
})
}
} else {
document.getElementById("next-notification").innerText = "now";
if (document.getElementById("fake-requests").checked) {
window.alertIntervalCounter = 15;
document.getElementById("next-notification").innerText = "15 seconds";
} else {
window.fetch("/api/emergency-real").then(() => {
window.alertIntervalCounter = 15;
document.getElementById("next-notification").innerText = "15 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 = window.alertIntervalCounter + " second" + (window.alertIntervalCounter > 1 ? "s" : "");
}
}, 1000);
}
function disableAlert() {
clearInterval(window.alertInterval);
window.alertIntervalCounter = 15;
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>
|