Skip to content

Commit 6834b54

Browse files
committed
panic key fix
1 parent 712797f commit 6834b54

File tree

2 files changed

+49
-26
lines changed

2 files changed

+49
-26
lines changed

javascripts/cloak.js

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,57 @@ const urlToOpen = document.querySelector('.container div .urlToOpen');
44
panicKey.addEventListener('click', (e) => {
55
e.preventDefault();
66

7-
const p = prompt("Do you want these settings to last throughout multiple sessions [yes/no]");
7+
panicKey.addEventListener('input', (e) => {
8+
e.preventDefault();
89

9-
if (p === 'yes') {
10-
panicKey.addEventListener('input', (e) => {
10+
panicKey.addEventListener('keypress', (e) => {
1111
e.preventDefault();
12-
13-
panicKey.addEventListener('keypress', (e) => {
14-
e.preventDefault();
15-
16-
if (e.key === 'Enter') {
17-
const selectedKey = panicKey.value.trim() || ']';
18-
19-
localStorage.setItem('panicKey', selectedKey);
20-
21-
panicKey.addEventListener('keypress', (e) => {
22-
if (e.key === localStorage.getItem('panicKey')) {
23-
const url = urlToOpen.value;
24-
25-
if (url == '' || !url.startsWith('https') || !url.startsWith('http')) {
26-
alert("Please provide a valid URL");
27-
}
28-
29-
12+
13+
if (e.key === 'Enter') {
14+
const selectedKey = panicKey.value.trim() || ']';
15+
16+
sessionStorage.setItem('panicKey', selectedKey);
17+
18+
window.addEventListener('keypress', (e) => {
19+
if (e.key === sessionStorage.getItem('panicKey')) {
20+
const url = urlToOpen.value || 'https://myapps.classlink.com';
21+
22+
if (url == '') {
23+
alert("Please provide a valid URL");
24+
}
25+
26+
window.location.replace(url);
27+
28+
if (!url.startsWith('https') || !url.startsWith('http') && url.match(/(https?:\/\/([-\w\.]+[-\w]){1,63}\.[a-zA-Z]{2,6}(\/[^\s]*)?)/g)) {
29+
window.location.replace(`https://${url}`);
30+
}
31+
}
32+
});
33+
}
34+
});
35+
36+
urlToOpen.addEventListener('keypress', (e) => {
37+
if (e.key === 'Enter') {
38+
const selectedKey = panicKey.value.trim() || ']';
39+
40+
sessionStorage.setItem('panicKey', selectedKey);
41+
42+
window.addEventListener('keypress', (e) => {
43+
if (e.key === sessionStorage.getItem('panicKey')) {
44+
const url = urlToOpen.value || 'https://myapps.classlink.com';
45+
46+
if (url == '') {
47+
alert("Please provide a valid URL");
48+
}
49+
50+
window.location.replace(url);
51+
52+
if (!url.startsWith('https') || !url.startsWith('http') && url.match(/(https?:\/\/([-\w\.]+[-\w]){1,63}\.[a-zA-Z]{2,6}(\/[^\s]*)?)/g)) {
53+
window.location.replace(`https://${url}`);
3054
}
31-
});
32-
}
33-
});
55+
}
56+
});
57+
}
3458
});
35-
}
59+
});
3660
});

styles/style.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ body
275275
&:hover
276276
{
277277
box-shadow: 5px 9px 12px #00000034;
278-
transform: rotate3d(1, 1, 2, 3deg) scale(1.14);
279278
}
280279
input
281280
{

0 commit comments

Comments
 (0)