Alicia1908/high-school-planner-pro
0
1document.addEventListener('DOMContentLoaded', function() {2 // Initialize the plan table3 const grades = [9, 10, 11, 12];4 const options = {5 ela: ["Literature & Composition 1","Literature & Composition 2","Literature & Composition 3","Literature & Composition 4","AP Seminar","AP English Language Arts","AP English Literature","Dual Enrollment English"],6 math: ["Algebra C&C","Geometry C&C","Advanced Algebra C&C","College Readiness Math","Statistical Reasoning","Precalculus","AP Precal & Advanced Algebra","AP Calculus AB","Dual Enrollment Math"],7 science: ["Biology","Physical Science Physics","Environmental Science","Chemistry","Forensics","Earth Systems","Physics","AP Physics","AP Biology","Dual Enrollment Science"],8 ss: ["American Government","AP Govt/Civics","World History","US History","Personal Finance & Economics","AP World History","AP Macroeconomics","AP Microeconomics"],9 ctae: ["Intro to Business & Tech","Business Technology","Business Communications","Food Nutrition & Wellness","Food for Life","Food Science","Basic Agricultural Science","General Horticulture and Plant Science","Animal Science","Floral Design and Mgmt","Introduction to Software","Introduction to Hardware Tech","Digital Design","Web Design","Marketing Principles","Marketing Management","Marketing Entrepreneurship","Found of Engineering/Tech","Engineering Concepts","Engineering Applications","JROTC","Intro to Law and Public Safety","Criminal Justice Essentials","Criminal Investigations","Visual Arts/Comp 1","Visual Arts/Comp 2","Vis Arts/Draw & Paint 1","Vis Arts/Ceramics 1","Vis Arts/Ceramics 2","Vis Arts/Sculpture","AP Art & Des: Drawing","AP Art & Des: 2D","Dance","Theatre Arts/Fundamentals 1","Theatre Arts/Acting","Spanish 1","Spanish 2","French 1","French 2"],10 electives: ["Sociology","Psychology","Ethnic Studies","Team Sports Intro","Team Sports Interm","Intro to African American Studies","Current Events","Weight Lifting","Body Sculpting","Mythology","Journalism 1","Journalism 2","Oral/Written Comm (Speech)"]11 };12 13 const tableBody = document.getElementById('plan-table');14 15 grades.forEach(g => {16 const row = document.createElement('tr');17 row.className = 'hover:bg-gray-50';18 row.innerHTML = `19 <td class="p-3 border-b border-gray-200 font-medium">${g}th Grade</td>20 <td class="p-3 border-b border-gray-200">21 <select id="ela_${g}" class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></select>22 </td>23 <td class="p-3 border-b border-gray-200">24 <select id="math_${g}" class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></select>25 </td>26 <td class="p-3 border-b border-gray-200">27 <select id="sci_${g}" onchange="toggleSciExtra(this,'sci_extra_${g}')" class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></select>28 <input id="sci_extra_${g}" class="science-extra w-full p-2 mt-1 border border-gray-300 rounded-md focus:ring-primary focus:border-primary" type="text" placeholder="Enter Dual Enrollment Science course"/>29 </td>30 <td class="p-3 border-b border-gray-200">31 <select id="ss_${g}" class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></select>32 <div class="half-credit">33 <input type="checkbox" id="ss_${g}_half" onchange="recalc()" class="rounded text-primary focus:ring-primary"/>34 <label for="ss_${g}_half">0.5 credit</label>35 </div>36 </td>37 <td class="p-3 border-b border-gray-200">38 <select id="ctae_${g}" class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></select>39 </td>40 <td class="p-3 border-b border-gray-200">41 <select id="el1_${g}" class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></select>42 <div class="half-credit">43 <input type="checkbox" id="el1_${g}_half" onchange="recalc()" class="rounded text-primary focus:ring-primary"/>44 <label for="el1_${g}_half">0.5 credit</label>45 </div>46 </td>47 <td class="p-3 border-b border-gray-200">48 <select id="el2_${g}" class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></select>49 <div class="half-credit">50 <input type="checkbox" id="el2_${g}_half" onchange="recalc()" class="rounded text-primary focus:ring-primary"/>51 <label for="el2_${g}_half">0.5 credit</label>52 </div>53 </td>54 <td class="p-3 border-b border-gray-200">55 <textarea id="notes_${g}" placeholder="Notes..." class="w-full p-2 border border-gray-300 rounded-md focus:ring-primary focus:border-primary"></textarea>56 </td>57 `;58 tableBody.appendChild(row);59 });60 61 // Populate dropdowns62 populate();63});64 65// Helper functions66function id(x) { return document.getElementById(x); }67function val(x) { return id(x)?.value || ''; }68function chk(x) { return id(x)?.checked; }69 70function fill(id, arr) {71 const s = document.getElementById(id);72 s.innerHTML = '<option value="">Select...</option>' + arr.map(v => `<option>${v}</option>`).join('');73 s.addEventListener('change', recalc);74}75 76function populate() {77 const grades = [9, 10, 11, 12];78 const options = {79 ela: ["Literature & Composition 1","Literature & Composition 2","Literature & Composition 3","Literature & Composition 4","AP Seminar","AP English Language Arts","AP English Literature","Dual Enrollment English"],80 math: ["Algebra C&C","Geometry C&C","Advanced Algebra C&C","College Readiness Math","Statistical Reasoning","Precalculus","AP Precal & Advanced Algebra","AP Calculus AB","Dual Enrollment Math"],81 science: ["Biology","Physical Science Physics","Environmental Science","Chemistry","Forensics","Earth Systems","Physics","AP Physics","AP Biology","Dual Enrollment Science"],82 ss: ["American Government","AP Govt/Civics","World History","US History","Personal Finance & Economics","AP World History","AP Macroeconomics","AP Microeconomics"],83 ctae: ["Intro to Business & Tech","Business Technology","Business Communications","Food Nutrition & Wellness","Food for Life","Food Science","Basic Agricultural Science","General Horticulture and Plant Science","Animal Science","Floral Design and Mgmt","Introduction to Software","Introduction to Hardware Tech","Digital Design","Web Design","Marketing Principles","Marketing Management","Marketing Entrepreneurship","Found of Engineering/Tech","Engineering Concepts","Engineering Applications","JROTC","Intro to Law and Public Safety","Criminal Justice Essentials","Criminal Investigations","Visual Arts/Comp 1","Visual Arts/Comp 2","Vis Arts/Draw & Paint 1","Vis Arts/Ceramics 1","Vis Arts/Ceramics 2","Vis Arts/Sculpture","AP Art & Des: Drawing","AP Art & Des: 2D","Dance","Theatre Arts/Fundamentals 1","Theatre Arts/Acting","Spanish 1","Spanish 2","French 1","French 2"],84 electives: ["Sociology","Psychology","Ethnic Studies","Team Sports Intro","Team Sports Interm","Intro to African American Studies","Current Events","Weight Lifting","Body Sculpting","Mythology","Journalism 1","Journalism 2","Oral/Written Comm (Speech)"]85 };86 87 grades.forEach(g => {88 fill('ela_' + g, options.ela);89 fill('math_' + g, options.math);90 fill('sci_' + g, options.science);91 fill('ss_' + g, options.ss);92 fill('ctae_' + g, options.ctae);93 fill('el1_' + g, options.electives);94 fill('el2_' + g, options.electives);95 });96 recalc();97}98 99function getCredit(v, h) { return v ? (h ? 0.5 : 1) : 0; }100 101function recalc() {102 const grades = [9, 10, 11, 12];103 let tE = 0, tM = 0, tS = 0, tSS = 0, tC = 0, tEl = 0;104 105 grades.forEach(g => {106 tE += getCredit(val('ela_' + g));107 tM += getCredit(val('math_' + g));108 tS += getCredit(val('sci_' + g));109 tSS += getCredit(val('ss_' + g), chk('ss_' + g + '_half'));110 tC += getCredit(val('ctae_' + g));111 tEl += getCredit(val('el1_' + g), chk('el1_' + g + '_half')) + getCredit(val('el2_' + g), chk('el2_' + g + '_half'));112 });113 114 const T = tE + tM + tS + tSS + tC + tEl;115 116 id('t_ela').textContent = tE.toFixed(1);117 id('t_math').textContent = tM.toFixed(1);118 id('t_sci').textContent = tS.toFixed(1);119 id('t_ss').textContent = tSS.toFixed(1);120 id('t_ctae').textContent = tC.toFixed(1);121 id('t_elec').textContent = tEl.toFixed(1);122 id('t_total').textContent = T.toFixed(1);123}124 125function toggleSciExtra(s, id2) {126 id(id2).style.display = (s.value === 'Dual Enrollment Science') ? 'block' : 'none';127 recalc();128}129 130// Save/Load functionality131function savePlan() {132 const plan = {};133 const grades = [9, 10, 11, 12];134 135 grades.forEach(g => {136 plan[`ela_${g}`] = val(`ela_${g}`);137 plan[`math_${g}`] = val(`math_${g}`);138 plan[`sci_${g}`] = val(`sci_${g}`);139 plan[`sci_extra_${g}`] = val(`sci_extra_${g}`);140 plan[`ss_${g}`] = val(`ss_${g}`);141 plan[`ss_${g}_half`] = chk(`ss_${g}_half`);142 plan[`ctae_${g}`] = val(`ctae_${g}`);143 plan[`el1_${g}`] = val(`el1_${g}`);144 plan[`el1_${g}_half`] = chk(`el1_${g}_half`);145 plan[`el2_${g}`] = val(`el2_${g}`);146 plan[`el2_${g}_half`] = chk(`el2_${g}_half`);147 plan[`notes_${g}`] = val(`notes_${g}`);148 });149 150 plan['chk_student'] = chk('chk_student');151 plan['chk_counselor'] = chk('chk_counselor');152 153 localStorage.setItem('highSchoolPlan', JSON.stringify(plan));154 alert('Plan saved successfully!');155}156 157function loadPlan() {158 const savedPlan = localStorage.getItem('highSchoolPlan');159 if (!savedPlan) {160 alert('No saved plan found.');161 return;162 }163 164 const plan = JSON.parse(savedPlan);165 const grades = [9, 10, 11, 12];166 167 grades.forEach(g => {168 if (plan[`ela_${g}`]) id(`ela_${g}`).value = plan[`ela_${g}`];169 if (plan[`math_${g}`]) id(`math_${g}`).value = plan[`math_${g}`];170 if (plan[`sci_${g}`]) id(`sci_${g}`).value = plan[`sci_${g}`];171 if (plan[`sci_extra_${g}`]) id(`sci_extra_${g}`).value = plan[`sci_extra_${g}`];172 if (plan[`ss_${g}`]) id(`ss_${g}`).value = plan[`ss_${g}`];173 id(`ss_${g}_half`).checked = plan[`ss_${g}_half`] || false;174 if (plan[`ctae_${g}`]) id(`ctae_${g}`).value = plan[`ctae_${g}`];175 if (plan[`el1_${g}`]) id(`el1_${g}`).value = plan[`el1_${g}`];176 id(`el1_${g}_half`).checked = plan[`el1_${g}_half`] || false;177 if (plan[`el2_${g}`]) id(`el2_${g}`).value = plan[`el2_${g}`];178 id(`el2_${g}_half`).checked = plan[`el2_${g}_half`] || false;179 if (plan[`notes_${g}`]) id(`notes_${g}`).value = plan[`notes_${g}`];180 });181 182 id('chk_student').checked = plan['chk_student'] || false;183 id('chk_counselor').checked = plan['chk_counselor'] || false;184 185 // Update science extra fields visibility186 grades.forEach(g => {187 toggleSciExtra(id(`sci_${g}`), `sci_extra_${g}`);188 });189 190 recalc();191 alert('Plan loaded successfully!');192}193 194function clearPlan() {195 if (confirm('Are you sure you want to clear all data? This cannot be undone.')) {196 localStorage.removeItem('highSchoolPlan');197 populate();198 document.querySelectorAll('textarea').forEach(t => t.value = '');199 document.querySelectorAll('input[type="checkbox"]').forEach(c => c.checked = false);200 recalc();201 }202}203 204// Expose functions to global scope for HTML onclick205window.savePlan = savePlan;206window.loadPlan = loadPlan;207window.clearPlan = clearPlan;208window.toggleSciExtra = toggleSciExtra;209window.recalc = recalc;