Update static/style.css
Browse files- static/style.css +495 -427
static/style.css
CHANGED
|
@@ -10,15 +10,16 @@
|
|
| 10 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.css"/>
|
| 11 |
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.js"></script>
|
| 12 |
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/contrib/auto-render.min.js"></script>
|
|
|
|
|
|
|
| 13 |
<style>
|
| 14 |
-
/* ========== ุงูู
ุชุบูุฑุงุช ูุงูุชูุณููุงุช ุงูุฃุณุงุณูุฉ ========== */
|
| 15 |
:root {
|
| 16 |
--bg: #0d0f14; --surface: #161920; --surface2: #1e2230; --surface3: #252a3a;
|
| 17 |
--border: #2a2f42; --border2: #333a52;
|
| 18 |
--accent: #4f8ef7; --accent2: #7c5cf7; --accent-soft: rgba(79,142,247,0.12);
|
| 19 |
--text: #e8eaf2; --text2: #9aa3be; --text3: #5c6480;
|
| 20 |
--user-bubble: #1a2340; --bot-bubble: #161920;
|
| 21 |
-
--danger: #f75f5f;
|
| 22 |
--radius: 28px; --radius-sm: 18px; --radius-pill: 50px;
|
| 23 |
--sidebar-w: 280px; --tr: 0.3s cubic-bezier(.4,0,.2,1);
|
| 24 |
}
|
|
@@ -29,120 +30,104 @@
|
|
| 29 |
--user-bubble: #dde6ff; --bot-bubble: #fff; --accent-soft: rgba(79,142,247,0.1);
|
| 30 |
}
|
| 31 |
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
| 32 |
-
html,body{height:100%;font-family:'Cairo',sans-serif;background:var(--bg);color:var(--text);
|
| 33 |
::-webkit-scrollbar{width:6px}::-webkit-scrollbar-track{background:transparent}
|
| 34 |
::-webkit-scrollbar-thumb{background:var(--border2);border-radius:var(--radius-pill)}
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
.app{display:flex;height:100vh;overflow:hidden}
|
| 37 |
|
| 38 |
/* SIDEBAR */
|
| 39 |
.sidebar{width:var(--sidebar-w);min-width:var(--sidebar-w);background:var(--surface);
|
| 40 |
border-right:1px solid var(--border);display:flex;flex-direction:column;
|
| 41 |
transition:width var(--tr),min-width var(--tr);overflow:hidden;
|
| 42 |
-
border-top-right-radius:
|
| 43 |
-
[dir="rtl"] .sidebar
|
| 44 |
.sidebar.collapsed{width:0;min-width:0;border:none}
|
| 45 |
.sidebar-header{padding:24px 20px 16px;display:flex;align-items:center;gap:12px;}
|
| 46 |
.s-logo{display:flex;align-items:center;gap:12px;flex:1}
|
| 47 |
-
.s-logo img{width:36px;height:36px;border-radius:12px;object-fit:cover;
|
| 48 |
.s-logo-name{font-size:1.2rem;font-weight:700;background:linear-gradient(135deg,var(--accent),var(--accent2));-webkit-background-clip:text;-webkit-text-fill-color:transparent}
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
.close-sidebar-btn
|
| 52 |
-
background: none; border: none; color: var(--text2); font-size: 1.4rem;
|
| 53 |
-
cursor: pointer; padding: 6px 10px; border-radius: var(--radius-pill);
|
| 54 |
-
transition: all 0.2s; display: flex; align-items: center; justify-content: center;
|
| 55 |
-
width: 36px; height: 36px;
|
| 56 |
-
}
|
| 57 |
-
.close-sidebar-btn:hover { background: var(--surface2); color: var(--danger); transform: scale(1.1); }
|
| 58 |
|
| 59 |
.btn-new{margin:12px 16px;padding:12px 16px;background:linear-gradient(135deg,var(--accent),var(--accent2));
|
| 60 |
color:#fff;border:none;border-radius:var(--radius-pill);cursor:pointer;font-family:'Cairo',sans-serif;
|
| 61 |
-
font-size:.95rem;font-weight:600;display:flex;align-items:center;gap:8px;
|
| 62 |
-
transition:all var(--tr);
|
| 63 |
.btn-new:hover{opacity:.9;transform:translateY(-2px)}
|
| 64 |
.s-label{padding:10px 20px;font-size:.75rem;font-weight:700;color:var(--text3);letter-spacing:.08em;text-transform:uppercase}
|
| 65 |
.chats-list{flex:1;overflow-y:auto;padding:4px 12px;display:flex;flex-direction:column;gap:6px}
|
| 66 |
.chat-item{padding:10px 16px;border-radius:var(--radius-sm);cursor:pointer;font-size:.9rem;color:var(--text2);
|
| 67 |
-
display:flex;align-items:center;gap:10px;transition:all var(--tr);
|
| 68 |
-
|
| 69 |
-
|
| 70 |
.chat-item.active{background:var(--accent-soft);color:var(--accent);font-weight:600;}
|
| 71 |
.chat-item .ct{flex:1;overflow:hidden;text-overflow:ellipsis}
|
| 72 |
-
.del-btn{opacity:0;background:none;border:none;color:var(--danger);cursor:pointer;
|
| 73 |
-
padding:4px;border-radius:50%;transition:all var(--tr); display:flex; align-items:center; justify-content:center;}
|
| 74 |
.chat-item:hover .del-btn{opacity:1}
|
| 75 |
-
.del-btn:hover{background:rgba(247,95,95,.15);
|
| 76 |
-
.s-footer{padding:16px;display:flex;align-items:center;gap:12px;
|
| 77 |
-
.btn-icon{width:42px;height:42px;background:var(--surface2);border:none;
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
.btn-icon:hover{background:var(--surface3);color:var(--text);
|
| 81 |
|
| 82 |
/* MAIN */
|
| 83 |
-
.main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0;
|
| 84 |
-
.topbar{height:70px;padding:0 24px;display:flex;align-items:center;gap:16px;
|
| 85 |
.topbar-title{flex:1;font-size:1.05rem;font-weight:600;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 86 |
|
| 87 |
/* CHAT AREA */
|
| 88 |
-
.chat-area{flex:1;overflow-y:auto;padding:20px 0 40px;display:flex;flex-direction:column;
|
| 89 |
.welcome{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
|
| 90 |
-
gap:20px;padding:40px 24px;text-align:center;
|
| 91 |
.w-logo{width:85px;height:85px;border-radius:24px;object-fit:cover;box-shadow:0 12px 40px var(--accent-soft)}
|
| 92 |
-
.w-title{font-size:2.4rem;font-weight:700;background:linear-gradient(135deg,var(--accent),var(--accent2));
|
| 93 |
-
-webkit-background-clip:text;-webkit-text-fill-color:transparent}
|
| 94 |
.w-sub{color:var(--text2);font-size:1.05rem}
|
| 95 |
.chips{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-top:12px;max-width:600px}
|
| 96 |
.chip{padding:10px 20px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-pill);
|
| 97 |
-
font-size:.9rem;color:var(--text);cursor:pointer;transition:all var(--tr);
|
| 98 |
-
.chip:hover{background:var(--accent-soft);border-color:var(--accent);color:var(--accent);
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
.msg-row{display:flex;padding:8px 30px;gap:16px; animation: popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;}
|
| 102 |
-
@keyframes popIn { from { opacity: 0; transform: translateY(15px) scale(0.98); filter: blur(4px); } to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); } }
|
| 103 |
-
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 104 |
.msg-row.user{flex-direction:row-reverse}
|
| 105 |
.msg-av{width:38px;height:38px;border-radius:14px;flex-shrink:0;display:flex;align-items:center;
|
| 106 |
-
justify-content:center;font-size:1.1rem;font-weight:700;margin-top:2px;overflow:hidden;
|
| 107 |
-
box-shadow: 0 4px 10px rgba(0,0,0,0.1);}
|
| 108 |
.msg-row.bot .msg-av{background:linear-gradient(135deg,var(--accent),var(--accent2))}
|
| 109 |
.msg-row.bot .msg-av img{width:100%;height:100%;object-fit:cover}
|
| 110 |
.msg-row.user .msg-av{background:var(--surface3);color:var(--text)}
|
| 111 |
-
|
| 112 |
-
.bubble{max-width:min(700px,80vw);padding:16px 22px;border-radius:var(--radius);
|
| 113 |
-
font-size:.98rem;line-height:1.75;word-break:break-word; box-shadow: 0 4px 15px rgba(0,0,0,0.03);}
|
| 114 |
-
.msg-row.bot .bubble{background:transparent;border:none;padding:8px 4px;box-shadow:none;border-top-left-radius:var(--radius);}[dir="rtl"] .msg-row.bot .bubble { border-top-left-radius:var(--radius); border-top-right-radius:var(--radius); }
|
| 115 |
-
.msg-row.user .bubble{background:var(--user-bubble);border:none; border-top-right-radius:6px}[dir="rtl"] .msg-row.user .bubble { border-top-right-radius:var(--radius); border-top-left-radius:6px; }
|
| 116 |
-
|
| 117 |
-
.bubble img {
|
| 118 |
-
max-width: 100%; height: auto; border-radius: 16px; margin: 12px 0;
|
| 119 |
-
box-shadow: 0 8px 25px rgba(0,0,0,0.15); cursor: zoom-in; transition: transform 0.2s;
|
| 120 |
-
border: 1px solid var(--border);
|
| 121 |
-
}
|
| 122 |
-
.bubble img:active { transform: scale(1.02); }
|
| 123 |
|
| 124 |
-
.
|
| 125 |
-
|
|
|
|
|
|
|
| 126 |
|
| 127 |
-
.
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
}
|
| 134 |
-
@keyframes skeletonLoading
|
| 135 |
|
| 136 |
-
/* MARKDOWN STYLES */
|
| 137 |
.bubble p{margin-bottom:12px}.bubble p:last-child{margin-bottom:0}
|
| 138 |
.bubble ul,.bubble ol{padding-inline-start:24px;margin:12px 0}
|
| 139 |
-
.bubble li
|
| 140 |
.bubble .table-wrapper{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;margin:16px 0;border-radius:var(--radius-sm);border:1px solid var(--border);}
|
| 141 |
.bubble table{width:100%;border-collapse:collapse;min-width:400px;}
|
| 142 |
.bubble th,.bubble td{border:1px solid var(--border);padding:10px 14px;text-align:start;white-space:nowrap;}
|
| 143 |
.bubble th{background:var(--surface3);font-weight:600;}
|
| 144 |
|
| 145 |
-
/* Code Blocks */
|
| 146 |
.code-container{position:relative;margin:16px 0;background:var(--surface3);border-radius:var(--radius-sm);border:1px solid var(--border);overflow:hidden;max-width:100%;}
|
| 147 |
.code-header{display:flex;justify-content:space-between;align-items:center;background:#12141a;padding:8px 16px;font-size:0.8rem;color:var(--text2);font-family:'JetBrains Mono',monospace;}
|
| 148 |
.copy-btn{background:var(--surface2);border:none;color:var(--text);cursor:pointer;display:flex;align-items:center;gap:6px;font-size:0.8rem;padding:4px 10px;border-radius:var(--radius-pill);transition:all 0.2s;}
|
|
@@ -151,119 +136,100 @@
|
|
| 151 |
.code-container pre code{white-space:pre;display:block;}
|
| 152 |
.bubble code:not(pre code){font-family:'JetBrains Mono',monospace;font-size:.85rem;background:var(--surface3);padding:3px 6px;border-radius:6px;color:var(--accent);}
|
| 153 |
|
| 154 |
-
/* KaTeX */
|
| 155 |
.katex-display{overflow-x:auto;overflow-y:hidden;padding:8px 0;-webkit-overflow-scrolling:touch;}
|
| 156 |
.katex{font-size:1.05em;}
|
| 157 |
|
| 158 |
-
|
| 159 |
-
.file-chip {
|
| 160 |
-
.file-chip button
|
| 161 |
-
.file-
|
| 162 |
-
.
|
| 163 |
-
|
| 164 |
-
.mem-badge{font-size:.75rem;color:var(--text3);padding:4px 30px 10px;display:flex;align-items:center;gap:6px; font-weight: 600;}
|
| 165 |
|
| 166 |
/* INPUT */
|
| 167 |
-
.input-area{padding:0 24px 30px;
|
| 168 |
-
.input-wrapper{width:100%;
|
| 169 |
-
.file-chips-container
|
| 170 |
-
.input-box{display:flex;align-items:flex-end;gap:
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
.
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
.
|
| 177 |
-
|
| 178 |
-
.input-box textarea{flex:1;background:none;border:none;outline:none;color:var(--text);
|
| 179 |
-
font-family:'Cairo',sans-serif;font-size:.98rem;resize:none;max-height:160px;line-height:1.6; padding: 6px 0;}
|
| 180 |
.input-box textarea::placeholder{color:var(--text3)}
|
| 181 |
-
|
| 182 |
-
/*
|
| 183 |
-
.btn-send,
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
.btn-send {background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff;}
|
| 190 |
-
.btn-send:hover{opacity:.9;transform:scale(1.08) rotate(-10deg);}[dir="rtl"] .btn-send:hover{transform:scale(1.08) rotate(10deg);}
|
| 191 |
.btn-send:disabled{opacity:.4;cursor:not-allowed;transform:none;}
|
| 192 |
-
|
| 193 |
-
.btn-stop
|
| 194 |
-
.btn-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
.btn-voice
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
}
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
/* MODAL */
|
| 212 |
-
.overlay{position:fixed;inset:0;z-index:999;background:rgba(0,0,0,.6);display:flex;
|
| 213 |
-
align-items:center;justify-content:center;backdrop-filter:blur(8px);
|
| 214 |
-
opacity:0;pointer-events:none;transition:opacity var(--tr)}
|
| 215 |
.overlay.open{opacity:1;pointer-events:all}
|
| 216 |
-
.modal{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:32px;
|
| 217 |
-
width:min(440px,90vw);box-shadow:0 30px 80px rgba(0,0,0,.5);
|
| 218 |
-
transform:translateY(20px) scale(0.95);transition:all var(--tr)}
|
| 219 |
.overlay.open .modal{transform:translateY(0) scale(1)}
|
| 220 |
.m-header{display:flex;align-items:center;gap:12px;margin-bottom:24px}
|
| 221 |
.m-title{font-size:1.3rem;font-weight:700;flex:1}
|
| 222 |
-
.m-close{background:var(--surface2);border:none;color:var(--text);cursor:pointer;width:36px;height:36px;
|
| 223 |
-
.m-close:hover{background:var(--danger);
|
| 224 |
.s-row{display:flex;align-items:center;justify-content:space-between;padding:16px 0;border-bottom:1px solid var(--border)}
|
| 225 |
.s-lbl{font-size:.95rem;font-weight:600;color:var(--text)}
|
| 226 |
.s-desc{font-size:.8rem;color:var(--text3);margin-top:4px}
|
| 227 |
.toggle{position:relative;width:48px;height:26px}
|
| 228 |
.toggle input{opacity:0;width:0;height:0}
|
| 229 |
.tslider{position:absolute;inset:0;background:var(--surface3);border-radius:var(--radius-pill);cursor:pointer;transition:all var(--tr)}
|
| 230 |
-
.tslider::before{content:'';position:absolute;width:20px;height:20px;border-radius:50%;
|
| 231 |
-
background:#fff;top:3px;left:4px;transition:all var(--tr); box-shadow: 0 2px 5px rgba(0,0,0,0.2);}
|
| 232 |
.toggle input:checked+.tslider{background:var(--accent)}
|
| 233 |
.toggle input:checked+.tslider::before{transform:translateX(20px)}
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
.btn-save{width:100%;margin-top:24px;padding:14px;background:linear-gradient(135deg,var(--accent),var(--accent2));
|
| 237 |
-
color:#fff;border:none;border-radius:var(--radius-pill);cursor:pointer;font-family:'Cairo',sans-serif;font-size:1rem;font-weight:700; transition:opacity var(--tr);}
|
| 238 |
.btn-save:hover{opacity:.9}
|
| 239 |
-
.btn-danger{padding:8px 18px;background:rgba(247,95,95,.12);border:1px solid var(--danger);
|
| 240 |
-
|
| 241 |
-
.btn-danger:hover{background:var(--danger); color:#fff;}
|
| 242 |
|
| 243 |
-
/* โโ RESPONSIVE MOBILE โโ */
|
| 244 |
@media (max-width: 640px) {
|
| 245 |
-
.msg-row
|
| 246 |
-
.bubble
|
| 247 |
-
.msg-row.bot .bubble
|
| 248 |
-
.topbar
|
| 249 |
-
.input-area
|
| 250 |
-
.code-container pre
|
| 251 |
-
.bubble th,
|
| 252 |
-
.w-title
|
| 253 |
-
.chips
|
| 254 |
-
.chip
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
.sidebar
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
}
|
| 261 |
-
[dir="rtl"] .sidebar { left: auto; right: 0; }
|
| 262 |
-
.sidebar.collapsed {
|
| 263 |
-
transform: translateX(-100%); width: var(--sidebar-w) !important; min-width: var(--sidebar-w) !important;
|
| 264 |
-
}
|
| 265 |
-
[dir="rtl"] .sidebar.collapsed { transform: translateX(100%); }
|
| 266 |
-
.sidebar:not(.collapsed) { transform: translateX(0); }
|
| 267 |
}
|
| 268 |
</style>
|
| 269 |
</head>
|
|
@@ -275,36 +241,59 @@
|
|
| 275 |
<img src="https://copilot.microsoft.com/th/id/BCO.f29916dd-b0c1-4089-87cd-43d099a7d1a6.png" alt="Genisi"/>
|
| 276 |
<span class="s-logo-name">Genisi AI</span>
|
| 277 |
</div>
|
| 278 |
-
<button class="close-sidebar-btn" onclick="toggleSidebar()" title="ุฅุฎูุงุก ุงููุงุฆู
ุฉ">
|
|
|
|
|
|
|
| 279 |
</div>
|
| 280 |
-
<button class="btn-new" onclick="newChat()" id="i18n-new-chat">
|
|
|
|
|
|
|
|
|
|
| 281 |
<div class="s-label" id="i18n-chats-label">CHATS</div>
|
| 282 |
<div class="chats-list" id="chats-list"></div>
|
| 283 |
<div class="s-footer">
|
| 284 |
-
<button class="btn-icon" onclick="openSettings()">
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
</div>
|
| 287 |
</aside>
|
| 288 |
|
| 289 |
<main class="main">
|
| 290 |
<div class="topbar">
|
| 291 |
-
<button class="btn-icon" id="menu-toggle-btn" onclick="toggleSidebar()">
|
|
|
|
|
|
|
| 292 |
<div class="topbar-title" id="topbar-title">Genisi AI</div>
|
| 293 |
</div>
|
| 294 |
<div class="chat-area" id="chat-area"></div>
|
| 295 |
<div class="input-area">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
<div class="file-chips-container" id="file-chips"></div>
|
| 297 |
<div class="input-wrapper">
|
| 298 |
<div class="input-box">
|
| 299 |
<input type="file" id="file-input" multiple hidden onchange="handleFiles(this.files)" />
|
| 300 |
-
<button class="btn-attach" onclick="document.getElementById('file-input').click()">
|
|
|
|
|
|
|
| 301 |
<textarea id="msg-input" rows="1" onkeydown="handleKey(event)" oninput="autoResize(this)" placeholder="Type a message..."></textarea>
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
<
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
<
|
|
|
|
|
|
|
|
|
|
| 308 |
</div>
|
| 309 |
</div>
|
| 310 |
</div>
|
|
@@ -316,7 +305,9 @@
|
|
| 316 |
<div class="modal">
|
| 317 |
<div class="m-header">
|
| 318 |
<div class="m-title" id="i18n-settings-title">Settings</div>
|
| 319 |
-
<button class="m-close" onclick="closeSettings()">
|
|
|
|
|
|
|
| 320 |
</div>
|
| 321 |
<div class="s-row">
|
| 322 |
<div class="s-lbl" id="i18n-lang-lbl">Language</div>
|
|
@@ -334,24 +325,36 @@
|
|
| 334 |
<span class="tslider"></span>
|
| 335 |
</label>
|
| 336 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
<div class="s-row">
|
| 338 |
<div>
|
| 339 |
<div class="s-lbl" id="i18n-del-lbl">Delete All Chats</div>
|
| 340 |
<div class="s-desc" id="i18n-del-desc">This action cannot be undone</div>
|
| 341 |
</div>
|
| 342 |
-
<button class="btn-danger" onclick="clearAllChats()" id="i18n-del-btn">
|
|
|
|
|
|
|
| 343 |
</div>
|
| 344 |
-
<button class="btn-save" onclick="closeSettings()" id="i18n-save-btn">
|
| 345 |
</div>
|
| 346 |
</div>
|
| 347 |
|
| 348 |
<script>
|
| 349 |
// โโโโโโโโ i18n โโโโโโโโ
|
| 350 |
const i18n = {
|
| 351 |
-
en: { newChat:
|
| 352 |
-
ar: { newChat:
|
| 353 |
-
fr: { newChat:
|
| 354 |
-
es: { newChat:
|
| 355 |
};
|
| 356 |
|
| 357 |
let currentLang = localStorage.getItem('genisi_lang') || 'en';
|
|
@@ -360,376 +363,441 @@ function applyI18n() {
|
|
| 360 |
const t = i18n[currentLang];
|
| 361 |
document.documentElement.dir = currentLang === 'ar' ? 'rtl' : 'ltr';
|
| 362 |
document.documentElement.lang = currentLang;
|
| 363 |
-
|
| 364 |
-
|
| 365 |
document.getElementById('i18n-chats-label').textContent = t.chatsLabel;
|
| 366 |
document.getElementById('i18n-settings-title').textContent = t.settings;
|
| 367 |
document.getElementById('i18n-lang-lbl').textContent = t.lang;
|
| 368 |
document.getElementById('i18n-dark-lbl').textContent = t.dark;
|
|
|
|
|
|
|
| 369 |
document.getElementById('i18n-del-lbl').textContent = t.del;
|
| 370 |
document.getElementById('i18n-del-desc').textContent = t.delDesc;
|
| 371 |
-
document.getElementById('i18n-del-btn').textContent = t.delBtn;
|
| 372 |
document.getElementById('i18n-save-btn').textContent = t.saveBtn;
|
| 373 |
document.getElementById('msg-input').placeholder = t.placeholder;
|
| 374 |
-
|
| 375 |
if(!activeChatId) renderWelcome();
|
| 376 |
renderChatList();
|
| 377 |
}
|
| 378 |
-
function changeLanguage(val)
|
| 379 |
|
| 380 |
-
// โโโโโโโโ STATE
|
| 381 |
-
const genId = () => Date.now().toString(36)
|
| 382 |
let userId = localStorage.getItem('genisi_user_id');
|
| 383 |
-
if
|
| 384 |
|
| 385 |
-
let chats = JSON.parse(localStorage.getItem('genisi_chats')
|
| 386 |
let activeChatId = null;
|
| 387 |
let isGenerating = false;
|
| 388 |
-
let pendingFiles =[];
|
| 389 |
let currentAbortController = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
const renderer = new marked.Renderer();
|
| 398 |
renderer.code = function(token) {
|
| 399 |
const codeText = typeof token === 'string' ? token : token.text || '';
|
| 400 |
const lang = typeof token === 'string' ? arguments[1] : token.lang || 'text';
|
| 401 |
-
const escapedCode = String(codeText).replace(/&/g,
|
| 402 |
-
return `<div class="code-container"><div class="code-header"><span>${lang}</span><button class="copy-btn" onclick="copyCode(this,
|
| 403 |
};
|
| 404 |
renderer.table = function(header, body) {
|
| 405 |
-
if
|
| 406 |
-
const token
|
| 407 |
-
const hdr
|
| 408 |
-
const rows
|
| 409 |
return `<div class="table-wrapper"><table><thead><tr>${hdr}</tr></thead><tbody>${rows}</tbody></table></div>`;
|
| 410 |
}
|
| 411 |
return `<div class="table-wrapper"><table><thead>${header}</thead><tbody>${body}</tbody></table></div>`;
|
| 412 |
};
|
| 413 |
-
renderer.html = function(html)
|
| 414 |
-
marked.setOptions({ renderer
|
| 415 |
|
| 416 |
-
function safeMarked(text)
|
| 417 |
-
if
|
| 418 |
-
|
| 419 |
-
return DOMPurify.sanitize(rawHtml, { USE_PROFILES: { html: true } });
|
| 420 |
}
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
if (window.renderMathInElement) {
|
| 424 |
-
renderMathInElement(el, { delimiters:[{left: '$$', right: '$$', display: true},{left: '$', right: '$', display: false},{left: '\\(', right: '\\)', display: false},{left: '\\[', right: '\\]', display: true}], throwOnError: false });
|
| 425 |
-
}
|
| 426 |
}
|
| 427 |
-
function copyCode(btn, encodedCode)
|
| 428 |
-
navigator.clipboard.writeText(decodeURIComponent(encodedCode)).then(()
|
| 429 |
-
const
|
| 430 |
-
btn.innerHTML = "
|
| 431 |
-
|
|
|
|
| 432 |
});
|
| 433 |
}
|
| 434 |
-
function removeGeminiCursor()
|
| 435 |
|
| 436 |
-
// โโโโโโโโ UTILS
|
| 437 |
-
const saveChats = () => localStorage.setItem('genisi_chats',
|
| 438 |
-
const getChat = (id) => chats.find(c
|
| 439 |
function esc(t){ return String(t).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
document.getElementById('file-input').value = '';
|
| 456 |
}
|
| 457 |
-
function renderFileChips()
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
|
|
|
| 463 |
}
|
| 464 |
-
function removeFile(idx)
|
| 465 |
|
| 466 |
-
// โโโโโโโโ THEME
|
| 467 |
function applyTheme(t){
|
| 468 |
document.documentElement.setAttribute('data-theme',t);
|
| 469 |
localStorage.setItem('genisi_theme',t);
|
| 470 |
-
document.getElementById('theme-btn').textContent = t==='dark'?'๐':'โ๏ธ';
|
| 471 |
document.getElementById('dark-toggle').checked = t==='dark';
|
|
|
|
|
|
|
|
|
|
| 472 |
}
|
| 473 |
function toggleTheme(){ applyTheme(document.documentElement.getAttribute('data-theme')==='dark'?'light':'dark'); }
|
| 474 |
function applyThemeToggle(){ applyTheme(document.getElementById('dark-toggle').checked?'dark':'light'); }
|
| 475 |
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
const sidebar
|
| 479 |
-
|
|
|
|
|
|
|
| 480 |
}
|
| 481 |
-
function toggleSidebar()
|
| 482 |
-
|
| 483 |
-
sidebar.
|
| 484 |
-
|
| 485 |
-
}
|
| 486 |
-
function initSidebarState() {
|
| 487 |
-
const sidebar = document.getElementById('sidebar');
|
| 488 |
-
if (window.innerWidth <= 640) sidebar.classList.add('collapsed');
|
| 489 |
else sidebar.classList.remove('collapsed');
|
| 490 |
updateMenuIcon();
|
| 491 |
}
|
| 492 |
-
window.addEventListener('resize',
|
| 493 |
-
const sidebar
|
| 494 |
-
if
|
| 495 |
else sidebar.classList.add('collapsed');
|
| 496 |
updateMenuIcon();
|
| 497 |
});
|
| 498 |
|
| 499 |
-
|
|
|
|
| 500 |
function closeSettings(){ document.getElementById('settings-modal').classList.remove('open'); }
|
| 501 |
|
|
|
|
| 502 |
function renderChatList(){
|
| 503 |
const list=document.getElementById('chats-list'); list.innerHTML='';
|
| 504 |
[...chats].reverse().forEach(chat=>{
|
| 505 |
const div=document.createElement('div');
|
| 506 |
div.className='chat-item'+(chat.id===activeChatId?' active':'');
|
| 507 |
-
div.innerHTML=`<
|
| 508 |
-
div.onclick = ()
|
| 509 |
list.appendChild(div);
|
| 510 |
});
|
|
|
|
| 511 |
}
|
|
|
|
| 512 |
function renderWelcome(){
|
| 513 |
-
const t
|
| 514 |
document.getElementById('topbar-title').textContent='Genisi AI';
|
| 515 |
document.getElementById('chat-area').innerHTML=`<div class="welcome" id="welcome"><img src="https://copilot.microsoft.com/th/id/BCO.f29916dd-b0c1-4089-87cd-43d099a7d1a6.png" class="w-logo" alt="Genisi"/><div class="w-title">${t.welcomeTitle}</div><div class="w-sub">${t.welcomeSub}</div><div class="chips"><div class="chip" onclick="quickSend('${t.c1}')">${t.c1}</div><div class="chip" onclick="quickSend('${t.c2}')">${t.c2}</div><div class="chip" onclick="quickSend('${t.c3}')">${t.c3}</div><div class="chip" onclick="quickSend('${t.c4}')">${t.c4}</div></div></div>`;
|
| 516 |
}
|
|
|
|
| 517 |
function newChat(){ activeChatId=null; pendingFiles=[]; renderFileChips(); document.getElementById('msg-input').value=''; renderWelcome(); renderChatList(); }
|
|
|
|
| 518 |
function loadChat(id){
|
| 519 |
activeChatId=id; const chat=getChat(id); if(!chat) return;
|
| 520 |
document.getElementById('topbar-title').textContent=chat.title;
|
| 521 |
const area=document.getElementById('chat-area'); area.innerHTML='';
|
| 522 |
-
chat.history.forEach(
|
| 523 |
-
if
|
| 524 |
scrollToBottom(); renderChatList();
|
| 525 |
}
|
| 526 |
function deleteChat(id,e){ e.stopPropagation(); chats=chats.filter(c=>c.id!==id); saveChats(); if(activeChatId===id) newChat(); else renderChatList(); }
|
| 527 |
function clearAllChats(){ chats=[]; saveChats(); newChat(); closeSettings(); }
|
| 528 |
-
|
| 529 |
-
function stopGeneration() { if (currentAbortController) currentAbortController.abort(); }
|
| 530 |
-
|
| 531 |
function quickSend(text){ document.getElementById('msg-input').value=text; sendMessage(); }
|
| 532 |
function handleKey(e){ if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMessage();} }
|
| 533 |
function autoResize(el){ el.style.height='auto'; el.style.height=Math.min(el.scrollHeight,160)+'px'; }
|
| 534 |
|
| 535 |
-
// โโโโโโโโ
|
| 536 |
async function sendMessage(){
|
| 537 |
-
if(isGenerating
|
| 538 |
-
const input
|
| 539 |
-
if(!text
|
| 540 |
-
const welcome
|
| 541 |
input.value=''; input.style.height='auto';
|
|
|
|
| 542 |
|
| 543 |
if(!activeChatId){
|
| 544 |
-
activeChatId
|
| 545 |
-
const chatTitle
|
| 546 |
-
chats.push({id:activeChatId,
|
| 547 |
document.getElementById('topbar-title').textContent=chatTitle;
|
| 548 |
}
|
| 549 |
-
const chat
|
| 550 |
-
const uiFiles
|
| 551 |
-
pendingFiles.forEach(f
|
| 552 |
-
|
| 553 |
-
|
| 554 |
});
|
| 555 |
-
appendBubble('user',
|
| 556 |
-
pendingFiles
|
| 557 |
-
|
| 558 |
-
isGenerating
|
| 559 |
-
document.getElementById('send-btn').style.display
|
| 560 |
-
document.getElementById('stop-btn').style.display
|
| 561 |
-
const botContentDiv
|
| 562 |
-
|
| 563 |
-
const imageTriggers
|
| 564 |
-
const isImageRequest
|
| 565 |
-
currentAbortController
|
| 566 |
-
let fullBotResponse
|
| 567 |
|
| 568 |
try {
|
| 569 |
-
const response
|
| 570 |
-
method:
|
| 571 |
-
body:
|
| 572 |
-
signal:
|
| 573 |
});
|
| 574 |
if(!response.ok) throw new Error("Server Error");
|
| 575 |
-
const reader
|
| 576 |
-
const decoder
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
const { value, done } = await reader.read();
|
| 580 |
if(done) break;
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
botContentDiv.innerHTML =
|
| 585 |
-
|
| 586 |
-
else botContentDiv.innerHTML += '<span class="gemini-cursor"></span>';
|
| 587 |
renderKaTeX(botContentDiv); scrollToBottom();
|
| 588 |
}
|
| 589 |
-
|
| 590 |
-
botContentDiv.innerHTML = finalHtml;
|
| 591 |
renderKaTeX(botContentDiv);
|
| 592 |
-
|
| 593 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
} catch(err){
|
| 595 |
removeGeminiCursor();
|
| 596 |
-
if
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
} else { botContentDiv.innerHTML
|
| 602 |
} finally {
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
|
|
|
| 607 |
}
|
| 608 |
}
|
| 609 |
|
| 610 |
-
// โโโโโโโโ
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
try {
|
| 627 |
-
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
| 628 |
-
mediaRecorder = new MediaRecorder(stream);
|
| 629 |
-
audioChunks =[];
|
| 630 |
-
|
| 631 |
-
mediaRecorder.ondataavailable = event => {
|
| 632 |
-
audioChunks.push(event.data);
|
| 633 |
-
};
|
| 634 |
-
|
| 635 |
-
mediaRecorder.onstop = async () => {
|
| 636 |
-
const audioBlob = new Blob(audioChunks, { type: 'audio/webm' });
|
| 637 |
-
const reader = new FileReader();
|
| 638 |
-
reader.readAsDataURL(audioBlob);
|
| 639 |
-
reader.onloadend = async () => {
|
| 640 |
-
const base64data = reader.result.split(',')[1];
|
| 641 |
-
|
| 642 |
-
const welcome = document.getElementById('welcome');
|
| 643 |
-
if(welcome) welcome.remove();
|
| 644 |
-
|
| 645 |
-
// ุนุฑุถ ู
ุคุดุฑ ููู
ุณุชุฎุฏู
ูู ุงูู
ุญุงุฏุซุฉ
|
| 646 |
-
appendBubble('user', t.vMsg, false);
|
| 647 |
-
const botContentDiv = appendBubble('bot', t.vThink, false);
|
| 648 |
-
|
| 649 |
-
try {
|
| 650 |
-
const response = await fetch('/voice-chat', {
|
| 651 |
-
method: 'POST',
|
| 652 |
-
headers: { 'Content-Type': 'application/json' },
|
| 653 |
-
body: JSON.stringify({ audio_b64: base64data, mime_type: 'audio/webm' })
|
| 654 |
-
});
|
| 655 |
-
|
| 656 |
-
const data = await response.json();
|
| 657 |
-
|
| 658 |
-
if (data.status === "success") {
|
| 659 |
-
botContentDiv.innerHTML = t.vPlay;
|
| 660 |
-
|
| 661 |
-
// ุชุดุบูู ุงูุตูุช ุชููุงุฆูุงู
|
| 662 |
-
const botAudio = new Audio(`data:${data.mime_type};base64,${data.audio_b64}`);
|
| 663 |
-
botAudio.play();
|
| 664 |
-
|
| 665 |
-
// ุนูุฏ ุงูุชูุงุก ุงูุตูุช
|
| 666 |
-
botAudio.onended = () => {
|
| 667 |
-
botContentDiv.innerHTML = t.vEnd;
|
| 668 |
-
};
|
| 669 |
-
} else {
|
| 670 |
-
botContentDiv.innerHTML = `<span style="color:var(--danger)">โ ๏ธ ุฎุทุฃ: ${data.message}</span>`;
|
| 671 |
-
}
|
| 672 |
-
} catch (err) {
|
| 673 |
-
botContentDiv.innerHTML = `<span style="color:var(--danger)">โ ๏ธ ${t.errConnect}</span>`;
|
| 674 |
-
} finally {
|
| 675 |
-
voiceBtn.textContent = '๐ค';
|
| 676 |
-
voiceBtn.disabled = false;
|
| 677 |
-
scrollToBottom();
|
| 678 |
-
stream.getTracks().forEach(track => track.stop()); // ุฅุบูุงู ุงูู
ุงููุฑูููู
|
| 679 |
-
}
|
| 680 |
-
};
|
| 681 |
-
};
|
| 682 |
-
|
| 683 |
-
mediaRecorder.start();
|
| 684 |
-
isRecording = true;
|
| 685 |
-
voiceBtn.classList.add('recording');
|
| 686 |
-
voiceBtn.textContent = 'โน'; // ุฃููููุฉ ุงูุฅููุงู
|
| 687 |
-
} catch (err) {
|
| 688 |
-
alert('ูุฑุฌู ุงูุณู
ุงุญ ุจุงุณุชุฎุฏุงู
ุงูู
ููุฑูููู ููุชู
ูู ู
ู ุงูุชุญุฏุซ.');
|
| 689 |
-
console.error(err);
|
| 690 |
}
|
|
|
|
|
|
|
| 691 |
}
|
| 692 |
|
| 693 |
-
// โโโโโโโโ
|
| 694 |
-
function appendBubble(role,
|
| 695 |
const area=document.getElementById('chat-area');
|
| 696 |
const row=document.createElement('div'); row.className=`msg-row ${role}`;
|
| 697 |
const av=document.createElement('div'); av.className='msg-av';
|
| 698 |
-
if(role==='bot') av.innerHTML=`<img src="https://copilot.microsoft.com/th/id/BCO.f29916dd-b0c1-4089-87cd-43d099a7d1a6.png" alt="G"/>`;
|
| 699 |
-
else av.
|
| 700 |
const bub=document.createElement('div'); bub.className='bubble';
|
| 701 |
-
if(filesList
|
| 702 |
-
const contentDiv
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
contentDiv.innerHTML = isMarkdown ? safeMarked(text) : esc(text).replace(/\n/g, '<br/>');
|
| 708 |
-
if (isMarkdown) renderKaTeX(contentDiv);
|
| 709 |
}
|
| 710 |
-
bub.appendChild(contentDiv);
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
if
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
} else scrollToBottom();
|
| 718 |
-
return contentDiv;
|
| 719 |
}
|
| 720 |
|
| 721 |
-
function appendMemBadge(count,
|
| 722 |
const area=document.getElementById('chat-area'); const b=document.createElement('div'); b.className='mem-badge';
|
| 723 |
-
b.innerHTML=`
|
| 724 |
-
area.appendChild(b);
|
|
|
|
|
|
|
| 725 |
}
|
| 726 |
|
| 727 |
// โโโโโโโโ INIT โโโโโโโโ
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 733 |
</script>
|
| 734 |
</body>
|
| 735 |
</html>
|
|
|
|
| 10 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.css"/>
|
| 11 |
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.js"></script>
|
| 12 |
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/contrib/auto-render.min.js"></script>
|
| 13 |
+
<!-- Lucide Icons -->
|
| 14 |
+
<script src="https://unpkg.com/lucide@latest/dist/umd/lucide.min.js"></script>
|
| 15 |
<style>
|
|
|
|
| 16 |
:root {
|
| 17 |
--bg: #0d0f14; --surface: #161920; --surface2: #1e2230; --surface3: #252a3a;
|
| 18 |
--border: #2a2f42; --border2: #333a52;
|
| 19 |
--accent: #4f8ef7; --accent2: #7c5cf7; --accent-soft: rgba(79,142,247,0.12);
|
| 20 |
--text: #e8eaf2; --text2: #9aa3be; --text3: #5c6480;
|
| 21 |
--user-bubble: #1a2340; --bot-bubble: #161920;
|
| 22 |
+
--danger: #f75f5f;
|
| 23 |
--radius: 28px; --radius-sm: 18px; --radius-pill: 50px;
|
| 24 |
--sidebar-w: 280px; --tr: 0.3s cubic-bezier(.4,0,.2,1);
|
| 25 |
}
|
|
|
|
| 30 |
--user-bubble: #dde6ff; --bot-bubble: #fff; --accent-soft: rgba(79,142,247,0.1);
|
| 31 |
}
|
| 32 |
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
| 33 |
+
html,body{height:100%;font-family:'Cairo',sans-serif;background:var(--bg);color:var(--text);scroll-behavior:smooth;}
|
| 34 |
::-webkit-scrollbar{width:6px}::-webkit-scrollbar-track{background:transparent}
|
| 35 |
::-webkit-scrollbar-thumb{background:var(--border2);border-radius:var(--radius-pill)}
|
| 36 |
|
| 37 |
+
/* Lucide icon base style */
|
| 38 |
+
.icon { width:20px; height:20px; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; pointer-events:none; flex-shrink:0; }
|
| 39 |
+
.icon-sm { width:16px; height:16px; }
|
| 40 |
+
.icon-lg { width:22px; height:22px; }
|
| 41 |
+
|
| 42 |
.app{display:flex;height:100vh;overflow:hidden}
|
| 43 |
|
| 44 |
/* SIDEBAR */
|
| 45 |
.sidebar{width:var(--sidebar-w);min-width:var(--sidebar-w);background:var(--surface);
|
| 46 |
border-right:1px solid var(--border);display:flex;flex-direction:column;
|
| 47 |
transition:width var(--tr),min-width var(--tr);overflow:hidden;
|
| 48 |
+
border-top-right-radius:var(--radius);border-bottom-right-radius:var(--radius);}
|
| 49 |
+
[dir="rtl"] .sidebar{border-right:none;border-left:1px solid var(--border);border-radius:0 var(--radius) var(--radius) 0;}
|
| 50 |
.sidebar.collapsed{width:0;min-width:0;border:none}
|
| 51 |
.sidebar-header{padding:24px 20px 16px;display:flex;align-items:center;gap:12px;}
|
| 52 |
.s-logo{display:flex;align-items:center;gap:12px;flex:1}
|
| 53 |
+
.s-logo img{width:36px;height:36px;border-radius:12px;object-fit:cover;box-shadow:0 4px 12px var(--accent-soft);}
|
| 54 |
.s-logo-name{font-size:1.2rem;font-weight:700;background:linear-gradient(135deg,var(--accent),var(--accent2));-webkit-background-clip:text;-webkit-text-fill-color:transparent}
|
| 55 |
+
|
| 56 |
+
.close-sidebar-btn{background:none;border:none;color:var(--text2);cursor:pointer;padding:8px;border-radius:var(--radius-pill);transition:all 0.2s;display:flex;align-items:center;justify-content:center;width:36px;height:36px;}
|
| 57 |
+
.close-sidebar-btn:hover{background:var(--surface2);color:var(--danger);transform:scale(1.1);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
.btn-new{margin:12px 16px;padding:12px 16px;background:linear-gradient(135deg,var(--accent),var(--accent2));
|
| 60 |
color:#fff;border:none;border-radius:var(--radius-pill);cursor:pointer;font-family:'Cairo',sans-serif;
|
| 61 |
+
font-size:.95rem;font-weight:600;display:flex;align-items:center;gap:8px;justify-content:center;
|
| 62 |
+
transition:all var(--tr);box-shadow:0 4px 15px var(--accent-soft);}
|
| 63 |
.btn-new:hover{opacity:.9;transform:translateY(-2px)}
|
| 64 |
.s-label{padding:10px 20px;font-size:.75rem;font-weight:700;color:var(--text3);letter-spacing:.08em;text-transform:uppercase}
|
| 65 |
.chats-list{flex:1;overflow-y:auto;padding:4px 12px;display:flex;flex-direction:column;gap:6px}
|
| 66 |
.chat-item{padding:10px 16px;border-radius:var(--radius-sm);cursor:pointer;font-size:.9rem;color:var(--text2);
|
| 67 |
+
display:flex;align-items:center;gap:10px;transition:all var(--tr);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
| 68 |
+
.chat-item:hover{background:var(--surface2);color:var(--text);transform:translateX(4px);}
|
| 69 |
+
[dir="rtl"] .chat-item:hover{transform:translateX(-4px);}
|
| 70 |
.chat-item.active{background:var(--accent-soft);color:var(--accent);font-weight:600;}
|
| 71 |
.chat-item .ct{flex:1;overflow:hidden;text-overflow:ellipsis}
|
| 72 |
+
.del-btn{opacity:0;background:none;border:none;color:var(--danger);cursor:pointer;padding:4px;border-radius:50%;transition:all var(--tr);display:flex;align-items:center;justify-content:center;}
|
|
|
|
| 73 |
.chat-item:hover .del-btn{opacity:1}
|
| 74 |
+
.del-btn:hover{background:rgba(247,95,95,.15);transform:scale(1.1);}
|
| 75 |
+
.s-footer{padding:16px;display:flex;align-items:center;gap:12px;justify-content:center;}
|
| 76 |
+
.btn-icon{width:42px;height:42px;background:var(--surface2);border:none;border-radius:var(--radius-pill);
|
| 77 |
+
color:var(--text2);cursor:pointer;display:flex;align-items:center;justify-content:center;
|
| 78 |
+
transition:all var(--tr)}
|
| 79 |
+
.btn-icon:hover{background:var(--surface3);color:var(--text);transform:rotate(10deg);}
|
| 80 |
|
| 81 |
/* MAIN */
|
| 82 |
+
.main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0;background:var(--bg);}
|
| 83 |
+
.topbar{height:70px;padding:0 24px;display:flex;align-items:center;gap:16px;flex-shrink:0}
|
| 84 |
.topbar-title{flex:1;font-size:1.05rem;font-weight:600;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 85 |
|
| 86 |
/* CHAT AREA */
|
| 87 |
+
.chat-area{flex:1;overflow-y:auto;padding:20px 0 40px;display:flex;flex-direction:column;scroll-behavior:smooth;}
|
| 88 |
.welcome{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
|
| 89 |
+
gap:20px;padding:40px 24px;text-align:center;animation:fadeSlideUp 0.6s ease;}
|
| 90 |
.w-logo{width:85px;height:85px;border-radius:24px;object-fit:cover;box-shadow:0 12px 40px var(--accent-soft)}
|
| 91 |
+
.w-title{font-size:2.4rem;font-weight:700;background:linear-gradient(135deg,var(--accent),var(--accent2));-webkit-background-clip:text;-webkit-text-fill-color:transparent}
|
|
|
|
| 92 |
.w-sub{color:var(--text2);font-size:1.05rem}
|
| 93 |
.chips{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-top:12px;max-width:600px}
|
| 94 |
.chip{padding:10px 20px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-pill);
|
| 95 |
+
font-size:.9rem;color:var(--text);cursor:pointer;transition:all var(--tr);box-shadow:0 4px 12px rgba(0,0,0,0.05);}
|
| 96 |
+
.chip:hover{background:var(--accent-soft);border-color:var(--accent);color:var(--accent);transform:translateY(-2px);}
|
| 97 |
+
|
| 98 |
+
@keyframes popIn{from{opacity:0;transform:translateY(15px) scale(0.98);filter:blur(4px);}to{opacity:1;transform:translateY(0) scale(1);filter:blur(0);}}
|
| 99 |
+
@keyframes fadeSlideUp{from{opacity:0;transform:translateY(20px);}to{opacity:1;transform:translateY(0);}}
|
| 100 |
|
| 101 |
+
.msg-row{display:flex;padding:8px 30px;gap:16px;animation:popIn 0.4s cubic-bezier(0.16,1,0.3,1) forwards;}
|
|
|
|
|
|
|
|
|
|
| 102 |
.msg-row.user{flex-direction:row-reverse}
|
| 103 |
.msg-av{width:38px;height:38px;border-radius:14px;flex-shrink:0;display:flex;align-items:center;
|
| 104 |
+
justify-content:center;font-size:1.1rem;font-weight:700;margin-top:2px;overflow:hidden;box-shadow:0 4px 10px rgba(0,0,0,0.1);}
|
|
|
|
| 105 |
.msg-row.bot .msg-av{background:linear-gradient(135deg,var(--accent),var(--accent2))}
|
| 106 |
.msg-row.bot .msg-av img{width:100%;height:100%;object-fit:cover}
|
| 107 |
.msg-row.user .msg-av{background:var(--surface3);color:var(--text)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
+
.bubble{max-width:min(700px,80vw);padding:16px 22px;border-radius:var(--radius);font-size:.98rem;line-height:1.75;word-break:break-word;box-shadow:0 4px 15px rgba(0,0,0,0.03);}
|
| 110 |
+
.msg-row.bot .bubble{background:transparent;border:none;padding:8px 4px;box-shadow:none;border-top-left-radius:var(--radius);}
|
| 111 |
+
.msg-row.user .bubble{background:var(--user-bubble);border:none;border-top-right-radius:6px}
|
| 112 |
+
[dir="rtl"] .msg-row.user .bubble{border-top-right-radius:var(--radius);border-top-left-radius:6px;}
|
| 113 |
|
| 114 |
+
.bubble img{max-width:100%;height:auto;border-radius:16px;margin:12px 0;box-shadow:0 8px 25px rgba(0,0,0,0.15);cursor:zoom-in;transition:transform 0.2s;border:1px solid var(--border);}
|
| 115 |
+
.bubble img:active{transform:scale(1.02);}
|
| 116 |
+
|
| 117 |
+
.gemini-cursor{display:inline-block;width:14px;height:14px;margin-inline-start:6px;background:linear-gradient(135deg,var(--accent),var(--accent2));mask-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 0l2.5 9.5L24 12l-9.5 2.5L12 24l-2.5-9.5L0 12l9.5-2.5z"/></svg>');-webkit-mask-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 0l2.5 9.5L24 12l-9.5 2.5L12 24l-2.5-9.5L0 12l9.5-2.5z"/></svg>');mask-size:cover;-webkit-mask-size:cover;animation:spinPulse 1s infinite linear;transform-origin:center;vertical-align:middle;}
|
| 118 |
+
@keyframes spinPulse{0%{transform:scale(0.8) rotate(0deg);opacity:0.5;}50%{transform:scale(1.2) rotate(90deg);opacity:1;filter:drop-shadow(0 0 5px var(--accent));}100%{transform:scale(0.8) rotate(180deg);opacity:0.5;}}
|
| 119 |
+
|
| 120 |
+
.skeleton-img{width:100%;max-width:400px;height:350px;margin:15px auto;border-radius:18px;background:linear-gradient(90deg,var(--surface2) 25%,var(--surface3) 50%,var(--surface2) 75%);background-size:200% 100%;animation:skeletonLoading 1.5s infinite linear;box-shadow:0 8px 25px rgba(0,0,0,0.1);display:flex;align-items:center;justify-content:center;color:var(--text3);font-size:2rem;}
|
| 121 |
+
@keyframes skeletonLoading{0%{background-position:200% 0;}100%{background-position:-200% 0;}}
|
| 122 |
|
|
|
|
| 123 |
.bubble p{margin-bottom:12px}.bubble p:last-child{margin-bottom:0}
|
| 124 |
.bubble ul,.bubble ol{padding-inline-start:24px;margin:12px 0}
|
| 125 |
+
.bubble li{margin-bottom:6px;}
|
| 126 |
.bubble .table-wrapper{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;margin:16px 0;border-radius:var(--radius-sm);border:1px solid var(--border);}
|
| 127 |
.bubble table{width:100%;border-collapse:collapse;min-width:400px;}
|
| 128 |
.bubble th,.bubble td{border:1px solid var(--border);padding:10px 14px;text-align:start;white-space:nowrap;}
|
| 129 |
.bubble th{background:var(--surface3);font-weight:600;}
|
| 130 |
|
|
|
|
| 131 |
.code-container{position:relative;margin:16px 0;background:var(--surface3);border-radius:var(--radius-sm);border:1px solid var(--border);overflow:hidden;max-width:100%;}
|
| 132 |
.code-header{display:flex;justify-content:space-between;align-items:center;background:#12141a;padding:8px 16px;font-size:0.8rem;color:var(--text2);font-family:'JetBrains Mono',monospace;}
|
| 133 |
.copy-btn{background:var(--surface2);border:none;color:var(--text);cursor:pointer;display:flex;align-items:center;gap:6px;font-size:0.8rem;padding:4px 10px;border-radius:var(--radius-pill);transition:all 0.2s;}
|
|
|
|
| 136 |
.code-container pre code{white-space:pre;display:block;}
|
| 137 |
.bubble code:not(pre code){font-family:'JetBrains Mono',monospace;font-size:.85rem;background:var(--surface3);padding:3px 6px;border-radius:6px;color:var(--accent);}
|
| 138 |
|
|
|
|
| 139 |
.katex-display{overflow-x:auto;overflow-y:hidden;padding:8px 0;-webkit-overflow-scrolling:touch;}
|
| 140 |
.katex{font-size:1.05em;}
|
| 141 |
|
| 142 |
+
.file-chip{display:inline-flex;align-items:center;gap:6px;background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius-pill);padding:4px 12px;font-size:0.85rem;margin:0 4px 8px 0;color:var(--text);}
|
| 143 |
+
.file-chip button{background:none;border:none;color:var(--danger);cursor:pointer;font-size:1rem;padding:0;margin-left:4px;transition:transform 0.2s;}
|
| 144 |
+
.file-chip button:hover{transform:scale(1.2);}
|
| 145 |
+
.file-prev{display:flex;align-items:center;gap:8px;background:var(--surface3);padding:8px 12px;border-radius:8px;margin-bottom:8px;font-size:0.85rem;}
|
| 146 |
+
.mem-badge{font-size:.75rem;color:var(--text3);padding:4px 30px 10px;display:flex;align-items:center;gap:6px;font-weight:600;}
|
|
|
|
|
|
|
| 147 |
|
| 148 |
/* INPUT */
|
| 149 |
+
.input-area{padding:0 24px 30px;display:flex;flex-direction:column;align-items:center;flex-shrink:0;}
|
| 150 |
+
.input-wrapper{width:100%;max-width:850px;position:relative;}
|
| 151 |
+
.file-chips-container{width:100%;max-width:850px;display:flex;flex-wrap:wrap;margin-bottom:8px;}
|
| 152 |
+
.input-box{display:flex;align-items:flex-end;gap:10px;background:var(--surface);border:1px solid var(--border);border-radius:32px;padding:10px 14px;transition:all var(--tr);box-shadow:0 8px 30px rgba(0,0,0,0.15);}
|
| 153 |
+
.input-box:focus-within{border-color:var(--accent);box-shadow:0 8px 30px var(--accent-soft),0 0 0 3px var(--accent-soft);}
|
| 154 |
+
|
| 155 |
+
.btn-attach{background:none;border:none;color:var(--text3);cursor:pointer;padding:8px;border-radius:50%;transition:all var(--tr);display:flex;align-items:center;justify-content:center;width:38px;height:38px;}
|
| 156 |
+
.btn-attach:hover{color:var(--accent);background:var(--surface2);}
|
| 157 |
+
|
| 158 |
+
.input-box textarea{flex:1;background:none;border:none;outline:none;color:var(--text);font-family:'Cairo',sans-serif;font-size:.98rem;resize:none;max-height:160px;line-height:1.6;padding:8px 0;}
|
|
|
|
|
|
|
|
|
|
| 159 |
.input-box textarea::placeholder{color:var(--text3)}
|
| 160 |
+
|
| 161 |
+
/* Action buttons in input */
|
| 162 |
+
.btn-send,.btn-stop,.btn-voice{width:38px;height:38px;border:none;border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--tr);flex-shrink:0;margin-bottom:2px;}
|
| 163 |
+
.btn-send{background:linear-gradient(135deg,var(--accent),var(--accent2));color:#fff;}
|
| 164 |
+
.btn-send:hover{opacity:.9;transform:scale(1.08) rotate(-10deg);}
|
| 165 |
+
[dir="rtl"] .btn-send:hover{transform:scale(1.08) rotate(10deg);}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
.btn-send:disabled{opacity:.4;cursor:not-allowed;transform:none;}
|
| 167 |
+
.btn-stop{background:var(--surface3);color:var(--text);border:1px solid var(--border);}
|
| 168 |
+
.btn-stop:hover{background:var(--danger);color:#fff;transform:scale(1.05);}
|
| 169 |
+
.btn-voice{background:var(--surface2);color:var(--text2);}
|
| 170 |
+
.btn-voice:hover{background:var(--surface3);color:var(--accent);transform:scale(1.05);}
|
| 171 |
+
|
| 172 |
+
/* Recording state */
|
| 173 |
+
.btn-voice.recording{background:var(--danger);color:#fff;animation:pulseRecord 1.5s infinite;}
|
| 174 |
+
@keyframes pulseRecord{0%{box-shadow:0 0 0 0 rgba(247,95,95,0.4);}70%{box-shadow:0 0 0 12px rgba(247,95,95,0);}100%{box-shadow:0 0 0 0 rgba(247,95,95,0);}}
|
| 175 |
+
|
| 176 |
+
/* STT status banner */
|
| 177 |
+
.stt-status{display:none;align-items:center;gap:10px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-pill);padding:8px 18px;font-size:.85rem;color:var(--text2);width:100%;max-width:850px;margin-bottom:8px;box-shadow:0 4px 15px rgba(0,0,0,0.1);}
|
| 178 |
+
.stt-status.visible{display:flex;}
|
| 179 |
+
.stt-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);animation:pulseRecord 1.5s infinite;flex-shrink:0;}
|
| 180 |
+
.stt-text{flex:1;font-style:italic;}
|
| 181 |
+
/* TTS playing indicator */
|
| 182 |
+
.tts-badge{display:inline-flex;align-items:center;gap:6px;background:linear-gradient(135deg,rgba(79,142,247,0.15),rgba(124,92,247,0.15));border:1px solid var(--border);border-radius:var(--radius-pill);padding:5px 14px;font-size:.8rem;color:var(--accent);margin-top:8px;cursor:pointer;}
|
| 183 |
+
.tts-badge:hover{background:var(--accent-soft);}
|
| 184 |
+
.tts-wave{display:flex;align-items:center;gap:2px;height:14px;}
|
| 185 |
+
.tts-wave span{display:block;width:3px;border-radius:2px;background:var(--accent);animation:wave 1s ease-in-out infinite;}
|
| 186 |
+
.tts-wave span:nth-child(1){height:5px;animation-delay:0s;}
|
| 187 |
+
.tts-wave span:nth-child(2){height:10px;animation-delay:0.15s;}
|
| 188 |
+
.tts-wave span:nth-child(3){height:14px;animation-delay:0.3s;}
|
| 189 |
+
.tts-wave span:nth-child(4){height:10px;animation-delay:0.45s;}
|
| 190 |
+
.tts-wave span:nth-child(5){height:5px;animation-delay:0.6s;}
|
| 191 |
+
@keyframes wave{0%,100%{transform:scaleY(0.5);}50%{transform:scaleY(1);}}
|
| 192 |
|
| 193 |
/* MODAL */
|
| 194 |
+
.overlay{position:fixed;inset:0;z-index:999;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;backdrop-filter:blur(8px);opacity:0;pointer-events:none;transition:opacity var(--tr)}
|
|
|
|
|
|
|
| 195 |
.overlay.open{opacity:1;pointer-events:all}
|
| 196 |
+
.modal{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:32px;width:min(440px,90vw);box-shadow:0 30px 80px rgba(0,0,0,.5);transform:translateY(20px) scale(0.95);transition:all var(--tr)}
|
|
|
|
|
|
|
| 197 |
.overlay.open .modal{transform:translateY(0) scale(1)}
|
| 198 |
.m-header{display:flex;align-items:center;gap:12px;margin-bottom:24px}
|
| 199 |
.m-title{font-size:1.3rem;font-weight:700;flex:1}
|
| 200 |
+
.m-close{background:var(--surface2);border:none;color:var(--text);cursor:pointer;width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:background var(--tr);}
|
| 201 |
+
.m-close:hover{background:var(--danger);color:#fff;}
|
| 202 |
.s-row{display:flex;align-items:center;justify-content:space-between;padding:16px 0;border-bottom:1px solid var(--border)}
|
| 203 |
.s-lbl{font-size:.95rem;font-weight:600;color:var(--text)}
|
| 204 |
.s-desc{font-size:.8rem;color:var(--text3);margin-top:4px}
|
| 205 |
.toggle{position:relative;width:48px;height:26px}
|
| 206 |
.toggle input{opacity:0;width:0;height:0}
|
| 207 |
.tslider{position:absolute;inset:0;background:var(--surface3);border-radius:var(--radius-pill);cursor:pointer;transition:all var(--tr)}
|
| 208 |
+
.tslider::before{content:'';position:absolute;width:20px;height:20px;border-radius:50%;background:#fff;top:3px;left:4px;transition:all var(--tr);box-shadow:0 2px 5px rgba(0,0,0,0.2);}
|
|
|
|
| 209 |
.toggle input:checked+.tslider{background:var(--accent)}
|
| 210 |
.toggle input:checked+.tslider::before{transform:translateX(20px)}
|
| 211 |
+
select.s-input{width:auto;padding:8px 16px;background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius-pill);color:var(--text);cursor:pointer;font-family:'Cairo',sans-serif;font-weight:600;}
|
| 212 |
+
.btn-save{width:100%;margin-top:24px;padding:14px;background:linear-gradient(135deg,var(--accent),var(--accent2));color:#fff;border:none;border-radius:var(--radius-pill);cursor:pointer;font-family:'Cairo',sans-serif;font-size:1rem;font-weight:700;transition:opacity var(--tr);}
|
|
|
|
|
|
|
| 213 |
.btn-save:hover{opacity:.9}
|
| 214 |
+
.btn-danger{padding:8px 18px;background:rgba(247,95,95,.12);border:1px solid var(--danger);color:var(--danger);border-radius:var(--radius-pill);cursor:pointer;font-size:.9rem;font-weight:600;font-family:'Cairo',sans-serif;transition:all var(--tr);}
|
| 215 |
+
.btn-danger:hover{background:var(--danger);color:#fff;}
|
|
|
|
| 216 |
|
|
|
|
| 217 |
@media (max-width: 640px) {
|
| 218 |
+
.msg-row{padding:6px 12px;gap:10px;}
|
| 219 |
+
.bubble{max-width:92vw;padding:12px 14px;font-size:.93rem;}
|
| 220 |
+
.msg-row.bot .bubble{padding:6px 2px;}
|
| 221 |
+
.topbar{height:56px;padding:0 14px;}
|
| 222 |
+
.input-area{padding:0 10px 18px;}
|
| 223 |
+
.code-container pre{font-size:0.78rem;padding:12px;}
|
| 224 |
+
.bubble th,.bubble td{font-size:0.85rem;padding:8px 10px;}
|
| 225 |
+
.w-title{font-size:1.8rem;}
|
| 226 |
+
.chips{gap:8px;}
|
| 227 |
+
.chip{font-size:.82rem;padding:8px 14px;}
|
| 228 |
+
.sidebar{position:fixed;top:0;bottom:0;left:0;z-index:100;height:100vh;box-shadow:4px 0 20px rgba(0,0,0,0.2);transition:transform 0.3s ease,width 0.3s ease;}
|
| 229 |
+
[dir="rtl"] .sidebar{left:auto;right:0;}
|
| 230 |
+
.sidebar.collapsed{transform:translateX(-100%);width:var(--sidebar-w) !important;min-width:var(--sidebar-w) !important;}
|
| 231 |
+
[dir="rtl"] .sidebar.collapsed{transform:translateX(100%);}
|
| 232 |
+
.sidebar:not(.collapsed){transform:translateX(0);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
}
|
| 234 |
</style>
|
| 235 |
</head>
|
|
|
|
| 241 |
<img src="https://copilot.microsoft.com/th/id/BCO.f29916dd-b0c1-4089-87cd-43d099a7d1a6.png" alt="Genisi"/>
|
| 242 |
<span class="s-logo-name">Genisi AI</span>
|
| 243 |
</div>
|
| 244 |
+
<button class="close-sidebar-btn" onclick="toggleSidebar()" title="ุฅุฎูุงุก ุงููุงุฆู
ุฉ">
|
| 245 |
+
<i data-lucide="x" class="icon"></i>
|
| 246 |
+
</button>
|
| 247 |
</div>
|
| 248 |
+
<button class="btn-new" onclick="newChat()" id="i18n-new-chat">
|
| 249 |
+
<i data-lucide="sparkles" class="icon-sm"></i>
|
| 250 |
+
<span>New Chat</span>
|
| 251 |
+
</button>
|
| 252 |
<div class="s-label" id="i18n-chats-label">CHATS</div>
|
| 253 |
<div class="chats-list" id="chats-list"></div>
|
| 254 |
<div class="s-footer">
|
| 255 |
+
<button class="btn-icon" onclick="openSettings()" title="Settings">
|
| 256 |
+
<i data-lucide="settings" class="icon"></i>
|
| 257 |
+
</button>
|
| 258 |
+
<button class="btn-icon" id="theme-btn" onclick="toggleTheme()" title="Toggle theme">
|
| 259 |
+
<i data-lucide="moon" class="icon" id="theme-icon"></i>
|
| 260 |
+
</button>
|
| 261 |
</div>
|
| 262 |
</aside>
|
| 263 |
|
| 264 |
<main class="main">
|
| 265 |
<div class="topbar">
|
| 266 |
+
<button class="btn-icon" id="menu-toggle-btn" onclick="toggleSidebar()">
|
| 267 |
+
<i data-lucide="menu" class="icon" id="menu-icon"></i>
|
| 268 |
+
</button>
|
| 269 |
<div class="topbar-title" id="topbar-title">Genisi AI</div>
|
| 270 |
</div>
|
| 271 |
<div class="chat-area" id="chat-area"></div>
|
| 272 |
<div class="input-area">
|
| 273 |
+
<div class="stt-status" id="stt-status">
|
| 274 |
+
<div class="stt-dot"></div>
|
| 275 |
+
<span class="stt-text" id="stt-text">Listening...</span>
|
| 276 |
+
<button class="btn-icon" style="width:28px;height:28px;" onclick="stopSpeechInput()" title="Stop">
|
| 277 |
+
<i data-lucide="square" class="icon-sm"></i>
|
| 278 |
+
</button>
|
| 279 |
+
</div>
|
| 280 |
<div class="file-chips-container" id="file-chips"></div>
|
| 281 |
<div class="input-wrapper">
|
| 282 |
<div class="input-box">
|
| 283 |
<input type="file" id="file-input" multiple hidden onchange="handleFiles(this.files)" />
|
| 284 |
+
<button class="btn-attach" onclick="document.getElementById('file-input').click()" title="Attach file">
|
| 285 |
+
<i data-lucide="paperclip" class="icon"></i>
|
| 286 |
+
</button>
|
| 287 |
<textarea id="msg-input" rows="1" onkeydown="handleKey(event)" oninput="autoResize(this)" placeholder="Type a message..."></textarea>
|
| 288 |
+
<button class="btn-voice" id="voice-btn" onclick="toggleSpeechInput()" title="Voice input">
|
| 289 |
+
<i data-lucide="mic" class="icon" id="mic-icon"></i>
|
| 290 |
+
</button>
|
| 291 |
+
<button class="btn-send" id="send-btn" onclick="sendMessage()" title="Send">
|
| 292 |
+
<i data-lucide="send" class="icon"></i>
|
| 293 |
+
</button>
|
| 294 |
+
<button class="btn-stop" id="stop-btn" onclick="stopGeneration()" style="display:none;" title="Stop generation">
|
| 295 |
+
<i data-lucide="square" class="icon"></i>
|
| 296 |
+
</button>
|
| 297 |
</div>
|
| 298 |
</div>
|
| 299 |
</div>
|
|
|
|
| 305 |
<div class="modal">
|
| 306 |
<div class="m-header">
|
| 307 |
<div class="m-title" id="i18n-settings-title">Settings</div>
|
| 308 |
+
<button class="m-close" onclick="closeSettings()">
|
| 309 |
+
<i data-lucide="x" class="icon-sm"></i>
|
| 310 |
+
</button>
|
| 311 |
</div>
|
| 312 |
<div class="s-row">
|
| 313 |
<div class="s-lbl" id="i18n-lang-lbl">Language</div>
|
|
|
|
| 325 |
<span class="tslider"></span>
|
| 326 |
</label>
|
| 327 |
</div>
|
| 328 |
+
<div class="s-row">
|
| 329 |
+
<div>
|
| 330 |
+
<div class="s-lbl" id="i18n-tts-lbl">Auto-speak Responses</div>
|
| 331 |
+
<div class="s-desc" id="i18n-tts-desc">Read bot responses aloud automatically</div>
|
| 332 |
+
</div>
|
| 333 |
+
<label class="toggle">
|
| 334 |
+
<input type="checkbox" id="tts-toggle" onchange="saveTtsSetting()"/>
|
| 335 |
+
<span class="tslider"></span>
|
| 336 |
+
</label>
|
| 337 |
+
</div>
|
| 338 |
<div class="s-row">
|
| 339 |
<div>
|
| 340 |
<div class="s-lbl" id="i18n-del-lbl">Delete All Chats</div>
|
| 341 |
<div class="s-desc" id="i18n-del-desc">This action cannot be undone</div>
|
| 342 |
</div>
|
| 343 |
+
<button class="btn-danger" onclick="clearAllChats()" id="i18n-del-btn">
|
| 344 |
+
<i data-lucide="trash-2" class="icon-sm" style="display:inline;vertical-align:middle;margin-right:4px;"></i>Delete
|
| 345 |
+
</button>
|
| 346 |
</div>
|
| 347 |
+
<button class="btn-save" onclick="closeSettings()" id="i18n-save-btn">Close</button>
|
| 348 |
</div>
|
| 349 |
</div>
|
| 350 |
|
| 351 |
<script>
|
| 352 |
// โโโโโโโโ i18n โโโโโโโโ
|
| 353 |
const i18n = {
|
| 354 |
+
en: { newChat:"โฆ New Chat", chatsLabel:"CHATS", settings:"Settings", lang:"Language", dark:"Dark Mode", ttsLabel:"Auto-speak Responses", ttsDesc:"Read bot responses aloud automatically", del:"Delete All Chats", delDesc:"This action cannot be undone", delBtn:"Delete", saveBtn:"Close", placeholder:"Type your message... (Enter to send)", welcomeTitle:"Welcome to Genisi", welcomeSub:"Your smart assistant by AnesNT โ Batna ๐ฉ๐ฟ", c1:"What is AI?", c2:"Write Python code", c3:"Summarize a topic", c4:"Design an image in space ๐", errConnect:"Connection Error", memBadge:"Memory: {c}/{t} messages", stopMsg:"[Generation stopped by user]", vListening:"Listening... speak now", vProcessing:"Processing your voice...", vPlay:"Speaking response...", vEnd:"Done speaking", vNotSupported:"Voice input not supported in this browser" },
|
| 355 |
+
ar: { newChat:"โฆ ู
ุญุงุฏุซุฉ ุฌุฏูุฏุฉ", chatsLabel:"ุงูู
ุญุงุฏุซุงุช", settings:"ุงูุฅุนุฏุงุฏุงุช", lang:"ุงููุบุฉ", dark:"ุงููุถุน ุงููููู", ttsLabel:"ูุฑุงุกุฉ ุงูุฑุฏูุฏ ุตูุชูุงู", ttsDesc:"ุงูุฑุฃ ุฑุฏูุฏ ุงูุฐูุงุก ุงูุงุตุทูุงุนู ุจุตูุช ุชููุงุฆู", del:"ุญุฐู ุฌู
ูุน ุงูู
ุญุงุฏุซุงุช", delDesc:"ูุง ูู
ูู ุงูุชุฑุงุฌุน ุนู ูุฐุง ุงูุฅุฌุฑุงุก", delBtn:"ุญุฐู", saveBtn:"ุฅุบูุงู", placeholder:"ุงูุชุจ ุฑุณุงูุชู... (Enter ููุฅุฑุณุงู)", welcomeTitle:"ู
ุฑุญุจูุง ูู Genisi", welcomeSub:"ุฃูุง Genisiุ ู
ุณุงุนุฏู ุงูุฐูู ู
ู AnesNT โ ุจุงุชูุฉ ๐ฉ๐ฟ", c1:"ู
ุง ูู ุงูุฐูุงุก ุงูุงุตุทูุงุนูุ", c2:"ุงูุชุจ ููุฏ ุจุงูุซูู", c3:"ูุฎุต ูู ู
ูุถูุนุงู", c4:"ุตู
ู
ุตูุฑุฉ ุจุงููุถุงุก ๐", errConnect:"ุฎุทุฃ ูู ุงูุงุชุตุงู", memBadge:"ุงูุฐุงูุฑุฉ: {c}/{t} ุฑุณุงุฆู", stopMsg:"[ุชู
ุฅููุงู ุงูุชูููุฏ]", vListening:"ุงุณุชู
ุน... ุชุญุฏุซ ุงูุขู", vProcessing:"ุฌุงุฑู ู
ุนุงูุฌุฉ ุตูุชู...", vPlay:"ููุฑุฃ ุงูุฑุฏ ุงูุขู...", vEnd:"ุงูุชูุช ุงููุฑุงุกุฉ ุงูุตูุชูุฉ", vNotSupported:"ุงูุชุนุฑู ุนูู ุงูููุงู
ุบูุฑ ู
ุฏุนูู
ูู ูุฐุง ุงูู
ุชุตูุญ" },
|
| 356 |
+
fr: { newChat:"โฆ Nouveau", chatsLabel:"DISCUSSIONS", settings:"Paramรจtres", lang:"Langue", dark:"Mode Sombre", ttsLabel:"Lire les rรฉponses", ttsDesc:"Lire les rรฉponses du bot ร voix haute", del:"Supprimer Tout", delDesc:"Action irrรฉversible", delBtn:"Supprimer", saveBtn:"Fermer", placeholder:"รcrivez votre message...", welcomeTitle:"Bienvenue sur Genisi", welcomeSub:"Votre assistant par AnesNT โ Batna ๐ฉ๐ฟ", c1:"Qu'est-ce que l'IA?", c2:"Code Python", c3:"Rรฉsumer un sujet", c4:"Crรฉer une image ๐", errConnect:"Erreur de connexion", memBadge:"Mรฉmoire: {c}/{t} msgs", stopMsg:"[Gรฉnรฉration arrรชtรฉe]", vListening:"รcoute... parlez maintenant", vProcessing:"Traitement de votre voix...", vPlay:"Lecture en cours...", vEnd:"Fin de la lecture", vNotSupported:"Reconnaissance vocale non supportรฉe" },
|
| 357 |
+
es: { newChat:"โฆ Nuevo Chat", chatsLabel:"CHATS", settings:"Ajustes", lang:"Idioma", dark:"Modo Oscuro", ttsLabel:"Leer respuestas", ttsDesc:"Leer respuestas del bot en voz alta", del:"Borrar Todo", delDesc:"Acciรณn irreversible", delBtn:"Borrar", saveBtn:"Cerrar", placeholder:"Escribe tu mensaje...", welcomeTitle:"Bienvenido a Genisi", welcomeSub:"Tu asistente por AnesNT โ Batna ๐ฉ๐ฟ", c1:"ยฟQuรฉ es la IA?", c2:"Cรณdigo Python", c3:"Resumir", c4:"Diseรฑar imagen ๐", errConnect:"Error de conexiรณn", memBadge:"Memoria: {c}/{t} msgs", stopMsg:"[Generaciรณn detenida]", vListening:"Escuchando... habla ahora", vProcessing:"Procesando tu voz...", vPlay:"Leyendo respuesta...", vEnd:"Fin de la lectura", vNotSupported:"Reconocimiento de voz no soportado" }
|
| 358 |
};
|
| 359 |
|
| 360 |
let currentLang = localStorage.getItem('genisi_lang') || 'en';
|
|
|
|
| 363 |
const t = i18n[currentLang];
|
| 364 |
document.documentElement.dir = currentLang === 'ar' ? 'rtl' : 'ltr';
|
| 365 |
document.documentElement.lang = currentLang;
|
| 366 |
+
const newChatBtn = document.getElementById('i18n-new-chat');
|
| 367 |
+
newChatBtn.querySelector('span').textContent = t.newChat;
|
| 368 |
document.getElementById('i18n-chats-label').textContent = t.chatsLabel;
|
| 369 |
document.getElementById('i18n-settings-title').textContent = t.settings;
|
| 370 |
document.getElementById('i18n-lang-lbl').textContent = t.lang;
|
| 371 |
document.getElementById('i18n-dark-lbl').textContent = t.dark;
|
| 372 |
+
document.getElementById('i18n-tts-lbl').textContent = t.ttsLabel;
|
| 373 |
+
document.getElementById('i18n-tts-desc').textContent = t.ttsDesc;
|
| 374 |
document.getElementById('i18n-del-lbl').textContent = t.del;
|
| 375 |
document.getElementById('i18n-del-desc').textContent = t.delDesc;
|
|
|
|
| 376 |
document.getElementById('i18n-save-btn').textContent = t.saveBtn;
|
| 377 |
document.getElementById('msg-input').placeholder = t.placeholder;
|
|
|
|
| 378 |
if(!activeChatId) renderWelcome();
|
| 379 |
renderChatList();
|
| 380 |
}
|
| 381 |
+
function changeLanguage(val){ currentLang=val; localStorage.setItem('genisi_lang',val); applyI18n(); }
|
| 382 |
|
| 383 |
+
// โโโโโโโโ STATE โโโโโโโโ
|
| 384 |
+
const genId = () => Date.now().toString(36)+Math.random().toString(36).substring(2,6);
|
| 385 |
let userId = localStorage.getItem('genisi_user_id');
|
| 386 |
+
if(!userId){ userId='user_'+genId(); localStorage.setItem('genisi_user_id',userId); }
|
| 387 |
|
| 388 |
+
let chats = JSON.parse(localStorage.getItem('genisi_chats')||'[]');
|
| 389 |
let activeChatId = null;
|
| 390 |
let isGenerating = false;
|
| 391 |
+
let pendingFiles = [];
|
| 392 |
let currentAbortController = null;
|
| 393 |
+
let autoTTS = localStorage.getItem('genisi_tts') !== 'false';
|
| 394 |
+
let currentUtterance = null;
|
| 395 |
+
|
| 396 |
+
// โโโโโโโโ SPEECH RECOGNITION (STT) โโโโโโโโ
|
| 397 |
+
let recognition = null;
|
| 398 |
+
let isListening = false;
|
| 399 |
+
|
| 400 |
+
function initSpeechRecognition() {
|
| 401 |
+
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 402 |
+
if (!SpeechRecognition) return null;
|
| 403 |
+
const rec = new SpeechRecognition();
|
| 404 |
+
rec.continuous = false;
|
| 405 |
+
rec.interimResults = true;
|
| 406 |
+
// Set language based on current UI language
|
| 407 |
+
const langMap = { en: 'en-US', ar: 'ar-DZ', fr: 'fr-FR', es: 'es-ES' };
|
| 408 |
+
rec.lang = langMap[currentLang] || 'en-US';
|
| 409 |
+
|
| 410 |
+
rec.onstart = () => {
|
| 411 |
+
isListening = true;
|
| 412 |
+
document.getElementById('stt-status').classList.add('visible');
|
| 413 |
+
document.getElementById('stt-text').textContent = i18n[currentLang].vListening;
|
| 414 |
+
const voiceBtn = document.getElementById('voice-btn');
|
| 415 |
+
voiceBtn.classList.add('recording');
|
| 416 |
+
// swap mic icon to mic-off
|
| 417 |
+
lucide.createIcons({ icons: { 'mic-off': lucide.icons['mic-off'] }, attrs: { class: 'icon' } });
|
| 418 |
+
const micIcon = document.getElementById('mic-icon');
|
| 419 |
+
micIcon.setAttribute('data-lucide', 'mic-off');
|
| 420 |
+
lucide.createIcons({ nameAttr: 'data-lucide', attrs: { class: 'icon' } });
|
| 421 |
+
};
|
| 422 |
+
|
| 423 |
+
rec.onresult = (event) => {
|
| 424 |
+
let interim = '';
|
| 425 |
+
let final = '';
|
| 426 |
+
for (let i = event.resultIndex; i < event.results.length; i++) {
|
| 427 |
+
if (event.results[i].isFinal) final += event.results[i][0].transcript;
|
| 428 |
+
else interim += event.results[i][0].transcript;
|
| 429 |
+
}
|
| 430 |
+
const input = document.getElementById('msg-input');
|
| 431 |
+
input.value = (final || interim);
|
| 432 |
+
autoResize(input);
|
| 433 |
+
if (final) document.getElementById('stt-text').textContent = final;
|
| 434 |
+
else document.getElementById('stt-text').textContent = interim || i18n[currentLang].vListening;
|
| 435 |
+
};
|
| 436 |
+
|
| 437 |
+
rec.onend = () => {
|
| 438 |
+
isListening = false;
|
| 439 |
+
document.getElementById('stt-status').classList.remove('visible');
|
| 440 |
+
const voiceBtn = document.getElementById('voice-btn');
|
| 441 |
+
voiceBtn.classList.remove('recording');
|
| 442 |
+
const micIcon = document.getElementById('mic-icon');
|
| 443 |
+
micIcon.setAttribute('data-lucide', 'mic');
|
| 444 |
+
lucide.createIcons({ nameAttr: 'data-lucide', attrs: { class: 'icon' } });
|
| 445 |
+
// Auto-send if there's text
|
| 446 |
+
const input = document.getElementById('msg-input');
|
| 447 |
+
if (input.value.trim()) sendMessage();
|
| 448 |
+
};
|
| 449 |
+
|
| 450 |
+
rec.onerror = (event) => {
|
| 451 |
+
console.error('STT error:', event.error);
|
| 452 |
+
isListening = false;
|
| 453 |
+
document.getElementById('stt-status').classList.remove('visible');
|
| 454 |
+
const voiceBtn = document.getElementById('voice-btn');
|
| 455 |
+
voiceBtn.classList.remove('recording');
|
| 456 |
+
const micIcon = document.getElementById('mic-icon');
|
| 457 |
+
micIcon.setAttribute('data-lucide', 'mic');
|
| 458 |
+
lucide.createIcons({ nameAttr: 'data-lucide', attrs: { class: 'icon' } });
|
| 459 |
+
};
|
| 460 |
+
|
| 461 |
+
return rec;
|
| 462 |
+
}
|
| 463 |
|
| 464 |
+
function toggleSpeechInput() {
|
| 465 |
+
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 466 |
+
if (!SpeechRecognition) {
|
| 467 |
+
alert(i18n[currentLang].vNotSupported);
|
| 468 |
+
return;
|
| 469 |
+
}
|
| 470 |
+
if (isListening) {
|
| 471 |
+
stopSpeechInput();
|
| 472 |
+
return;
|
| 473 |
+
}
|
| 474 |
+
recognition = initSpeechRecognition();
|
| 475 |
+
if (recognition) recognition.start();
|
| 476 |
+
}
|
| 477 |
|
| 478 |
+
function stopSpeechInput() {
|
| 479 |
+
if (recognition && isListening) recognition.stop();
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
// โโโโโโโโ TTS (Text-to-Speech) โโโโโโโโ
|
| 483 |
+
function saveTtsSetting() {
|
| 484 |
+
autoTTS = document.getElementById('tts-toggle').checked;
|
| 485 |
+
localStorage.setItem('genisi_tts', autoTTS);
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
function speakText(text) {
|
| 489 |
+
if (!window.speechSynthesis) return;
|
| 490 |
+
// Cancel any ongoing speech
|
| 491 |
+
window.speechSynthesis.cancel();
|
| 492 |
+
// Strip markdown symbols for cleaner speech
|
| 493 |
+
const clean = text
|
| 494 |
+
.replace(/```[\s\S]*?```/g, 'code block.')
|
| 495 |
+
.replace(/`([^`]+)`/g, '$1')
|
| 496 |
+
.replace(/\*\*([^*]+)\*\*/g, '$1')
|
| 497 |
+
.replace(/\*([^*]+)\*/g, '$1')
|
| 498 |
+
.replace(/#{1,6}\s/g, '')
|
| 499 |
+
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
|
| 500 |
+
.replace(/!\[([^\]]+)\]\([^)]+\)/g, 'image.')
|
| 501 |
+
.replace(/\n+/g, '. ')
|
| 502 |
+
.trim();
|
| 503 |
+
|
| 504 |
+
const utterance = new SpeechSynthesisUtterance(clean);
|
| 505 |
+
const langMap = { en: 'en-US', ar: 'ar-SA', fr: 'fr-FR', es: 'es-ES' };
|
| 506 |
+
utterance.lang = langMap[currentLang] || 'en-US';
|
| 507 |
+
utterance.rate = 1.0;
|
| 508 |
+
utterance.pitch = 1.0;
|
| 509 |
+
currentUtterance = utterance;
|
| 510 |
+
window.speechSynthesis.speak(utterance);
|
| 511 |
+
return utterance;
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
function stopTTS() {
|
| 515 |
+
if (window.speechSynthesis) window.speechSynthesis.cancel();
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
// โโโโโโโโ MARKDOWN โโโโโโโโ
|
| 519 |
const renderer = new marked.Renderer();
|
| 520 |
renderer.code = function(token) {
|
| 521 |
const codeText = typeof token === 'string' ? token : token.text || '';
|
| 522 |
const lang = typeof token === 'string' ? arguments[1] : token.lang || 'text';
|
| 523 |
+
const escapedCode = String(codeText).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');
|
| 524 |
+
return `<div class="code-container"><div class="code-header"><span>${lang}</span><button class="copy-btn" onclick="copyCode(this,'${encodeURIComponent(codeText)}')"><i data-lucide="copy" class="icon-sm"></i> Copy</button></div><pre><code class="language-${lang}">${escapedCode}</code></pre></div>`;
|
| 525 |
};
|
| 526 |
renderer.table = function(header, body) {
|
| 527 |
+
if(typeof header==='object'&&header!==null&&'header' in header){
|
| 528 |
+
const token=header;
|
| 529 |
+
const hdr=token.header.map(cell=>`<th>${cell.tokens.map(t=>t.raw||'').join('')}</th>`).join('');
|
| 530 |
+
const rows=(token.rows||[]).map(row=>`<tr>${row.map(cell=>`<td>${cell.tokens.map(t=>t.raw||'').join('')}</td>`).join('')}</tr>`).join('');
|
| 531 |
return `<div class="table-wrapper"><table><thead><tr>${hdr}</tr></thead><tbody>${rows}</tbody></table></div>`;
|
| 532 |
}
|
| 533 |
return `<div class="table-wrapper"><table><thead>${header}</thead><tbody>${body}</tbody></table></div>`;
|
| 534 |
};
|
| 535 |
+
renderer.html = function(html){ return html; };
|
| 536 |
+
marked.setOptions({ renderer, breaks:true, gfm:true });
|
| 537 |
|
| 538 |
+
function safeMarked(text){
|
| 539 |
+
if(!text) return '';
|
| 540 |
+
return DOMPurify.sanitize(marked.parse(text),{USE_PROFILES:{html:true}});
|
|
|
|
| 541 |
}
|
| 542 |
+
function renderKaTeX(el){
|
| 543 |
+
if(window.renderMathInElement) renderMathInElement(el,{delimiters:[{left:'$$',right:'$$',display:true},{left:'$',right:'$',display:false},{left:'\\(',right:'\\)',display:false},{left:'\\[',right:'\\]',display:true}],throwOnError:false});
|
|
|
|
|
|
|
|
|
|
| 544 |
}
|
| 545 |
+
function copyCode(btn, encodedCode){
|
| 546 |
+
navigator.clipboard.writeText(decodeURIComponent(encodedCode)).then(()=>{
|
| 547 |
+
const orig = btn.innerHTML;
|
| 548 |
+
btn.innerHTML = '<i data-lucide="check" class="icon-sm" style="color:var(--accent)"></i> Copied!';
|
| 549 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon-sm'} });
|
| 550 |
+
setTimeout(()=>{btn.innerHTML=orig; lucide.createIcons({nameAttr:'data-lucide',attrs:{class:'icon-sm'}});},2000);
|
| 551 |
});
|
| 552 |
}
|
| 553 |
+
function removeGeminiCursor(){ document.querySelectorAll('.gemini-cursor').forEach(el=>el.remove()); }
|
| 554 |
|
| 555 |
+
// โโโโโโโโ UTILS โโโโโโโโ
|
| 556 |
+
const saveChats = () => localStorage.setItem('genisi_chats',JSON.stringify(chats));
|
| 557 |
+
const getChat = (id) => chats.find(c=>c.id===(id??activeChatId));
|
| 558 |
function esc(t){ return String(t).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
|
| 559 |
+
function scrollToBottom(){ const area=document.getElementById('chat-area'); area.scrollTop=area.scrollHeight; }
|
| 560 |
+
|
| 561 |
+
async function handleFiles(files){
|
| 562 |
+
for(let f of files){
|
| 563 |
+
const isText = f.type.startsWith('text/')||f.name.match(/\.(py|js|html|css|json|md|txt|csv|cpp|java)$/i);
|
| 564 |
+
const reader = new FileReader();
|
| 565 |
+
reader.onload = (e)=>{
|
| 566 |
+
let data=e.target.result;
|
| 567 |
+
if(!isText) data=data.split(',')[1];
|
| 568 |
+
pendingFiles.push({name:f.name,type:f.type||'application/octet-stream',data,isText});
|
| 569 |
+
renderFileChips();
|
| 570 |
+
};
|
| 571 |
+
if(isText) reader.readAsText(f); else reader.readAsDataURL(f);
|
| 572 |
+
}
|
| 573 |
+
document.getElementById('file-input').value='';
|
|
|
|
| 574 |
}
|
| 575 |
+
function renderFileChips(){
|
| 576 |
+
const c=document.getElementById('file-chips'); c.innerHTML='';
|
| 577 |
+
pendingFiles.forEach((f,idx)=>{
|
| 578 |
+
const icon = f.isText ? 'file-text' : 'image';
|
| 579 |
+
c.innerHTML += `<div class="file-chip"><i data-lucide="${icon}" class="icon-sm"></i>${f.name}<button onclick="removeFile(${idx})"><i data-lucide="x" class="icon-sm"></i></button></div>`;
|
| 580 |
+
});
|
| 581 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon-sm'} });
|
| 582 |
}
|
| 583 |
+
function removeFile(idx){ pendingFiles.splice(idx,1); renderFileChips(); }
|
| 584 |
|
| 585 |
+
// โโโโโโโโ THEME โโโโโโโโ
|
| 586 |
function applyTheme(t){
|
| 587 |
document.documentElement.setAttribute('data-theme',t);
|
| 588 |
localStorage.setItem('genisi_theme',t);
|
|
|
|
| 589 |
document.getElementById('dark-toggle').checked = t==='dark';
|
| 590 |
+
const themeIcon = document.getElementById('theme-icon');
|
| 591 |
+
themeIcon.setAttribute('data-lucide', t==='dark'?'moon':'sun');
|
| 592 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon'} });
|
| 593 |
}
|
| 594 |
function toggleTheme(){ applyTheme(document.documentElement.getAttribute('data-theme')==='dark'?'light':'dark'); }
|
| 595 |
function applyThemeToggle(){ applyTheme(document.getElementById('dark-toggle').checked?'dark':'light'); }
|
| 596 |
|
| 597 |
+
// โโโโโโโโ SIDEBAR โโโโโโโโ
|
| 598 |
+
function updateMenuIcon(){
|
| 599 |
+
const sidebar=document.getElementById('sidebar');
|
| 600 |
+
const menuIcon=document.getElementById('menu-icon');
|
| 601 |
+
menuIcon.setAttribute('data-lucide', sidebar.classList.contains('collapsed')?'menu':'x');
|
| 602 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon'} });
|
| 603 |
}
|
| 604 |
+
function toggleSidebar(){ document.getElementById('sidebar').classList.toggle('collapsed'); updateMenuIcon(); }
|
| 605 |
+
function initSidebarState(){
|
| 606 |
+
const sidebar=document.getElementById('sidebar');
|
| 607 |
+
if(window.innerWidth<=640) sidebar.classList.add('collapsed');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 608 |
else sidebar.classList.remove('collapsed');
|
| 609 |
updateMenuIcon();
|
| 610 |
}
|
| 611 |
+
window.addEventListener('resize',()=>{
|
| 612 |
+
const sidebar=document.getElementById('sidebar');
|
| 613 |
+
if(window.innerWidth>640) sidebar.classList.remove('collapsed');
|
| 614 |
else sidebar.classList.add('collapsed');
|
| 615 |
updateMenuIcon();
|
| 616 |
});
|
| 617 |
|
| 618 |
+
// โโโโโโโโ SETTINGS โโโโโโโโ
|
| 619 |
+
function openSettings(){ document.getElementById('settings-modal').classList.add('open'); document.getElementById('lang-select').value=currentLang; document.getElementById('tts-toggle').checked=autoTTS; }
|
| 620 |
function closeSettings(){ document.getElementById('settings-modal').classList.remove('open'); }
|
| 621 |
|
| 622 |
+
// โโโโโโโโ CHAT LIST โโโโโโโโ
|
| 623 |
function renderChatList(){
|
| 624 |
const list=document.getElementById('chats-list'); list.innerHTML='';
|
| 625 |
[...chats].reverse().forEach(chat=>{
|
| 626 |
const div=document.createElement('div');
|
| 627 |
div.className='chat-item'+(chat.id===activeChatId?' active':'');
|
| 628 |
+
div.innerHTML=`<i data-lucide="message-circle" class="icon-sm"></i><span class="ct">${esc(chat.title||'Chat')}</span><button class="del-btn" onclick="deleteChat('${chat.id}',event)"><i data-lucide="x" class="icon-sm"></i></button>`;
|
| 629 |
+
div.onclick = ()=>loadChat(chat.id);
|
| 630 |
list.appendChild(div);
|
| 631 |
});
|
| 632 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon-sm'} });
|
| 633 |
}
|
| 634 |
+
|
| 635 |
function renderWelcome(){
|
| 636 |
+
const t=i18n[currentLang];
|
| 637 |
document.getElementById('topbar-title').textContent='Genisi AI';
|
| 638 |
document.getElementById('chat-area').innerHTML=`<div class="welcome" id="welcome"><img src="https://copilot.microsoft.com/th/id/BCO.f29916dd-b0c1-4089-87cd-43d099a7d1a6.png" class="w-logo" alt="Genisi"/><div class="w-title">${t.welcomeTitle}</div><div class="w-sub">${t.welcomeSub}</div><div class="chips"><div class="chip" onclick="quickSend('${t.c1}')">${t.c1}</div><div class="chip" onclick="quickSend('${t.c2}')">${t.c2}</div><div class="chip" onclick="quickSend('${t.c3}')">${t.c3}</div><div class="chip" onclick="quickSend('${t.c4}')">${t.c4}</div></div></div>`;
|
| 639 |
}
|
| 640 |
+
|
| 641 |
function newChat(){ activeChatId=null; pendingFiles=[]; renderFileChips(); document.getElementById('msg-input').value=''; renderWelcome(); renderChatList(); }
|
| 642 |
+
|
| 643 |
function loadChat(id){
|
| 644 |
activeChatId=id; const chat=getChat(id); if(!chat) return;
|
| 645 |
document.getElementById('topbar-title').textContent=chat.title;
|
| 646 |
const area=document.getElementById('chat-area'); area.innerHTML='';
|
| 647 |
+
chat.history.forEach(entry=>{ appendBubble('user',entry.user,false,entry.uiFiles); appendBubble('bot',entry.bot,true); });
|
| 648 |
+
if(chat.history.length) appendMemBadge(chat.history.length,chat.history.length);
|
| 649 |
scrollToBottom(); renderChatList();
|
| 650 |
}
|
| 651 |
function deleteChat(id,e){ e.stopPropagation(); chats=chats.filter(c=>c.id!==id); saveChats(); if(activeChatId===id) newChat(); else renderChatList(); }
|
| 652 |
function clearAllChats(){ chats=[]; saveChats(); newChat(); closeSettings(); }
|
| 653 |
+
function stopGeneration(){ if(currentAbortController) currentAbortController.abort(); }
|
|
|
|
|
|
|
| 654 |
function quickSend(text){ document.getElementById('msg-input').value=text; sendMessage(); }
|
| 655 |
function handleKey(e){ if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMessage();} }
|
| 656 |
function autoResize(el){ el.style.height='auto'; el.style.height=Math.min(el.scrollHeight,160)+'px'; }
|
| 657 |
|
| 658 |
+
// โโโโโโโโ SEND MESSAGE โโโโโโโโ
|
| 659 |
async function sendMessage(){
|
| 660 |
+
if(isGenerating||isListening) return;
|
| 661 |
+
const input=document.getElementById('msg-input'); let text=input.value.trim();
|
| 662 |
+
if(!text&&pendingFiles.length===0) return;
|
| 663 |
+
const welcome=document.getElementById('welcome'); if(welcome) welcome.remove();
|
| 664 |
input.value=''; input.style.height='auto';
|
| 665 |
+
stopTTS();
|
| 666 |
|
| 667 |
if(!activeChatId){
|
| 668 |
+
activeChatId=genId();
|
| 669 |
+
const chatTitle=text?text.slice(0,35)+'...':(pendingFiles[0]?pendingFiles[0].name:'Chat');
|
| 670 |
+
chats.push({id:activeChatId,title:chatTitle,history:[]});
|
| 671 |
document.getElementById('topbar-title').textContent=chatTitle;
|
| 672 |
}
|
| 673 |
+
const chat=getChat();
|
| 674 |
+
const uiFiles=pendingFiles.map(f=>f.name); const binaryFiles=[];
|
| 675 |
+
pendingFiles.forEach(f=>{
|
| 676 |
+
if(f.isText){ text+=`\n\n\`\`\`${f.name.split('.').pop()}\n// File: ${f.name}\n${f.data}\n\`\`\``; }
|
| 677 |
+
else{ binaryFiles.push({name:f.name,mime_type:f.type,data:f.data}); }
|
| 678 |
});
|
| 679 |
+
appendBubble('user',text,false,uiFiles);
|
| 680 |
+
pendingFiles=[]; renderFileChips();
|
| 681 |
+
|
| 682 |
+
isGenerating=true;
|
| 683 |
+
document.getElementById('send-btn').style.display='none';
|
| 684 |
+
document.getElementById('stop-btn').style.display='flex';
|
| 685 |
+
const botContentDiv=appendBubble('bot','',true);
|
| 686 |
+
|
| 687 |
+
const imageTriggers=["ุงุฑุณู
","ุตู
ู
","ุชุฎูู","ุตูุฑุฉ ู","draw","generate","imagine","create an image","ุชุตู
ูู
"];
|
| 688 |
+
const isImageRequest=imageTriggers.some(trigger=>text.toLowerCase().startsWith(trigger));
|
| 689 |
+
currentAbortController=new AbortController();
|
| 690 |
+
let fullBotResponse="";
|
| 691 |
|
| 692 |
try {
|
| 693 |
+
const response=await fetch('/chat',{
|
| 694 |
+
method:'POST',headers:{'Content-Type':'application/json'},
|
| 695 |
+
body:JSON.stringify({user_id:userId,message:text,history:chat.history,files:binaryFiles}),
|
| 696 |
+
signal:currentAbortController.signal
|
| 697 |
});
|
| 698 |
if(!response.ok) throw new Error("Server Error");
|
| 699 |
+
const reader=response.body.getReader();
|
| 700 |
+
const decoder=new TextDecoder("utf-8");
|
| 701 |
+
while(true){
|
| 702 |
+
const{value,done}=await reader.read();
|
|
|
|
| 703 |
if(done) break;
|
| 704 |
+
fullBotResponse+=decoder.decode(value,{stream:true});
|
| 705 |
+
let safeHtml=safeMarked(fullBotResponse);
|
| 706 |
+
botContentDiv.innerHTML=safeHtml;
|
| 707 |
+
if(isImageRequest&&!botContentDiv.querySelector('img')) botContentDiv.innerHTML+='<div class="skeleton-img">๐จ ุฌุงุฑู ุงูุชุฎูู...</div>';
|
| 708 |
+
else botContentDiv.innerHTML+='<span class="gemini-cursor"></span>';
|
|
|
|
| 709 |
renderKaTeX(botContentDiv); scrollToBottom();
|
| 710 |
}
|
| 711 |
+
botContentDiv.innerHTML=safeMarked(fullBotResponse);
|
|
|
|
| 712 |
renderKaTeX(botContentDiv);
|
| 713 |
+
// Add TTS play button
|
| 714 |
+
appendTTSBadge(botContentDiv, fullBotResponse);
|
| 715 |
+
// Auto TTS
|
| 716 |
+
if(autoTTS) speakText(fullBotResponse);
|
| 717 |
+
chat.history.push({user:text,bot:fullBotResponse,uiFiles});
|
| 718 |
+
saveChats(); appendMemBadge(chat.history.length,chat.history.length);
|
| 719 |
} catch(err){
|
| 720 |
removeGeminiCursor();
|
| 721 |
+
if(err.name==='AbortError'){
|
| 722 |
+
botContentDiv.innerHTML=safeMarked(fullBotResponse)+`<br><br><span style="color:var(--text3);font-style:italic;">${i18n[currentLang].stopMsg}</span>`;
|
| 723 |
+
renderKaTeX(botContentDiv);
|
| 724 |
+
chat.history.push({user:text,bot:fullBotResponse+"\n\n*"+i18n[currentLang].stopMsg+"*",uiFiles});
|
| 725 |
+
saveChats();
|
| 726 |
+
} else { botContentDiv.innerHTML=`<span style="color:var(--danger)">โ ๏ธ ${i18n[currentLang].errConnect}: ${err.message}</span>`; }
|
| 727 |
} finally {
|
| 728 |
+
removeGeminiCursor(); isGenerating=false;
|
| 729 |
+
document.getElementById('send-btn').style.display='flex';
|
| 730 |
+
document.getElementById('stop-btn').style.display='none';
|
| 731 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon'} });
|
| 732 |
+
renderChatList(); scrollToBottom();
|
| 733 |
}
|
| 734 |
}
|
| 735 |
|
| 736 |
+
// โโโโโโโโ TTS BADGE โโโโโโโโ
|
| 737 |
+
function appendTTSBadge(container, text) {
|
| 738 |
+
if (!window.speechSynthesis) return;
|
| 739 |
+
const badge = document.createElement('div');
|
| 740 |
+
badge.className = 'tts-badge';
|
| 741 |
+
badge.title = 'Click to play / stop';
|
| 742 |
+
badge.innerHTML = `<div class="tts-wave"><span></span><span></span><span></span><span></span><span></span></div><span id="tts-label-${Date.now()}">Play</span>`;
|
| 743 |
+
let playing = false;
|
| 744 |
+
badge.onclick = () => {
|
| 745 |
+
if (playing) {
|
| 746 |
+
stopTTS(); playing = false;
|
| 747 |
+
badge.querySelector('span:last-child').textContent = 'Play';
|
| 748 |
+
} else {
|
| 749 |
+
const utt = speakText(text); playing = true;
|
| 750 |
+
badge.querySelector('span:last-child').textContent = i18n[currentLang].vPlay;
|
| 751 |
+
if (utt) utt.onend = () => { playing=false; badge.querySelector('span:last-child').textContent='Play'; };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
}
|
| 753 |
+
};
|
| 754 |
+
container.appendChild(badge);
|
| 755 |
}
|
| 756 |
|
| 757 |
+
// โโโโโโโโ BUBBLES โโโโโโโโ
|
| 758 |
+
function appendBubble(role,text,isMarkdown,filesList=[]){
|
| 759 |
const area=document.getElementById('chat-area');
|
| 760 |
const row=document.createElement('div'); row.className=`msg-row ${role}`;
|
| 761 |
const av=document.createElement('div'); av.className='msg-av';
|
| 762 |
+
if(role==='bot') av.innerHTML=`<img src="https://copilot.microsoft.com/th/id/BCO.f29916dd-b0c1-4089-87cd-43d099a7d1a6.png" alt="G"/>`;
|
| 763 |
+
else av.innerHTML=`<i data-lucide="user" class="icon"></i>`;
|
| 764 |
const bub=document.createElement('div'); bub.className='bubble';
|
| 765 |
+
if(filesList&&filesList.length>0) filesList.forEach(name=>{ bub.innerHTML+=`<div class="file-prev"><i data-lucide="paperclip" class="icon-sm"></i>${esc(name)}</div>`; });
|
| 766 |
+
const contentDiv=document.createElement('div');
|
| 767 |
+
contentDiv.dir='auto'; contentDiv.style.unicodeBidi='plaintext';
|
| 768 |
+
if(text){
|
| 769 |
+
contentDiv.innerHTML=isMarkdown?safeMarked(text):esc(text).replace(/\n/g,'<br/>');
|
| 770 |
+
if(isMarkdown) renderKaTeX(contentDiv);
|
|
|
|
|
|
|
| 771 |
}
|
| 772 |
+
bub.appendChild(contentDiv); row.appendChild(av); row.appendChild(bub); area.appendChild(row);
|
| 773 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon'} });
|
| 774 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon-sm'} });
|
| 775 |
+
if(role==='bot'){
|
| 776 |
+
const images=bub.querySelectorAll('img');
|
| 777 |
+
if(images.length) Promise.all(Array.from(images).map(img=>img.complete?Promise.resolve():new Promise(r=>img.onload=r))).then(()=>scrollToBottom());
|
| 778 |
+
else scrollToBottom();
|
| 779 |
} else scrollToBottom();
|
| 780 |
+
return contentDiv;
|
| 781 |
}
|
| 782 |
|
| 783 |
+
function appendMemBadge(count,total){
|
| 784 |
const area=document.getElementById('chat-area'); const b=document.createElement('div'); b.className='mem-badge';
|
| 785 |
+
b.innerHTML=`<i data-lucide="brain" class="icon-sm"></i>${i18n[currentLang].memBadge.replace('{c}',count).replace('{t}',total)}`;
|
| 786 |
+
area.appendChild(b);
|
| 787 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon-sm'} });
|
| 788 |
+
scrollToBottom();
|
| 789 |
}
|
| 790 |
|
| 791 |
// โโโโโโโโ INIT โโโโโโโโ
|
| 792 |
+
window.addEventListener('DOMContentLoaded', ()=>{
|
| 793 |
+
applyTheme(localStorage.getItem('genisi_theme')||'dark');
|
| 794 |
+
document.getElementById('lang-select').value=currentLang;
|
| 795 |
+
document.getElementById('tts-toggle').checked=autoTTS;
|
| 796 |
+
applyI18n();
|
| 797 |
+
initSidebarState();
|
| 798 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon'} });
|
| 799 |
+
lucide.createIcons({ nameAttr:'data-lucide', attrs:{class:'icon-sm'} });
|
| 800 |
+
});
|
| 801 |
</script>
|
| 802 |
</body>
|
| 803 |
</html>
|