Spaces:
Running
Running
Delete script.js
Browse files
script.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
| 1 |
-
const $ = s => document.querySelector(s);
|
| 2 |
-
const $$ = s => Array.from(document.querySelectorAll(s));
|
| 3 |
-
|
| 4 |
-
const out = $('#out');
|
| 5 |
-
const hint = $('#hint');
|
| 6 |
-
const copyBtn = $('#copy');
|
| 7 |
-
const copyOpenBtn = $('#copyOpen');
|
| 8 |
-
const GPT_URL = 'https://chatgpt.com/g/g-6864ab7c8c188191b8641483747e63c2-coursemaster-pro';
|
| 9 |
-
|
| 10 |
-
function getSingle(name){
|
| 11 |
-
const on = $(`.toggles[data-name="${name}"] .toggle[aria-pressed="true"]`);
|
| 12 |
-
return on ? on.textContent.trim() : '';
|
| 13 |
-
}
|
| 14 |
-
function getAddons(){
|
| 15 |
-
const add = {};
|
| 16 |
-
$$('.toggles.multi .toggle').forEach(btn=>{
|
| 17 |
-
add[btn.dataset.key] = btn.getAttribute('aria-pressed') === 'true';
|
| 18 |
-
});
|
| 19 |
-
return add;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
function wireToggles(){
|
| 23 |
-
$$('.toggles').forEach(group=>{
|
| 24 |
-
group.addEventListener('click', e=>{
|
| 25 |
-
const btn = e.target.closest('.toggle');
|
| 26 |
-
if(!btn) return;
|
| 27 |
-
const multi = group.classList.contains('multi');
|
| 28 |
-
const pressed = btn.getAttribute('aria-pressed') === 'true';
|
| 29 |
-
if(multi){
|
| 30 |
-
btn.setAttribute('aria-pressed', (!pressed).toString());
|
| 31 |
-
}else{
|
| 32 |
-
group.querySelectorAll('.toggle').forEach(b=>b.setAttribute('aria-pressed','false'));
|
| 33 |
-
btn.setAttribute('aria-pressed','true');
|
| 34 |
-
}
|
| 35 |
-
});
|
| 36 |
-
});
|
| 37 |
-
}
|
| 38 |
-
wireToggles();
|
| 39 |
-
|
| 40 |
-
function buildUserPrompt(){
|
| 41 |
-
const topic = $('#topic').value.trim();
|
| 42 |
-
if(!topic){
|
| 43 |
-
hint.textContent = 'Please enter a Topic.';
|
| 44 |
-
return '';
|
| 45 |
-
}
|
| 46 |
-
hint.textContent = '';
|
| 47 |
-
|
| 48 |
-
const audience = getSingle('audience') || 'Students';
|
| 49 |
-
const level = getSingle('level') || 'Beginner';
|
| 50 |
-
const delivery = getSingle('delivery') || 'Online';
|
| 51 |
-
const language = getSingle('language') || 'Auto';
|
| 52 |
-
const tone = getSingle('tone') || 'Professional';
|
| 53 |
-
const depth = getSingle('depth') || 'Standard';
|
| 54 |
-
const duration = $('#duration').value.trim() || '6 weeks';
|
| 55 |
-
const localization = $('#localization').value.trim() || 'Auto';
|
| 56 |
-
const exportFmt = $('#export').value.trim() || 'PDF';
|
| 57 |
-
const notes = $('#notes').value.trim();
|
| 58 |
-
const add = getAddons();
|
| 59 |
-
|
| 60 |
-
const flags = [];
|
| 61 |
-
if(add.video) flags.push('Video Support');
|
| 62 |
-
if(add.bloom) flags.push('Bloom Mapping');
|
| 63 |
-
if(add.assess) flags.push('Assessments');
|
| 64 |
-
|
| 65 |
-
const parts = [
|
| 66 |
-
`Topic: ${topic}`,
|
| 67 |
-
`Audience: ${audience}`,
|
| 68 |
-
`Level: ${level}`,
|
| 69 |
-
`Duration: ${duration}`,
|
| 70 |
-
`Delivery: ${delivery}`,
|
| 71 |
-
`Language: ${language}`,
|
| 72 |
-
`Tone: ${tone}`,
|
| 73 |
-
`Depth: ${depth}`,
|
| 74 |
-
`Localization: ${localization}`,
|
| 75 |
-
`Export: ${exportFmt}`,
|
| 76 |
-
flags.length ? `Add-ons: ${flags.join(', ')}` : '',
|
| 77 |
-
notes ? `Notes: ${notes}` : ''
|
| 78 |
-
].filter(Boolean);
|
| 79 |
-
|
| 80 |
-
return `Please generate a complete course outline based on the following selections:\n\n${parts.join('\n')}`;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
$('#build').addEventListener('click', () => {
|
| 84 |
-
const prompt = buildUserPrompt();
|
| 85 |
-
if(!prompt) return;
|
| 86 |
-
out.textContent = prompt;
|
| 87 |
-
copyBtn.classList.remove('hidden');
|
| 88 |
-
copyOpenBtn.classList.remove('hidden');
|
| 89 |
-
});
|
| 90 |
-
|
| 91 |
-
document.addEventListener('keydown', e => {
|
| 92 |
-
if(e.key === 'Enter' && document.activeElement.id !== 'notes'){
|
| 93 |
-
e.preventDefault();
|
| 94 |
-
$('#build').click();
|
| 95 |
-
}
|
| 96 |
-
});
|
| 97 |
-
|
| 98 |
-
async function copyToClipboard(text){
|
| 99 |
-
try{
|
| 100 |
-
await navigator.clipboard.writeText(text);
|
| 101 |
-
return true;
|
| 102 |
-
}catch{
|
| 103 |
-
return false;
|
| 104 |
-
}
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
copyBtn.addEventListener('click', async () => {
|
| 108 |
-
const txt = out.textContent.trim();
|
| 109 |
-
if(!txt){ hint.textContent = 'Nothing to copy.'; return; }
|
| 110 |
-
hint.textContent = '';
|
| 111 |
-
copyBtn.disabled = true;
|
| 112 |
-
const ok = await copyToClipboard(txt);
|
| 113 |
-
copyBtn.textContent = ok ? 'Copied!' : 'Copy failed';
|
| 114 |
-
setTimeout(()=>{ copyBtn.textContent = 'Copy Prompt'; copyBtn.disabled = false; }, 1200);
|
| 115 |
-
});
|
| 116 |
-
|
| 117 |
-
copyOpenBtn.addEventListener('click', async () => {
|
| 118 |
-
const txt = out.textContent.trim();
|
| 119 |
-
if(!txt){ hint.textContent = 'Nothing to copy.'; return; }
|
| 120 |
-
hint.textContent = '';
|
| 121 |
-
copyOpenBtn.disabled = true;
|
| 122 |
-
|
| 123 |
-
const copied = await copyToClipboard(txt);
|
| 124 |
-
const w = window.open(GPT_URL, '_blank');
|
| 125 |
-
const opened = !!w;
|
| 126 |
-
|
| 127 |
-
copyOpenBtn.textContent = `${copied ? 'Copied' : 'Copy failed'} • ${opened ? 'Opening GPT…' : 'Open blocked'}`;
|
| 128 |
-
setTimeout(()=>{
|
| 129 |
-
copyOpenBtn.textContent = 'Copy & Paste in GPT';
|
| 130 |
-
copyOpenBtn.disabled = false;
|
| 131 |
-
}, 1400);
|
| 132 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|