Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
-
const GPT_URL = 'https://your-custom-gpt-url';
|
| 2 |
-
|
| 3 |
const $ = s => document.querySelector(s);
|
| 4 |
const $$ = s => Array.from(document.querySelectorAll(s));
|
| 5 |
|
| 6 |
const out = $('#out');
|
| 7 |
const hint = $('#hint');
|
| 8 |
-
const
|
|
|
|
|
|
|
| 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
|
| 15 |
-
const
|
| 16 |
-
$$('.toggles.multi .toggle').forEach(
|
| 17 |
-
|
| 18 |
-
obj[k] = b.getAttribute('aria-pressed') === 'true';
|
| 19 |
});
|
| 20 |
-
return
|
| 21 |
}
|
| 22 |
-
|
|
|
|
| 23 |
$$('.toggles').forEach(group=>{
|
| 24 |
group.addEventListener('click', e=>{
|
| 25 |
const btn = e.target.closest('.toggle');
|
|
@@ -30,15 +30,21 @@ function toggleBehavior(){
|
|
| 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',
|
| 34 |
}
|
| 35 |
});
|
| 36 |
});
|
| 37 |
}
|
| 38 |
-
|
| 39 |
|
| 40 |
-
function
|
| 41 |
const topic = $('#topic').value.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
const audience = getSingle('audience') || 'Students';
|
| 43 |
const level = getSingle('level') || 'Beginner';
|
| 44 |
const delivery = getSingle('delivery') || 'Online';
|
|
@@ -49,135 +55,43 @@ function buildPrompt(){
|
|
| 49 |
const localization = $('#localization').value.trim() || 'Auto';
|
| 50 |
const exportFmt = $('#export').value.trim() || 'PDF';
|
| 51 |
const notes = $('#notes').value.trim();
|
| 52 |
-
const add =
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
:
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
🌐 Language & Tone:
|
| 76 |
-
📌 ${langLine}
|
| 77 |
-
📌 Maintain a consistently ${tone.toLowerCase()} and motivational tone.
|
| 78 |
-
|
| 79 |
-
📦 Core Output Structure:
|
| 80 |
-
Every course must include:
|
| 81 |
-
|
| 82 |
-
📘 Course Title – Clear and topic-relevant
|
| 83 |
-
🎯 Course Objectives – Key learning goals in bullet format
|
| 84 |
-
📚 Lessons Outline – Numbered weekly or modular format, each with:
|
| 85 |
-
Complete lesson summary
|
| 86 |
-
Integrated ethical/moral training
|
| 87 |
-
2–4 recall questions (no answers)
|
| 88 |
-
1–2 open-ended prompts
|
| 89 |
-
1 real-life application scenario
|
| 90 |
-
📝 Practical Activities – Assignments or tasks per lesson
|
| 91 |
-
💡 Expected Outcomes – What learners will achieve
|
| 92 |
-
🧭 Ethical Integration – Values like honesty, responsibility, and respect
|
| 93 |
-
🎥 Video Lesson Support (if requested)
|
| 94 |
-
|
| 95 |
-
🎥 Video Lesson Support (requested): ${wantVideo}
|
| 96 |
-
If "Yes", for each lesson, include:
|
| 97 |
-
Video Title, Suggested Duration (5–10 min), Script Outline, Visual Slide Topics, Suggested Tools (OBS, VN, mic), Call-to-Action + link to next step.
|
| 98 |
-
|
| 99 |
-
🪄 If online and not mentioned:
|
| 100 |
-
"اگر آپ چاہیں تو اس کورس کے لیے ریکارڈڈ ویڈیو لیسنز بھی شامل کیے جا سکتے ہیں تاکہ سٹوڈنٹس بعد میں آسانی سے دوبارہ دیکھ سکیں۔ میں ویڈیو اسکرپٹس، سلائیڈ ٹاپکس اور ویڈیو پلاننگ میں مدد کر سکتا ہوں۔"
|
| 101 |
-
– Add a simple progression matrix showing skill build-up.
|
| 102 |
-
|
| 103 |
-
🔬 Research & Pedagogical Design:
|
| 104 |
-
Align with global learning science standards
|
| 105 |
-
Match complexity to user's cognitive level (${level})
|
| 106 |
-
Use clear, simple explanations; include analogies, short stories, modular steps when beneficial.
|
| 107 |
-
|
| 108 |
-
📊 Deliverables Format Summary:
|
| 109 |
-
Section Included
|
| 110 |
-
Title ✅
|
| 111 |
-
Objectives ✅
|
| 112 |
-
Lessons + Ethics + Recall + Prompts ✅
|
| 113 |
-
Assignments ✅
|
| 114 |
-
Outcomes ✅
|
| 115 |
-
Optional Video Content ${wantVideo === 'Yes' ? '✅' : '➖'}
|
| 116 |
-
Language Flexibility ✅
|
| 117 |
-
Real-Life Applications ✅
|
| 118 |
-
|
| 119 |
-
🧩 Adaptive & Advanced Features:
|
| 120 |
-
🔄 Adaptive Course Customization Logic:
|
| 121 |
-
Ask clarifying questions if the prompt is vague.
|
| 122 |
-
📊 Learner Assessment Module: ${wantAssess}
|
| 123 |
-
🧠 Bloom’s Taxonomy Mapping: ${wantBloom}
|
| 124 |
-
|
| 125 |
-
🌐 Cultural Localization:
|
| 126 |
-
Adapt tone and examples to: ${localization}
|
| 127 |
-
|
| 128 |
-
📂 Output Format Options:
|
| 129 |
-
Preferred Export: ${exportFmt}
|
| 130 |
-
|
| 131 |
-
🧠 Topic:
|
| 132 |
-
${topic}
|
| 133 |
-
|
| 134 |
-
👥 Audience: ${audience}
|
| 135 |
-
📈 Level: ${level}
|
| 136 |
-
🕒 Duration: ${duration}
|
| 137 |
-
🎓 Delivery: ${delivery}
|
| 138 |
-
📌 Depth: ${depth}
|
| 139 |
-
|
| 140 |
-
🗒️ Notes:
|
| 141 |
-
${notes || 'N/A'}
|
| 142 |
-
|
| 143 |
-
✅ Example Interaction:
|
| 144 |
-
If the user asks for a ${duration} ${delivery.toLowerCase()} course on "${topic}" for ${audience.toLowerCase()}, respond with the full structure above.
|
| 145 |
-
|
| 146 |
-
🤝 Confirmation & Feedback:
|
| 147 |
-
Always end with:
|
| 148 |
-
"Does this course outline align with your expectations, or would you like any adjustments?"
|
| 149 |
-
"Thank you for using CourseMaster AI GPT. If satisfied, please consider leaving a positive rating or feedback. Your response is highly appreciated."
|
| 150 |
-
|
| 151 |
-
⚠️ Behavior Control:
|
| 152 |
-
Use all elements naturally and selectively — avoid forced or unnecessary details.
|
| 153 |
-
Stay user-centered, respectful, and context-aware at all times.`;
|
| 154 |
-
|
| 155 |
-
return text + `\n\n— CourseMaster`;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
function typewriter(el, text){
|
| 159 |
-
el.textContent = '';
|
| 160 |
-
let i = 0;
|
| 161 |
-
const step = () => {
|
| 162 |
-
if(i < text.length){
|
| 163 |
-
el.textContent += text[i++];
|
| 164 |
-
requestAnimationFrame(step);
|
| 165 |
-
}
|
| 166 |
-
};
|
| 167 |
-
requestAnimationFrame(step);
|
| 168 |
}
|
| 169 |
|
| 170 |
-
$('#
|
| 171 |
-
const prompt =
|
| 172 |
if(!prompt) return;
|
| 173 |
-
|
| 174 |
-
|
|
|
|
| 175 |
});
|
| 176 |
|
| 177 |
document.addEventListener('keydown', e => {
|
| 178 |
if(e.key === 'Enter' && document.activeElement.id !== 'notes'){
|
| 179 |
e.preventDefault();
|
| 180 |
-
$('#
|
| 181 |
}
|
| 182 |
});
|
| 183 |
|
|
@@ -190,14 +104,29 @@ async function copyToClipboard(text){
|
|
| 190 |
}
|
| 191 |
}
|
| 192 |
|
| 193 |
-
|
| 194 |
const txt = out.textContent.trim();
|
| 195 |
if(!txt){ hint.textContent = 'Nothing to copy.'; return; }
|
| 196 |
hint.textContent = '';
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
const copied = await copyToClipboard(txt);
|
| 199 |
const w = window.open(GPT_URL, '_blank');
|
| 200 |
const opened = !!w;
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
});
|
|
|
|
|
|
|
|
|
|
| 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');
|
|
|
|
| 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';
|
|
|
|
| 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 |
|
|
|
|
| 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 |
});
|