-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfetchWeighting.js
40 lines (36 loc) · 1.07 KB
/
fetchWeighting.js
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
function fetchWeightingNames() {
tables = document.querySelectorAll("td.GrayDrawHeader");
assignmentType = tables[0].querySelectorAll("b");
category = [];
for (i = 0; i < assignmentType.length; i++) {
category[i] = assignmentType[i].innerHTML;
}
let index = category.indexOf("Weighted Grade");
split = category.slice(0, index);
return split;
}
function fetchWeightPercentages() {
len = fetchWeightingNames().length;
tables = document.querySelectorAll("td.GrayDrawHeader");
assignmentType = tables[0].querySelectorAll("td");
category = [];
for (i = 0; i < assignmentType.length; i++) {
category[i] = assignmentType[i].innerHTML;
}
let index = category.indexOf("<b>Weighted Grade</b>");
split = category.slice(index + 1, index + 1 + len)
return split;
}
function weightingObject() {
let percentages = fetchWeightPercentages();
let names = fetchWeightingNames();
let weighting = [];
for (i=0; i<names.length; i++) {
weighting[i] = {
category: names[i],
weight: percentages[i]
}
}
return weighting;
}
weightingObject();