-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
203 lines (154 loc) · 5.24 KB
/
index.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<head>
<title>SAJE Schedule Compiler</title>
<link rel="stylesheet" href="jquery-ui-1.12.1/jquery-ui.css">
<style>/*CSS portion*/
body{
text-align: center;
font-size: 14px;
font-family: Arial;
}
#findbutton {
background-color: #00B4CC;
width: 25%;
border-radius: 5px 0px 5px 5px;
float: left;
margin: auto;
padding: 5px;
cursor: pointer;
transition: 200ms;
color: white;
}
#findbutton:hover {
width: 30%;
}
.searchbox {
width: 30%;
position: relative;
display: inline-block;
float:left;
}
.searchTerm {
float: center;
width: 100%;
border: 3px solid #00B4CC;
padding: 15px;
height: 20px;
border-radius: 5px;
outline: none;
color: #9DBFAF;
display:inline-block;
position: relative;
float:left;
padding:20px;
}
.searchTerm:focus{
background-color: #dfe9eb;
}
/*Resize the wrap to see the search bar change!
.wrap{
width: 50%;
position: relative;
top: 20%;
left: 50%;
transform: translate(-50%, -50%);
}*/
/*end CSS portion*/
</style>
</head>
<body>
<p></p>
<p><p>Please input your desired classes, one in each box.</p>
<div class="wrap">
<div class="searchbox">
<div class="ui-widget">
<input id ="search1" type="text" class="searchTerm" placeholder="First Class">
</div>
<div class="ui-widget">
<input id="search2" type="text" class="searchTerm" placeholder="Second Class">
</div>
<div class="ui-widget">
<input id="search3" type="text" class="searchTerm" placeholder="Third Class">
</div>
<div class="ui-widget">
<input id="search4" type="text" class="searchTerm" placeholder="Fourth Class">
</div>
<div class="ui-widget">
<input id="search5" type="text" class="searchTerm" placeholder="Fifth Class">
</div>
<div class="ui-widget">
<input id="search6" type="text" class="searchTerm" placeholder="Sixth Class">
</div>
<div class="ui-widget">
<input id="search7" type="text" class="searchTerm" placeholder="Seventh Class">
</div>
<div class="ui-widget">
<input id="search8" type="text" class="searchTerm" placeholder="Eighth Class">
</div>
<div id="findbutton" onclick="find()">Find your schedules</button>
</div>
</div>
<script src="jquery-3.1.0.min.js"></script>
<script src="jquery-ui-1.12.1/jquery-ui.min.js"></script>
<script src="classes2018f.js"></script>
<script src="saje.js"></script>
<script src="mutate.js"></script>
<script src="skyeFilter.js"></script>
<script src="cycle.js"></script>
<script type="text/javascript">
var classList = sortClasses(mutate(classesLong));
var courseNames = [];
for (var course of classList) {
courseNames.push(course.courseTitle);
}
$(".searchTerm").autocomplete({
source: courseNames
});
function findClassByName(name) {
for (var course of classList) {
if (course.courseTitle === name) {
return course;
}
}
return null;
}
var foundpaths = [];
function find() {
var classesToSchedule = [];
for (var i = 1; i <= 8; i++) {
var course = findClassByName($("#search" + i).val());
if (course) {
classesToSchedule.push(course);
}
}
console.log("Classes to schedule", classesToSchedule);
console.log("Running...");
var combos = 0;
if (classesToSchedule.length > 0) {
for (var s of classesToSchedule[0].sections) {
combos += findSchedules([], s, 0,
classesToSchedule, foundpaths);
}
}
console.log("Done.");
console.log("foundpaths", foundpaths);
if (foundpaths.length === 0) {
$("body").html("Sorry, no schedules were found with no conflicts.");
} else {
$("link").remove();
$("style").remove();
$("body").html(combos + " schedules found.<ul id=\"sched-list\"></ul>");
for (var i = 1; i <= foundpaths.length; i++) {
$("#sched-list").append(
"<li style=\"cursor: pointer;\" onclick=\"displaySchedule(" +
i + ")\">Schedule " + i + "</li>");
}
}
}
function displaySchedule(i) {
var schedule = foundpaths[i - 1];
console.log("schedule selected", schedule);
window.location = "schedule.html?s=" + encodeURIComponent(
JSON.stringify(JSON.decycle(schedule)));
}
</script>
</body>