diff --git a/ProgramFiles/CourseSelector.js b/ProgramFiles/CourseSelector.js old mode 100644 new mode 100755 index 1dcb724..fecec51 --- a/ProgramFiles/CourseSelector.js +++ b/ProgramFiles/CourseSelector.js @@ -8,6 +8,7 @@ var offBlockNum; var blockArrays = []; var schedules = []; var error = false; +var numberOfSelectedClasses = 0; function courseCheckboxes() { for (var a = 0; a < deptTitles.length; a++) { @@ -17,12 +18,13 @@ function courseCheckboxes() { //document.body.appendChild(header); document.getElementById("mainStuff").appendChild(header); for (var b = 0; b < allCourses.length; b++) { - console.log("hey"); - console.log(allCourses[b].dept); + //console.log("hey"); + //console.log(allCourses[b].dept); if (allCourses[b].dept == a + 1) { var cb = document.createElement("input"); cb.type = "checkbox"; cb.id = allCourses[b].title; + cb.setAttribute("onclick", "checkboxPressed(this)") //cb.class = "page0"; pageElements[0].push(cb); //document.body.appendChild(cb); @@ -62,6 +64,8 @@ function getSelectedCourses() { //TODO: try again button at end of schedules //TODO: error code if schedules is empty after findGoodSchedules //TODO: maybe add in more complex error codes later (like what u were working on in beginning of generateschedules) + //console.log("TEST") + //console.log(allCourses[0]) for (var a = 0; a < allCourses.length; a++) { for (var b = 0; b < checkedBoxes.length; b++) { if (allCourses[a].title == checkedBoxes[b].id) { @@ -137,8 +141,11 @@ function nextPage() { generateSchedules(); findGoodSchedules(); displaySchedules(); - document.body.removeChild(document.getElementById("nextButton")); - //tryAgainButton(); + document.getElementById("nextButton").removeChild(document.getElementById("buttonItself")); + //document.getElementById("nextButton").selected = false + //document.getElementById("nextButton").setAttribute("onclick", "reloadPage()") + //document.getElementById("nextButton").disabled = false + tryAgainButton(); removeStuff(page); break; } @@ -171,9 +178,11 @@ function errorCode(message) { } function tryAgainButton() { - document.getElementById("buttonItself").innerHTML = "Try Again"; - document.getElementById("buttonItself").onClick = "Try Again"; - window.location.href = 'course-selector.html'; + var button = document.createElement("button"); + button.innerHTML = "Try Again"; + button.setAttribute("onclick", "reloadPage()"); + document.getElementById("nextButton").appendChild(button); + //window.location.href = 'course-selector.html'; } function findGoodSchedules() { @@ -205,6 +214,7 @@ function displaySchedules() { for (var a = 0; a < schedules.length; a++) { makeHTML("h3", "Schedule " + (a + 1) + ":"); for (var b = 0; b < schedules[a].length; b++) { + var teachersList = "" var teachersArr = schedules[a][b].getTeachersForBlock(b + 1); if (teachersArr.length == 1) { teachersList = teachersArr[0]; @@ -217,6 +227,7 @@ function displaySchedules() { } } } + //TODO maybe instead of getting rid of next button make it be a try again or whatever button and it reloads the page?? (like just calls up the html page over again??) function makeHTML(type, words) { var elem = document.createElement(type); @@ -262,12 +273,12 @@ function generateSchedules() { for (var b in zeroes) { if (singles.length > 1 && b == singles.length - 1) { message += " and"; - } + } messsage += singles[b].title; } message += (zeroes.length == 1 ? " doesn't" : " don't") + " have any possible classes to fill " + (zeroes.length == 1 ? "it " : "them ") + ". Try choosing a broader range of teachers, or putting " + (zeroes.length == 1 ? "this block as an option " : "these blocks as options ") + "for off blocks."; break; - } + } }*/ for (var a in blockArrays[0]) { for (var b in blockArrays[1]) { @@ -327,7 +338,7 @@ function makeOffBlocks() { } blockChoices.push(singleBlock); } - + for (var a = 0; a < offBlockNum; a++) { let ob = new Course("OFF", 9, ["N/A"], [blockChoices[a]]); selectedCourses.push(ob); @@ -340,7 +351,7 @@ function getSelectedTeacherBlocks() { checkedBoxes.push(boxes2[a]); } } - + for (var a = 0; a < selectedCourses.length; a++) { var teacherNameIndexes = []; for (var b = 0; b < selectedCourses[a].teacherNames.length; b++) { @@ -358,7 +369,7 @@ function getSelectedTeacherBlocks() { } } } -} +} function inArray(obj, arr) { for (var a in arr) { @@ -373,4 +384,47 @@ function removeStuff(page) { for (var a = 0; a < pageElements[page].length; a++) { document.getElementById(pageElements[page][a].parentElement.id).removeChild(pageElements[page][a]); } -} \ No newline at end of file +} + +function checkboxPressed(checkbox) +{ + if (checkbox.checked) + { + numberOfSelectedClasses += 1 + + if (numberOfSelectedClasses == 8) + { + for (cb in boxes1) + { + if (!boxes1[cb].checked) + { + boxes1[cb].disabled = true + } + } + } + } + else + { + numberOfSelectedClasses -= 1 + + if (numberOfSelectedClasses == 7) + { + for (cb in boxes1) + { + if (!boxes1[cb].checked) + { + boxes1[cb].disabled = false + } + } + } + } +} + +function reloadPage() +{ + //if (page != 3) { return } + + var div = document.createElement('div') + div.innerHTML = '' + document.body.appendChild(div) +} diff --git a/ProgramFiles/course-selector.html b/ProgramFiles/course-selector.html old mode 100644 new mode 100755 index e985e98..a10c72b --- a/ProgramFiles/course-selector.html +++ b/ProgramFiles/course-selector.html @@ -18,12 +18,12 @@

Choose Your Classes

- +

- +
- \ No newline at end of file + diff --git a/ProgramFiles/packages.config b/ProgramFiles/packages.config deleted file mode 100644 index 6ef4c48..0000000 --- a/ProgramFiles/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/ProgramFiles/storeroom.js b/ProgramFiles/storeroom.js old mode 100644 new mode 100755 index 7ec4d05..a1c3270 --- a/ProgramFiles/storeroom.js +++ b/ProgramFiles/storeroom.js @@ -78,7 +78,10 @@ function processData() { currentClass = "none"; } } + console.log(allCourses); + + courseCheckboxes() } function removeDuplicates(arr) { @@ -127,4 +130,4 @@ function inArray(obj, arr) { } } return false; -} \ No newline at end of file +}