Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 6ad3b40

Browse files
Switch from window.alert() to sweetalert2
1 parent 3637ab7 commit 6ad3b40

File tree

2 files changed

+73
-13
lines changed

2 files changed

+73
-13
lines changed

public/js/settings.js

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,40 @@ switch (localStorage.getItem('favicon')) {
3838

3939
function changeProxy(proxy) {
4040
if (proxy === 'Aero') {
41-
if (window.confirm('NOTE: aero is very unstable and may break are you sure you want to use it? (Press OK to continue)')) {
42-
localStorage.setItem('proxy', proxy)
43-
} else {
44-
window.alert('Ok, defaulting to last selected option...')
45-
window.location.reload();
46-
}
47-
} else {
41+
Swal.fire({
42+
title: 'Are you sure?',
43+
text: "aero is very unstable and may cause issues and break",
44+
icon: 'warning',
45+
color: 'var(--text-color)',
46+
background: 'var(--bg-color)',
47+
showCancelButton: true,
48+
confirmButtonColor: '#3085d6',
49+
cancelButtonColor: '#d33',
50+
confirmButtonText: 'Yes, I am sure'
51+
}).then((result) => {
52+
if (result.isConfirmed) {
53+
Swal.fire({
54+
title: 'Changed',
55+
text: 'You are now using aero',
56+
icon: 'success',
57+
color: 'var(--text-color)',
58+
background: 'var(--bg-color)',
59+
});
60+
localStorage.setItem('proxy', proxy);
61+
}
62+
else {
63+
Swal.fire({
64+
title: 'Defaulting...',
65+
text: 'Defaulting to previously selected option',
66+
color: 'var(--text-color)',
67+
background: 'var(--bg-color)',
68+
}).then(() => {
69+
window.location.reload();
70+
})
71+
}
72+
})
73+
}
74+
else {
4875
localStorage.setItem('proxy', proxy);
4976
}
5077
}
@@ -121,13 +148,43 @@ function handleClickOff() {
121148
}
122149

123150
function setPassword(value) {
124-
if (window.confirm('Are you sure you want to set a password?')) {
125-
localStorage.setItem('password', value);
126-
window.location.reload();
127-
} else {
128-
alert('OK then, your password will not be set.');
151+
Swal.fire({
152+
title: 'Are you sure you would like to set a password?',
153+
text: "If you don't remember this password you will have to clear all data on this website",
154+
icon: 'warning',
155+
color: 'var(--text-color)',
156+
background: 'var(--bg-color)',
157+
showCancelButton: true,
158+
confirmButtonColor: '#3085d6',
159+
cancelButtonColor: '#d33',
160+
confirmButtonText: 'Yes, I am sure'
161+
}).then((result) => {
162+
if (result.isConfirmed) {
163+
localStorage.setItem('password', value);
164+
Swal.fire({
165+
title: 'Password Set!',
166+
text: 'Your password is now set! As a reminder here is the password: ' + localStorage.getItem('password'),
167+
icon: 'success',
168+
color: 'var(--text-color)',
169+
background: 'var(--bg-color)',
170+
}).then(() => {
171+
localStorage.setItem('unlocked', false)
172+
window.location.reload()
173+
})
174+
}
175+
else {
176+
Swal.fire({
177+
title: 'Password not set',
178+
color: 'var(--text-color)',
179+
icon: 'info',
180+
background: 'var(--bg-color)',
181+
})
182+
.then(() => {
183+
window.location.reload();
184+
})
185+
}
186+
});
129187
}
130-
}
131188

132189
function changeFullscreen(value) {
133190
localStorage.setItem('fullscreenBehavior', value);
@@ -170,6 +227,8 @@ function resetAll() {
170227
localStorage.removeItem('bgeffect');
171228
localStorage.removeItem('clickoff');
172229
localStorage.removeItem('fullscreenBehavior');
230+
localStorage.removeItem('password');
231+
localStorage.removeItem('unlocked');
173232
document.cookie =
174233
'allowads=; Max-Age=0; path=/; domain=' + window.location.hostname;
175234
localStorage.removeItem('adsallowed');

src/pages/settings.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import Password from '../components/password';
4747
content="https://user-images.githubusercontent.com/73721704/210157935-6aa8ec46-6fa4-4dd5-956f-6bfe351de42c.png"
4848
/>
4949
<!-- END METADATA -->
50+
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11" defer></script>
5051
</head>
5152
<body>
5253
<Header />

0 commit comments

Comments
 (0)