monra commited on
Commit
ac313ad
1 Parent(s): e14c042

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
@@ -68,6 +68,10 @@ a:-webkit-any-link {
68
  animation: fadeIn 1s forwards;
69
  }
70
 
 
 
 
 
71
  @keyframes fadeIn {
72
  to {
73
  opacity: 1;
 
68
  animation: fadeIn 1s forwards;
69
  }
70
 
71
+ pre {
72
+ white-space: pre-wrap;
73
+ }
74
+
75
  @keyframes fadeIn {
76
  to {
77
  opacity: 1;
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
@@ -16,3 +16,4 @@
16
  @import "./options.css";
17
  @import "./theme-toggler.css";
18
  @import "./api-key.css";
 
 
16
  @import "./options.css";
17
  @import "./theme-toggler.css";
18
  @import "./api-key.css";
19
+ @import "./message-input.css";
client/html/index.html CHANGED
@@ -141,7 +141,7 @@
141
  </div>
142
  </div>
143
  </div>
144
- <div class="mobile-sidebar">
145
  <i class="fa-solid fa-bars"></i>
146
  </div>
147
 
@@ -156,5 +156,6 @@
156
  <script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
157
  <script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
158
  <script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
 
159
  </body>
160
  </html>
 
141
  </div>
142
  </div>
143
  </div>
144
+ <div class="menu-button">
145
  <i class="fa-solid fa-bars"></i>
146
  </div>
147
 
 
156
  <script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
157
  <script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
158
  <script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
159
+ <script src="{{ url_for('bp.static', filename='js/sidebar-toggler.js') }}"></script>
160
  </body>
161
  </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`);
@@ -129,7 +129,9 @@ const ask_gpt = async (message) => {
129
 
130
  chunk = decodeUnicode(new TextDecoder().decode(value));
131
 
132
- if (chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)) {
 
 
133
  chunk = `cloudflare token expired, please refresh the page.`;
134
  }
135
 
@@ -188,21 +190,15 @@ const ask_gpt = async (message) => {
188
  };
189
 
190
  const add_user_message_box = (message) => {
191
- const messageDiv = document.createElement("div");
192
- messageDiv.classList.add("message");
193
-
194
- const avatarContainer = document.createElement("div");
195
- avatarContainer.classList.add("avatar-container");
196
- avatarContainer.innerHTML = user_image;
197
-
198
- const contentDiv = document.createElement("div");
199
- contentDiv.classList.add("content");
200
- contentDiv.id = `user_${token}`;
201
- contentDiv.innerText = message;
202
-
203
- messageDiv.appendChild(avatarContainer);
204
- messageDiv.appendChild(contentDiv);
205
 
 
206
  message_box.appendChild(messageDiv);
207
  };
208
 
@@ -285,19 +281,14 @@ const load_conversation = async (conversation_id) => {
285
  };
286
 
287
  const load_user_message_box = (content) => {
288
- const messageDiv = document.createElement("div");
289
- messageDiv.classList.add("message");
290
-
291
- const avatarContainer = document.createElement("div");
292
- avatarContainer.classList.add("avatar-container");
293
- avatarContainer.innerHTML = user_image;
294
 
295
- const contentDiv = document.createElement("div");
296
- contentDiv.classList.add("content");
297
- contentDiv.innerText = content;
298
-
299
- messageDiv.appendChild(avatarContainer);
300
- messageDiv.appendChild(contentDiv);
301
 
302
  return messageDiv.outerHTML;
303
  };
@@ -452,22 +443,6 @@ window.onload = async () => {
452
  register_settings_localstorage();
453
  };
454
 
455
- document.querySelector(".mobile-sidebar").addEventListener("click", (event) => {
456
- const sidebar = document.querySelector(".sidebar");
457
-
458
- if (sidebar.classList.contains("shown")) {
459
- sidebar.classList.remove("shown");
460
- event.target.classList.remove("rotated");
461
- document.body.style.overflow = "auto";
462
- } else {
463
- sidebar.classList.add("shown");
464
- event.target.classList.add("rotated");
465
- document.body.style.overflow = "hidden";
466
- }
467
-
468
- window.scrollTo(0, 0);
469
- });
470
-
471
  const register_settings_localstorage = async () => {
472
  settings_ids = ["switch", "model", "jailbreak"];
473
  settings_elements = settings_ids.map((id) => document.getElementById(id));
@@ -509,8 +484,26 @@ const load_settings_localstorage = async () => {
509
  function clearTextarea(textarea) {
510
  textarea.style.removeProperty("height");
511
  textarea.style.height = `${textarea.scrollHeight + 4}px`;
512
-
513
  if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
514
  textarea.value = "";
515
  }
516
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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`);
 
129
 
130
  chunk = decodeUnicode(new TextDecoder().decode(value));
131
 
132
+ if (
133
+ chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)
134
+ ) {
135
  chunk = `cloudflare token expired, please refresh the page.`;
136
  }
137
 
 
190
  };
191
 
192
  const add_user_message_box = (message) => {
193
+ const messageDiv = createElement("div", { classNames: ["message"] });
194
+ const avatarContainer = createElement("div", { classNames: ["avatar-container"], innerHTML: user_image });
195
+ const contentDiv = createElement("div", {
196
+ classNames: ["content"],
197
+ id: `user_${token}`,
198
+ textContent: message,
199
+ });
 
 
 
 
 
 
 
200
 
201
+ messageDiv.append(avatarContainer, contentDiv);
202
  message_box.appendChild(messageDiv);
203
  };
204
 
 
281
  };
282
 
283
  const load_user_message_box = (content) => {
284
+ const messageDiv = createElement("div", { classNames: ["message"] });
285
+ const avatarContainer = createElement("div", { classNames: ["avatar-container"], innerHTML: user_image });
286
+ const contentDiv = createElement("div", { classNames: ["content"] });
287
+ const preElement = document.createElement("pre");
288
+ preElement.textContent = content;
289
+ contentDiv.appendChild(preElement);
290
 
291
+ messageDiv.append(avatarContainer, contentDiv);
 
 
 
 
 
292
 
293
  return messageDiv.outerHTML;
294
  };
 
443
  register_settings_localstorage();
444
  };
445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  const register_settings_localstorage = async () => {
447
  settings_ids = ["switch", "model", "jailbreak"];
448
  settings_elements = settings_ids.map((id) => document.getElementById(id));
 
484
  function clearTextarea(textarea) {
485
  textarea.style.removeProperty("height");
486
  textarea.style.height = `${textarea.scrollHeight + 4}px`;
 
487
  if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
488
  textarea.value = "";
489
  }
490
  }
491
+
492
+ function createElement(tag, { classNames, id, innerHTML, textContent } = {}) {
493
+ const el = document.createElement(tag);
494
+ if (classNames) {
495
+ el.classList.add(...classNames);
496
+ }
497
+ if (id) {
498
+ el.id = id;
499
+ }
500
+ if (innerHTML) {
501
+ el.innerHTML = innerHTML;
502
+ }
503
+ if (textContent) {
504
+ const preElement = document.createElement("pre");
505
+ preElement.textContent = textContent;
506
+ el.appendChild(preElement);
507
+ }
508
+ return el;
509
+ }
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
+ });