-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphantom.js
More file actions
55 lines (53 loc) · 2.57 KB
/
phantom.js
File metadata and controls
55 lines (53 loc) · 2.57 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
var page = require('webpage').create();
var system = require('system');
var url = system.args[1];
var meal = system.args[2];
var save = system.args[3];
page.viewportSize = {width: 390, height: 2500};
page.open(url, function(status) {
if(save == 'seasons') page.render('/root/dining/public/seasons.png');
if(save == 'conversations') page.render('/root/dining/public/conversations.png');
if(save == 'udm') page.render('/root/dining/public/udm.png');
if(save == 'storms') page.render('/root/dining/public/storms.png');
var closed = page.evaluate(function() {
return document.querySelectorAll(".event-header").length;
});
if(closed < 1) {
console.log("---");
phantom.exit();
}
var top, bottom;
if(meal == 0) {
top = page.evaluate(function() {
return document.querySelectorAll(".event-header")[0].getBoundingClientRect().top;
});
bottom = page.evaluate(function() {
return document.querySelectorAll(".event-header")[1].getBoundingClientRect().top;
});
} else if(meal == 1) {
top = page.evaluate(function() {
var check = document.querySelectorAll(".event-header").length;
if(check == 2) return document.querySelectorAll(".event-header")[0].getBoundingClientRect().top;
else return document.querySelectorAll(".event-header")[1].getBoundingClientRect().top;
});
bottom = page.evaluate(function() {
var check = document.querySelectorAll(".event-header").length;
if(check == 2) return document.querySelectorAll(".event-header")[1].getBoundingClientRect().top;
else return document.querySelectorAll(".event-header")[2].getBoundingClientRect().top;
});
} else {
top = page.evaluate(function() {
var check = document.querySelectorAll(".event-header").length;
if(check == 1) return document.querySelectorAll(".event-header")[0].getBoundingClientRect().top;
if(check == 2) return document.querySelectorAll(".event-header")[1].getBoundingClientRect().top;
else return document.querySelectorAll(".event-header")[2].getBoundingClientRect().top;
});
bottom = page.evaluate(function() {
var check = document.querySelectorAll(".event-header").length;
if(check > 3) return document.querySelectorAll(".event-header")[3].getBoundingClientRect().top;
else return document.querySelectorAll(".legend")[0].getBoundingClientRect().top;
});
}
console.log(top + "---" + bottom);
phantom.exit();
});