-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavaScript.js
More file actions
executable file
·129 lines (100 loc) · 3.15 KB
/
javaScript.js
File metadata and controls
executable file
·129 lines (100 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
var moduleLimit = 6;
var isAllowed = true;
function allowDrop(ev)
{
ev.preventDefault();
}
function drag(ev,id)
{
hideInfo(id);
ev.dataTransfer.setData("text", ev.target.id);
ev.dataTransfer.setData("id", id);
}
function dontAllowDrop(ev)
{
// var x = document.getElementsByClassName("moduleitem");
window.alert("You can't do that");
ev.preventDefault();
isAllowed = false;
}
function drop(ev,id)
{
if (isAllowed==false)
{
isAllowed = true;
return false;
}
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
var id = ev.dataTransfer.getData("id");
document.getElementById(id).style.padding = "10px 10px";
ev.target.appendChild(document.getElementById(data));
hideInfo(id);
update();
}
function setVisible()
{
if(document.getElementById("With_Management").checked == true)
{
document.getElementById("6SSMN339").style.display = "block";
document.getElementById("6SSMN325").style.display = "block";
moduleLimit = 4;
}
else
{
document.getElementById("6SSMN339").style.display = "none";
document.getElementById("6SSMN325").style.display = "none";
moduleLimit = 6;
}
}
function getInfo(moduleID)
{
// we want to have a variable that will store the id of the module that has been clicked ( to show the info) and when
// another one is clicked it should close the info of that module and display the one that is being clicked
// document.getElementById(moduleID + "Info").style.display = "inline";
document.getElementById(moduleID+"Info").style.visibility = "visible";
document.getElementById(moduleID+"Info").style.display = "inline";
window.scroll(0,findPos(document.getElementById(moduleID+"Info")));
}
function hideInfo(moduleID)
{
document.getElementById(moduleID+"Info").style.display = "none";
}
function update()
{
var modulesSelected = document.getElementById("table2").children;
var moduleCount = modulesSelected.length - 3;
var output = "Optional modules selected: " + moduleCount + '\n';
if (moduleCount > moduleLimit) {
output += "ERROR: You can't have that many modules!" + '\n';
}
// Each module in the HTML needs either a "sem1" or "sem2" class, depending on which semester it is taken, in order for this code to work
var sem1Count = 0;
var sem1Modules = document.querySelectorAll('li.sem1');
for (var i = 0; i < sem1Modules.length; i++)
{
for (var j = 2; j < modulesSelected.length; j++)
{
if (sem1Modules[i].id === modulesSelected[j].id) {
sem1Count++;
}
}
}
output += "Semester 1 modules: " + sem1Count + '\n';
if (sem1Count > moduleLimit / 2) {
output += "ERROR: Too many modules selected for semester 1!" + '\n';
}
var sem2Count = moduleCount - sem1Count;
output += "Semester 2 modules: " + sem2Count + '\n';
if (sem2Count > moduleLimit / 2) {
output += "ERROR: Too many modules selected for semester 2!" + '\n';
}
window.alert(output);
}
function autoScroll(moduleID)
{
if (moduleID == "6CCS3TSP")
{
document.getElementById(moduleID+'Info').scollIntoView();
}
}