prithivMLmods commited on
Commit
94811c4
1 Parent(s): 7b95e38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -33,13 +33,37 @@ def check_text(prompt, negative=""):
33
 
34
 
35
  js_func = """
36
- function refresh() {
37
- const url = new URL(window.location);
38
- if (url.searchParams.get('__theme') !== 'dark') {
 
 
 
39
  url.searchParams.set('__theme', 'dark');
40
- window.location.href = url.href;
 
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