-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaq-issue.js
More file actions
4 lines (3 loc) · 2.41 KB
/
Copy pathfaq-issue.js
File metadata and controls
4 lines (3 loc) · 2.41 KB
1
2
3
4
async function sleep(t){return new Promise(s=>setTimeout(s,t))}async function submitIssue(){const t=document.getElementById("issue-description").value.trim();if(!t){alert("Please describe your issue first.");return}const s=document.getElementById("ai-preview"),n=document.getElementById("ai-output"),a=document.getElementById("issue-repo").value,e=[document.getElementById("step-1"),document.getElementById("step-2"),document.getElementById("step-3"),document.getElementById("step-4")];e.forEach(o=>{o.className="ai-step"}),s.style.display="none",e[0].classList.add("visible","active"),await sleep(500),e[0].classList.remove("active"),e[0].classList.add("done"),e[1].classList.add("visible","active");const r=`You are a bug report formatter. Convert the following user problem description into a proper GitHub issue. Include: Title (short, clear), Description (what happened), Steps to Reproduce (inferred from the description if possible), Expected Behavior, Actual Behavior, System Info placeholder (ask user to fill in). Format with markdown. Do NOT include any preamble or explanation. Just output the formatted bug report.
User problem: `+t,l=fetch("https://text.pollinations.ai/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:r}],model:"openai",private:!0})});await sleep(600),e[1].classList.remove("active"),e[1].classList.add("done"),e[2].classList.add("visible","active");try{const i=await(await l).text();e[2].classList.remove("active"),e[2].classList.add("done"),e[3].classList.add("visible","done"),n.textContent=i,s.style.display="block",window._issueRepo=a,window._issueTitle=i.split(`
`)[0].replace(/^#+\s*/,"").replace(/^Title:\s*/i,"").trim()}catch{e[2].classList.remove("active"),e[2].classList.add("done"),e[2].style.color="var(--gnome-color)",e[2].querySelector(".ai-step-icon").style.borderColor="var(--gnome-color)",e[2].innerHTML='<span class="ai-step-icon" style="background:var(--gnome-color);border-color:var(--gnome-color);color:#000;">!</span> Error connecting to Pollinations.ai. Please try again.',e[3].style.display="none"}}function openGitHubIssue(){if(!window._issueRepo||!window._issueTitle){alert("Please analyze your issue first.");return}const t=document.getElementById("ai-output").textContent,s="https://github.com/"+window._issueRepo+"/issues/new?title="+encodeURIComponent(window._issueTitle)+"&body="+encodeURIComponent(t);window.open(s,"_blank","noopener")}