-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontPageSelector.js
41 lines (34 loc) · 1.14 KB
/
frontPageSelector.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
var staticViewEndpoint = require("./staticViewEndpoint.js");
var sales = staticViewEndpoint("sales/view.html", "sales/productData.json");
var downtime = staticViewEndpoint("downtime/view.html");
var prelaunch = staticViewEndpoint("prelaunch/view.html");
function frontPageSelector(req, res) {
return prelaunch(req, res);
if(req.query.forceState == "salesStarted") {
return sales(req, res);
}
if(req.query.forceState == "salesEnded") {
return downtime(req, res);
}
if(req.query.forceState == "prelaunch") {
return prelaunch(req, res);
}
var rn = new Date();
var humanMonth = rn.getMonth() + 1;
var humanDate = rn.getDate();
//If we're after sale ends
if(humanMonth >= 12 && humanDate >= 23) {
return downtime(req, res);
}
//If we're after sale starts
if(humanMonth >= 11) {
return sales(req, res);
}
//If we're in or later than september
if(humanMonth >= 9) {
return prelaunch(req, res);
}
//Otherwise (before september) we're in downtime
return downtime(req, res);
}
module.exports = frontPageSelector;