Gomega AI — chat, math steps, premium features & global keys (Firebase support).
Not premium — limited
Chat limit
Free: 25 messages/day • Premium: 1,300 messages / 2 days
Press Ctrl+Shift+1 for Admin keys panel
\n", explain: "Simple HTML + script template. Paste into an .html file and open in browser." }; } return { code: "// " + task + " — pseudocode / template\n/* Describe expected input/output and replace with real language implementation */", explain: "Generic template; tell me which language you want for a full example." }; } // ---------- AI engine (math & code priority) ---------- async function simulatedAIResponse(userText, model) { var priority = (licenseActive() && priorityModeCheckbox && priorityModeCheckbox.checked); var baseDelay = Math.max(1200, Math.min(10000, userText.length * 60)); var delay = priority ? Math.max(350, Math.floor(baseDelay * 0.5)) : baseDelay; return new Promise(function(resolve) { setTimeout(async function() { var txt = userText.trim(); var ltxt = txt.toLowerCase(); try { if (txt.indexOf("=") !== -1 && /[xX]/.test(txt)) { var quad = trySolveQuadratic(txt); if (quad) { var out = "I solved the equation for you.\n\n"; quad.steps.forEach(function(s){ out += s + "\n"; }); out += "\nSolution: " + quad.result; resolve(out); return; } var lin = trySolveLinear(txt); if (lin) { var out2 = "I solved the linear equation.\n\n"; lin.steps.forEach(function(s){ out2 += s + "\n"; }); out2 += "\nSolution: " + lin.result; resolve(out2); return; } } if (isPureMathExpression(txt)) { var tokens = tokenizeMath(txt); if (!tokens) { resolve("I can't parse that expression. Use numbers, parentheses and + - * / ^ %."); return; } try { var rpn = shuntingYard(tokens); var evalRes = evalRPNWithSteps(rpn); var out3 = "Expression: " + txt + "\n\nStep-by-step evaluation:\n"; evalRes.steps.forEach(function(s,i){ out3 += String(i+1) + ") " + s + "\n"; }); out3 += "\nResult: " + evalRes.result; resolve(out3); return; } catch(e) { resolve("Error evaluating expression: " + e.message); return; } } } catch(e) { console.error("Math parsing error", e); } var memoryNote = ""; try { if (licenseActive() && convMemoryToggle.checked) { var mem = getMemory(); if (mem.length) { var facts = mem.slice(-4).map(function(m){ return m.fact; }); var joined = facts.join("; "); memoryNote = "\n\n(Stored memory: " + joined.slice(0,150) + (joined.length > 150 ? "..." : "") + ")"; } } } catch(e){} if (/\b(write|implement|create|generate|make)\b.*\b(function|script|program|class|component|api|endpoint|lambda|handler)\b/i.test(txt) || /\b(js|javascript|python|html|css|react|node|express|flask|django)\b/i.test(txt)) { var lang = "python"; var langMatch = txt.match(/\b(python|javascript|js|html|css|react|node|express|flask|django)\b/i); if (langMatch) lang = langMatch[1]; var task = txt; var templ = generateCodeTemplate(lang, task); var out4 = "I will generate a " + lang + " example with explanation and tests.\n\n"; out4 += "--- Explanation ---\n" + templ.explain + "\n\n--- Code ---\n" + templ.code + "\n\n--- Next steps ---\n1) Replace TODOs with your logic.\n2) Add edge-case tests.\n3) Run the simple test included.\n" + memoryNote; resolve(out4); return; } var reply = "I didn't quite catch that — can you tell me more about what you'd like?"; if (/^\s*(hi|hello|hey|howdy|sup)\b/.test(ltxt)) reply = "Hey! I'm Gomega AI — how can I help you today?"; else if (/\bhow are you\b|\bhow's it going\b/.test(ltxt)) reply = "I'm running smoothly — tell me your goal and I'll help."; else if (/\b(help|how do i|how to|what is|explain)\b/.test(ltxt)) reply = "I can provide step-by-step instructions, code snippets, math steps, or explain concepts. What do you want?"; else if (/\b(openai|api|backend|functions|server|cloud)\b/.test(ltxt)) reply = "I can show you server code for a secure proxy and how to wire premium models — I can generate the Cloud Function or Express code."; else if (/\b(buy|premium|upgrade|plus)\b/.test(ltxt)) reply = "Use Activate and paste the key. Admins register keys and can configure consumable/reusable keys."; else if (/\b(debug|error|stack trace|exception)\b/.test(ltxt) || /\bfix\b.*\bbug\b/.test(ltxt)) reply = "Share the exact error or code snippet and I'll suggest fixes and tests."; else if (ltxt.length < 30) reply = "Give me a bit more detail — what's the goal or the issue?"; else { var short = txt.length > 160 ? txt.slice(0,160) + "..." : txt; var options = "\n\nOptions:\n1) Explain steps to achieve this.\n2) Provide a short example or template."; reply = "Thanks — I understand: \"" + short + "\"" + options + memoryNote; } if (model.indexOf("v5") !== -1 && licenseActive() && betaModelsToggle.checked) reply += "\n\n(Using gomega v5.o — premium beta simulated.)"; else if (model.indexOf("v4") !== -1 && licenseActive()) reply += "\n\n(Using gomega v4.0 mini — premium simulated.)"; resolve(reply); }, delay); }); } async function runAI(userText, model) { setTyping(true); var simulatedReply = await simulatedAIResponse(userText, model); var aiMsg = { role:"ai", text: simulatedReply, ts: new Date().toISOString() }; appendMessageToDOM(aiMsg); pushMessage(aiMsg); setTyping(false); } // ---------- photo upload ---------- photoUploadBtn.addEventListener("click", async function() { if (!licenseActive()) { toast("Photo upload is Premium-only"); return; } var file = photoInput.files && photoInput.files[0]; if (!file) { toast("Pick a photo file first"); return; } if (useFirebase && storage) { var path = "uploads/" + (Date.now()) + "_" + Math.random().toString(36).slice(2,8) + "_" + file.name; var ref = storageRef(storage, path); try { await uploadBytes(ref, file); var url = await getDownloadURL(ref); photoPreviewArea.innerHTML = ""; var p0 = document.createElement("div"); p0.className = "small muted"; p0.textContent = "Uploaded to Firebase Storage:"; var a = document.createElement("a"); a.href = url; a.target = "_blank"; a.textContent = url; var d = document.createElement("div"); d.style.marginTop = "8px"; var img = document.createElement("img"); img.src = url; img.alt = "uploaded"; d.appendChild(img); photoPreviewArea.appendChild(p0); photoPreviewArea.appendChild(a); photoPreviewArea.appendChild(d); toast("Upload complete"); } catch (e) { console.error(e); toast("Upload failed"); } } else { var reader = new FileReader(); reader.onload = function(ev) { photoPreviewArea.innerHTML = ""; var p0 = document.createElement("div"); p0.className = "small muted"; p0.textContent = "Preview (not uploaded — configure Firebase Storage to enable uploads):"; var d = document.createElement("div"); d.style.marginTop = "8px"; var img = document.createElement("img"); img.src = ev.target.result; img.alt = "preview"; d.appendChild(img); photoPreviewArea.appendChild(p0); photoPreviewArea.appendChild(d); }; reader.readAsDataURL(file); toast("Preview generated (local only)"); } }); // ---------- attach events ---------- function attachEvents() { $("helpBtn").addEventListener("click", function() { // fixed quoting here so editor doesn't choke on mixed quotes/escapes appendMessageToDOM({ role:"ai", text: "Quick help:\n- Activate a key to unlock premium\n- Memory: send 'Remember: ...' while Memory is enabled\n- Math: 2*(3+4)^2 or 3x+2=11\n- Upload photos for premium users (uses Firebase Storage if configured).", ts: new Date().toISOString() }); }); modelSelect.addEventListener("change", function() { var sel = modelSelect.options[modelSelect.selectedIndex]; if (sel.dataset && sel.dataset.premium && !licenseActive()) toast("That model needs Premium — click Activate!"); }); convMemoryToggle.addEventListener("change", function() { if (convMemoryToggle.checked && !licenseActive()) { convMemoryToggle.checked = false; toast("Memory is Premium only"); } }); setInterval(loadLicenseUI, 60000); } // ---------- greeting ---------- function startupGreeting() { var obj = getChatCountObj(); if (!licenseActive() && (obj.count || 0) >= FREE_DAILY_LIMIT) { appendMessageToDOM({ role:"ai", text: "You reached your free daily limit. Activate a premium key to continue chatting.", ts: new Date().toISOString() }); } else { appendMessageToDOM({ role:"ai", text: "Welcome! Ask anything — math, code, upload photos (Premium). Try \"2*(3+4)^2\" or \"3x+2=11\".", ts: new Date().toISOString() }); } } // expose debug helpers window.Gomega = { getLocalKeys: getLocalKeys, saveLocalKeys: saveLocalKeys, randomKey: randomKey, getLicense: getLicense, clearLicense: clearLicense, setChatCountObj: function(o){ localStorage.setItem(CHAT_COUNT_KEY, JSON.stringify(o)); } }; // ensure scroll on new messages var obs = new MutationObserver(function(){ messagesEl.scrollTop = messagesEl.scrollHeight; }); obs.observe(messagesEl, { childList:true });