change chat gpt provider (#12)

This commit is contained in:
Dmitry Afanasyev
2023-09-26 19:15:13 +03:00
committed by GitHub
parent 665bb51c0c
commit d6afab4ee4
145 changed files with 6146 additions and 7652 deletions

View File

@@ -1,26 +0,0 @@
.button {
display: flex;
padding: 8px 12px;
align-items: center;
justify-content: center;
border: 1px solid var(--conversations);
border-radius: var(--border-radius-1);
width: 100%;
background: transparent;
cursor: pointer;
}
.button span {
color: var(--colour-3);
font-size: 0.875rem;
}
.button i::before {
margin-right: 8px;
}
@media screen and (max-width: 990px) {
.button span {
font-size: 0.75rem;
}
}

View File

@@ -1,4 +0,0 @@
.buttons {
display: flex;
justify-content: left;
}

View File

@@ -1,55 +0,0 @@
.checkbox input {
height: 0;
width: 0;
display: none;
}
.checkbox span {
font-size: 0.875rem;
color: var(--colour-2);
margin-left: 4px;
}
.checkbox label:after {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 5px;
width: 20px;
height: 20px;
background: var(--blur-border);
border-radius: 90px;
transition: 0.33s;
}
.checkbox input + label:after,
.checkbox input:checked + label {
background: var(--colour-3);
}
.checkbox input + label,
.checkbox input:checked + label:after {
background: var(--blur-border);
}
.checkbox input:checked + label:after {
left: calc(100% - 5px - 20px);
}
@media screen and (max-width: 990px) {
.checkbox label {
width: 25px;
height: 15px;
}
.checkbox label:after {
left: 2px;
width: 10px;
height: 10px;
}
.checkbox input:checked + label:after {
left: calc(100% - 2px - 10px);
}
}

View File

@@ -1,158 +0,0 @@
.conversation {
width: 60%;
margin: 0px 16px;
display: flex;
flex-direction: column;
}
.conversation #messages {
width: 100%;
display: flex;
flex-direction: column;
overflow: auto;
overflow-wrap: break-word;
padding-bottom: 8px;
}
.conversation .user-input {
max-height: 180px;
margin: 16px 0px;
}
.conversation .user-input input {
font-size: 1rem;
background: none;
border: none;
outline: none;
color: var(--colour-3);
}
.conversation .user-input input::placeholder {
color: var(--user-input);
}
.conversation-title {
color: var(--colour-3);
font-size: 14px;
}
.conversation .user-input textarea {
font-size: 1rem;
width: 100%;
height: 100%;
padding: 12px;
background: none;
border: none;
outline: none;
color: var(--colour-3);
resize: vertical;
max-height: 150px;
min-height: 80px;
}
.box {
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: var(--blur-bg);
height: 100%;
width: 100%;
border-radius: var(--border-radius-1);
border: 1px solid var(--blur-border);
}
.box.input-box {
position: relative;
align-items: center;
padding: 8px;
cursor: pointer;
}
#send-button {
position: absolute;
bottom: 25%;
right: 10px;
z-index: 1;
padding: 16px;
}
#cursor {
line-height: 17px;
margin-left: 3px;
-webkit-animation: blink 0.8s infinite;
animation: blink 0.8s infinite;
width: 7px;
height: 15px;
}
@keyframes blink {
0% {
background: #ffffff00;
}
50% {
background: white;
}
100% {
background: #ffffff00;
}
}
@-webkit-keyframes blink {
0% {
background: #ffffff00;
}
50% {
background: white;
}
100% {
background: #ffffff00;
}
}
/* scrollbar */
.conversation #messages::-webkit-scrollbar {
width: 4px;
padding: 8px 0px;
}
.conversation #messages::-webkit-scrollbar-track {
background-color: #ffffff00;
}
.conversation #messages::-webkit-scrollbar-thumb {
background-color: #555555;
border-radius: 10px;
}
@media screen and (max-width: 990px) {
.conversation {
width: 100%;
height: 90%;
}
}
@media screen and (max-height: 720px) {
.conversation.box {
height: 70%;
}
.conversation .user-input textarea {
font-size: 0.875rem;
}
}
@media screen and (max-width: 360px) {
.box {
border-radius: 0;
}
.conversation {
margin: 0;
margin-top: 48px;
}
.conversation .user-input {
margin: 2px 0 8px 0;
}
}

View File

@@ -1,10 +0,0 @@
.dropdown {
border: 1px solid var(--conversations);
}
@media screen and (max-width: 990px) {
.dropdown {
padding: 4px 8px;
font-size: 0.75rem;
}
}

View File

@@ -1,11 +0,0 @@
.field {
display: flex;
align-items: center;
padding: 4px;
}
@media screen and (max-width: 990px) {
.field {
flex-wrap: nowrap;
}
}

View File

@@ -1,70 +0,0 @@
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap");
* {
--font-1: "Inter", sans-serif;
--section-gap: 24px;
--border-radius-1: 8px;
margin: 0;
padding: 0;
box-sizing: border-box;
position: relative;
font-family: var(--font-1);
}
.theme-light {
--colour-1: #f5f5f5;
--colour-2: #000000;
--colour-3: #474747;
--colour-4: #949494;
--colour-5: #ebebeb;
--colour-6: #dadada;
--accent: #3a3a3a;
--blur-bg: #ffffff;
--blur-border: #dbdbdb;
--user-input: #282828;
--conversations: #666666;
}
.theme-dark {
--colour-1: #181818;
--colour-2: #ccc;
--colour-3: #dadada;
--colour-4: #f0f0f0;
--colour-5: #181818;
--colour-6: #242424;
--accent: #151718;
--blur-bg: #242627;
--blur-border: #242627;
--user-input: #f5f5f5;
--conversations: #555555;
}
html,
body {
background: var(--colour-1);
color: var(--colour-3);
}
ol,
ul {
padding-left: 20px;
}
.shown {
display: flex !important;
}
a:-webkit-any-link {
color: var(--accent);
}
pre {
white-space: pre-wrap;
}
@media screen and (max-height: 720px) {
:root {
--section-gap: 16px;
}
}

View File

@@ -1,68 +0,0 @@
.hljs {
color: #e9e9f4;
background: #28293629;
border-radius: var(--border-radius-1);
border: 1px solid var(--blur-border);
font-size: 15px;
word-wrap: break-word;
white-space: pre-wrap;
}
/* style for hljs copy */
.hljs-copy-wrapper {
position: relative;
overflow: hidden;
}
.hljs-copy-wrapper:hover .hljs-copy-button,
.hljs-copy-button:focus {
transform: translateX(0);
}
.hljs-copy-button {
position: absolute;
transform: translateX(calc(100% + 1.125em));
top: 1em;
right: 1em;
width: 2rem;
height: 2rem;
text-indent: -9999px;
color: #fff;
border-radius: 0.25rem;
border: 1px solid #ffffff22;
background-color: #2d2b57;
background-image: url('data:image/svg+xml;utf-8,<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 5C5.73478 5 5.48043 5.10536 5.29289 5.29289C5.10536 5.48043 5 5.73478 5 6V20C5 20.2652 5.10536 20.5196 5.29289 20.7071C5.48043 20.8946 5.73478 21 6 21H18C18.2652 21 18.5196 20.8946 18.7071 20.7071C18.8946 20.5196 19 20.2652 19 20V6C19 5.73478 18.8946 5.48043 18.7071 5.29289C18.5196 5.10536 18.2652 5 18 5H16C15.4477 5 15 4.55228 15 4C15 3.44772 15.4477 3 16 3H18C18.7956 3 19.5587 3.31607 20.1213 3.87868C20.6839 4.44129 21 5.20435 21 6V20C21 20.7957 20.6839 21.5587 20.1213 22.1213C19.5587 22.6839 18.7957 23 18 23H6C5.20435 23 4.44129 22.6839 3.87868 22.1213C3.31607 21.5587 3 20.7957 3 20V6C3 5.20435 3.31607 4.44129 3.87868 3.87868C4.44129 3.31607 5.20435 3 6 3H8C8.55228 3 9 3.44772 9 4C9 4.55228 8.55228 5 8 5H6Z" fill="white"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3C7 1.89543 7.89543 1 9 1H15C16.1046 1 17 1.89543 17 3V5C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5V3ZM15 3H9V5H15V3Z" fill="white"/></svg>');
background-repeat: no-repeat;
background-position: center;
transition: background-color 200ms ease, transform 200ms ease-out;
}
.hljs-copy-button:hover {
border-color: #ffffff44;
}
.hljs-copy-button:active {
border-color: #ffffff66;
}
.hljs-copy-button[data-copied="true"] {
text-indent: 0;
width: auto;
background-image: none;
}
.hljs-copy-alert {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
@media (prefers-reduced-motion) {
.hljs-copy-button {
transition: none;
}
}

View File

@@ -1,16 +0,0 @@
label {
cursor: pointer;
text-indent: -9999px;
width: 50px;
height: 30px;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: var(--blur-bg);
border-radius: var(--border-radius-1);
border: 1px solid var(--blur-border);
display: block;
border-radius: 100px;
position: relative;
overflow: hidden;
transition: 0.33s;
}

View File

@@ -1,14 +0,0 @@
.main-container {
display: flex;
padding: var(--section-gap);
height: 100vh;
justify-content: center;
box-sizing: border-box;
}
@media screen and (max-width: 360px) {
.main-container {
padding: 0px;
height: 90vh;
}
}

View File

@@ -1,27 +0,0 @@
#message-input {
margin-right: 30px;
height: 64px;
}
#message-input::-webkit-scrollbar {
width: 5px;
}
#message-input::-webkit-scrollbar-track {
background: #f1f1f1;
}
#message-input::-webkit-scrollbar-thumb {
background: #c7a2ff;
}
#message-input::-webkit-scrollbar-thumb:hover {
background: #8b3dff;
}
@media screen and (max-width: 360px) {
#message-input {
margin: 0;
}
}

View File

@@ -1,65 +0,0 @@
.message {
width: 100%;
overflow-wrap: break-word;
display: flex;
gap: var(--section-gap);
padding: var(--section-gap);
padding-bottom: 0;
}
.message:last-child {
animation: 0.6s show_message;
}
@keyframes show_message {
from {
transform: translateY(10px);
opacity: 0;
}
}
.message .avatar-container img {
max-width: 48px;
max-height: 48px;
box-shadow: 0.4px 0.5px 0.7px -2px rgba(0, 0, 0, 0.08), 1.1px 1.3px 2px -2px rgba(0, 0, 0, 0.041),
2.7px 3px 4.8px -2px rgba(0, 0, 0, 0.029), 9px 10px 16px -2px rgba(0, 0, 0, 0.022);
}
.message .content {
display: flex;
flex-direction: column;
width: 90%;
gap: 18px;
}
.message .content p,
.message .content li,
.message .content code {
font-size: 1rem;
line-height: 1.3;
}
@media screen and (max-height: 720px) {
.message {
padding: 12px;
gap: 0;
}
.message .content {
margin-left: 8px;
width: 80%;
}
.message .avatar-container img {
max-width: 32px;
max-height: 32px;
}
.message .content,
.message .content p,
.message .content li,
.message .content code {
font-size: 0.875rem;
line-height: 1.3;
}
}

View File

@@ -1,10 +0,0 @@
.options-container {
display: flex;
flex-wrap: wrap;
}
@media screen and (max-width: 990px) {
.options-container {
justify-content: space-between;
}
}

View File

@@ -1,35 +0,0 @@
select {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-backdrop-filter: blur(20px);
backdrop-filter: blur(20px);
cursor: pointer;
background-color: var(--blur-bg);
border: 1px solid var(--blur-border);
color: var(--colour-3);
display: block;
position: relative;
overflow: hidden;
outline: none;
padding: 8px 16px;
appearance: none;
}
/* scrollbar */
select.dropdown::-webkit-scrollbar {
width: 4px;
padding: 8px 0px;
}
select.dropdown::-webkit-scrollbar-track {
background-color: #ffffff00;
}
select.dropdown::-webkit-scrollbar-thumb {
background-color: #555555;
border-radius: 10px;
}

View File

@@ -1,44 +0,0 @@
.settings-container {
color: var(--colour-2);
margin: 24px 0px 8px 0px;
justify-content: center;
}
.settings-container span {
font-size: 0.875rem;
margin: 0;
}
.settings-container label {
width: 24px;
height: 16px;
}
.settings-container .field {
justify-content: space-between;
}
.settings-container .checkbox input + label,
.settings-container .checkbox input:checked + label:after {
background: var(--colour-1);
}
.settings-container .checkbox input + label:after,
.settings-container .checkbox input:checked + label {
background: var(--colour-3);
}
.settings-container .checkbox label:after {
left: 2px;
width: 10px;
height: 10px;
}
.settings-container .checkbox input:checked + label:after {
left: calc(100% - 2px - 10px);
}
.settings-container .dropdown {
padding: 4px 8px;
font-size: 0.75rem;
}

View File

@@ -1,197 +0,0 @@
.sidebar {
max-width: 260px;
padding: var(--section-gap);
flex-shrink: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.sidebar .title {
font-size: 14px;
font-weight: 500;
}
.sidebar .conversation-sidebar {
padding: 8px 12px;
display: flex;
gap: 18px;
align-items: center;
user-select: none;
justify-content: space-between;
}
.sidebar .conversation-sidebar .left {
cursor: pointer;
display: flex;
align-items: center;
gap: 10px;
}
.sidebar i {
color: var(--conversations);
cursor: pointer;
}
.sidebar .top {
display: flex;
flex-direction: column;
overflow: hidden;
gap: 16px;
padding-right: 8px;
}
.sidebar .top:hover {
overflow: auto;
}
.sidebar .info {
padding: 8px 12px 0px 12px;
display: flex;
align-items: center;
justify-content: center;
user-select: none;
background: transparent;
width: 100%;
border: none;
text-decoration: none;
}
.sidebar .info span {
color: var(--conversations);
line-height: 1.5;
font-size: 0.75rem;
}
.sidebar .info i::before {
margin-right: 8px;
}
.sidebar-footer {
width: 100%;
margin-top: 16px;
display: flex;
flex-direction: column;
}
.sidebar-footer button {
cursor: pointer;
user-select: none;
background: transparent;
}
.sidebar.shown {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
.sidebar.shown .box {
background-color: #16171a;
width: 80%;
height: 100%;
overflow-y: auto;
}
@keyframes spinner {
to {
transform: rotate(360deg);
}
}
/* scrollbar */
.sidebar .top::-webkit-scrollbar {
width: 4px;
padding: 8px 0px;
}
.sidebar .top::-webkit-scrollbar-track {
background-color: #ffffff00;
}
.sidebar .top::-webkit-scrollbar-thumb {
background-color: #555555;
border-radius: 10px;
}
.spinner:before {
content: "";
box-sizing: border-box;
position: absolute;
top: 50%;
left: 45%;
width: 20px;
height: 20px;
border-radius: 50%;
border: 1px solid var(--conversations);
border-top-color: white;
animation: spinner 0.6s linear infinite;
}
.menu-button {
display: none !important;
position: absolute;
z-index: 100000;
top: 0;
left: 0;
margin: 10px;
font-size: 1rem;
cursor: pointer;
width: 30px;
height: 30px;
justify-content: center;
align-items: center;
transition: 0.33s;
}
.menu-button i {
transition: 0.33s;
}
.rotated {
transform: rotate(360deg);
}
.menu-button.rotated {
position: fixed;
top: 10px;
left: 10px;
z-index: 1001;
}
@media screen and (max-width: 990px) {
.sidebar {
display: none;
width: 100%;
max-width: none;
}
.menu-button {
display: flex !important;
}
}
@media (max-width: 990px) {
.sidebar .top {
padding-top: 48px;
}
}
@media (min-width: 768px) {
.sidebar.shown {
position: static;
width: auto;
height: auto;
background-color: transparent;
}
.sidebar.shown .box {
background-color: #16171a;
width: auto;
height: auto;
overflow-y: auto;
}
}

View File

@@ -1,38 +0,0 @@
.stop-generating {
position: absolute;
bottom: 128px;
left: 50%;
transform: translateX(-50%);
z-index: 1000000;
}
.stop-generating button {
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: var(--blur-bg);
color: var(--colour-3);
cursor: pointer;
animation: show_popup 0.4s;
}
@keyframes show_popup {
from {
opacity: 0;
transform: translateY(10px);
}
}
@keyframes hide_popup {
to {
opacity: 0;
transform: translateY(10px);
}
}
.stop-generating-hiding button {
animation: hide_popup 0.4s;
}
.stop-generating-hidden button {
display: none;
}

View File

@@ -1,18 +1,821 @@
@import "global.css";
@import "hljs.css";
@import "main.css";
@import "sidebar.css";
@import "conversation.css";
@import "message.css";
@import "stop-generating.css";
@import "typing.css";
@import "checkbox.css";
@import "label.css";
@import "button.css";
@import "buttons.css";
@import "dropdown.css";
@import "field.css";
@import "select.css";
@import "options.css";
@import "settings.css";
@import "message-input.css";
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap");
/* :root {
--colour-1: #ffffff;
--colour-2: #000000;
--colour-3: #000000;
--colour-4: #000000;
--colour-5: #000000;
--colour-6: #000000;
--accent: #ffffff;
--blur-bg: #98989866;
--blur-border: #00000040;
--user-input: #000000;
--conversations: #000000;
} */
:root {
--colour-1: #000000;
--colour-2: #ccc;
--colour-3: #e4d4ff;
--colour-4: #f0f0f0;
--colour-5: #181818;
--colour-6: #242424;
--accent: #8b3dff;
--blur-bg: #16101b66;
--blur-border: #84719040;
--user-input: #ac87bb;
--conversations: #c7a2ff;
}
:root {
--font-1: "Inter", sans-serif;
--section-gap: 25px;
--border-radius-1: 8px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
position: relative;
font-family: var(--font-1);
}
html,
body {
scroll-behavior: smooth;
overflow: hidden;
}
body {
padding: var(--section-gap);
background: var(--colour-1);
color: var(--colour-3);
min-height: 100vh;
}
.row {
display: flex;
gap: var(--section-gap);
height: 100%;
}
.box {
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: var(--blur-bg);
height: 100%;
width: 100%;
border-radius: var(--border-radius-1);
border: 1px solid var(--blur-border);
}
.conversations {
max-width: 260px;
padding: var(--section-gap);
overflow: auto;
flex-shrink: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.conversation {
width: 100%;
min-height: 50%;
height: 100vh;
overflow-y: scroll;
overflow-x: hidden;
display: flex;
flex-direction: column;
gap: 15px;
}
.conversation #messages {
width: 100%;
display: flex;
flex-direction: column;
overflow-wrap: break-word;
overflow-y: inherit;
overflow-x: hidden;
padding-bottom: 50px;
}
.conversation .user-input {
max-height: 10vh;
}
.conversation .user-input input {
font-size: 15px;
width: 100%;
height: 100%;
padding: 12px 15px;
background: none;
border: none;
outline: none;
color: var(--colour-3);
}
.conversation .user-input input::placeholder {
color: var(--user-input)
}
.gradient:nth-child(1) {
--top: 0;
--right: 0;
--size: 70vw;
--blur: calc(0.5 * var(--size));
--opacity: 0.3;
animation: zoom_gradient 6s infinite;
}
.gradient {
position: absolute;
z-index: -1;
border-radius: calc(0.5 * var(--size));
background-color: var(--accent);
background: radial-gradient(circle at center, var(--accent), var(--accent));
width: 70vw;
height: 70vw;
top: 50%;
right: 0;
transform: translateY(-50%);
filter: blur(calc(0.5 * 70vw)) opacity(var(--opacity));
}
.conversations {
display: flex;
flex-direction: column;
gap: 16px;
flex: auto;
min-width: 0;
}
.conversations .title {
font-size: 14px;
font-weight: 500;
}
.conversations .convo {
padding: 8px 12px;
display: flex;
gap: 18px;
align-items: center;
user-select: none;
justify-content: space-between;
}
.conversations .convo .left {
cursor: pointer;
display: flex;
align-items: center;
gap: 10px;
flex: auto;
min-width: 0;
}
.conversations i {
color: var(--conversations);
cursor: pointer;
}
.convo-title {
color: var(--colour-3);
font-size: 14px;
overflow: hidden;
text-overflow: ellipsis;
}
.message {
width: 100%;
overflow-wrap: break-word;
display: flex;
gap: var(--section-gap);
padding: var(--section-gap);
padding-bottom: 0;
}
.message:last-child {
animation: 0.6s show_message;
}
@keyframes show_message {
from {
transform: translateY(10px);
opacity: 0;
}
}
.message .user {
max-width: 48px;
max-height: 48px;
flex-shrink: 0;
}
.message .user img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 8px;
outline: 1px solid var(--blur-border);
}
.message .user:after {
content: "63";
position: absolute;
bottom: 0;
right: 0;
height: 60%;
width: 60%;
background: var(--colour-3);
filter: blur(10px) opacity(0.5);
z-index: 10000;
}
.message .content {
display: flex;
flex-direction: column;
gap: 18px;
min-width: 0;
}
.message .content p,
.message .content li,
.message .content code {
font-size: 15px;
line-height: 1.3;
}
.message .user i {
position: absolute;
bottom: -6px;
right: -6px;
z-index: 1000;
}
.new_convo {
padding: 8px 12px;
display: flex;
gap: 18px;
align-items: center;
cursor: pointer;
user-select: none;
background: transparent;
border: 1px dashed var(--conversations);
border-radius: var(--border-radius-1);
}
.new_convo span {
color: var(--colour-3);
font-size: 14px;
}
.new_convo:hover {
border-style: solid;
}
.stop_generating {
position: absolute;
bottom: 118px;
/* left: 10px;
bottom: 125px;
right: 8px; */
left: 50%;
transform: translateX(-50%);
z-index: 1000000;
}
.stop_generating button {
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: var(--blur-bg);
border-radius: var(--border-radius-1);
border: 1px solid var(--blur-border);
padding: 10px 15px;
color: var(--colour-3);
display: flex;
justify-content: center;
align-items: center;
gap: 12px;
cursor: pointer;
animation: show_popup 0.4s;
}
@keyframes show_popup {
from {
opacity: 0;
transform: translateY(10px);
}
}
@keyframes hide_popup {
to {
opacity: 0;
transform: translateY(10px);
}
}
.stop_generating-hiding button {
animation: hide_popup 0.4s;
}
.stop_generating-hidden button {
display: none;
}
.typing {
position: absolute;
top: -25px;
left: 0;
font-size: 14px;
animation: show_popup 0.4s;
}
.typing-hiding {
animation: hide_popup 0.4s;
}
.typing-hidden {
display: none;
}
input[type="checkbox"] {
height: 0;
width: 0;
display: none;
}
label {
cursor: pointer;
text-indent: -9999px;
width: 50px;
height: 30px;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: var(--blur-bg);
border-radius: var(--border-radius-1);
border: 1px solid var(--blur-border);
display: block;
border-radius: 100px;
position: relative;
overflow: hidden;
transition: 0.33s;
}
label:after {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 5px;
width: 20px;
height: 20px;
background: var(--colour-3);
border-radius: 90px;
transition: 0.33s;
}
input:checked+label {
background: var(--blur-border);
}
input:checked+label:after {
left: calc(100% - 5px - 20px);
}
.buttons {
min-height: 10vh;
display: flex;
align-items: start;
justify-content: left;
width: 100%;
}
.field {
height: fit-content;
display: flex;
align-items: center;
gap: 16px;
padding-right: 15px
}
.field .about {
font-size: 14px;
color: var(--colour-3);
}
.disable-scrollbars::-webkit-scrollbar {
background: transparent; /* Chrome/Safari/Webkit */
width: 0px;
}
.disable-scrollbars {
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE 10+ */
}
select {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-backdrop-filter: blur(20px);
backdrop-filter: blur(20px);
cursor: pointer;
background-color: var(--blur-bg);
border: 1px solid var(--blur-border);
color: var(--colour-3);
display: block;
position: relative;
overflow: hidden;
outline: none;
padding: 8px 16px;
appearance: none;
}
.input-box {
display: flex;
align-items: center;
padding-right: 15px;
cursor: pointer;
}
.info {
padding: 8px 12px;
display: flex;
gap: 18px;
align-items: center;
user-select: none;
background: transparent;
border-radius: var(--border-radius-1);
width: 100%;
cursor: default;
border: 1px dashed var(--conversations)
}
.bottom_buttons {
width: 100%;
display: flex;
flex-direction: column;
gap: 10px;
}
.bottom_buttons button {
padding: 8px 12px;
display: flex;
gap: 18px;
align-items: center;
cursor: pointer;
user-select: none;
background: transparent;
border: 1px solid #c7a2ff;
border-radius: var(--border-radius-1);
width: 100%;
}
.bottom_buttons button span {
color: var(--colour-3);
font-size: 14px;
}
.conversations .top {
display: flex;
flex-direction: column;
gap: 16px;
overflow: auto;
}
#cursor {
line-height: 17px;
margin-left: 3px;
-webkit-animation: blink 0.8s infinite;
animation: blink 0.8s infinite;
width: 7px;
height: 15px;
}
@keyframes blink {
0% {
background: #ffffff00;
}
50% {
background: white;
}
100% {
background: #ffffff00;
}
}
@-webkit-keyframes blink {
0% {
background: #ffffff00;
}
50% {
background: white;
}
100% {
background: #ffffff00;
}
}
ol,
ul {
padding-left: 20px;
}
@keyframes spinner {
to {
transform: rotate(360deg);
}
}
.spinner:before {
content: '';
box-sizing: border-box;
position: absolute;
top: 50%;
left: 45%;
width: 20px;
height: 20px;
border-radius: 50%;
border: 1px solid var(--conversations);
border-top-color: white;
animation: spinner .6s linear infinite;
}
.grecaptcha-badge {
visibility: hidden;
}
.mobile-sidebar {
display: none !important;
position: absolute;
z-index: 100000;
top: 0;
left: 0;
margin: 10px;
font-size: 20px;
cursor: pointer;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
background-color: var(--blur-bg);
border-radius: 10px;
border: 1px solid var(--blur-border);
width: 40px;
height: 40px;
justify-content: center;
align-items: center;
transition: 0.33s;
}
.mobile-sidebar i {
transition: 0.33s;
}
.rotated {
transform: rotate(360deg);
}
@media screen and (max-width: 990px) {
.conversations {
display: none;
width: 100%;
max-width: none;
}
.buttons {
flex-wrap: wrap;
gap: 5px;
padding-bottom: 10vh;
margin-bottom: 10vh;
}
.field {
min-height: 5%;
width: fit-content;
}
.mobile-sidebar {
display: flex !important;
}
}
@media screen and (max-height: 640px) {
body {
height: 87vh
}
}
.shown {
display: flex;
}
a:-webkit-any-link {
color: var(--accent);
}
.conversation .user-input textarea {
font-size: 15px;
width: 100%;
height: 100%;
padding: 12px 15px;
background: none;
border: none;
outline: none;
color: var(--colour-3);
resize: vertical;
max-height: 150px;
min-height: 80px;
}
/* style for hljs copy */
.hljs-copy-wrapper {
position: relative;
overflow: hidden
}
.hljs-copy-wrapper:hover .hljs-copy-button,
.hljs-copy-button:focus {
transform: translateX(0)
}
.hljs-copy-button {
position: absolute;
transform: translateX(calc(100% + 1.125em));
top: 1em;
right: 1em;
width: 2rem;
height: 2rem;
text-indent: -9999px;
color: #fff;
border-radius: .25rem;
border: 1px solid #ffffff22;
background-color: #2d2b57;
background-image: url('data:image/svg+xml;utf-8,<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 5C5.73478 5 5.48043 5.10536 5.29289 5.29289C5.10536 5.48043 5 5.73478 5 6V20C5 20.2652 5.10536 20.5196 5.29289 20.7071C5.48043 20.8946 5.73478 21 6 21H18C18.2652 21 18.5196 20.8946 18.7071 20.7071C18.8946 20.5196 19 20.2652 19 20V6C19 5.73478 18.8946 5.48043 18.7071 5.29289C18.5196 5.10536 18.2652 5 18 5H16C15.4477 5 15 4.55228 15 4C15 3.44772 15.4477 3 16 3H18C18.7956 3 19.5587 3.31607 20.1213 3.87868C20.6839 4.44129 21 5.20435 21 6V20C21 20.7957 20.6839 21.5587 20.1213 22.1213C19.5587 22.6839 18.7957 23 18 23H6C5.20435 23 4.44129 22.6839 3.87868 22.1213C3.31607 21.5587 3 20.7957 3 20V6C3 5.20435 3.31607 4.44129 3.87868 3.87868C4.44129 3.31607 5.20435 3 6 3H8C8.55228 3 9 3.44772 9 4C9 4.55228 8.55228 5 8 5H6Z" fill="white"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3C7 1.89543 7.89543 1 9 1H15C16.1046 1 17 1.89543 17 3V5C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5V3ZM15 3H9V5H15V3Z" fill="white"/></svg>');
background-repeat: no-repeat;
background-position: center;
transition: background-color 200ms ease, transform 200ms ease-out
}
.hljs-copy-button:hover {
border-color: #ffffff44
}
.hljs-copy-button:active {
border-color: #ffffff66
}
.hljs-copy-button[data-copied="true"] {
text-indent: 0;
width: auto;
background-image: none
}
@media(prefers-reduced-motion) {
.hljs-copy-button {
transition: none
}
}
.hljs-copy-alert {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px
}
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
.color-picker>fieldset {
border: 0;
display: flex;
width: fit-content;
background: var(--colour-1);
margin-inline: auto;
border-radius: 8px;
-webkit-backdrop-filter: blur(20px);
backdrop-filter: blur(20px);
cursor: pointer;
background-color: var(--blur-bg);
border: 1px solid var(--blur-border);
color: var(--colour-3);
display: block;
position: relative;
overflow: hidden;
outline: none;
padding: 6px 16px;
}
.color-picker input[type="radio"]:checked {
background-color: var(--radio-color);
}
.color-picker input[type="radio"]#light {
--radio-color: gray;
}
.color-picker input[type="radio"]#pink {
--radio-color: pink;
}
.color-picker input[type="radio"]#blue {
--radio-color: blue;
}
.color-picker input[type="radio"]#green {
--radio-color: green;
}
.color-picker input[type="radio"]#dark {
--radio-color: #232323;
}
.pink {
--colour-1: hsl(310 50% 90%);
--clr-card-bg: hsl(310 50% 100%);
--colour-3: hsl(310 50% 15%);
--conversations: hsl(310 50% 25%);
}
.blue {
--colour-1: hsl(209 50% 90%);
--clr-card-bg: hsl(209 50% 100%);
--colour-3: hsl(209 50% 15%);
--conversations: hsl(209 50% 25%);
}
.green {
--colour-1: hsl(109 50% 90%);
--clr-card-bg: hsl(109 50% 100%);
--colour-3: hsl(109 50% 15%);
--conversations: hsl(109 50% 25%);
}
.dark {
--colour-1: hsl(209 50% 10%);
--clr-card-bg: hsl(209 50% 5%);
--colour-3: hsl(209 50% 90%);
--conversations: hsl(209 50% 80%);
}
:root:has(#pink:checked) {
--colour-1: hsl(310 50% 90%);
--clr-card-bg: hsl(310 50% 100%);
--colour-3: hsl(310 50% 15%);
--conversations: hsl(310 50% 25%);
}
:root:has(#blue:checked) {
--colour-1: hsl(209 50% 90%);
--clr-card-bg: hsl(209 50% 100%);
--colour-3: hsl(209 50% 15%);
--conversations: hsl(209 50% 25%);
}
:root:has(#green:checked) {
--colour-1: hsl(109 50% 90%);
--clr-card-bg: hsl(109 50% 100%);
--colour-3: hsl(109 50% 15%);
--conversations: hsl(109 50% 25%);
}
:root:has(#dark:checked) {
--colour-1: hsl(209 50% 10%);
--clr-card-bg: hsl(209 50% 5%);
--colour-3: hsl(209 50% 90%);
--conversations: hsl(209 50% 80%);
}
.trash-icon {
position: absolute;
top: 20px;
right: 20px;
}

View File

@@ -1,15 +0,0 @@
.typing {
position: absolute;
top: -25px;
left: 0;
font-size: 14px;
animation: show_popup 0.4s;
}
.typing-hiding {
animation: hide_popup 0.4s;
}
.typing-hidden {
display: none;
}

View File

@@ -1,135 +1,155 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1.0" />
<meta name="description" content="A conversational AI system that listens, learns, and challenges" />
<meta property="og:title" content="ChatGPT" />
<meta property="og:image" content="https://openai.com/content/images/2022/11/ChatGPT.jpg" />
<meta
property="og:description"
content="A conversational AI system that listens, learns, and challenges" />
<meta property="og:url" content="https://chat.acy.dev" />
<link rel="stylesheet" href="{{ url_for('bp.static', filename='css/style.css') }}" />
<link
rel="apple-touch-icon"
sizes="180x180"
href="{{ url_for('bp.static', filename='img/apple-touch-icon.png') }}" />
<link
rel="icon"
type="image/png"
sizes="32x32"
href="{{ url_for('bp.static', filename='img/favicon-32x32.png') }}" />
<link
rel="icon"
type="image/png"
sizes="16x16"
href="{{ url_for('bp.static', filename='img/favicon-16x16.png') }}" />
<link rel="manifest" href="{{ url_for('bp.static', filename='img/site.webmanifest') }}" />
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/styles/base16/dracula.min.css" />
<title>FreeGPT</title>
</head>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1.0">
<meta name="description" content="A conversational AI system that listens, learns, and challenges">
<meta property="og:title" content="ChatGPT">
<meta property="og:image" content="https://openai.com/content/images/2022/11/ChatGPT.jpg">
<meta property="og:description" content="A conversational AI system that listens, learns, and challenges">
<meta property="og:url" content="https://chat.acy.dev">
<link rel="stylesheet" href="/assets/css/style.css">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon-16x16.png">
<link rel="manifest" href="/assets/img/site.webmanifest">
<script src="/assets/js/icons.js"></script>
<script src="/assets/js/chat.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/styles/base16/dracula.min.css">
<script>
const user_image = `<img src="/assets/img/user.png" alt="User Avatar">`;
const gpt_image = `<img src="/assets/img/gpt.png" alt="GPT Avatar">`;
</script>
<style>
.hljs {
color: #e9e9f4;
background: #28293629;
border-radius: var(--border-radius-1);
border: 1px solid var(--blur-border);
font-size: 15px;
}
<body data-urlprefix="{{ url_prefix}}">
<div class="main-container">
<div class="box sidebar">
<div class="top">
<button class="button" onclick="new_conversation()">
<i class="fa-regular fa-plus"></i>
<span>{{_('New Conversation')}}</span>
</button>
<div class="spinner"></div>
</div>
<div class="sidebar-footer">
<button class="button" onclick="delete_conversations()">
<i class="fa-regular fa-trash"></i>
<span>{{_('Clear Conversations')}}</span>
</button>
<div class="settings-container">
<div class="checkbox field">
<span>{{_('Dark Mode')}}</span>
<input type="checkbox" id="theme-toggler" />
<label for="theme-toggler"></label>
</div>
<div class="field">
<span>{{_('Language')}}</span>
<select
class="dropdown"
id="language"
onchange="changeLanguage(this.value)"></select>
</div>
</div>
<a class="info" href="https://github.com/ramonvc/gptfree-jailbreak-webui" target="_blank">
<i class="fa-brands fa-github"></i>
<span class="conversation-title"> {{_('Version')}}: 0.1.0 </span>
</a>
</div>
</div>
<div class="conversation">
<div class="stop-generating stop-generating-hidden">
<button class="button" id="cancelButton">
<span>{{_('Stop Generating')}}</span>
</button>
</div>
<div class="box" id="messages"></div>
<div class="user-input">
<div class="box input-box">
<textarea
id="message-input"
placeholder="{{_('Ask a question')}}"
cols="30"
rows="10"
style="white-space: pre-wrap"></textarea>
<div id="send-button">
<i class="fa-regular fa-paper-plane-top"></i>
</div>
</div>
</div>
<div>
<div class="options-container">
<div class="buttons">
<div class="field">
<select class="dropdown" name="model" id="model">
<option value="gpt-3.5-turbo" selected>GPT-3.5</option>
<option value="gpt-3.5-turbo-16k">GPT-3.5-turbo-16k</option>
<option value="gpt-4">GPT-4</option>
</select>
</div>
<div class="field">
<select class="dropdown" name="jailbreak" id="jailbreak">
<option value="default" selected>{{_('Default')}}</option>
<option value="gpt-dan-11.0">{{_('DAN')}}</option>
<option value="gpt-evil">{{_('Evil')}}</option>
</select>
</div>
</div>
<div class="field checkbox">
<input type="checkbox" id="switch" />
<label for="switch"></label>
<span>{{_('Web Access')}}</span>
</div>
</div>
</div>
</div>
</div>
<div class="menu-button">
<i class="fa-solid fa-bars"></i>
</div>
#message-input {
margin-right: 30px;
height: 80px;
}
<!-- scripts -->
<script>
window.conversation_id = "{{ chat_id }}";
</script>
<script src="{{ url_for('bp.static', filename='js/icons.js') }}"></script>
<script src="{{ url_for('bp.static', filename='js/chat.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js"></script>
<script src="{{ url_for('bp.static', filename='js/highlight.min.js') }}"></script>
<script src="{{ url_for('bp.static', filename='js/highlightjs-copy.min.js') }}"></script>
<script src="{{ url_for('bp.static', filename='js/theme-toggler.js') }}"></script>
<script src="{{ url_for('bp.static', filename='js/sidebar-toggler.js') }}"></script>
<script src="{{ url_for('bp.static', filename='js/change-language.js') }}"></script>
</body>
#message-input::-webkit-scrollbar {
width: 5px;
}
/* Track */
#message-input::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
#message-input::-webkit-scrollbar-thumb {
background: #c7a2ff;
}
/* Handle on hover */
#message-input::-webkit-scrollbar-thumb:hover {
background: #8b3dff;
}
</style>
<script src="/assets/js/highlight.min.js"></script>
<script src="/assets/js/highlightjs-copy.min.js"></script>
<script>window.conversation_id = {{chat_id}} </script>
<title>ChatGPT</title>
</head>
<body>
<div class="gradient"></div>
<div class="row">
<div class="box conversations">
<div class="top">
<button class="new_convo" onclick="new_conversation()">
<i class="fa-regular fa-plus"></i>
<span>New Conversation</span>
</button>
<div class="spinner"></div>
</div>
<div class="bottom_buttons">
<button onclick="delete_conversations()">
<i class="fa-regular fa-trash"></i>
<span>Clear Conversations</span>
</button>
<div class="info">
<i class="fa-regular fa-circle-info"></i>
<span class="convo-title">By: Balsh<br>
Version: 0.0.6 <br>
Release: 2023-09-06<br>
</span>
</div>
</div>
</div>
<div class="conversation disable-scrollbars">
<div class="stop_generating stop_generating-hidden">
<button id="cancelButton">
<span>Stop Generating</span>
<i class="fa-regular fa-stop"></i>
</button>
</div>
<div class="box" id="messages">
</div>
<div class="user-input">
<div class="box input-box">
<textarea id="message-input" placeholder="Ask a question" cols="30" rows="10" style="white-space: pre-wrap;" oninput="resizeTextarea(this)"></textarea>
<div id="send-button">
<i class="fa-regular fa-paper-plane-top"></i>
</div>
</div>
</div>
<div class="buttons">
<div class="field">
<input type="checkbox" id="switch"/>
<label for="switch"></label>
<span class="about">Web Access</span>
</div>
<div class="field">
<select name="model" id="model">
## for m in model_list
{% if loop.index1 == 1 %}
<option value="{{ m }}" selected>{{ m }}</option>
{% else %}
<option value="{{ m }}">{{ m }}</option>
{% endif %}
## endfor
</select>
<!-- <span class="about">Model</span> -->
</div>
<div class="field">
<select name="jailbreak" id="jailbreak">
<option value="default" selected>default</option>
</select>
</div>
<form class="color-picker" action="">
<fieldset>
<legend class="visually-hidden">Pick a color scheme</legend>
<label for="light" class="visually-hidden">Light</label>
<input type="radio" title="light" name="theme" id="light" checked>
<label for="pink" class="visually-hidden">Pink theme</label>
<input type="radio" title="pink" id="pink" name="theme">
<label for="blue" class="visually-hidden">Blue theme</label>
<input type="radio" title="blue" id="blue" name="theme">
<label for="green" class="visually-hidden">Green theme</label>
<input type="radio" title="green" id="green" name="theme">
<label for="dark" class="visually-hidden">Dark theme</label>
<input type="radio" title="dark" id="dark" name="theme">
</fieldset>
</form>
</div>
</div>
</div>
<div class="mobile-sidebar">
<i class="fa-solid fa-bars"></i>
</div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,47 +0,0 @@
document.addEventListener('DOMContentLoaded', fetchLanguages);
async function fetchLanguages() {
try {
const [languagesResponse, currentLanguageResponse] = await Promise.all([
fetch(`${url_prefix}/get-languages`),
fetch(`${url_prefix}/get-locale`)
]);
const languages = await languagesResponse.json();
const currentLanguage = await currentLanguageResponse.text();
const languageSelect = document.getElementById('language');
languages.forEach(lang => {
const option = document.createElement('option');
option.value = lang;
option.textContent = lang;
languageSelect.appendChild(option);
});
const savedLanguage = localStorage.getItem("language") || currentLanguage;
setLanguageOnPageLoad(savedLanguage);
} catch (error) {
console.error("Failed to fetch languages or current language");
}
}
function setLanguageOnPageLoad(language) {
document.getElementById("language").value = language;
}
function changeLanguage(lang) {
fetch(`${url_prefix}/change-language`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ language: lang }),
}).then((response) => {
if (response.ok) {
localStorage.setItem("language", lang);
location.reload();
} else {
console.error("Failed to change language");
}
});
}

View File

@@ -1,84 +1,105 @@
const query = (obj) =>
Object.keys(obj)
.map((k) => encodeURIComponent(k) + "=" + encodeURIComponent(obj[k]))
.join("&");
const url_prefix = document.querySelector("body").getAttribute("data-urlprefix");
Object.keys(obj)
.map((k) => encodeURIComponent(k) + "=" + encodeURIComponent(obj[k]))
.join("&");
const colorThemes = document.querySelectorAll('[name="theme"]');
const markdown = window.markdownit();
const message_box = document.getElementById(`messages`);
const message_input = document.getElementById(`message-input`);
const box_conversations = document.querySelector(`.top`);
const spinner = box_conversations.querySelector(".spinner");
const stop_generating = document.querySelector(`.stop-generating`);
const stop_generating = document.querySelector(`.stop_generating`);
const send_button = document.querySelector(`#send-button`);
const user_image = `<img src="${url_prefix}/assets/img/user.png" alt="User Avatar">`;
const gpt_image = `<img src="${url_prefix}/assets/img/gpt.png" alt="GPT Avatar">`;
let prompt_lock = false;
hljs.addPlugin(new CopyButtonPlugin());
function resizeTextarea(textarea) {
textarea.style.height = '80px';
textarea.style.height = Math.min(textarea.scrollHeight, 200) + 'px';
}
const format = (text) => {
return text.replace(/(?:\r\n|\r|\n)/g, "<br>");
};
message_input.addEventListener("blur", () => {
window.scrollTo(0, 0);
window.scrollTo(0, 0);
});
message_input.addEventListener("focus", () => {
document.documentElement.scrollTop = document.documentElement.scrollHeight;
document.documentElement.scrollTop = document.documentElement.scrollHeight;
});
const delete_conversations = async () => {
localStorage.clear();
await new_conversation();
localStorage.clear();
await new_conversation();
};
const handle_ask = async () => {
message_input.style.height = `80px`;
window.scrollTo(0, 0);
let message = message_input.value;
message_input.style.height = `80px`;
message_input.focus();
if (message.length > 0) {
message_input.value = ``;
message_input.dispatchEvent(new Event("input"));
await ask_gpt(message);
}
window.scrollTo(0, 0);
let message = message_input.value;
if (message.length > 0) {
message_input.value = ``;
await ask_gpt(message);
}
};
const remove_cancel_button = async () => {
stop_generating.classList.add(`stop-generating-hiding`);
stop_generating.classList.add(`stop_generating-hiding`);
setTimeout(() => {
stop_generating.classList.remove(`stop-generating-hiding`);
stop_generating.classList.add(`stop-generating-hidden`);
}, 300);
setTimeout(() => {
stop_generating.classList.remove(`stop_generating-hiding`);
stop_generating.classList.add(`stop_generating-hidden`);
}, 300);
};
const ask_gpt = async (message) => {
try {
message_input.value = ``;
message_input.innerHTML = ``;
message_input.innerText = ``;
try {
message_input.value = ``;
message_input.innerHTML = ``;
message_input.innerText = ``;
add_conversation(window.conversation_id, message.substr(0, 16));
window.scrollTo(0, 0);
window.controller = new AbortController();
add_conversation(window.conversation_id, message.substr(0, 20));
window.scrollTo(0, 0);
window.controller = new AbortController();
jailbreak = document.getElementById("jailbreak");
model = document.getElementById("model");
prompt_lock = true;
window.text = ``;
window.token = message_id();
jailbreak = document.getElementById("jailbreak");
model = document.getElementById("model");
prompt_lock = true;
window.text = ``;
window.token = message_id();
stop_generating.classList.remove(`stop-generating-hidden`);
stop_generating.classList.remove(`stop_generating-hidden`);
add_user_message_box(message);
message_box.scrollTop = message_box.scrollHeight;
window.scrollTo(0, 0);
await new Promise((r) => setTimeout(r, 500));
window.scrollTo(0, 0);
message_box.innerHTML += `
message_box.innerHTML += `
<div class="message">
<div class="avatar-container">
${gpt_image}
<div class="user">
${user_image}
<i class="fa-regular fa-phone-arrow-up-right"></i>
</div>
<div class="content" id="user_${token}">
${format(message)}
</div>
<i class="fa fa-trash trash-icon" onclick="deleteMessage('${token}')"></i>
</div>
`;
/* .replace(/(?:\r\n|\r|\n)/g, '<br>') */
message_box.scrollTop = message_box.scrollHeight;
window.scrollTo(0, 0);
await new Promise((r) => setTimeout(r, 500));
window.scrollTo(0, 0);
message_box.innerHTML += `
<div class="message">
<div class="user">
${gpt_image} <i class="fa-regular fa-phone-arrow-down-left"></i>
</div>
<div class="content" id="gpt_${window.token}">
<div id="cursor"></div>
@@ -86,423 +107,493 @@ const ask_gpt = async (message) => {
</div>
`;
message_box.scrollTop = message_box.scrollHeight;
window.scrollTo(0, 0);
await new Promise((r) => setTimeout(r, 1000));
window.scrollTo(0, 0);
message_box.scrollTop = message_box.scrollHeight;
window.scrollTo(0, 0);
await new Promise((r) => setTimeout(r, 1000));
window.scrollTo(0, 0);
const response = await fetch(`${url_prefix}/backend-api/v2/conversation`, {
method: `POST`,
signal: window.controller.signal,
headers: {
"content-type": `application/json`,
accept: `text/event-stream`,
},
body: JSON.stringify({
conversation_id: window.conversation_id,
action: `_ask`,
model: model.options[model.selectedIndex].value,
jailbreak: jailbreak.options[jailbreak.selectedIndex].value,
meta: {
id: window.token,
content: {
conversation: await get_conversation(window.conversation_id),
internet_access: document.getElementById("switch").checked,
content_type: "text",
parts: [
{
content: message,
role: "user",
},
],
},
},
}),
});
const response = await fetch(`/backend-api/v2/conversation`, {
method: `POST`,
signal: window.controller.signal,
headers: {
"content-type": `application/json`,
accept: `text/event-stream`,
},
body: JSON.stringify({
conversation_id: window.conversation_id,
action: `_ask`,
model: model.options[model.selectedIndex].value,
jailbreak: jailbreak.options[jailbreak.selectedIndex].value,
meta: {
id: window.token,
content: {
conversation: await get_conversation(window.conversation_id),
internet_access: document.getElementById("switch").checked,
content_type: "text",
parts: [
{
content: message,
role: "user",
},
],
},
},
}),
});
const reader = response.body.getReader();
const reader = response.body.getReader();
while (true) {
const { value, done } = await reader.read();
if (done) break;
while (true) {
const { value, done } = await reader.read();
if (done) break;
chunk = decodeUnicode(new TextDecoder().decode(value));
chunk = new TextDecoder().decode(value);
if (
chunk.includes(`<form id="challenge-form" action="${url_prefix}/backend-api/v2/conversation?`)
) {
chunk = `cloudflare token expired, please refresh the page.`;
}
if (
chunk.includes(
`<form id="challenge-form" action="/backend-api/v2/conversation?`
)
) {
chunk = `cloudflare token expired, please refresh the page.`;
}
text += chunk;
text += chunk;
document.getElementById(`gpt_${window.token}`).innerHTML = markdown.render(text);
document.querySelectorAll(`code`).forEach((el) => {
hljs.highlightElement(el);
});
// const objects = chunk.match(/({.+?})/g);
window.scrollTo(0, 0);
message_box.scrollTo({ top: message_box.scrollHeight, behavior: "auto" });
}
// try { if (JSON.parse(objects[0]).success === false) throw new Error(JSON.parse(objects[0]).error) } catch (e) {}
// if text contains :
if (text.includes(`instead. Maintaining this website and API costs a lot of money`)) {
document.getElementById(`gpt_${window.token}`).innerHTML =
"An error occurred, please reload / refresh cache and try again.";
}
// objects.forEach((object) => {
// console.log(object)
// try { text += h2a(JSON.parse(object).content) } catch(t) { console.log(t); throw new Error(t)}
// });
add_message(window.conversation_id, "user", message);
add_message(window.conversation_id, "assistant", text);
document.getElementById(`gpt_${window.token}`).innerHTML =
markdown.render(text);
document.querySelectorAll(`code`).forEach((el) => {
hljs.highlightElement(el);
});
message_box.scrollTop = message_box.scrollHeight;
await remove_cancel_button();
prompt_lock = false;
window.scrollTo(0, 0);
message_box.scrollTo({ top: message_box.scrollHeight, behavior: "auto" });
}
await load_conversations(20, 0);
window.scrollTo(0, 0);
} catch (e) {
add_message(window.conversation_id, "user", message);
// if text contains :
if (
text.includes(
`instead. Maintaining this website and API costs a lot of money`
)
) {
document.getElementById(`gpt_${window.token}`).innerHTML =
"An error occured, please reload / refresh cache and try again.";
}
message_box.scrollTop = message_box.scrollHeight;
await remove_cancel_button();
prompt_lock = false;
add_message(window.conversation_id, "user", message, token);
add_message(window.conversation_id, "assistant", text, token);
await load_conversations(20, 0);
message_box.scrollTop = message_box.scrollHeight;
await remove_cancel_button();
prompt_lock = false;
console.log(e);
await load_conversations(20, 0);
window.scrollTo(0, 0);
} catch (e) {
add_message(window.conversation_id, "user", message, token);
let cursorDiv = document.getElementById(`cursor`);
if (cursorDiv) cursorDiv.parentNode.removeChild(cursorDiv);
message_box.scrollTop = message_box.scrollHeight;
await remove_cancel_button();
prompt_lock = false;
if (e.name != `AbortError`) {
let error_message = `oops ! something went wrong, please try again / reload. [stacktrace in console]`;
await load_conversations(20, 0);
document.getElementById(`gpt_${window.token}`).innerHTML = error_message;
add_message(window.conversation_id, "assistant", error_message);
} else {
document.getElementById(`gpt_${window.token}`).innerHTML += ` [aborted]`;
add_message(window.conversation_id, "assistant", text + ` [aborted]`);
}
console.log(e);
window.scrollTo(0, 0);
}
};
let cursorDiv = document.getElementById(`cursor`);
if (cursorDiv) cursorDiv.parentNode.removeChild(cursorDiv);
const add_user_message_box = (message) => {
const messageDiv = createElement("div", { classNames: ["message"] });
const avatarContainer = createElement("div", { classNames: ["avatar-container"], innerHTML: user_image });
const contentDiv = createElement("div", {
classNames: ["content"],
id: `user_${token}`,
textContent: message,
});
if (e.name != `AbortError`) {
let error_message = `oops ! something went wrong, please try again / reload. [stacktrace in console]`;
messageDiv.append(avatarContainer, contentDiv);
message_box.appendChild(messageDiv);
};
document.getElementById(`gpt_${window.token}`).innerHTML = error_message;
add_message(window.conversation_id, "assistant", error_message, token);
} else {
document.getElementById(`gpt_${window.token}`).innerHTML += ` [aborted]`;
add_message(window.conversation_id, "assistant", text + ` [aborted]`, token);
}
const decodeUnicode = (str) => {
return str.replace(/\\u([a-fA-F0-9]{4})/g, function (match, grp) {
return String.fromCharCode(parseInt(grp, 16));
});
window.scrollTo(0, 0);
}
};
const clear_conversations = async () => {
const elements = box_conversations.childNodes;
let index = elements.length;
const elements = box_conversations.childNodes;
let index = elements.length;
if (index > 0) {
while (index--) {
const element = elements[index];
if (element.nodeType === Node.ELEMENT_NODE && element.tagName.toLowerCase() !== `button`) {
box_conversations.removeChild(element);
}
}
}
if (index > 0) {
while (index--) {
const element = elements[index];
if (
element.nodeType === Node.ELEMENT_NODE &&
element.tagName.toLowerCase() !== `button`
) {
box_conversations.removeChild(element);
}
}
}
};
const clear_conversation = async () => {
let messages = message_box.getElementsByTagName(`div`);
let messages = message_box.getElementsByTagName(`div`);
while (messages.length > 0) {
message_box.removeChild(messages[0]);
}
while (messages.length > 0) {
message_box.removeChild(messages[0]);
}
};
const show_option = async (conversation_id) => {
const conv = document.getElementById(`conv-${conversation_id}`);
const yes = document.getElementById(`yes-${conversation_id}`);
const not = document.getElementById(`not-${conversation_id}`);
conv.style.display = "none";
yes.style.display = "block";
not.style.display = "block";
}
const hide_option = async (conversation_id) => {
const conv = document.getElementById(`conv-${conversation_id}`);
const yes = document.getElementById(`yes-${conversation_id}`);
const not = document.getElementById(`not-${conversation_id}`);
conv.style.display = "block";
yes.style.display = "none";
not.style.display = "none";
}
const delete_conversation = async (conversation_id) => {
localStorage.removeItem(`conversation:${conversation_id}`);
localStorage.removeItem(`conversation:${conversation_id}`);
if (window.conversation_id == conversation_id) {
await new_conversation();
}
const conversation = document.getElementById(`convo-${conversation_id}`);
conversation.remove();
await load_conversations(20, 0, true);
if (window.conversation_id == conversation_id) {
await new_conversation();
}
await load_conversations(20, 0, true);
};
const set_conversation = async (conversation_id) => {
history.pushState({}, null, `${url_prefix}/chat/${conversation_id}`);
window.conversation_id = conversation_id;
history.pushState({}, null, `{{chat_path}}/${conversation_id}`);
window.conversation_id = conversation_id;
await clear_conversation();
await load_conversation(conversation_id);
await load_conversations(20, 0, true);
await clear_conversation();
await load_conversation(conversation_id);
await load_conversations(20, 0, true);
};
const new_conversation = async () => {
history.pushState({}, null, `${url_prefix}/chat/`);
window.conversation_id = uuid();
history.pushState({}, null, `{{chat_path}}/`);
window.conversation_id = uuid();
await clear_conversation();
await load_conversations(20, 0, true);
await clear_conversation();
await load_conversations(20, 0, true);
};
const load_conversation = async (conversation_id) => {
let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
console.log(conversation, conversation_id);
let conversation = await JSON.parse(
localStorage.getItem(`conversation:${conversation_id}`)
);
console.log(conversation, conversation_id);
for (item of conversation.items) {
if (is_assistant(item.role)) {
message_box.innerHTML += load_gpt_message_box(item.content);
} else {
message_box.innerHTML += load_user_message_box(item.content);
}
}
document.querySelectorAll(`code`).forEach((el) => {
hljs.highlightElement(el);
});
message_box.scrollTo({ top: message_box.scrollHeight, behavior: "smooth" });
setTimeout(() => {
message_box.scrollTop = message_box.scrollHeight;
}, 500);
};
const load_user_message_box = (content) => {
const messageDiv = createElement("div", { classNames: ["message"] });
const avatarContainer = createElement("div", { classNames: ["avatar-container"], innerHTML: user_image });
const contentDiv = createElement("div", { classNames: ["content"] });
const preElement = document.createElement("pre");
preElement.textContent = content;
contentDiv.appendChild(preElement);
messageDiv.append(avatarContainer, contentDiv);
return messageDiv.outerHTML;
};
const load_gpt_message_box = (content) => {
return `
for (item of conversation.items) {
message_box.innerHTML += `
<div class="message">
<div class="avatar-container">
${gpt_image}
<div class="user">
${item.role == "assistant" ? gpt_image : user_image}
${
item.role == "assistant"
? `<i class="fa-regular fa-phone-arrow-down-left"></i>`
: `<i class="fa-regular fa-phone-arrow-up-right"></i>`
}
</div>
<div class="content">
${markdown.render(content)}
${
item.role == "user"
? `<div class="content" id="user_${item.token}">`
: `<div class="content" id="gpt_${item.token}">`
}
${
item.role == "assistant"
? markdown.render(item.content)
: item.content
}
</div>
${
item.role == "user"
? `<i class="fa fa-trash trash-icon" onclick="deleteMessage('${item.token}')"></i>`
: ''
}
</div>
`;
};
}
const is_assistant = (role) => {
return role == "assistant";
document.querySelectorAll(`code`).forEach((el) => {
hljs.highlightElement(el);
});
message_box.scrollTo({ top: message_box.scrollHeight, behavior: "smooth" });
setTimeout(() => {
message_box.scrollTop = message_box.scrollHeight;
}, 500);
};
const get_conversation = async (conversation_id) => {
let conversation = await JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
return conversation.items;
let conversation = await JSON.parse(
localStorage.getItem(`conversation:${conversation_id}`)
);
let result = conversation.items.slice(-4)
for (var i = 0; i < result.length; i++) {
delete result[i].token;
console.log(result[i]);
console.log(result[i]);
}
return result;
};
const add_conversation = async (conversation_id, title) => {
if (localStorage.getItem(`conversation:${conversation_id}`) == null) {
localStorage.setItem(
`conversation:${conversation_id}`,
JSON.stringify({
id: conversation_id,
title: title,
items: [],
})
);
}
if (localStorage.getItem(`conversation:${conversation_id}`) == null) {
localStorage.setItem(
`conversation:${conversation_id}`,
JSON.stringify({
id: conversation_id,
title: title,
items: [],
})
);
}
};
const add_message = async (conversation_id, role, content) => {
before_adding = JSON.parse(localStorage.getItem(`conversation:${conversation_id}`));
const add_message = async (conversation_id, role, content, token) => {
before_adding = JSON.parse(
localStorage.getItem(`conversation:${conversation_id}`)
);
before_adding.items.push({
role: role,
content: content,
});
before_adding.items.push({
role: role,
content: content,
token: token,
});
localStorage.setItem(`conversation:${conversation_id}`, JSON.stringify(before_adding)); // update conversation
localStorage.setItem(
`conversation:${conversation_id}`,
JSON.stringify(before_adding)
); // update conversation
};
const load_conversations = async (limit, offset, loader) => {
//console.log(loader);
//if (loader === undefined) box_conversations.appendChild(spinner);
//console.log(loader);
//if (loader === undefined) box_conversations.appendChild(spinner);
let conversations = [];
for (let i = 0; i < localStorage.length; i++) {
if (localStorage.key(i).startsWith("conversation:")) {
let conversation = localStorage.getItem(localStorage.key(i));
conversations.push(JSON.parse(conversation));
}
}
let conversations = [];
for (let i = 0; i < localStorage.length; i++) {
if (localStorage.key(i).startsWith("conversation:")) {
let conversation = localStorage.getItem(localStorage.key(i));
conversations.push(JSON.parse(conversation));
}
}
//if (loader === undefined) spinner.parentNode.removeChild(spinner)
await clear_conversations();
//if (loader === undefined) spinner.parentNode.removeChild(spinner)
await clear_conversations();
for (conversation of conversations) {
box_conversations.innerHTML += `
<div class="conversation-sidebar">
<div class="left" onclick="set_conversation('${conversation.id}')">
<i class="fa-regular fa-comments"></i>
<span class="conversation-title">${conversation.title}</span>
</div>
<i onclick="delete_conversation('${conversation.id}')" class="fa-regular fa-trash"></i>
</div>
`;
}
for (conversation of conversations) {
box_conversations.innerHTML += `
<div class="convo" id="convo-${conversation.id}">
<div class="left" onclick="set_conversation('${conversation.id}')">
<i class="fa-regular fa-comments"></i>
<span class="convo-title">${conversation.title}</span>
</div>
<i onclick="show_option('${conversation.id}')" class="fa-regular fa-trash" id="conv-${conversation.id}"></i>
<i onclick="delete_conversation('${conversation.id}')" class="fa-regular fa-check" id="yes-${conversation.id}" style="display:none;"></i>
<i onclick="hide_option('${conversation.id}')" class="fa-regular fa-x" id="not-${conversation.id}" style="display:none;"></i>
</div>
`;
}
document.querySelectorAll(`code`).forEach((el) => {
hljs.highlightElement(el);
});
document.querySelectorAll(`code`).forEach((el) => {
hljs.highlightElement(el);
});
};
document.getElementById(`cancelButton`).addEventListener(`click`, async () => {
window.controller.abort();
console.log(`aborted ${window.conversation_id}`);
window.controller.abort();
console.log(`aborted ${window.conversation_id}`);
});
function h2a(str1) {
var hex = str1.toString();
var str = "";
var hex = str1.toString();
var str = "";
for (var n = 0; n < hex.length; n += 2) {
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
}
for (var n = 0; n < hex.length; n += 2) {
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
}
return str;
return str;
}
const uuid = () => {
return `xxxxxxxx-xxxx-4xxx-yxxx-${Date.now().toString(16)}`.replace(/[xy]/g, function (c) {
var r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
return `xxxxxxxx-xxxx-4xxx-yxxx-${Date.now().toString(16)}`.replace(
/[xy]/g,
function (c) {
var r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
}
);
};
const message_id = () => {
random_bytes = (Math.floor(Math.random() * 1338377565) + 2956589730).toString(2);
unix = Math.floor(Date.now() / 1000).toString(2);
random_bytes = (Math.floor(Math.random() * 1338377565) + 2956589730).toString(
2
);
unix = Math.floor(Date.now() / 1000).toString(2);
return BigInt(`0b${unix}${random_bytes}`).toString();
return BigInt(`0b${unix}${random_bytes}`).toString();
};
window.onload = async () => {
load_settings_localstorage();
load_settings_localstorage();
conversations = 0;
for (let i = 0; i < localStorage.length; i++) {
if (localStorage.key(i).startsWith("conversation:")) {
conversations += 1;
}
}
conversations = 0;
for (let i = 0; i < localStorage.length; i++) {
if (localStorage.key(i).startsWith("conversation:")) {
conversations += 1;
}
}
if (conversations == 0) localStorage.clear();
if (conversations == 0) localStorage.clear();
await setTimeout(() => {
load_conversations(20, 0);
}, 1);
await setTimeout(() => {
load_conversations(20, 0);
}, 1);
if (!window.location.href.endsWith(`#`)) {
if (/\/chat\/.+/.test(window.location.href.slice(url_prefix.length))) {
await load_conversation(window.conversation_id);
}
}
if (!window.location.href.endsWith(`#`)) {
if (/\{{chat_path}}\/.+/.test(window.location.href)) {
await load_conversation(window.conversation_id);
}
}
message_input.addEventListener("keydown", async (evt) => {
if (prompt_lock) return;
message_input.addEventListener(`keydown`, async (evt) => {
if (prompt_lock) return;
if (evt.keyCode === 13 && !evt.shiftKey) {
evt.preventDefault();
console.log('pressed enter');
await handle_ask();
} else {
message_input.style.removeProperty("height");
message_input.style.height = message_input.scrollHeight + 4 + "px";
}
});
if (evt.key === "Enter" && !evt.shiftKey) {
evt.preventDefault();
await handle_ask();
}
});
send_button.addEventListener(`click`, async () => {
console.log("clicked send");
if (prompt_lock) return;
await handle_ask();
});
send_button.addEventListener("click", async (event) => {
event.preventDefault();
if (prompt_lock) return;
message_input.blur();
await handle_ask();
});
register_settings_localstorage();
register_settings_localstorage();
};
document.querySelector(".mobile-sidebar").addEventListener("click", (event) => {
const sidebar = document.querySelector(".conversations");
if (sidebar.classList.contains("shown")) {
sidebar.classList.remove("shown");
event.target.classList.remove("rotated");
} else {
sidebar.classList.add("shown");
event.target.classList.add("rotated");
}
window.scrollTo(0, 0);
});
const register_settings_localstorage = async () => {
settings_ids = ["switch", "model", "jailbreak"];
settings_elements = settings_ids.map((id) => document.getElementById(id));
settings_elements.map((element) =>
element.addEventListener(`change`, async (event) => {
switch (event.target.type) {
case "checkbox":
localStorage.setItem(event.target.id, event.target.checked);
break;
case "select-one":
localStorage.setItem(event.target.id, event.target.selectedIndex);
break;
default:
console.warn("Unresolved element type");
}
})
);
settings_ids = ["switch", "model", "jailbreak"];
settings_elements = settings_ids.map((id) => document.getElementById(id));
settings_elements.map((element) =>
element.addEventListener(`change`, async (event) => {
switch (event.target.type) {
case "checkbox":
localStorage.setItem(event.target.id, event.target.checked);
break;
case "select-one":
localStorage.setItem(event.target.id, event.target.selectedIndex);
break;
default:
console.warn("Unresolved element type");
}
})
);
};
const load_settings_localstorage = async () => {
settings_ids = ["switch", "model", "jailbreak"];
settings_elements = settings_ids.map((id) => document.getElementById(id));
settings_elements.map((element) => {
if (localStorage.getItem(element.id)) {
switch (element.type) {
case "checkbox":
element.checked = localStorage.getItem(element.id) === "true";
break;
case "select-one":
element.selectedIndex = parseInt(localStorage.getItem(element.id));
break;
default:
console.warn("Unresolved element type");
}
}
});
settings_ids = ["switch", "model", "jailbreak"];
settings_elements = settings_ids.map((id) => document.getElementById(id));
settings_elements.map((element) => {
if (localStorage.getItem(element.id)) {
switch (element.type) {
case "checkbox":
element.checked = localStorage.getItem(element.id) === "true";
break;
case "select-one":
element.selectedIndex = parseInt(localStorage.getItem(element.id));
break;
default:
console.warn("Unresolved element type");
}
}
});
};
function clearTextarea(textarea) {
textarea.style.removeProperty("height");
textarea.style.height = `${textarea.scrollHeight + 4}px`;
if (textarea.value.trim() === "" && textarea.value.includes("\n")) {
textarea.value = "";
}
// Theme storage for recurring viewers
const storeTheme = function (theme) {
localStorage.setItem("theme", theme);
};
// set theme when visitor returns
const setTheme = function () {
const activeTheme = localStorage.getItem("theme");
colorThemes.forEach((themeOption) => {
if (themeOption.id === activeTheme) {
themeOption.checked = true;
}
});
// fallback for no :has() support
document.documentElement.className = activeTheme;
};
colorThemes.forEach((themeOption) => {
themeOption.addEventListener("click", () => {
storeTheme(themeOption.id);
// fallback for no :has() support
document.documentElement.className = themeOption.id;
});
});
function deleteMessage(token) {
const messageDivUser = document.getElementById(`user_${token}`)
const messageDivGpt = document.getElementById(`gpt_${token}`)
if (messageDivUser) messageDivUser.parentNode.remove();
if (messageDivGpt) messageDivGpt.parentNode.remove();
const conversation = JSON.parse(localStorage.getItem(`conversation:${window.conversation_id}`));
conversation.items = conversation.items.filter(item => item.token !== token);
localStorage.setItem(`conversation:${window.conversation_id}`, JSON.stringify(conversation));
const messages = document.getElementsByClassName("message");
if (messages.length === 0) {
delete_conversation(window.conversation_id);
};
}
function createElement(tag, { classNames, id, innerHTML, textContent } = {}) {
const el = document.createElement(tag);
if (classNames) {
el.classList.add(...classNames);
}
if (id) {
el.id = id;
}
if (innerHTML) {
el.innerHTML = innerHTML;
}
if (textContent) {
const preElement = document.createElement("pre");
preElement.textContent = textContent;
el.appendChild(preElement);
}
return el;
}
document.onload = setTheme();

View File

@@ -1,34 +0,0 @@
const sidebar = document.querySelector(".sidebar");
const menuButton = document.querySelector(".menu-button");
function toggleSidebar(event) {
if (sidebar.classList.contains("shown")) {
hideSidebar(event.target);
} else {
showSidebar(event.target);
}
window.scrollTo(0, 0);
}
function showSidebar(target) {
sidebar.classList.add("shown");
target.classList.add("rotated");
document.body.style.overflow = "hidden";
}
function hideSidebar(target) {
sidebar.classList.remove("shown");
target.classList.remove("rotated");
document.body.style.overflow = "auto";
}
menuButton.addEventListener("click", toggleSidebar);
document.body.addEventListener('click', function(event) {
if (event.target.matches('.conversation-title')) {
const menuButtonStyle = window.getComputedStyle(menuButton);
if (menuButtonStyle.display !== 'none') {
hideSidebar(menuButton);
}
}
});

View File

@@ -1,22 +0,0 @@
var switch_theme_toggler = document.getElementById("theme-toggler");
switch_theme_toggler.addEventListener("change", toggleTheme);
function setTheme(themeName) {
localStorage.setItem("theme", themeName);
document.documentElement.className = themeName;
}
function toggleTheme() {
var currentTheme = localStorage.getItem("theme");
var newTheme = currentTheme === "theme-dark" ? "theme-light" : "theme-dark";
setTheme(newTheme);
switch_theme_toggler.checked = newTheme === "theme-dark";
}
(function () {
var currentTheme = localStorage.getItem("theme") || "theme-dark";
setTheme(currentTheme);
switch_theme_toggler.checked = currentTheme === "theme-dark";
})();