-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaq-issue.js
More file actions
1 lines (1 loc) · 2.62 KB
/
Copy pathfaq-issue.js
File metadata and controls
1 lines (1 loc) · 2.62 KB
1
async function sleep(ms){return new Promise(r=>setTimeout(r,ms))};async function submitIssue(){const desc=document.getElementById('issue-description').value.trim();if(!desc){alert('Please describe your issue first.');return}const preview=document.getElementById('ai-preview');const output=document.getElementById('ai-output');const repo=document.getElementById('issue-repo').value;const steps=[document.getElementById('step-1'),document.getElementById('step-2'),document.getElementById('step-3'),document.getElementById('step-4')];steps.forEach(s=>{s.className='ai-step'});preview.style.display='none';steps[0].classList.add('visible','active');await sleep(500);steps[0].classList.remove('active');steps[0].classList.add('done');steps[1].classList.add('visible','active');const prompt='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.\n\nUser problem: '+desc;const aiPromise=fetch('https://text.pollinations.ai/',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({messages:[{role:'user',content:prompt}],model:'openai',private:true})});await sleep(600);steps[1].classList.remove('active');steps[1].classList.add('done');steps[2].classList.add('visible','active');try{const res=await aiPromise;const data=await res.text();steps[2].classList.remove('active');steps[2].classList.add('done');steps[3].classList.add('visible','done');output.textContent=data;preview.style.display='block';window._issueRepo=repo;window._issueTitle=data.split('\n')[0].replace(/^#+\s*/,'').replace(/^Title:\s*/i,'').trim()}catch(e){steps[2].classList.remove('active');steps[2].classList.add('done');steps[2].style.color='var(--gnome-color)';steps[2].querySelector('.ai-step-icon').style.borderColor='var(--gnome-color)';steps[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.';steps[3].style.display='none'}}function openGitHubIssue(){if(!window._issueRepo||!window._issueTitle){alert('Please analyze your issue first.');return}const body=document.getElementById('ai-output').textContent;const url='https://github.com/'+window._issueRepo+'/issues/new?title='+encodeURIComponent(window._issueTitle)+'&body='+encodeURIComponent(body);window.open(url,'_blank','noopener')}