๐Ÿ“Ž
๐Ÿ”
๐Ÿ‘‹ Halo ๐Ÿ’ป Kode ๐Ÿ˜‚ Jokes ๐Ÿ”ข Hitung ๐Ÿฑ Gambar ๐Ÿ“„ Kalkulator
โœ•

Lihat console

'; else { alert('Preview hanya untuk HTML, CSS, JS'); return; } const win = window.open(); win.document.write(content); win.document.close(); } function downloadCode(code, lang) { const ext = lang === 'python' ? 'py' : lang === 'javascript' ? 'js' : lang; const blob = new Blob([code], { type: 'text/plain' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'tatang-code.' + ext; a.click(); } async function appendBotMsgWithTyping(fullText, speedMs = 1.5) { return new Promise((resolve) => { const scr = document.getElementById('chatScreen'); const wrap = document.createElement('div'); wrap.className = 'msg-wrap bot'; const name = document.createElement('div'); name.className = 'msg-name'; name.textContent = '๐Ÿค– Tatang'; const bubble = document.createElement('div'); bubble.className = 'msg-bubble'; bubble.style.whiteSpace = 'pre-wrap'; wrap.appendChild(name); wrap.appendChild(bubble); scr.appendChild(wrap); let index = 0; const totalLength = fullText.length; const cursor = document.createElement('span'); cursor.className = 'typing-cursor'; bubble.appendChild(cursor); typingActive = true; typingResolve = resolve; const typeNext = () => { if (!typingActive) { cursor.remove(); resolve(); return; } if (index < totalLength) { const char = fullText.charAt(index); const textNode = document.createTextNode(char); bubble.insertBefore(textNode, cursor); index++; scr.scrollTop = scr.scrollHeight; typingTimeoutId = setTimeout(typeNext, speedMs); } else { cursor.remove(); bubble.innerHTML = ''; renderRichText(bubble, fullText); typingActive = false; typingResolve = null; resolve(); } }; typeNext(); }); } function showTyping() { const scr = document.getElementById('chatScreen'); const wrap = document.createElement('div'); wrap.className = 'msg-wrap bot'; wrap.id = 'typingEl'; const name = document.createElement('div'); name.className = 'msg-name'; name.textContent = '๐Ÿค– Tatang'; const bub = document.createElement('div'); bub.className = 'msg-bubble'; bub.innerHTML = '
Sedang mikir...
'; wrap.appendChild(name); wrap.appendChild(bub); scr.appendChild(wrap); scr.scrollTop = scr.scrollHeight; return wrap; } function removeTyping(el) { if (el && el.parentNode) el.parentNode.removeChild(el); } function clearChat() { stopTyping(); chatHistory = []; attachments = []; document.getElementById('chatScreen').innerHTML = ''; document.getElementById('attachPreview').innerHTML = ''; document.getElementById('attachPreview').style.display = 'none'; appendBotMsg('Chat di-reset! Gw Tatang, siap bantu lagi bro! ๐Ÿ˜Š'); } function autoResize(el) { el.style.height = 'auto'; el.style.height = Math.min(el.scrollHeight, 130) + 'px'; } function handleFileUpload(e) { const file = e.target.files[0]; if (!file) return; const reader = new FileReader(); if (file.type.startsWith('image/')) { reader.onload = (ev) => { const att = { type: 'image', data: ev.target.result, name: file.name }; attachments.push(att); showAttachChip('๐Ÿ–ผ๏ธ ' + file.name, attachments.length - 1); }; reader.readAsDataURL(file); } else { reader.onload = (ev) => { const att = { type: 'text', data: ev.target.result, name: file.name }; attachments.push(att); showAttachChip('๐Ÿ“„ ' + file.name, attachments.length - 1); }; reader.readAsText(file); } e.target.value = ''; } function showAttachChip(label, idx) { const prev = document.getElementById('attachPreview'); prev.style.display = 'flex'; const chip = document.createElement('div'); chip.className = 'attach-chip'; chip.innerHTML = label + 'โœ•'; prev.appendChild(chip); } function removeAttach(idx) { attachments.splice(idx, 1); rebuildAttachUI(); } function rebuildAttachUI() { const prev = document.getElementById('attachPreview'); prev.innerHTML = ''; prev.style.display = attachments.length ? 'flex' : 'none'; attachments.forEach((a, i) => { showAttachChip((a.type === 'image' ? '๐Ÿ–ผ๏ธ' : '๐Ÿ“„') + ' ' + a.name, i); }); } function openImgViewer(src) { document.getElementById('viewerImg').src = src; document.getElementById('imgViewer').classList.add('show'); } function closeImgViewer() { document.getElementById('imgViewer').classList.remove('show'); } function downloadViewerImg() { const a = document.createElement('a'); a.href = lastGenImgUrl; a.download = 'tatang-gambar.jpg'; a.click(); } /* ===================================================== FILE GENERATION TEMPLATES ===================================================== */ function generateFileCode(type, desc) { if (type === 'html') return htmlTemplate(desc); if (type === 'css') return cssTemplate(desc); if (type === 'js') return jsTemplate(desc); if (type === 'python') return pythonTemplate(desc); if (type === 'php') return phpTemplate(desc); if (type === 'json') return jsonTemplate(desc); return txtTemplate(desc); } function htmlTemplate(desc) { return ` ${desc}

${desc}

Generated by Tatang AI

`; } function cssTemplate(desc) { return `/* ${desc} */\nbody{background:#0f0f17;color:#e8e8f0;}`; } function jsTemplate(desc) { return `// ${desc}\nconsole.log("Hello from Tatang AI!");`; } function pythonTemplate(desc) { return `# ${desc}\nprint("Hello from Tatang AI!")`; } function phpTemplate(desc) { return ``; } function jsonTemplate(desc) { return JSON.stringify({ description: desc, generated: true }, null, 2); } function txtTemplate(desc) { return `File: ${desc}\nGenerated by Tatang AI`; }