eaglelandsonce commited on
Commit
f3d266c
·
verified ·
1 Parent(s): bab596f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +68 -79
index.html CHANGED
@@ -5,7 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Slide Viewer with Grok Chat</title>
7
  <style>
8
- /* Original slide viewer styles */
9
  * {
10
  margin: 0;
11
  padding: 0;
@@ -14,20 +14,42 @@
14
  body {
15
  font-family: Arial, sans-serif;
16
  display: flex;
17
- flex-direction: column;
18
- justify-content: center;
19
- align-items: center;
20
  min-height: 100vh;
21
  background-color: #f0f0f0;
22
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  .container {
 
24
  position: relative;
25
- width: 100%;
26
- max-width: 1920px;
27
- aspect-ratio: 16 / 9;
28
- background: #000;
29
- overflow: hidden;
30
- border: 5px solid #444;
31
  }
32
  .top-bar {
33
  position: absolute;
@@ -79,50 +101,31 @@
79
  object-fit: contain;
80
  display: block;
81
  }
82
-
83
- /* Chat with Grok styles */
84
- .chat-section {
85
- margin-top: 20px;
86
- width: 100%;
87
- max-width: 600px;
88
- }
89
- #prompt {
90
- width: 100%;
91
- margin-bottom: 10px;
92
- padding: 10px;
93
- font-size: 16px;
94
- border: 1px solid #ccc;
95
- border-radius: 5px;
96
- }
97
- button {
98
- padding: 10px 20px;
99
- font-size: 16px;
100
- background-color: #007bff;
101
- color: #fff;
102
- border: none;
103
- border-radius: 5px;
104
- cursor: pointer;
105
- }
106
- button:disabled {
107
- background-color: #ccc;
108
- cursor: not-allowed;
109
- }
110
- .response-container {
111
- margin-top: 20px;
112
- padding: 20px;
113
- background-color: #fff;
114
  border: 1px solid #ccc;
115
  border-radius: 5px;
116
- }
117
- .response-container h3 {
118
- color: #007bff;
119
- }
120
- .response-container p {
121
- font-size: 16px;
122
  }
123
  </style>
124
  </head>
125
  <body>
 
 
 
 
 
 
 
 
 
126
  <div class="container">
127
  <div class="top-bar">
128
  <div class="nav-buttons">
@@ -134,19 +137,13 @@
134
  <div class="main">
135
  <div class="content">
136
  <img id="slide-image" src="images/01_mg.png" alt="Slide Image">
 
 
 
137
  </div>
138
  </div>
139
  </div>
140
 
141
- <div class="chat-section">
142
- <textarea id="prompt" rows="5" placeholder="Enter your prompt here..."></textarea>
143
- <button id="sendButton">Send</button>
144
- <div class="response-container" id="responseContainer" style="display: none;">
145
- <h3>Response:</h3>
146
- <p id="response"></p>
147
- </div>
148
- </div>
149
-
150
  <script>
151
  // Slide viewer script
152
  const slideTitle = document.getElementById('slide-title');
@@ -191,26 +188,17 @@
191
  // Initialize slides
192
  fetchSlides();
193
 
194
- // Chat with Grok script
195
  const API_KEY = "xai-hOb0j9QUXVVQMe86ULxWrvyWQQm2LqnWVdxh5hanvqsiVDsXcSPY9EA7YAM5uLCXaThgJscWxxFCHJFy";
196
  const BASE_URL = "https://api.x.ai/v1";
197
 
198
- const sendButton = document.getElementById("sendButton");
199
- const promptInput = document.getElementById("prompt");
200
- const responseContainer = document.getElementById("responseContainer");
201
- const responseOutput = document.getElementById("response");
202
 
203
- async function sendPrompt() {
204
- const userPrompt = promptInput.value.trim();
205
- if (!userPrompt) {
206
- responseContainer.style.display = "block";
207
- responseOutput.textContent = "Please enter a valid prompt.";
208
- return;
209
- }
210
-
211
- sendButton.disabled = true;
212
- responseContainer.style.display = "block";
213
- responseOutput.textContent = "Loading...";
214
 
215
  try {
216
  const response = await fetch(`${BASE_URL}/chat/completions`, {
@@ -223,7 +211,7 @@
223
  model: "grok-beta",
224
  messages: [
225
  { role: "system", content: "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy." },
226
- { role: "user", content: userPrompt }
227
  ]
228
  })
229
  });
@@ -233,15 +221,16 @@
233
  }
234
 
235
  const data = await response.json();
236
- responseOutput.textContent = data.choices?.[0]?.message?.content || "Unexpected API response.";
237
  } catch (error) {
238
- responseOutput.textContent = `Error: ${error.message}`;
239
- } finally {
240
- sendButton.disabled = false;
241
  }
242
  }
243
 
244
- sendButton.addEventListener("click", sendPrompt);
 
 
 
245
  </script>
246
  </body>
247
  </html>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Slide Viewer with Grok Chat</title>
7
  <style>
8
+ /* General styling */
9
  * {
10
  margin: 0;
11
  padding: 0;
 
14
  body {
15
  font-family: Arial, sans-serif;
16
  display: flex;
17
+ flex-direction: row;
 
 
18
  min-height: 100vh;
19
  background-color: #f0f0f0;
20
  }
21
+ /* Sidebar styling */
22
+ .sidebar {
23
+ width: 40px;
24
+ background-color: #333;
25
+ color: white;
26
+ display: flex;
27
+ flex-direction: column;
28
+ align-items: center;
29
+ padding: 10px 0;
30
+ }
31
+ .prompt-icon {
32
+ margin: 20px 0;
33
+ cursor: pointer;
34
+ text-align: center;
35
+ }
36
+ .prompt-icon img {
37
+ width: 24px;
38
+ height: 24px;
39
+ margin-bottom: 5px;
40
+ }
41
+ .prompt-icon span {
42
+ font-size: 12px;
43
+ display: block;
44
+ }
45
+ /* Main content styling */
46
  .container {
47
+ flex: 1;
48
  position: relative;
49
+ display: flex;
50
+ flex-direction: column;
51
+ align-items: center;
52
+ justify-content: center;
 
 
53
  }
54
  .top-bar {
55
  position: absolute;
 
101
  object-fit: contain;
102
  display: block;
103
  }
104
+ /* Response box styling */
105
+ .response-box {
106
+ position: absolute;
107
+ top: 10%;
108
+ left: 10%;
109
+ background-color: rgba(255, 255, 255, 0.8);
110
+ color: #333;
111
+ padding: 15px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  border: 1px solid #ccc;
113
  border-radius: 5px;
114
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
115
+ display: none;
 
 
 
 
116
  }
117
  </style>
118
  </head>
119
  <body>
120
+ <!-- Sidebar -->
121
+ <div class="sidebar">
122
+ <div class="prompt-icon" id="promptIcon">
123
+ <img src="prompt-icon.png" alt="Prompt Icon">
124
+ <span>Prompt</span>
125
+ </div>
126
+ </div>
127
+
128
+ <!-- Main Container -->
129
  <div class="container">
130
  <div class="top-bar">
131
  <div class="nav-buttons">
 
137
  <div class="main">
138
  <div class="content">
139
  <img id="slide-image" src="images/01_mg.png" alt="Slide Image">
140
+ <div class="response-box" id="responseBox">
141
+ <p id="responseText"></p>
142
+ </div>
143
  </div>
144
  </div>
145
  </div>
146
 
 
 
 
 
 
 
 
 
 
147
  <script>
148
  // Slide viewer script
149
  const slideTitle = document.getElementById('slide-title');
 
188
  // Initialize slides
189
  fetchSlides();
190
 
191
+ // Grok Chat script
192
  const API_KEY = "xai-hOb0j9QUXVVQMe86ULxWrvyWQQm2LqnWVdxh5hanvqsiVDsXcSPY9EA7YAM5uLCXaThgJscWxxFCHJFy";
193
  const BASE_URL = "https://api.x.ai/v1";
194
 
195
+ const promptIcon = document.getElementById('promptIcon');
196
+ const responseBox = document.getElementById('responseBox');
197
+ const responseText = document.getElementById('responseText');
 
198
 
199
+ async function sendPrompt(prompt) {
200
+ responseBox.style.display = "block";
201
+ responseText.textContent = "Loading...";
 
 
 
 
 
 
 
 
202
 
203
  try {
204
  const response = await fetch(`${BASE_URL}/chat/completions`, {
 
211
  model: "grok-beta",
212
  messages: [
213
  { role: "system", content: "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy." },
214
+ { role: "user", content: prompt }
215
  ]
216
  })
217
  });
 
221
  }
222
 
223
  const data = await response.json();
224
+ responseText.textContent = data.choices?.[0]?.message?.content || "Unexpected API response.";
225
  } catch (error) {
226
+ responseText.textContent = `Error: ${error.message}`;
 
 
227
  }
228
  }
229
 
230
+ promptIcon.addEventListener('click', () => {
231
+ const slideText = slides[currentIndex]?.text || "Default prompt";
232
+ sendPrompt(slideText);
233
+ });
234
  </script>
235
  </body>
236
  </html>