Adieee5 commited on
Commit
3672af3
·
1 Parent(s): 07d9c40

Index theme

Browse files
Files changed (1) hide show
  1. templates/index.html +39 -24
templates/index.html CHANGED
@@ -6,8 +6,9 @@
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>University Assistant</title>
8
  <script src="https://cdn.tailwindcss.com"></script>
9
- <link rel="stylesheet"
10
- href="{{ url_for('static', filename='style.css') }}">
 
11
 
12
  <script>
13
  tailwind.config = {
@@ -16,38 +17,51 @@
16
  </script>
17
  </head>
18
 
19
- <body class="bg-zinc-100 dark:bg-slate-950 text-black dark:text-white flex items-center justify-center min-h-screen">
20
- <div class="flex w-full flex-col overflow-hidden border border-slate-800 dark:border-gray-700 shadow-lg rounded-lg h-screen">
 
 
 
 
 
 
 
 
21
  <div class="flex flex-col flex-grow overflow-hidden">
22
  <div id="chat-container" class="flex-grow overflow-y-auto p-3 space-y-3 bg-zinc-100 dark:bg-slate-950">
 
23
  </div>
24
- <div class="border-t p-2 border-slate-800 dark:border-slate-800">
25
  <div class="flex gap-2">
26
  <input id="chat-input"
27
- class="flex-grow rounded-md border border-slate-800 dark:border-slate-800 dark:bg-slate-950 bg-zinc-100 dark:bg-slate-800 px-3 py-1 text-sm text-black dark:text-white focus:outline-none"
28
  type="text" placeholder="Type your question here..." />
29
- <button id="send-button"
30
- class="rounded-md bg-blue-600 px-3 py-1 text-white hover:bg-blue-700">➤</button>
 
31
  </div>
32
  </div>
33
  </div>
34
  </div>
35
 
36
  <script>
37
- window.addEventListener("message", (event) => {
38
- // Temporarily allow all origins for testing
39
- // Later: if (event.origin !== "https://juit-ai-assistant.vercel.app") return;
40
-
41
- const { type, theme } = event.data;
42
-
43
- if (type === "set-theme" && (theme === "light" || theme === "dark")) {
44
- // Set theme via class or attribute
45
- document.documentElement.classList.toggle("dark", theme === "dark");
46
- document.body.classList.toggle("dark", theme === "dark");
47
- console.log("Theme set to:", theme);
48
- }
49
  });
50
 
 
 
 
 
 
51
  const API_BASE_URL = window.location.origin;
52
 
53
  const chatContainer = document.getElementById("chat-container");
@@ -73,7 +87,8 @@
73
 
74
  // Use complete URLs for images
75
  const baseUrl = window.location.origin;
76
- avatar.src = msg.isUser ? `${baseUrl}/static/profile.png` : `${baseUrl}/static/JUIT_icon.png`;
 
77
  avatar.alt = msg.isUser ? "User" : "Bot";
78
 
79
  avatar.onerror = function () {
@@ -87,7 +102,7 @@
87
  msgDiv.className = `max-w-[75%] break-words rounded-md px-3 py-1 text-sm ${
88
  msg.isUser
89
  ? "bg-blue-600 text-white rounded-tr-none"
90
- : "bg-gray-200 text-black dark:bg-gray-700 dark:text-white rounded-tl-none"
91
  }`;
92
  msgDiv.innerText = msg.text;
93
  bubble.appendChild(avatar);
@@ -99,8 +114,8 @@
99
  typing.className = "flex items-start gap-2";
100
  typing.innerHTML = `
101
  <img src="../static/JUIT_icon.png" alt="Bot" class="h-9 w-9 rounded-full object-cover" />
102
- <div class="max-w-[75%] rounded-md rounded-tl-none bg-gray-200 dark:bg-gray-700 px-3 py-1 text-sm">
103
- <div class="dot-typing text-black dark:text-white">
104
  <span>.</span><span>.</span><span>.</span>
105
  </div>
106
  </div>
 
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>University Assistant</title>
8
  <script src="https://cdn.tailwindcss.com"></script>
9
+ <!-- <link rel="stylesheet"
10
+ href="{{ url_for('static', filename='style.css') }}"> -->
11
+ <link rel="stylesheet" href="../static/style.css">
12
 
13
  <script>
14
  tailwind.config = {
 
17
  </script>
18
  </head>
19
 
20
+ <body class="bg-zinc-100 text-black dark:bg-slate-950 dark:text-white flex items-center justify-center min-h-screen">
21
+ <div
22
+ class="flex w-full flex-col overflow-hidden border border-gray-300 dark:border-gray-700 shadow-lg rounded-lg h-screen relative">
23
+ <!-- Theme Toggle Icon -->
24
+ <button id="theme-toggle"
25
+ class="absolute top-2 right-2 z-20 flex h-9 w-9 items-center justify-center rounded-full bg-gray-200 dark:bg-gray-800 hover:bg-gray-300 dark:hover:bg-gray-700 text-black dark:text-white shadow transition-all"
26
+ title="Toggle Theme">
27
+ 🌓
28
+ </button>
29
+
30
  <div class="flex flex-col flex-grow overflow-hidden">
31
  <div id="chat-container" class="flex-grow overflow-y-auto p-3 space-y-3 bg-zinc-100 dark:bg-slate-950">
32
+ <!-- Chat messages will appear here -->
33
  </div>
34
+ <div class="border-t p-2 border-gray-300 dark:border-slate-800">
35
  <div class="flex gap-2">
36
  <input id="chat-input"
37
+ class="flex-grow rounded-md border border-gray-300 dark:border-slate-800 bg-white dark:bg-slate-800 px-3 py-1 text-sm text-black dark:text-white focus:outline-none"
38
  type="text" placeholder="Type your question here..." />
39
+ <button id="send-button" class="rounded-md bg-blue-600 px-3 py-1 text-white hover:bg-blue-700">
40
+
41
+ </button>
42
  </div>
43
  </div>
44
  </div>
45
  </div>
46
 
47
  <script>
48
+ const toggleButton = document.getElementById("theme-toggle");
49
+ toggleButton.addEventListener("click", () => {
50
+ document.documentElement.classList.toggle("dark");
51
+
52
+ // Optional: save preference
53
+ if (document.documentElement.classList.contains("dark")) {
54
+ localStorage.setItem("theme", "dark");
55
+ } else {
56
+ localStorage.setItem("theme", "light");
57
+ }
 
 
58
  });
59
 
60
+ // Optional: load theme from localStorage
61
+ if (localStorage.getItem("theme") === "dark") {
62
+ document.documentElement.classList.add("dark");
63
+ }
64
+
65
  const API_BASE_URL = window.location.origin;
66
 
67
  const chatContainer = document.getElementById("chat-container");
 
87
 
88
  // Use complete URLs for images
89
  const baseUrl = window.location.origin;
90
+ // avatar.src = msg.isUser ? `${baseUrl}/static/profile.png` : `${baseUrl}/static/JUIT_icon.png`;
91
+ avatar.src = msg.isUser ? `../static/profile.png` : `../static/JUIT_icon.png`;
92
  avatar.alt = msg.isUser ? "User" : "Bot";
93
 
94
  avatar.onerror = function () {
 
102
  msgDiv.className = `max-w-[75%] break-words rounded-md px-3 py-1 text-sm ${
103
  msg.isUser
104
  ? "bg-blue-600 text-white rounded-tr-none"
105
+ : "bg-gray-200 text-black light:bg-gray-700 light:text-white rounded-tl-none"
106
  }`;
107
  msgDiv.innerText = msg.text;
108
  bubble.appendChild(avatar);
 
114
  typing.className = "flex items-start gap-2";
115
  typing.innerHTML = `
116
  <img src="../static/JUIT_icon.png" alt="Bot" class="h-9 w-9 rounded-full object-cover" />
117
+ <div class="max-w-[75%] rounded-md rounded-tl-none bg-gray-200 light:bg-gray-700 px-3 py-1 text-sm">
118
+ <div class="dot-typing text-black light:text-white">
119
  <span>.</span><span>.</span><span>.</span>
120
  </div>
121
  </div>