Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 67 additions & 13 deletions ProgramFiles/CourseSelector.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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];
Expand All @@ -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);
Expand Down Expand Up @@ -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]) {
Expand Down Expand Up @@ -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);
Expand All @@ -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++) {
Expand All @@ -358,7 +369,7 @@ function getSelectedTeacherBlocks() {
}
}
}
}
}

function inArray(obj, arr) {
for (var a in arr) {
Expand All @@ -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]);
}
}
}

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 = '<meta http-equiv="refresh" content="0;url=./course-selector.html">'
document.body.appendChild(div)
}
6 changes: 3 additions & 3 deletions ProgramFiles/course-selector.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<div id ="mainStuff">
<h1 id="header">Choose Your Classes</h1>
</div>
<script>courseCheckboxes();</script>
<script>//courseCheckboxes();</script>
<div id="error"></div>
<div id="nextButton">
<br>
<button id ="buttonItself "type="button" onclick="nextPage()">Next</button>
<button id="buttonItself" type="button" onclick="nextPage()">Next</button>
</div>
<!window.location.href='teacher-selector.html'>
</body>
</html>
</html>
4 changes: 0 additions & 4 deletions ProgramFiles/packages.config

This file was deleted.

5 changes: 4 additions & 1 deletion ProgramFiles/storeroom.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ function processData() {
currentClass = "none";
}
}

console.log(allCourses);

courseCheckboxes()
}

function removeDuplicates(arr) {
Expand Down Expand Up @@ -127,4 +130,4 @@ function inArray(obj, arr) {
}
}
return false;
}
}