-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduler.js
74 lines (56 loc) · 2.39 KB
/
scheduler.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
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
var page = require('webpage').create();
var system = require('system');
var args = system.args;
var url = String(args[1]);
page.open(url,
function(status) {
if (status == "success") {
window.setTimeout(function() {
page.render('confirm.png');
//convert content to html and add to DOM
var dummy = document.createElement('html');
dummy.innerHTML = page.content;
//will hold html elements from table
var tableArr = [];
//will hold boundaries for comparison
var boundaryArr = [];
//get each day
days = dummy.getElementsByClassName('wk-day-body');
for (var i = 0; i < days.length; i++) {
var tableRow = [];
for (var j = 0; j < days[i].childNodes.length; j++) {
var child = days[i].childNodes[j];
if (child.className == "course-box") {
tableRow.push(child);
}
}
tableArr.push(tableRow);
}
//account for row of labels
tableArr.shift();
//loop through arr and calculate heights
for (var col = 0; col < tableArr.length; col++) {
var boundaryRow = [];
for (var row = 0; row < tableArr[col].length; row++) {
var elem = tableArr[col][row].style;
var height = parseFloat(elem.getPropertyValue('height'));
var top = parseFloat(elem.getPropertyValue('top'));
var bottom = top + height;
boundaryRow.push([top.toFixed(2), bottom.toFixed(2)]);
if (row < tableArr[col].length - 1) {
boundaryRow.push(":");
}
}
boundaryArr.push(boundaryRow);
if (col < tableArr.length - 1) {
boundaryArr.push("|");
}
}
console.log(boundaryArr);
phantom.exit();
}, 2000);
} else {
console.log("Error occurred.... idk what happened lol");
phantom.exit();
}
});