monra commited on
Commit
9ba650c
1 Parent(s): 93793e7

Synced repo using 'sync_with_huggingface' Github Action

Browse files
client/css/conversation.css CHANGED
@@ -143,3 +143,16 @@
143
  font-size: 0.875rem;
144
  }
145
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  font-size: 0.875rem;
144
  }
145
  }
146
+
147
+ @media screen and (max-width: 360px) {
148
+ .box {
149
+ border-radius: 0;
150
+ }
151
+ .conversation {
152
+ margin: 0;
153
+ margin-top: 48px;
154
+ }
155
+ .conversation .user-input {
156
+ margin: 2px 0 8px 0;
157
+ }
158
+ }
client/css/global.css CHANGED
@@ -59,6 +59,10 @@ a:-webkit-any-link {
59
  color: var(--accent);
60
  }
61
 
 
 
 
 
62
  @media screen and (max-height: 720px) {
63
  :root {
64
  --section-gap: 16px;
 
59
  color: var(--accent);
60
  }
61
 
62
+ pre {
63
+ white-space: pre-wrap;
64
+ }
65
+
66
  @media screen and (max-height: 720px) {
67
  :root {
68
  --section-gap: 16px;
client/css/hljs.css CHANGED
@@ -8,30 +8,6 @@
8
  white-space: pre-wrap;
9
  }
10
 
11
- #message-input {
12
- margin-right: 30px;
13
- height: 64px;
14
- }
15
-
16
- #message-input::-webkit-scrollbar {
17
- width: 5px;
18
- }
19
-
20
- /* Track */
21
- #message-input::-webkit-scrollbar-track {
22
- background: #f1f1f1;
23
- }
24
-
25
- /* Handle */
26
- #message-input::-webkit-scrollbar-thumb {
27
- background: #c7a2ff;
28
- }
29
-
30
- /* Handle on hover */
31
- #message-input::-webkit-scrollbar-thumb:hover {
32
- background: #8b3dff;
33
- }
34
-
35
  /* style for hljs copy */
36
  .hljs-copy-wrapper {
37
  position: relative;
 
8
  white-space: pre-wrap;
9
  }
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  /* style for hljs copy */
12
  .hljs-copy-wrapper {
13
  position: relative;
client/css/main.css CHANGED
@@ -5,3 +5,10 @@
5
  justify-content: center;
6
  box-sizing: border-box;
7
  }
 
 
 
 
 
 
 
 
5
  justify-content: center;
6
  box-sizing: border-box;
7
  }
8
+
9
+ @media screen and (max-width: 360px) {
10
+ .main-container {
11
+ padding: 0px;
12
+ height: 90vh;
13
+ }
14
+ }
client/css/message-input.css ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #message-input {
2
+ margin-right: 30px;
3
+ height: 64px;
4
+ }
5
+
6
+ #message-input::-webkit-scrollbar {
7
+ width: 5px;
8
+ }
9
+
10
+ #message-input::-webkit-scrollbar-track {
11
+ background: #f1f1f1;
12
+ }
13
+
14
+ #message-input::-webkit-scrollbar-thumb {
15
+ background: #c7a2ff;
16
+ }
17
+
18
+ #message-input::-webkit-scrollbar-thumb:hover {
19
+ background: #8b3dff;
20
+ }
21
+
22
+ @media screen and (max-width: 360px) {
23
+ #message-input {
24
+ margin: 0;
25
+ }
26
+ }
27
+
client/css/message.css CHANGED
@@ -40,6 +40,16 @@
40
  }
41
 
42
  @media screen and (max-height: 720px) {
 
 
 
 
 
 
 
 
 
 
43
  .message .avatar-container img {
44
  max-width: 32px;
45
  max-height: 32px;
 
40
  }
41
 
42
  @media screen and (max-height: 720px) {
43
+ .message {
44
+ padding: 12px;
45
+ gap: 0;
46
+ }
47
+
48
+ .message .content {
49
+ margin-left: 8px;
50
+ width: 80%;
51
+ }
52
+
53
  .message .avatar-container img {
54
  max-width: 32px;
55
  max-height: 32px;
client/css/sidebar.css CHANGED
@@ -131,7 +131,7 @@
131
  animation: spinner 0.6s linear infinite;
132
  }
133
 
134
- .mobile-sidebar {
135
  display: none !important;
136
  position: absolute;
137
  z-index: 100000;
@@ -147,7 +147,7 @@
147
  transition: 0.33s;
148
  }
149
 
150
- .mobile-sidebar i {
151
  transition: 0.33s;
152
  }
153
 
@@ -155,7 +155,7 @@
155
  transform: rotate(360deg);
156
  }
157
 
158
- .mobile-sidebar.rotated {
159
  position: fixed;
160
  top: 10px;
161
  left: 10px;
@@ -169,7 +169,7 @@
169
  max-width: none;
170
  }
171
 
172
- .mobile-sidebar {
173
  display: flex !important;
174
  }
175
  }
 
131
  animation: spinner 0.6s linear infinite;
132
  }
133
 
134
+ .menu-button {
135
  display: none !important;
136
  position: absolute;
137
  z-index: 100000;
 
147
  transition: 0.33s;
148
  }
149
 
150
+ .menu-button i {
151
  transition: 0.33s;
152
  }
153
 
 
155
  transform: rotate(360deg);
156
  }
157
 
158
+ .menu-button.rotated {
159
  position: fixed;
160
  top: 10px;
161
  left: 10px;
 
169
  max-width: none;
170
  }
171
 
172
+ .menu-button {
173
  display: flex !important;
174
  }
175
  }
client/css/style.css CHANGED
@@ -15,3 +15,4 @@
15
  @import "./select.css";
16
  @import "./options.css";
17
  @import "./theme-toggler.css";
 
 
15
  @import "./select.css";
16
  @import "./options.css";
17
  @import "./theme-toggler.css";
18
+ @import "./message-input.css";
client/html/index.html CHANGED
@@ -101,7 +101,7 @@
101
  </div>
102
  </div>
103
  </div>
104
- <div class="mobile-sidebar">
105
  <i class="fa-solid fa-bars"></i>
106
  </div>
107
 
@@ -115,5 +115,6 @@
115
  <script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
116
  <script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
117
  <script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
 
118
  </body>
119
  </html>
 
101
  </div>
102
  </div>
103
  </div>
104
+ <div class="menu-button">
105
  <i class="fa-solid fa-bars"></i>
106
  </div>
107
 
 
115
  <script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
116
  <script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
117
  <script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
118
+ <script src="{{ url_for('bp.static', filename='js/sidebar-toggler.js') }}"></script>
119
  </body>
120
  </html>
client/js/chat.js CHANGED
@@ -2,7 +2,7 @@ const query = (obj) =>
2
  Object.keys(obj)
3
  .map((k) => encodeURIComponent(k) + "=" + encodeURIComponent(obj[k]))
4
  .join("&");
5
- const url_prefix = document.querySelector('body').getAttribute('data-urlprefix')
6
  const markdown = window.markdownit();
7
  const message_box = document.getElementById(`messages`);
8
  const message_input = document.getElementById(`message-input`);
@@ -128,7 +128,9 @@ const ask_gpt = async (message) => {
128
 
129
  chunk = decodeUnicode(new TextDecoder().decode(value));
130
 
131
- if (chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)) {
 
 
132
  chunk = `cloudflare token expired, please refresh the page.`;
133
  }
134
 
@@ -187,21 +189,15 @@ const ask_gpt = async (message) => {
187
  };
188
 
189
  const add_user_message_box = (message) => {
190
- const messageDiv = document.createElement("div");
191
- messageDiv.classList.add("message");
192
-
193
- const avatarContainer = document.createElement("div");
194
- avatarContainer.classList.add("avatar-container");
195
- avatarContainer.innerHTML = user_image;
196
-
197
- const contentDiv = document.createElement("div");
198
- contentDiv.classList.add("content");
199
- contentDiv.id = `user_${token}`;
200
- contentDiv.innerText = message;
201
-
202
- messageDiv.appendChild(avatarContainer);
203
- messageDiv.appendChild(contentDiv);
204
 
 
205
  message_box.appendChild(messageDiv);
206
  };
207
 
@@ -284,19 +280,14 @@ const load_conversation = async (conversation_id) => {
284
  };
285
 
286
  const load_user_message_box = (content) => {
287
- const messageDiv = document.createElement("div");
288
- messageDiv.classList.add("message");
289
-
290
- const avatarContainer = document.createElement("div");
291
- avatarContainer.classList.add("avatar-container");
292
- avatarContainer.innerHTML = user_image;
293
 
294
- const contentDiv = document.createElement("div");
295
- contentDiv.classList.add("content");
296
- contentDiv.innerText = content;
297
-
298
- messageDiv.appendChild(avatarContainer);
299
- messageDiv.appendChild(contentDiv);
300
 
301
  return messageDiv.outerHTML;
302
  };
@@ -451,22 +442,6 @@ window.onload = async () => {
451
  register_settings_localstorage();
452
  };
453
 
454
- document.querySelector(".mobile-sidebar").addEventListener("click", (event) => {
455
- const sidebar = document.querySelector(".sidebar");
456
-
457
- if (sidebar.classList.contains("shown")) {
458
- sidebar.classList.remove("shown");
459
- event.target.classList.remove("rotated");
460
- document.body.style.overflow = "auto";
461
- } else {
462
- sidebar.classList.add("shown");
463
- event.target.classList.add("rotated");
464
- document.body.style.overflow = "hidden";
465
- }
466
-
467
- window.scrollTo(0, 0);
468
- });
469
-
470
  const register_settings_localstorage = async () => {
471
  settings_ids = ["switch", "model", "jailbreak"];
472
  settings_elements = settings_ids.map((id) => document.getElementById(id));
@@ -508,8 +483,26 @@ const load_settings_localstorage = async () => {
508
  function clearTextarea(textarea) {
509
  textarea.style.removeProperty("height");
510
  textarea.style.height = `${textarea.scrollHeight + 4}px`;
511
-
512
  if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
513
  textarea.value = "";
514
  }
515
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  Object.keys(obj)
3
  .map((k) => encodeURIComponent(k) + "=" + encodeURIComponent(obj[k]))
4
  .join("&");
5
+ const url_prefix = document.querySelector("body").getAttribute("data-urlprefix");
6
  const markdown = window.markdownit();
7
  const message_box = document.getElementById(`messages`);
8
  const message_input = document.getElementById(`message-input`);
 
128
 
129
  chunk = decodeUnicode(new TextDecoder().decode(value));
130
 
131
+ if (
132
+ chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)
133
+ ) {
134
  chunk = `cloudflare token expired, please refresh the page.`;
135
  }
136
 
 
189
  };
190
 
191
  const add_user_message_box = (message) => {
192
+ const messageDiv = createElement("div", { classNames: ["message"] });
193
+ const avatarContainer = createElement("div", { classNames: ["avatar-container"], innerHTML: user_image });
194
+ const contentDiv = createElement("div", {
195
+ classNames: ["content"],
196
+ id: `user_${token}`,
197
+ textContent: message,
198
+ });
 
 
 
 
 
 
 
199
 
200
+ messageDiv.append(avatarContainer, contentDiv);
201
  message_box.appendChild(messageDiv);
202
  };
203
 
 
280
  };
281
 
282
  const load_user_message_box = (content) => {
283
+ const messageDiv = createElement("div", { classNames: ["message"] });
284
+ const avatarContainer = createElement("div", { classNames: ["avatar-container"], innerHTML: user_image });
285
+ const contentDiv = createElement("div", { classNames: ["content"] });
286
+ const preElement = document.createElement("pre");
287
+ preElement.textContent = content;
288
+ contentDiv.appendChild(preElement);
289
 
290
+ messageDiv.append(avatarContainer, contentDiv);
 
 
 
 
 
291
 
292
  return messageDiv.outerHTML;
293
  };
 
442
  register_settings_localstorage();
443
  };
444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  const register_settings_localstorage = async () => {
446
  settings_ids = ["switch", "model", "jailbreak"];
447
  settings_elements = settings_ids.map((id) => document.getElementById(id));
 
483
  function clearTextarea(textarea) {
484
  textarea.style.removeProperty("height");
485
  textarea.style.height = `${textarea.scrollHeight + 4}px`;
 
486
  if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
487
  textarea.value = "";
488
  }
489
  }
490
+
491
+ function createElement(tag, { classNames, id, innerHTML, textContent } = {}) {
492
+ const el = document.createElement(tag);
493
+ if (classNames) {
494
+ el.classList.add(...classNames);
495
+ }
496
+ if (id) {
497
+ el.id = id;
498
+ }
499
+ if (innerHTML) {
500
+ el.innerHTML = innerHTML;
501
+ }
502
+ if (textContent) {
503
+ const preElement = document.createElement("pre");
504
+ preElement.textContent = textContent;
505
+ el.appendChild(preElement);
506
+ }
507
+ return el;
508
+ }
client/js/sidebar-toggler.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const sidebar = document.querySelector(".sidebar");
2
+ const menuButton = document.querySelector(".menu-button");
3
+
4
+ function toggleSidebar(event) {
5
+ if (sidebar.classList.contains("shown")) {
6
+ hideSidebar(event.target);
7
+ } else {
8
+ showSidebar(event.target);
9
+ }
10
+ window.scrollTo(0, 0);
11
+ }
12
+
13
+ function showSidebar(target) {
14
+ sidebar.classList.add("shown");
15
+ target.classList.add("rotated");
16
+ document.body.style.overflow = "hidden";
17
+ }
18
+
19
+ function hideSidebar(target) {
20
+ sidebar.classList.remove("shown");
21
+ target.classList.remove("rotated");
22
+ document.body.style.overflow = "auto";
23
+ }
24
+
25
+ menuButton.addEventListener("click", toggleSidebar);
26
+
27
+ document.body.addEventListener('click', function(event) {
28
+ if (event.target.matches('.conversation-title')) {
29
+ const menuButtonStyle = window.getComputedStyle(menuButton);
30
+ if (menuButtonStyle.display !== 'none') {
31
+ hideSidebar(menuButton);
32
+ }
33
+ }
34
+ });