Spaces:
Running
Running
Vedika commited on
Update index.html
Browse files- index.html +228 -199
index.html
CHANGED
|
@@ -34,10 +34,10 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 34 |
|
| 35 |
/* --- MAIN LAYOUT (CHAT + WORKSPACE) --- */
|
| 36 |
.shell{position:relative;z-index:1;display:flex;height:100vh;width:100vw;overflow:hidden;}
|
| 37 |
-
.sidebar{width:280px;display:flex;flex-direction:column;background:var(--bg-secondary);border-right:1px solid var(--border-light);flex-shrink:0;}
|
| 38 |
.main-wrapper{flex:1;display:flex;position:relative;overflow:hidden;}
|
| 39 |
.chat-main{flex:1;display:flex;flex-direction:column;background:transparent;position:relative;min-width:300px;transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);}
|
| 40 |
-
.workspace{width:0;background:#fafafa;border-left:1px solid var(--border-light);display:flex;flex-direction:column;transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);overflow:hidden;box-shadow:-10px 0 30px rgba(0,0,0,0.02);}
|
| 41 |
.workspace.open{width:50%;}
|
| 42 |
|
| 43 |
/* --- SIDEBAR & BRANDING --- */
|
|
@@ -47,14 +47,27 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 47 |
.logo-text{line-height:1.2;}
|
| 48 |
.logo-name{font-family:var(--font-sans);font-weight:800;font-size:18px;color:var(--text-main);letter-spacing:-0.5px;}
|
| 49 |
.logo-sub{font-size:10px;font-weight:600;letter-spacing:1px;text-transform:uppercase;color:var(--text-muted);}
|
| 50 |
-
.settings{padding:20px;flex:1;overflow-y:auto;display:flex;flex-direction:column;}
|
| 51 |
.settings::-webkit-scrollbar{width:4px;}
|
| 52 |
.settings::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.1);border-radius:10px;}
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
.brand-box img {width: 70px; height: 70px; border-radius: 16px; object-fit: cover; margin-bottom: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);}
|
| 55 |
.brand-box h3 {font-family: var(--font-sans); font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 6px;}
|
| 56 |
.brand-box p {font-size: 10px; font-weight: 600; color: var(--accent-green); line-height: 1.4; letter-spacing: 0.5px;}
|
| 57 |
-
|
|
|
|
| 58 |
.clear-btn:hover{background:#fff0f0;color:#ff3b30;border-color:#ff3b30;}
|
| 59 |
|
| 60 |
/* --- CHAT AREA --- */
|
|
@@ -65,32 +78,45 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 65 |
.messages::-webkit-scrollbar{width:6px;}
|
| 66 |
.messages::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.1);border-radius:10px;}
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 70 |
.welcome-logo{width:80px;height:80px;border-radius:24px;object-fit:cover;box-shadow:var(--shadow-md);margin-bottom:24px;border:1px solid var(--border-light);}
|
| 71 |
.welcome-title{font-size:32px;font-weight:800;letter-spacing:-1px;margin-bottom:12px;}
|
| 72 |
-
.welcome-sub{font-size:15px;color:var(--text-muted);line-height:1.6;margin-bottom:32px;}
|
| 73 |
-
|
| 74 |
-
.
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
.msg.user{flex-direction:row-reverse;align-self:flex-end;}
|
| 77 |
.msg.bot{align-self:flex-start;}
|
| 78 |
.avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;overflow:hidden;}
|
| 79 |
.msg.user .avatar{background:#f0f0f0;color:var(--text-main);border:1px solid var(--border-light);}
|
| 80 |
.msg.bot .avatar{border:1px solid var(--border-light);background:#fff;padding:2px;}
|
| 81 |
.msg.bot .avatar img{width:100%;height:100%;border-radius:50%;object-fit:cover;}
|
| 82 |
-
.body{display:flex;flex-direction:column;gap:6px;max-width:100%;}
|
| 83 |
.msg.user .body{align-items:flex-end;}
|
| 84 |
|
| 85 |
-
.bubble{padding:16px 20px;font-size:15px;line-height:1.6;color:var(--text-main);position:relative;}
|
| 86 |
.msg.user .bubble{background:var(--text-main);color:#ffffff;border-radius:20px 20px 4px 20px;box-shadow:var(--shadow-sm);}
|
| 87 |
.msg.bot .bubble{background:#ffffff;border:1px solid var(--border-light);border-radius:4px 20px 20px 20px;box-shadow:var(--shadow-sm);width:100%;}
|
| 88 |
|
| 89 |
/* BOT ACTIONS (Copy Button below text) */
|
| 90 |
-
.msg-actions{display:flex;gap:8px;margin-top:4px;padding-left:12px;opacity:0;transition:opacity 0.2s;}
|
| 91 |
.msg.bot:hover .msg-actions{opacity:1;}
|
| 92 |
-
.action-btn{background:
|
| 93 |
-
.action-btn:hover{background:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
/* Markdown inside bubble */
|
| 96 |
.bubble p{margin-bottom:12px;}
|
|
@@ -98,38 +124,35 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 98 |
.bubble code{font-family:var(--font-mono);background:rgba(0,0,0,0.05);padding:3px 6px;border-radius:6px;font-size:0.85em;color:#e83e8c;}
|
| 99 |
.msg.user .bubble code{background:rgba(255,255,255,0.2);color:#fff;}
|
| 100 |
.bubble img{max-width:100%;border-radius:12px;margin:10px 0;box-shadow:var(--shadow-sm);border:1px solid var(--border-light);}
|
| 101 |
-
|
| 102 |
-
/* Generated Image Loader */
|
| 103 |
-
.img-loader {display:flex;align-items:center;gap:12px;padding:12px;background:rgba(255,153,51,0.1);border:1px solid rgba(255,153,51,0.3);border-radius:12px;color:var(--accent);font-weight:600;font-size:14px;margin-bottom:10px;}
|
| 104 |
-
.spinner {width:20px;height:20px;border:3px solid rgba(255,153,51,0.3);border-top-color:var(--accent);border-radius:50%;animation:spin 1s linear infinite;}
|
| 105 |
-
@keyframes spin{to{transform:rotate(360deg);}}
|
| 106 |
|
| 107 |
/* Workspace Trigger Card in Chat */
|
| 108 |
-
.ws-trigger-card {background: var(--bg-secondary);border: 1px solid var(--border-light);border-radius: 12px;padding: 16px;margin: 12px 0;display: flex;align-items: center;justify-content: space-between;}
|
| 109 |
.ws-trigger-info {display: flex;align-items: center;gap: 12px;}
|
| 110 |
-
.ws-trigger-icon {width:
|
| 111 |
.ws-trigger-text h4 {font-size: 14px;font-weight: 600;margin-bottom: 2px;}
|
| 112 |
-
.ws-trigger-text p {font-size: 12px;color: var(--text-muted);font-family: var(--font-mono);}
|
| 113 |
-
.ws-btn {padding: 8px 16px;background: var(--text-main);color: #fff;border: none;border-radius: 8px;font-size: 13px;font-weight:
|
| 114 |
-
.ws-btn:hover {transform: scale(1.05);}
|
| 115 |
|
| 116 |
-
/* Typing
|
|
|
|
|
|
|
| 117 |
.typing{display:flex;align-items:center;gap:6px;padding:4px;}
|
| 118 |
.typing span{width:6px;height:6px;border-radius:50%;background:var(--text-muted);opacity:0.4;animation:bounce 1.4s infinite ease-in-out both;}
|
| 119 |
.typing span:nth-child(1){animation-delay:-0.32s;}.typing span:nth-child(2){animation-delay:-0.16s;}
|
| 120 |
@keyframes bounce{0%,80%,100%{transform:scale(0);}40%{transform:scale(1);}}
|
| 121 |
|
| 122 |
-
/* --- SCROLL TO BOTTOM BUTTON --- */
|
| 123 |
-
.scroll-bottom-btn {position:absolute;bottom:
|
| 124 |
-
.scroll-bottom-btn.show {opacity:1;pointer-events:auto;transform:translateY(0);}
|
| 125 |
-
.scroll-bottom-btn:hover {background:#fff;transform:translateY(-3px);}
|
| 126 |
|
| 127 |
-
/* --- INPUT AREA
|
| 128 |
.input-container{padding:0 40px 30px;background:linear-gradient(to top, var(--bg-color) 70%, transparent);position:relative;z-index:20;}
|
| 129 |
.input-wrap{display:flex;flex-direction:column;background:var(--glass-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--border-light);border-radius:24px;box-shadow:var(--shadow-md);transition:box-shadow 0.3s, border-color 0.3s;}
|
| 130 |
.input-wrap:focus-within{border-color:var(--border-focus);box-shadow:0 12px 40px rgba(0,0,0,0.1), 0 0 0 3px rgba(255,153,51,0.1);}
|
| 131 |
|
| 132 |
-
/* Image Preview Inside Input */
|
| 133 |
.img-prev-inline{display:none;padding:12px 20px 0;align-items:center;gap:12px;}
|
| 134 |
.img-prev-inline.show{display:flex;animation:fadeIn 0.3s;}
|
| 135 |
.inline-th{width:40px;height:40px;object-fit:cover;border-radius:8px;border:1px solid var(--border-light);}
|
|
@@ -138,26 +161,21 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 138 |
.inline-rm{background:rgba(0,0,0,0.05);border:none;width:24px;height:24px;border-radius:50%;cursor:pointer;font-size:10px;display:flex;align-items:center;justify-content:center;transition:background 0.2s;}
|
| 139 |
.inline-rm:hover{background:#ff3b30;color:#fff;}
|
| 140 |
|
| 141 |
-
.input-row{display:flex;align-items:flex-end;gap:12px;padding:
|
| 142 |
-
.chat-ta{flex:1;border:none;outline:none;background:transparent;font-family:var(--font-sans);font-size:15px;color:var(--text-main);line-height:1.5;resize:none;max-height:200px;min-height:24px;padding:
|
| 143 |
.chat-ta::placeholder{color:var(--text-muted);}
|
| 144 |
-
.input-acts{display:flex;align-items:center;gap:8px;padding-bottom:6px;}
|
| 145 |
|
| 146 |
-
/* Modern Attachment
|
| 147 |
-
.attach-btn{width:
|
| 148 |
.attach-btn:hover{background:rgba(0,0,0,0.04);color:var(--text-main);}
|
| 149 |
.attach-btn input{position:absolute;inset:0;opacity:0;cursor:pointer;}
|
| 150 |
.attach-btn svg{width:20px;height:20px;}
|
| 151 |
|
| 152 |
-
|
| 153 |
-
.send-btn{width:
|
| 154 |
-
.send-btn:
|
| 155 |
-
/* Let's make the arrow black on the gradient, no dark inner needed */
|
| 156 |
-
.send-btn::before{display:none;}
|
| 157 |
-
.send-btn svg{width:18px;height:18px;fill:#1d1d1f;z-index:1;transition:transform 0.2s;}
|
| 158 |
-
.send-btn:hover{box-shadow:0 6px 16px rgba(255,153,51,0.3);}
|
| 159 |
.send-btn:hover svg{transform:translate(2px, -2px);}
|
| 160 |
-
.send-btn:disabled{opacity:0.4;cursor:not-allowed;filter:grayscale(100%);}
|
| 161 |
|
| 162 |
.input-hint{text-align:center;font-size:11px;color:var(--text-muted);margin-top:12px;font-weight:500;}
|
| 163 |
|
|
@@ -165,10 +183,10 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 165 |
.ws-hdr{padding:14px 20px;border-bottom:1px solid var(--border-light);background:#fff;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;}
|
| 166 |
.ws-title{font-size:14px;font-weight:600;display:flex;align-items:center;gap:8px;}
|
| 167 |
.ws-actions{display:flex;gap:8px;}
|
| 168 |
-
.ws-icon-btn{
|
| 169 |
.ws-icon-btn:hover{background:#e5e5ea;}
|
| 170 |
-
.ws-close{background:transparent;color:
|
| 171 |
-
.ws-close:hover{color:#ff3b30;}
|
| 172 |
.ws-content{flex:1;overflow-y:auto;background:#fafafa;padding:20px;}
|
| 173 |
.ws-content pre{margin:0;padding:20px;background:#fff;border:1px solid var(--border-light);border-radius:12px;font-family:var(--font-mono);font-size:14px;line-height:1.6;overflow-x:auto;box-shadow:var(--shadow-sm);}
|
| 174 |
|
|
@@ -180,11 +198,12 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 180 |
.messages{padding:20px;}
|
| 181 |
.input-container{padding:0 20px 20px;}
|
| 182 |
.msg{max-width:95%;}
|
| 183 |
-
.scroll-bottom-btn{
|
| 184 |
}
|
| 185 |
</style>
|
| 186 |
</head>
|
| 187 |
-
<
|
|
|
|
| 188 |
|
| 189 |
<div class="bg">
|
| 190 |
<div class="orb orb1"></div>
|
|
@@ -199,11 +218,24 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 199 |
<img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png" alt="Tiranga Logo" class="logo-img">
|
| 200 |
<div class="logo-text">
|
| 201 |
<div class="logo-name">TIRANGA</div>
|
| 202 |
-
<div class="logo-sub">
|
| 203 |
</div>
|
| 204 |
</div>
|
| 205 |
</div>
|
|
|
|
| 206 |
<div class="settings">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
<div class="brand-box">
|
| 208 |
<img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png" alt="Tiranga Identity">
|
| 209 |
<h3>TIRANGA</h3>
|
|
@@ -227,20 +259,30 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 227 |
<!-- Welcome Screen -->
|
| 228 |
<div class="welcome" id="welcome">
|
| 229 |
<img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png" alt="Tiranga Logo" class="welcome-logo">
|
| 230 |
-
<div class="welcome-title">
|
| 231 |
-
<div class="welcome-sub">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
</div>
|
| 233 |
</div>
|
| 234 |
|
| 235 |
-
<!-- Scroll to bottom button -->
|
| 236 |
<button class="scroll-bottom-btn" id="scrollBtn" onclick="forceScrollDown()">
|
| 237 |
-
<svg width="
|
| 238 |
</button>
|
| 239 |
|
| 240 |
<!-- Input Area -->
|
| 241 |
<div class="input-container">
|
| 242 |
<div class="input-wrap">
|
| 243 |
-
<!-- Inline Image Preview -->
|
| 244 |
<div class="img-prev-inline" id="imgPrev">
|
| 245 |
<img class="inline-th" id="imgThumb" src="">
|
| 246 |
<div class="inline-info">
|
|
@@ -260,7 +302,7 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 260 |
</button>
|
| 261 |
</div>
|
| 262 |
</div>
|
| 263 |
-
<div class="input-hint">TIRANGA is engineered for extreme performance. Verified by Divy
|
| 264 |
</div>
|
| 265 |
</main>
|
| 266 |
|
|
@@ -268,11 +310,11 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 268 |
<aside class="workspace" id="workspace">
|
| 269 |
<div class="ws-hdr">
|
| 270 |
<div class="ws-title">
|
| 271 |
-
<span
|
| 272 |
<span id="wsTitleText">Generated Code</span>
|
| 273 |
</div>
|
| 274 |
<div class="ws-actions">
|
| 275 |
-
<button class="ws-icon-btn" onclick="copyWorkspaceCode()"
|
| 276 |
<button class="ws-icon-btn ws-close" onclick="closeWorkspace()" title="Close">✕</button>
|
| 277 |
</div>
|
| 278 |
</div>
|
|
@@ -284,18 +326,24 @@ html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--tex
|
|
| 284 |
</div>
|
| 285 |
|
| 286 |
<script>
|
| 287 |
-
// --- STATE MANAGEMENT
|
| 288 |
const S = {
|
| 289 |
history: [],
|
| 290 |
pending: null,
|
| 291 |
busy: false,
|
| 292 |
isUserScrolling: false,
|
| 293 |
-
|
|
|
|
| 294 |
};
|
| 295 |
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
window.onload = () => {
|
| 298 |
-
const saved = localStorage.getItem('
|
| 299 |
if(saved) {
|
| 300 |
try {
|
| 301 |
S.history = JSON.parse(saved);
|
|
@@ -305,21 +353,18 @@ window.onload = () => {
|
|
| 305 |
if(msg.role === 'user') appendUserDOM(msg.content, msg.badge);
|
| 306 |
else appendBotDOM(msg.content);
|
| 307 |
});
|
|
|
|
| 308 |
}
|
| 309 |
-
} catch(e) {
|
| 310 |
}
|
| 311 |
};
|
| 312 |
|
| 313 |
function saveMemory() {
|
| 314 |
-
// Keep last 20 messages to prevent local storage overflow
|
| 315 |
const memToSave = S.history.slice(-20);
|
| 316 |
-
localStorage.setItem('
|
| 317 |
}
|
| 318 |
-
|
| 319 |
function clearMemory() {
|
| 320 |
-
localStorage.removeItem('
|
| 321 |
-
S.history = [];
|
| 322 |
-
document.getElementById('msgs').innerHTML = '';
|
| 323 |
location.reload();
|
| 324 |
}
|
| 325 |
|
|
@@ -342,11 +387,10 @@ function removeImg(){S.pending=null;document.getElementById('imgPrev').classList
|
|
| 342 |
function handleKey(e){if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMsg();}}
|
| 343 |
function autoGrow(el){el.style.height='auto';el.style.height=Math.min(el.scrollHeight,200)+'px';}
|
| 344 |
|
| 345 |
-
// Scroll Handling
|
| 346 |
function checkScroll() {
|
| 347 |
const m = document.getElementById('msgs');
|
| 348 |
-
//
|
| 349 |
-
const isAtBottom = Math.abs((m.scrollHeight - m.scrollTop) - m.clientHeight) <
|
| 350 |
S.isUserScrolling = !isAtBottom;
|
| 351 |
|
| 352 |
const btn = document.getElementById('scrollBtn');
|
|
@@ -357,6 +401,7 @@ function forceScrollDown(){
|
|
| 357 |
const m=document.getElementById('msgs');
|
| 358 |
m.scrollTo({top: m.scrollHeight, behavior: 'smooth'});
|
| 359 |
S.isUserScrolling = false;
|
|
|
|
| 360 |
}
|
| 361 |
function autoScroll() {
|
| 362 |
if(!S.isUserScrolling) {
|
|
@@ -365,90 +410,75 @@ function autoScroll() {
|
|
| 365 |
}
|
| 366 |
}
|
| 367 |
|
| 368 |
-
// --- COPY
|
| 369 |
function copyText(btn, text) {
|
| 370 |
navigator.clipboard.writeText(text);
|
| 371 |
const orig = btn.innerHTML;
|
| 372 |
-
btn.innerHTML = "✓ Copied
|
| 373 |
setTimeout(() => btn.innerHTML = orig, 2000);
|
| 374 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
|
| 376 |
// --- WORKSPACE LOGIC ---
|
| 377 |
-
function openWorkspace(
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
document.getElementById('wsTitleText').textContent = lang ? `Generated ${lang.toUpperCase()}` : "Generated Code";
|
|
|
|
| 381 |
const codeBlock = document.getElementById('wsCodeBlock');
|
| 382 |
-
codeBlock.className = `hljs language-${lang || 'plaintext'}`;
|
| 383 |
-
codeBlock.textContent = code;
|
| 384 |
hljs.highlightElement(codeBlock);
|
| 385 |
|
| 386 |
document.getElementById('workspace').classList.add('open');
|
| 387 |
-
|
| 388 |
-
if(window.innerWidth <= 850) {
|
| 389 |
-
document.getElementById('sidebar').classList.remove('show');
|
| 390 |
-
}
|
| 391 |
}
|
| 392 |
-
function closeWorkspace() {
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
// --- IMAGE GENERATION INTERCEPTOR ---
|
| 401 |
-
function isImageRequest(text) {
|
| 402 |
-
const t = text.toLowerCase();
|
| 403 |
-
const keywords = ['image', 'photo', 'picture', 'draw', 'generate', 'create', 'तस्वीर', 'चित्र', 'फोटो', 'बनाओ', 'बना'];
|
| 404 |
-
// Very basic intent check
|
| 405 |
-
if((t.includes('create') || t.includes('generate') || t.includes('draw') || t.includes('बनाओ') || t.includes('बना')) &&
|
| 406 |
-
(t.includes('image') || t.includes('photo') || t.includes('picture') || t.includes('तस्वीर') || t.includes('चित्र') || t.includes('फोटो'))) {
|
| 407 |
-
return true;
|
| 408 |
-
}
|
| 409 |
-
return false;
|
| 410 |
-
}
|
| 411 |
-
|
| 412 |
-
async function handleImageGeneration(msg) {
|
| 413 |
-
// Add User msg
|
| 414 |
-
appendUserDOM(msg);
|
| 415 |
-
S.history.push({role: 'user', content: msg});
|
| 416 |
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
botDiv.innerHTML=`<div class="avatar"><img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png"></div><div class="body"><div class="bubble"><div class="img-loader"><div class="spinner"></div> 🇮🇳 TIRANGA is creating your image...</div></div></div>`;
|
| 420 |
-
document.getElementById('msgs').appendChild(botDiv);
|
| 421 |
-
forceScrollDown();
|
| 422 |
-
|
| 423 |
-
// Parse logic for Pollinations
|
| 424 |
-
const models = ['flux', 'flux-realism', 'flux-anime', 'flux-3d'];
|
| 425 |
-
let selectedModel = models[0]; // default
|
| 426 |
-
const tl = msg.toLowerCase();
|
| 427 |
-
if(tl.includes('real')) selectedModel = 'flux-realism';
|
| 428 |
-
if(tl.includes('anime')) selectedModel = 'flux-anime';
|
| 429 |
-
if(tl.includes('3d')) selectedModel = 'flux-3d';
|
| 430 |
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
/
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
}
|
| 453 |
|
| 454 |
// --- MAIN CHAT LOGIC ---
|
|
@@ -457,12 +487,6 @@ async function sendMsg(){
|
|
| 457 |
const inp=document.getElementById('chatInput');
|
| 458 |
const msg=inp.value.trim();if(!msg && !S.pending)return;
|
| 459 |
inp.value='';inp.style.height='auto';
|
| 460 |
-
|
| 461 |
-
// Image Generation Intercept
|
| 462 |
-
if(!S.pending && isImageRequest(msg)) {
|
| 463 |
-
handleImageGeneration(msg);
|
| 464 |
-
return;
|
| 465 |
-
}
|
| 466 |
|
| 467 |
document.getElementById('sendBtn').disabled=true;
|
| 468 |
S.busy=true;
|
|
@@ -489,14 +513,23 @@ async function sendMsg(){
|
|
| 489 |
document.getElementById('msgs').appendChild(botDiv);
|
| 490 |
forceScrollDown();
|
| 491 |
|
| 492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
|
| 494 |
const payload = {
|
| 495 |
message: msg,
|
| 496 |
attachments: attachments,
|
| 497 |
system_prompt: sysPrompt,
|
| 498 |
max_tokens: 4096,
|
| 499 |
-
temperature: 0.
|
| 500 |
};
|
| 501 |
|
| 502 |
try{
|
|
@@ -525,19 +558,22 @@ async function sendMsg(){
|
|
| 525 |
const dataObj = JSON.parse(dataStr);
|
| 526 |
if (dataObj.choices && dataObj.choices[0].delta.content) {
|
| 527 |
accumulatedText += dataObj.choices[0].delta.content;
|
| 528 |
-
renderBotText(botDiv, accumulatedText);
|
| 529 |
autoScroll();
|
| 530 |
}
|
| 531 |
} catch (e) { }
|
| 532 |
}
|
| 533 |
}
|
| 534 |
}
|
| 535 |
-
//
|
|
|
|
|
|
|
|
|
|
| 536 |
S.history.push({role: 'bot', content: accumulatedText});
|
| 537 |
saveMemory();
|
| 538 |
|
| 539 |
}catch(err){
|
| 540 |
-
renderBotText(botDiv,`**Error:**
|
| 541 |
}
|
| 542 |
|
| 543 |
S.busy=false;
|
|
@@ -545,72 +581,65 @@ async function sendMsg(){
|
|
| 545 |
autoScroll();
|
| 546 |
}
|
| 547 |
|
| 548 |
-
|
|
|
|
|
|
|
| 549 |
function appendUserDOM(text, badgeText){
|
| 550 |
let bHtml = badgeText ? `<div style="font-size:11px;color:var(--accent);margin-bottom:4px;font-weight:600;">${esc(badgeText)}</div>` : '';
|
| 551 |
const el=document.createElement('div');el.className='msg user';
|
| 552 |
el.innerHTML=`<div class="avatar">U</div><div class="body">${bHtml}<div class="bubble">${esc(text)}</div></div>`;
|
| 553 |
document.getElementById('msgs').appendChild(el);
|
| 554 |
}
|
|
|
|
| 555 |
function appendBotDOM(content) {
|
| 556 |
const el=document.createElement('div');el.className='msg bot';
|
| 557 |
-
//
|
| 558 |
-
if(content.includes('<img src="https://image.pollinations')) {
|
| 559 |
-
el.innerHTML=`<div class="avatar"><img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png"></div><div class="body"><div class="bubble">${content}</div></div>`;
|
| 560 |
-
} else {
|
| 561 |
-
el.innerHTML=`<div class="avatar"><img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png"></div><div class="body"><div class="bubble"></div></div>`;
|
| 562 |
-
renderBotText(el, content);
|
| 563 |
-
}
|
| 564 |
document.getElementById('msgs').appendChild(el);
|
|
|
|
| 565 |
}
|
| 566 |
|
| 567 |
-
//
|
| 568 |
-
function renderBotText(el, raw) {
|
| 569 |
const b = el.querySelector('.bubble');
|
| 570 |
|
| 571 |
-
//
|
| 572 |
-
|
| 573 |
-
const codeBlockRegex = /```(\w*)\n([\s\S]*?)```/g;
|
| 574 |
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
return `
|
| 578 |
-
<div class="ws-trigger-card">
|
| 579 |
-
<div class="ws-trigger-info">
|
| 580 |
-
<div class="ws-trigger-icon">💻</div>
|
| 581 |
-
<div class="ws-trigger-text">
|
| 582 |
-
<h4>Code Generated</h4>
|
| 583 |
-
<p>${lang || 'snippet'}</p>
|
| 584 |
-
</div>
|
| 585 |
-
</div>
|
| 586 |
-
<button class="ws-btn" onclick="openWorkspace('${encoded}', '${lang}')">View in Workspace</button>
|
| 587 |
-
</div>`;
|
| 588 |
-
});
|
| 589 |
-
|
| 590 |
-
const html = marked.parse(processText);
|
| 591 |
|
| 592 |
-
//
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
|
|
|
| 602 |
|
| 603 |
b.innerHTML = html;
|
| 604 |
|
| 605 |
-
//
|
| 606 |
let actionsDiv = el.querySelector('.msg-actions');
|
| 607 |
-
if(!actionsDiv) {
|
| 608 |
-
const
|
| 609 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
}
|
| 611 |
}
|
| 612 |
|
| 613 |
function esc(t){return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');}
|
| 614 |
</script>
|
| 615 |
</body>
|
| 616 |
-
</html>
|
|
|
|
|
|
| 34 |
|
| 35 |
/* --- MAIN LAYOUT (CHAT + WORKSPACE) --- */
|
| 36 |
.shell{position:relative;z-index:1;display:flex;height:100vh;width:100vw;overflow:hidden;}
|
| 37 |
+
.sidebar{width:280px;display:flex;flex-direction:column;background:var(--bg-secondary);border-right:1px solid var(--border-light);flex-shrink:0;z-index:30;}
|
| 38 |
.main-wrapper{flex:1;display:flex;position:relative;overflow:hidden;}
|
| 39 |
.chat-main{flex:1;display:flex;flex-direction:column;background:transparent;position:relative;min-width:300px;transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);}
|
| 40 |
+
.workspace{width:0;background:#fafafa;border-left:1px solid var(--border-light);display:flex;flex-direction:column;transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);overflow:hidden;box-shadow:-10px 0 30px rgba(0,0,0,0.02);z-index:25;}
|
| 41 |
.workspace.open{width:50%;}
|
| 42 |
|
| 43 |
/* --- SIDEBAR & BRANDING --- */
|
|
|
|
| 47 |
.logo-text{line-height:1.2;}
|
| 48 |
.logo-name{font-family:var(--font-sans);font-weight:800;font-size:18px;color:var(--text-main);letter-spacing:-0.5px;}
|
| 49 |
.logo-sub{font-size:10px;font-weight:600;letter-spacing:1px;text-transform:uppercase;color:var(--text-muted);}
|
| 50 |
+
.settings{padding:20px;flex:1;overflow-y:auto;display:flex;flex-direction:column;gap: 20px;}
|
| 51 |
.settings::-webkit-scrollbar{width:4px;}
|
| 52 |
.settings::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.1);border-radius:10px;}
|
| 53 |
+
|
| 54 |
+
/* Custom Toggle Switch for Thinking */
|
| 55 |
+
.toggle-wrapper {display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 16px; border-radius: 12px; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm);}
|
| 56 |
+
.toggle-label {font-size: 13px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px;}
|
| 57 |
+
.toggle-label span {font-size: 11px; color: var(--text-muted); font-weight: 500; display: block; margin-top: 2px;}
|
| 58 |
+
.switch {position: relative; display: inline-block; width: 44px; height: 24px;}
|
| 59 |
+
.switch input {opacity: 0; width: 0; height: 0;}
|
| 60 |
+
.slider {position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #e5e5ea; transition: .4s; border-radius: 24px;}
|
| 61 |
+
.slider:before {position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2);}
|
| 62 |
+
input:checked + .slider {background-color: var(--accent-green);}
|
| 63 |
+
input:checked + .slider:before {transform: translateX(20px);}
|
| 64 |
+
|
| 65 |
+
.brand-box {background: #ffffff;border: 1px solid var(--border-light);border-radius: var(--radius-md);padding: 24px 16px;text-align: center;box-shadow: var(--shadow-sm);margin-top:auto;}
|
| 66 |
.brand-box img {width: 70px; height: 70px; border-radius: 16px; object-fit: cover; margin-bottom: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);}
|
| 67 |
.brand-box h3 {font-family: var(--font-sans); font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 6px;}
|
| 68 |
.brand-box p {font-size: 10px; font-weight: 600; color: var(--accent-green); line-height: 1.4; letter-spacing: 0.5px;}
|
| 69 |
+
|
| 70 |
+
.clear-btn{width:100%;padding:12px;border-radius:var(--radius-sm);background:#ffffff;border:1px solid var(--border-light);color:var(--text-main);font-size:13px;font-weight:600;cursor:pointer;transition:all 0.2s;}
|
| 71 |
.clear-btn:hover{background:#fff0f0;color:#ff3b30;border-color:#ff3b30;}
|
| 72 |
|
| 73 |
/* --- CHAT AREA --- */
|
|
|
|
| 78 |
.messages::-webkit-scrollbar{width:6px;}
|
| 79 |
.messages::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.1);border-radius:10px;}
|
| 80 |
|
| 81 |
+
/* Welcome Screen & Prompts */
|
| 82 |
+
.welcome{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:40px 20px;margin:auto;animation:fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;width:100%;max-width:650px;}
|
| 83 |
+
@keyframes fadeInUp{from{opacity:0;transform:translateY(20px);}to{opacity:1;transform:none;}}
|
| 84 |
.welcome-logo{width:80px;height:80px;border-radius:24px;object-fit:cover;box-shadow:var(--shadow-md);margin-bottom:24px;border:1px solid var(--border-light);}
|
| 85 |
.welcome-title{font-size:32px;font-weight:800;letter-spacing:-1px;margin-bottom:12px;}
|
| 86 |
+
.welcome-sub{font-size:15px;color:var(--text-muted);line-height:1.6;margin-bottom:32px;max-width: 500px;}
|
| 87 |
+
.ex-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;width:100%;}
|
| 88 |
+
.ex-card{background:var(--glass-bg);backdrop-filter:blur(10px);border:1px solid var(--border-light);border-radius:var(--radius-md);padding:16px;cursor:pointer;text-align:left;transition:all 0.2s;box-shadow:var(--shadow-sm);}
|
| 89 |
+
.ex-card:hover{transform:translateY(-3px);box-shadow:var(--shadow-md);border-color:var(--accent);}
|
| 90 |
+
.ex-title{font-size:13px;font-weight:600;color:var(--text-main);margin-bottom:4px;display:flex;align-items:center;gap:6px;}
|
| 91 |
+
.ex-desc{font-size:12px;color:var(--text-muted);line-height:1.4;}
|
| 92 |
+
|
| 93 |
+
/* Messages */
|
| 94 |
+
.msg{display:flex;gap:16px;animation:msgIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;max-width:85%;}
|
| 95 |
+
@keyframes msgIn{from{opacity:0;transform:translateY(15px) scale(0.96);}to{opacity:1;transform:none;}}
|
| 96 |
.msg.user{flex-direction:row-reverse;align-self:flex-end;}
|
| 97 |
.msg.bot{align-self:flex-start;}
|
| 98 |
.avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;overflow:hidden;}
|
| 99 |
.msg.user .avatar{background:#f0f0f0;color:var(--text-main);border:1px solid var(--border-light);}
|
| 100 |
.msg.bot .avatar{border:1px solid var(--border-light);background:#fff;padding:2px;}
|
| 101 |
.msg.bot .avatar img{width:100%;height:100%;border-radius:50%;object-fit:cover;}
|
| 102 |
+
.body{display:flex;flex-direction:column;gap:6px;max-width:100%; width: 100%;}
|
| 103 |
.msg.user .body{align-items:flex-end;}
|
| 104 |
|
| 105 |
+
.bubble{padding:16px 20px;font-size:15px;line-height:1.6;color:var(--text-main);position:relative;word-break:break-word;overflow-wrap:anywhere;}
|
| 106 |
.msg.user .bubble{background:var(--text-main);color:#ffffff;border-radius:20px 20px 4px 20px;box-shadow:var(--shadow-sm);}
|
| 107 |
.msg.bot .bubble{background:#ffffff;border:1px solid var(--border-light);border-radius:4px 20px 20px 20px;box-shadow:var(--shadow-sm);width:100%;}
|
| 108 |
|
| 109 |
/* BOT ACTIONS (Copy Button below text) */
|
| 110 |
+
.msg-actions{display:flex;gap:8px;margin-top:4px;padding-left:12px;opacity:0.7;transition:opacity 0.2s;}
|
| 111 |
.msg.bot:hover .msg-actions{opacity:1;}
|
| 112 |
+
.action-btn{background:var(--bg-secondary);border:1px solid var(--border-light);color:var(--text-main);font-size:12px;font-weight:500;cursor:pointer;display:flex;align-items:center;gap:6px;padding:6px 12px;border-radius:8px;transition:all 0.2s;}
|
| 113 |
+
.action-btn:hover{background:#e5e5ea;transform:translateY(-1px);}
|
| 114 |
+
|
| 115 |
+
/* Reasoning / Thinking Box */
|
| 116 |
+
.think-box {background: #fdfdfd;border: 1px solid var(--border-light);border-left: 4px solid var(--accent-green);border-radius: 8px;padding: 14px 16px;margin-bottom: 16px;font-family: var(--font-mono);font-size: 13.5px;color: var(--text-muted);line-height: 1.5;box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);}
|
| 117 |
+
.think-title {font-weight: 600; color: var(--text-main); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; font-family: var(--font-sans);}
|
| 118 |
+
/* Controlled by body class */
|
| 119 |
+
body:not(.show-thinking) .think-box {display: none;}
|
| 120 |
|
| 121 |
/* Markdown inside bubble */
|
| 122 |
.bubble p{margin-bottom:12px;}
|
|
|
|
| 124 |
.bubble code{font-family:var(--font-mono);background:rgba(0,0,0,0.05);padding:3px 6px;border-radius:6px;font-size:0.85em;color:#e83e8c;}
|
| 125 |
.msg.user .bubble code{background:rgba(255,255,255,0.2);color:#fff;}
|
| 126 |
.bubble img{max-width:100%;border-radius:12px;margin:10px 0;box-shadow:var(--shadow-sm);border:1px solid var(--border-light);}
|
| 127 |
+
.bubble pre {display: none;} /* Native pre hidden since we override code blocks */
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
/* Workspace Trigger Card in Chat */
|
| 130 |
+
.ws-trigger-card {background: var(--bg-secondary);border: 1px solid var(--border-light);border-radius: 12px;padding: 16px;margin: 12px 0;display: flex;align-items: center;justify-content: space-between;box-shadow: inset 0 1px 2px rgba(255,255,255,0.5);}
|
| 131 |
.ws-trigger-info {display: flex;align-items: center;gap: 12px;}
|
| 132 |
+
.ws-trigger-icon {width: 44px;height: 44px;border-radius: 10px;background: #fff;display: flex;align-items: center;justify-content: center;font-size: 22px;box-shadow: var(--shadow-sm);border: 1px solid var(--border-light);}
|
| 133 |
.ws-trigger-text h4 {font-size: 14px;font-weight: 600;margin-bottom: 2px;}
|
| 134 |
+
.ws-trigger-text p {font-size: 12px;color: var(--text-muted);font-family: var(--font-mono);text-transform: uppercase;}
|
| 135 |
+
.ws-btn {padding: 8px 16px;background: var(--text-main);color: #fff;border: none;border-radius: 8px;font-size: 13px;font-weight: 600;cursor: pointer;transition: all 0.2s;}
|
| 136 |
+
.ws-btn:hover {transform: scale(1.05); background: var(--accent);}
|
| 137 |
|
| 138 |
+
/* Typing & Cursor */
|
| 139 |
+
.blinking-cursor {display: inline-block; width: 8px; height: 16px; background: var(--accent); margin-left: 4px; animation: blink 1s step-end infinite; vertical-align: middle;}
|
| 140 |
+
@keyframes blink { 50% { opacity: 0; } }
|
| 141 |
.typing{display:flex;align-items:center;gap:6px;padding:4px;}
|
| 142 |
.typing span{width:6px;height:6px;border-radius:50%;background:var(--text-muted);opacity:0.4;animation:bounce 1.4s infinite ease-in-out both;}
|
| 143 |
.typing span:nth-child(1){animation-delay:-0.32s;}.typing span:nth-child(2){animation-delay:-0.16s;}
|
| 144 |
@keyframes bounce{0%,80%,100%{transform:scale(0);}40%{transform:scale(1);}}
|
| 145 |
|
| 146 |
+
/* --- SCROLL TO BOTTOM BUTTON (Centered) --- */
|
| 147 |
+
.scroll-bottom-btn {position:absolute;bottom:120px;left:50%;width:44px;height:44px;border-radius:50%;background:var(--glass-bg);backdrop-filter:blur(10px);border:1px solid var(--border-light);box-shadow:var(--shadow-md);display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:18px;color:var(--text-main);opacity:0;pointer-events:none;transform:translateX(-50%) translateY(20px);transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);z-index:20;}
|
| 148 |
+
.scroll-bottom-btn.show {opacity:1;pointer-events:auto;transform:translateX(-50%) translateY(0);}
|
| 149 |
+
.scroll-bottom-btn:hover {background:#fff;transform:translateX(-50%) translateY(-3px);box-shadow:var(--shadow-lg);}
|
| 150 |
|
| 151 |
+
/* --- INPUT AREA --- */
|
| 152 |
.input-container{padding:0 40px 30px;background:linear-gradient(to top, var(--bg-color) 70%, transparent);position:relative;z-index:20;}
|
| 153 |
.input-wrap{display:flex;flex-direction:column;background:var(--glass-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--border-light);border-radius:24px;box-shadow:var(--shadow-md);transition:box-shadow 0.3s, border-color 0.3s;}
|
| 154 |
.input-wrap:focus-within{border-color:var(--border-focus);box-shadow:0 12px 40px rgba(0,0,0,0.1), 0 0 0 3px rgba(255,153,51,0.1);}
|
| 155 |
|
|
|
|
| 156 |
.img-prev-inline{display:none;padding:12px 20px 0;align-items:center;gap:12px;}
|
| 157 |
.img-prev-inline.show{display:flex;animation:fadeIn 0.3s;}
|
| 158 |
.inline-th{width:40px;height:40px;object-fit:cover;border-radius:8px;border:1px solid var(--border-light);}
|
|
|
|
| 161 |
.inline-rm{background:rgba(0,0,0,0.05);border:none;width:24px;height:24px;border-radius:50%;cursor:pointer;font-size:10px;display:flex;align-items:center;justify-content:center;transition:background 0.2s;}
|
| 162 |
.inline-rm:hover{background:#ff3b30;color:#fff;}
|
| 163 |
|
| 164 |
+
.input-row{display:flex;align-items:flex-end;gap:12px;padding:12px 16px 12px 20px;}
|
| 165 |
+
.chat-ta{flex:1;border:none;outline:none;background:transparent;font-family:var(--font-sans);font-size:15px;color:var(--text-main);line-height:1.5;resize:none;max-height:200px;min-height:24px;padding:8px 0;}
|
| 166 |
.chat-ta::placeholder{color:var(--text-muted);}
|
|
|
|
| 167 |
|
| 168 |
+
/* Modern Attachment & Send */
|
| 169 |
+
.attach-btn{width:38px;height:38px;border-radius:12px;background:transparent;border:1px solid transparent;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--text-muted);transition:all 0.2s;position:relative;overflow:hidden;padding-bottom:4px;}
|
| 170 |
.attach-btn:hover{background:rgba(0,0,0,0.04);color:var(--text-main);}
|
| 171 |
.attach-btn input{position:absolute;inset:0;opacity:0;cursor:pointer;}
|
| 172 |
.attach-btn svg{width:20px;height:20px;}
|
| 173 |
|
| 174 |
+
.send-btn{width:42px;height:42px;border-radius:14px;border:none;background:linear-gradient(135deg, #FF9933 0%, #ffffff 50%, #138808 100%);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all 0.3s;box-shadow:0 4px 12px rgba(0,0,0,0.1);}
|
| 175 |
+
.send-btn svg{width:18px;height:18px;fill:#1d1d1f;transition:transform 0.2s;}
|
| 176 |
+
.send-btn:hover{box-shadow:0 6px 16px rgba(255,153,51,0.3);transform:translateY(-1px);}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
.send-btn:hover svg{transform:translate(2px, -2px);}
|
| 178 |
+
.send-btn:disabled{opacity:0.4;cursor:not-allowed;filter:grayscale(100%);transform:none;}
|
| 179 |
|
| 180 |
.input-hint{text-align:center;font-size:11px;color:var(--text-muted);margin-top:12px;font-weight:500;}
|
| 181 |
|
|
|
|
| 183 |
.ws-hdr{padding:14px 20px;border-bottom:1px solid var(--border-light);background:#fff;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;}
|
| 184 |
.ws-title{font-size:14px;font-weight:600;display:flex;align-items:center;gap:8px;}
|
| 185 |
.ws-actions{display:flex;gap:8px;}
|
| 186 |
+
.ws-icon-btn{padding:6px 12px;border-radius:8px;background:var(--bg-secondary);border:1px solid var(--border-light);cursor:pointer;display:flex;align-items:center;gap:6px;color:var(--text-main);transition:all 0.2s;font-size:12px;font-weight:600;}
|
| 187 |
.ws-icon-btn:hover{background:#e5e5ea;}
|
| 188 |
+
.ws-close{padding:6px;background:transparent;border-color:transparent;}
|
| 189 |
+
.ws-close:hover{color:#ff3b30;background:#fff0f0;}
|
| 190 |
.ws-content{flex:1;overflow-y:auto;background:#fafafa;padding:20px;}
|
| 191 |
.ws-content pre{margin:0;padding:20px;background:#fff;border:1px solid var(--border-light);border-radius:12px;font-family:var(--font-mono);font-size:14px;line-height:1.6;overflow-x:auto;box-shadow:var(--shadow-sm);}
|
| 192 |
|
|
|
|
| 198 |
.messages{padding:20px;}
|
| 199 |
.input-container{padding:0 20px 20px;}
|
| 200 |
.msg{max-width:95%;}
|
| 201 |
+
.scroll-bottom-btn{bottom:110px;}
|
| 202 |
}
|
| 203 |
</style>
|
| 204 |
</head>
|
| 205 |
+
<!-- Body controls the thinking visibility -->
|
| 206 |
+
<body class="show-thinking">
|
| 207 |
|
| 208 |
<div class="bg">
|
| 209 |
<div class="orb orb1"></div>
|
|
|
|
| 218 |
<img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png" alt="Tiranga Logo" class="logo-img">
|
| 219 |
<div class="logo-text">
|
| 220 |
<div class="logo-name">TIRANGA</div>
|
| 221 |
+
<div class="logo-sub">Advanced Edition</div>
|
| 222 |
</div>
|
| 223 |
</div>
|
| 224 |
</div>
|
| 225 |
+
|
| 226 |
<div class="settings">
|
| 227 |
+
<!-- Reasoning Toggle -->
|
| 228 |
+
<div class="toggle-wrapper">
|
| 229 |
+
<div class="toggle-label">
|
| 230 |
+
🧠 Reasoning Mode
|
| 231 |
+
<span>Show internal thinking</span>
|
| 232 |
+
</div>
|
| 233 |
+
<label class="switch">
|
| 234 |
+
<input type="checkbox" id="thinkingToggle" checked onchange="toggleThinking(this)">
|
| 235 |
+
<span class="slider"></span>
|
| 236 |
+
</label>
|
| 237 |
+
</div>
|
| 238 |
+
|
| 239 |
<div class="brand-box">
|
| 240 |
<img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png" alt="Tiranga Identity">
|
| 241 |
<h3>TIRANGA</h3>
|
|
|
|
| 259 |
<!-- Welcome Screen -->
|
| 260 |
<div class="welcome" id="welcome">
|
| 261 |
<img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png" alt="Tiranga Logo" class="welcome-logo">
|
| 262 |
+
<div class="welcome-title">Welcome, Divy Patel!</div>
|
| 263 |
+
<div class="welcome-sub">I am TIRANGA. I am equipped with advanced reasoning, workspace coding, and image generation. How can I assist you today?</div>
|
| 264 |
+
|
| 265 |
+
<div class="ex-grid">
|
| 266 |
+
<div class="ex-card" onclick="sendEx('Write a python script for a simple HTTP server. Provide the code.')">
|
| 267 |
+
<div class="ex-title">💻 Code Generation</div>
|
| 268 |
+
<div class="ex-desc">Generate secure, workspace-ready code</div>
|
| 269 |
+
</div>
|
| 270 |
+
<div class="ex-card" onclick="sendEx('Create an image of a futuristic Indian city with flying cars, highly detailed, 8k resolution.')">
|
| 271 |
+
<div class="ex-title">🎨 Generate Images</div>
|
| 272 |
+
<div class="ex-desc">Stunning visuals using Pollinations AI</div>
|
| 273 |
+
</div>
|
| 274 |
+
</div>
|
| 275 |
</div>
|
| 276 |
</div>
|
| 277 |
|
| 278 |
+
<!-- Scroll to bottom button (Centered) -->
|
| 279 |
<button class="scroll-bottom-btn" id="scrollBtn" onclick="forceScrollDown()">
|
| 280 |
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>
|
| 281 |
</button>
|
| 282 |
|
| 283 |
<!-- Input Area -->
|
| 284 |
<div class="input-container">
|
| 285 |
<div class="input-wrap">
|
|
|
|
| 286 |
<div class="img-prev-inline" id="imgPrev">
|
| 287 |
<img class="inline-th" id="imgThumb" src="">
|
| 288 |
<div class="inline-info">
|
|
|
|
| 302 |
</button>
|
| 303 |
</div>
|
| 304 |
</div>
|
| 305 |
+
<div class="input-hint">TIRANGA is engineered for extreme performance. Verified by Divy Patel.</div>
|
| 306 |
</div>
|
| 307 |
</main>
|
| 308 |
|
|
|
|
| 310 |
<aside class="workspace" id="workspace">
|
| 311 |
<div class="ws-hdr">
|
| 312 |
<div class="ws-title">
|
| 313 |
+
<span>💻</span>
|
| 314 |
<span id="wsTitleText">Generated Code</span>
|
| 315 |
</div>
|
| 316 |
<div class="ws-actions">
|
| 317 |
+
<button class="ws-icon-btn" onclick="copyWorkspaceCode()" id="wsCopyBtn">📋 Copy</button>
|
| 318 |
<button class="ws-icon-btn ws-close" onclick="closeWorkspace()" title="Close">✕</button>
|
| 319 |
</div>
|
| 320 |
</div>
|
|
|
|
| 326 |
</div>
|
| 327 |
|
| 328 |
<script>
|
| 329 |
+
// --- STATE MANAGEMENT ---
|
| 330 |
const S = {
|
| 331 |
history: [],
|
| 332 |
pending: null,
|
| 333 |
busy: false,
|
| 334 |
isUserScrolling: false,
|
| 335 |
+
codeBlocks: [], // Securely stores raw code to prevent HTML escaping bugs
|
| 336 |
+
currentWorkspaceId: null
|
| 337 |
};
|
| 338 |
|
| 339 |
+
function toggleThinking(el) {
|
| 340 |
+
if(el.checked) document.body.classList.add('show-thinking');
|
| 341 |
+
else document.body.classList.remove('show-thinking');
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
// Memory initialization
|
| 345 |
window.onload = () => {
|
| 346 |
+
const saved = localStorage.getItem('tiranga_v3_memory');
|
| 347 |
if(saved) {
|
| 348 |
try {
|
| 349 |
S.history = JSON.parse(saved);
|
|
|
|
| 353 |
if(msg.role === 'user') appendUserDOM(msg.content, msg.badge);
|
| 354 |
else appendBotDOM(msg.content);
|
| 355 |
});
|
| 356 |
+
setTimeout(forceScrollDown, 100);
|
| 357 |
}
|
| 358 |
+
} catch(e) {}
|
| 359 |
}
|
| 360 |
};
|
| 361 |
|
| 362 |
function saveMemory() {
|
|
|
|
| 363 |
const memToSave = S.history.slice(-20);
|
| 364 |
+
localStorage.setItem('tiranga_v3_memory', JSON.stringify(memToSave));
|
| 365 |
}
|
|
|
|
| 366 |
function clearMemory() {
|
| 367 |
+
localStorage.removeItem('tiranga_v3_memory');
|
|
|
|
|
|
|
| 368 |
location.reload();
|
| 369 |
}
|
| 370 |
|
|
|
|
| 387 |
function handleKey(e){if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMsg();}}
|
| 388 |
function autoGrow(el){el.style.height='auto';el.style.height=Math.min(el.scrollHeight,200)+'px';}
|
| 389 |
|
|
|
|
| 390 |
function checkScroll() {
|
| 391 |
const m = document.getElementById('msgs');
|
| 392 |
+
// Show center button only if user scrolled UP more than 80px
|
| 393 |
+
const isAtBottom = Math.abs((m.scrollHeight - m.scrollTop) - m.clientHeight) < 80;
|
| 394 |
S.isUserScrolling = !isAtBottom;
|
| 395 |
|
| 396 |
const btn = document.getElementById('scrollBtn');
|
|
|
|
| 401 |
const m=document.getElementById('msgs');
|
| 402 |
m.scrollTo({top: m.scrollHeight, behavior: 'smooth'});
|
| 403 |
S.isUserScrolling = false;
|
| 404 |
+
document.getElementById('scrollBtn').classList.remove('show');
|
| 405 |
}
|
| 406 |
function autoScroll() {
|
| 407 |
if(!S.isUserScrolling) {
|
|
|
|
| 410 |
}
|
| 411 |
}
|
| 412 |
|
| 413 |
+
// --- COPY UTILS ---
|
| 414 |
function copyText(btn, text) {
|
| 415 |
navigator.clipboard.writeText(text);
|
| 416 |
const orig = btn.innerHTML;
|
| 417 |
+
btn.innerHTML = "✓ Copied";
|
| 418 |
setTimeout(() => btn.innerHTML = orig, 2000);
|
| 419 |
}
|
| 420 |
+
function copyWorkspaceCode() {
|
| 421 |
+
if(S.currentWorkspaceId !== null) {
|
| 422 |
+
navigator.clipboard.writeText(S.codeBlocks[S.currentWorkspaceId].code);
|
| 423 |
+
const btn = document.getElementById('wsCopyBtn');
|
| 424 |
+
const orig = btn.innerHTML;
|
| 425 |
+
btn.innerHTML = "✓ Copied";
|
| 426 |
+
setTimeout(() => btn.innerHTML = orig, 2000);
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
|
| 430 |
// --- WORKSPACE LOGIC ---
|
| 431 |
+
function openWorkspace(id) {
|
| 432 |
+
S.currentWorkspaceId = id;
|
| 433 |
+
const block = S.codeBlocks[id];
|
| 434 |
+
document.getElementById('wsTitleText').textContent = block.lang ? `Generated ${block.lang.toUpperCase()}` : "Generated Code";
|
| 435 |
+
|
| 436 |
const codeBlock = document.getElementById('wsCodeBlock');
|
| 437 |
+
codeBlock.className = `hljs language-${block.lang || 'plaintext'}`;
|
| 438 |
+
codeBlock.textContent = block.code;
|
| 439 |
hljs.highlightElement(codeBlock);
|
| 440 |
|
| 441 |
document.getElementById('workspace').classList.add('open');
|
| 442 |
+
if(window.innerWidth <= 850) { document.getElementById('sidebar').classList.remove('show'); }
|
|
|
|
|
|
|
|
|
|
| 443 |
}
|
| 444 |
+
function closeWorkspace() { document.getElementById('workspace').classList.remove('open'); }
|
| 445 |
+
|
| 446 |
+
// --- MARKED.JS CUSTOM RENDERER (Fixes the Workspace Bug Completely) ---
|
| 447 |
+
const renderer = new marked.Renderer();
|
| 448 |
+
renderer.code = function(token) {
|
| 449 |
+
// Marked v12 might pass object or string based on usage. Safely extract.
|
| 450 |
+
const codeText = typeof token === 'string' ? token : (token.text || '');
|
| 451 |
+
const language = typeof token === 'string' ? arguments[1] : (token.lang || '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
|
| 453 |
+
const id = S.codeBlocks.length;
|
| 454 |
+
S.codeBlocks.push({ code: codeText, lang: language });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
|
| 456 |
+
// Return the Beautiful Trigger Card
|
| 457 |
+
return `
|
| 458 |
+
<div class="ws-trigger-card">
|
| 459 |
+
<div class="ws-trigger-info">
|
| 460 |
+
<div class="ws-trigger-icon">💻</div>
|
| 461 |
+
<div class="ws-trigger-text">
|
| 462 |
+
<h4>Code Generated</h4>
|
| 463 |
+
<p>${language || 'Snippet'}</p>
|
| 464 |
+
</div>
|
| 465 |
+
</div>
|
| 466 |
+
<button class="ws-btn" onclick="openWorkspace(${id})">View in Workspace</button>
|
| 467 |
+
</div>
|
| 468 |
+
`;
|
| 469 |
+
};
|
| 470 |
+
marked.use({ renderer });
|
| 471 |
+
|
| 472 |
+
// Custom Thinking Parser
|
| 473 |
+
function parseThinking(raw) {
|
| 474 |
+
const thinkRegex = /<think>([\s\S]*?)(<\/think>|$)/gi;
|
| 475 |
+
let text = raw;
|
| 476 |
+
let thinkContent = '';
|
| 477 |
+
text = text.replace(thinkRegex, (match, p1) => {
|
| 478 |
+
thinkContent += p1;
|
| 479 |
+
return '';
|
| 480 |
+
});
|
| 481 |
+
return { mainText: text.trim(), thinkText: thinkContent.trim() };
|
| 482 |
}
|
| 483 |
|
| 484 |
// --- MAIN CHAT LOGIC ---
|
|
|
|
| 487 |
const inp=document.getElementById('chatInput');
|
| 488 |
const msg=inp.value.trim();if(!msg && !S.pending)return;
|
| 489 |
inp.value='';inp.style.height='auto';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
|
| 491 |
document.getElementById('sendBtn').disabled=true;
|
| 492 |
S.busy=true;
|
|
|
|
| 513 |
document.getElementById('msgs').appendChild(botDiv);
|
| 514 |
forceScrollDown();
|
| 515 |
|
| 516 |
+
// Integrated Pollinations AI at Model Level (Using System Prompt constraints)
|
| 517 |
+
const sysPrompt = `You are TIRANGA, a state-of-the-art AI assistant. Developed by Divy Patel.
|
| 518 |
+
Always communicate respectfully.
|
| 519 |
+
|
| 520 |
+
CRITICAL IMAGE GENERATION PROTOCOL:
|
| 521 |
+
If the user asks to generate, create, or draw an image/photo, you MUST generate the image by responding with a markdown image tag using Pollinations AI.
|
| 522 |
+
Format to use: 
|
| 523 |
+
Available models for {MODEL}: flux, flux-realism, flux-anime, flux-3d.
|
| 524 |
+
Choose the best model based on the prompt. Example: if user says anime, use flux-anime.
|
| 525 |
+
Always include this markdown tag when image generation is requested.`;
|
| 526 |
|
| 527 |
const payload = {
|
| 528 |
message: msg,
|
| 529 |
attachments: attachments,
|
| 530 |
system_prompt: sysPrompt,
|
| 531 |
max_tokens: 4096,
|
| 532 |
+
temperature: 0.7
|
| 533 |
};
|
| 534 |
|
| 535 |
try{
|
|
|
|
| 558 |
const dataObj = JSON.parse(dataStr);
|
| 559 |
if (dataObj.choices && dataObj.choices[0].delta.content) {
|
| 560 |
accumulatedText += dataObj.choices[0].delta.content;
|
| 561 |
+
renderBotText(botDiv, accumulatedText, true);
|
| 562 |
autoScroll();
|
| 563 |
}
|
| 564 |
} catch (e) { }
|
| 565 |
}
|
| 566 |
}
|
| 567 |
}
|
| 568 |
+
// Final Render without cursor
|
| 569 |
+
renderBotText(botDiv, accumulatedText, false);
|
| 570 |
+
|
| 571 |
+
// Save to history
|
| 572 |
S.history.push({role: 'bot', content: accumulatedText});
|
| 573 |
saveMemory();
|
| 574 |
|
| 575 |
}catch(err){
|
| 576 |
+
renderBotText(botDiv,`**Error:** Server communication failed.`, false);
|
| 577 |
}
|
| 578 |
|
| 579 |
S.busy=false;
|
|
|
|
| 581 |
autoScroll();
|
| 582 |
}
|
| 583 |
|
| 584 |
+
function sendEx(t){document.getElementById('chatInput').value=t;sendMsg();}
|
| 585 |
+
|
| 586 |
+
// --- DOM INJECTION ---
|
| 587 |
function appendUserDOM(text, badgeText){
|
| 588 |
let bHtml = badgeText ? `<div style="font-size:11px;color:var(--accent);margin-bottom:4px;font-weight:600;">${esc(badgeText)}</div>` : '';
|
| 589 |
const el=document.createElement('div');el.className='msg user';
|
| 590 |
el.innerHTML=`<div class="avatar">U</div><div class="body">${bHtml}<div class="bubble">${esc(text)}</div></div>`;
|
| 591 |
document.getElementById('msgs').appendChild(el);
|
| 592 |
}
|
| 593 |
+
|
| 594 |
function appendBotDOM(content) {
|
| 595 |
const el=document.createElement('div');el.className='msg bot';
|
| 596 |
+
el.innerHTML=`<div class="avatar"><img src="https://i.ibb.co/x8m7DbMk/TIRANGA-20260523-101648-0000.png"></div><div class="body"><div class="bubble"></div></div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
document.getElementById('msgs').appendChild(el);
|
| 598 |
+
renderBotText(el, content, false);
|
| 599 |
}
|
| 600 |
|
| 601 |
+
// Render Markdown + Thinking Toggle + Actions
|
| 602 |
+
function renderBotText(el, raw, isStreaming) {
|
| 603 |
const b = el.querySelector('.bubble');
|
| 604 |
|
| 605 |
+
// 1. Separate Thinking and Main Text
|
| 606 |
+
const { mainText, thinkText } = parseThinking(raw);
|
|
|
|
| 607 |
|
| 608 |
+
// 2. Parse Markdown
|
| 609 |
+
let html = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
|
| 611 |
+
// Attach Thinking block if exists
|
| 612 |
+
if (thinkText) {
|
| 613 |
+
html += `<div class="think-box"><div class="think-title">🧠 Reasoning Process</div>${esc(thinkText)}</div>`;
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
html += marked.parse(mainText);
|
| 617 |
+
|
| 618 |
+
// Add Blinking Cursor if streaming
|
| 619 |
+
if(isStreaming) {
|
| 620 |
+
html += '<span class="blinking-cursor"></span>';
|
| 621 |
+
}
|
| 622 |
|
| 623 |
b.innerHTML = html;
|
| 624 |
|
| 625 |
+
// 3. Add Copy Action Button below bubble (only once streaming is done or if it's history load)
|
| 626 |
let actionsDiv = el.querySelector('.msg-actions');
|
| 627 |
+
if(!isStreaming && !actionsDiv && mainText.trim().length > 0) {
|
| 628 |
+
const cleanRaw = mainText.replace(/"/g, '"').replace(/'/g, "\\'").replace(/\n/g, '\\n');
|
| 629 |
+
const actionsHTML = `
|
| 630 |
+
<div class="msg-actions">
|
| 631 |
+
<button class="action-btn" onclick="copyText(this, \`${cleanRaw}\`)">
|
| 632 |
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
|
| 633 |
+
Copy Text
|
| 634 |
+
</button>
|
| 635 |
+
</div>
|
| 636 |
+
`;
|
| 637 |
+
el.querySelector('.body').insertAdjacentHTML('beforeend', actionsHTML);
|
| 638 |
}
|
| 639 |
}
|
| 640 |
|
| 641 |
function esc(t){return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');}
|
| 642 |
</script>
|
| 643 |
</body>
|
| 644 |
+
</html>
|
| 645 |
+
|