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

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +120 -93
index.html CHANGED
@@ -3,9 +3,9 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Responsive Slide Viewer</title>
7
  <style>
8
- /* General styles */
9
  * {
10
  margin: 0;
11
  padding: 0;
@@ -14,6 +14,7 @@
14
  body {
15
  font-family: Arial, sans-serif;
16
  display: flex;
 
17
  justify-content: center;
18
  align-items: center;
19
  min-height: 100vh;
@@ -27,56 +28,11 @@
27
  background: #000;
28
  overflow: hidden;
29
  border: 5px solid #444;
30
- display: flex;
31
- }
32
- .left-sidebar {
33
- width: 40px;
34
- background-color: #333;
35
- display: flex;
36
- flex-direction: column;
37
- align-items: center;
38
- padding: 10px 0;
39
- gap: 10px;
40
- position: relative;
41
- }
42
- .sidebar-button {
43
- width: 30px;
44
- height: 30px;
45
- background-color: #666;
46
- border: none;
47
- border-radius: 5px;
48
- display: flex;
49
- align-items: center;
50
- justify-content: center;
51
- cursor: pointer;
52
- position: absolute;
53
- top: 100px;
54
- }
55
- .sidebar-button:hover {
56
- background-color: #888;
57
- }
58
- .sidebar-button img {
59
- width: 20px;
60
- height: 20px;
61
- }
62
- .sidebar-button:hover::after {
63
- content: "Prompt";
64
- position: absolute;
65
- left: 50px;
66
- top: 50%;
67
- transform: translateY(-50%);
68
- background-color: #444;
69
- color: #fff;
70
- padding: 5px 10px;
71
- border-radius: 5px;
72
- white-space: nowrap;
73
- font-size: 14px;
74
- z-index: 100;
75
  }
76
  .top-bar {
77
  position: absolute;
78
  top: 0;
79
- width: calc(100% - 40px);
80
  background-color: #333;
81
  color: white;
82
  text-align: center;
@@ -84,18 +40,15 @@
84
  z-index: 10;
85
  display: flex;
86
  align-items: center;
87
- justify-content: center;
88
- left: 40px;
89
  }
90
  .top-bar h1 {
91
- margin: 0;
92
  text-align: center;
93
  }
94
  .nav-buttons {
95
  display: flex;
96
  gap: 10px;
97
- position: absolute;
98
- right: 10px;
99
  }
100
  .nav-buttons button {
101
  background-color: #666;
@@ -111,7 +64,6 @@
111
  .main {
112
  display: flex;
113
  height: 100%;
114
- flex: 1;
115
  }
116
  .content {
117
  flex: 1;
@@ -127,94 +79,169 @@
127
  object-fit: contain;
128
  display: block;
129
  }
130
- .prompt-box {
131
- position: absolute;
132
- top: 20%;
133
- left: 20%;
134
- width: 60%;
135
- background-color: rgba(255, 255, 255, 0.9);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  padding: 20px;
137
- border: 2px solid #333;
138
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
139
- font-size: 18px;
140
- display: none;
141
- z-index: 20;
 
 
 
 
142
  }
143
  </style>
144
  </head>
145
  <body>
146
  <div class="container">
147
- <div class="left-sidebar">
148
- <button class="sidebar-button" id="prompt-icon">
149
- <img src="images/prompt-icon.png" alt="Prompt">
150
- </button>
151
- </div>
152
  <div class="top-bar">
153
- <h1 id="slide-title">Slide Viewer</h1>
154
  <div class="nav-buttons">
155
  <button id="prev-btn">&#8592; Previous</button>
156
  <button id="next-btn">Next &#8594;</button>
157
  </div>
 
158
  </div>
159
  <div class="main">
160
  <div class="content">
161
  <img id="slide-image" src="images/01_mg.png" alt="Slide Image">
162
- <div class="prompt-box" id="prompt-box"></div>
163
  </div>
164
  </div>
165
  </div>
166
 
 
 
 
 
 
 
 
 
 
167
  <script>
 
168
  const slideTitle = document.getElementById('slide-title');
169
  const slideImage = document.getElementById('slide-image');
170
  const prevBtn = document.getElementById('prev-btn');
171
  const nextBtn = document.getElementById('next-btn');
172
- const promptIcon = document.getElementById('prompt-icon');
173
- const promptBox = document.getElementById('prompt-box');
174
- let data = [];
175
  let currentIndex = 0;
176
 
177
- // Fetch slide configuration
178
- async function fetchSlideConfig() {
179
  try {
180
  const response = await fetch('slide_config.json');
181
- const jsonData = await response.json();
182
- data = jsonData.slides;
183
  loadSlide(currentIndex);
184
  } catch (error) {
185
- console.error('Error loading slide configuration:', error);
186
  }
187
  }
188
 
189
  function loadSlide(index) {
190
- if (data.length === 0) return;
191
- const slide = data[index];
192
  slideTitle.textContent = slide.id.replace('_', ' ');
193
  slideImage.src = slide.image;
194
- promptBox.textContent = slide.text;
195
- promptBox.style.display = 'none'; // Hide the prompt box initially
196
  }
197
 
198
  prevBtn.addEventListener('click', () => {
199
- if (data.length > 0) {
200
- currentIndex = (currentIndex - 1 + data.length) % data.length;
201
  loadSlide(currentIndex);
202
  }
203
  });
204
 
205
  nextBtn.addEventListener('click', () => {
206
- if (data.length > 0) {
207
- currentIndex = (currentIndex + 1) % data.length;
208
  loadSlide(currentIndex);
209
  }
210
  });
211
 
212
- promptIcon.addEventListener('click', () => {
213
- promptBox.style.display = promptBox.style.display === 'none' ? 'block' : 'none';
214
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
- // Initialize
217
- fetchSlideConfig();
218
  </script>
219
  </body>
220
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
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
  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;
 
28
  background: #000;
29
  overflow: hidden;
30
  border: 5px solid #444;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
  .top-bar {
33
  position: absolute;
34
  top: 0;
35
+ width: 100%;
36
  background-color: #333;
37
  color: white;
38
  text-align: center;
 
40
  z-index: 10;
41
  display: flex;
42
  align-items: center;
43
+ justify-content: space-between;
 
44
  }
45
  .top-bar h1 {
46
+ flex: 1;
47
  text-align: center;
48
  }
49
  .nav-buttons {
50
  display: flex;
51
  gap: 10px;
 
 
52
  }
53
  .nav-buttons button {
54
  background-color: #666;
 
64
  .main {
65
  display: flex;
66
  height: 100%;
 
67
  }
68
  .content {
69
  flex: 1;
 
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">
129
  <button id="prev-btn">&#8592; Previous</button>
130
  <button id="next-btn">Next &#8594;</button>
131
  </div>
132
+ <h1 id="slide-title">Slide Viewer</h1>
133
  </div>
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');
153
  const slideImage = document.getElementById('slide-image');
154
  const prevBtn = document.getElementById('prev-btn');
155
  const nextBtn = document.getElementById('next-btn');
156
+ let slides = [];
 
 
157
  let currentIndex = 0;
158
 
159
+ async function fetchSlides() {
 
160
  try {
161
  const response = await fetch('slide_config.json');
162
+ const data = await response.json();
163
+ slides = data.slides;
164
  loadSlide(currentIndex);
165
  } catch (error) {
166
+ console.error('Error loading slides:', error);
167
  }
168
  }
169
 
170
  function loadSlide(index) {
171
+ if (!slides.length) return;
172
+ const slide = slides[index];
173
  slideTitle.textContent = slide.id.replace('_', ' ');
174
  slideImage.src = slide.image;
 
 
175
  }
176
 
177
  prevBtn.addEventListener('click', () => {
178
+ if (slides.length > 0) {
179
+ currentIndex = (currentIndex - 1 + slides.length) % slides.length;
180
  loadSlide(currentIndex);
181
  }
182
  });
183
 
184
  nextBtn.addEventListener('click', () => {
185
+ if (slides.length > 0) {
186
+ currentIndex = (currentIndex + 1) % slides.length;
187
  loadSlide(currentIndex);
188
  }
189
  });
190
 
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`, {
217
+ method: "POST",
218
+ headers: {
219
+ "Authorization": `Bearer ${API_KEY}`,
220
+ "Content-Type": "application/json"
221
+ },
222
+ body: JSON.stringify({
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
+ });
230
+
231
+ if (!response.ok) {
232
+ throw new Error(`Error: ${response.statusText}`);
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>