Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -33,13 +33,37 @@ def check_text(prompt, negative=""):
|
|
33 |
|
34 |
|
35 |
js_func = """
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
url.searchParams.set('__theme', 'dark');
|
40 |
-
|
|
|
41 |
}
|
|
|
|
|
|
|
|
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
"""
|
44 |
|
45 |
|
|
|
33 |
|
34 |
|
35 |
js_func = """
|
36 |
+
|
37 |
+
function toggleTheme() {
|
38 |
+
const url = new URL(window.location.href);
|
39 |
+
const currentTheme = url.searchParams.get('__theme');
|
40 |
+
|
41 |
+
if (currentTheme !== 'dark') {
|
42 |
url.searchParams.set('__theme', 'dark');
|
43 |
+
} else {
|
44 |
+
url.searchParams.delete('__theme');
|
45 |
}
|
46 |
+
|
47 |
+
history.pushState({}, '', url.href);
|
48 |
+
|
49 |
+
applyTheme();
|
50 |
}
|
51 |
+
|
52 |
+
function applyTheme() {
|
53 |
+
const url = new URL(window.location.href);
|
54 |
+
const currentTheme = url.searchParams.get('__theme');
|
55 |
+
|
56 |
+
if (currentTheme === 'dark') {
|
57 |
+
document.body.classList.add('dark-theme');
|
58 |
+
} else {
|
59 |
+
document.body.classList.remove('dark-theme');
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
window.onload = function() {
|
64 |
+
applyTheme();
|
65 |
+
}
|
66 |
+
|
67 |
"""
|
68 |
|
69 |
|