JSFiddle - React, Tailwind, and code Playground
by Ryan Brown
JavaScript
function decideSpecial(i) {
if (corequisitesMet(i)) {
addCourseCorequistesMet(i);
} else // Co-requisites are not met for course
{
addCourseCorequisitesNotMet(i);
}
}
function corequisitesMet(courseId) {
// Looks at a course and determines if the co-requisites are met
var coReqArray = courselist[parseInt(courseId)].CoReq;
if (coReqArray == null) {
return true;
}
var checked = true;
for (var i = 0; i < coReqArray.length; i++) {
if (!isTaken(coReqArray[i])) {
checked = false;
}
}
return checked;
}
function isTaken(coreq) {
// determines if a course
var taken = false;
for (var i = 0; i < courselist.length; i++) {
if ((courselist[i].Course == prereq) && (courselist[i].taken == true)) {
return true;
}
}
return false;
}
function addCourseCorequisitesMet(i) {
// Creates a div container for the course with ID to match the array index of the courselist
// appends the div to the center div list of all courses - not made draggable
var a = $('<div />', {
id: i.toString(),
class: 'classNotAvailable',
html: courselist[i].Course + " " + courselist[i].Name + String.fromCharCode(10) + " <br/> " + "<span class='tooltiptext'>" + courselist[i].details + "</span>",
});
$("#all").append(a);
}
function addCourseCorequistesNotMet(i) {
// Creates a div container for the course with ID to match the array index of the courselist
// appends the div to the center div list of all courses and makes it draggable
var a = $('<div />', {
id: i.toString(),
class: 'classAvailable',
html: courselist[i].Course + " " + courselist[i].Name + String.fromCharCode(10) + " <br/> " + "<span class='tooltiptext'>" + courselist[i].details + "</span>",
});
$("#all").append(a);
// Mak div draggable
$('#' + i).draggable({
start: function() {
startDrag = $(this).position();
}
});
}
function checkCorequisites() {
// Determines if pre-requisites are met and if so -...