forked from bdotdub/hummingbird
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweekly.js
37 lines (28 loc) · 1.12 KB
/
weekly.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
if(!Hummingbird) { Hummingbird = {}; }
Hummingbird.Weekly = {};
Hummingbird.Weekly.weekDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
Hummingbird.Weekly.init = function() {
var weekJson = "/week.json";
if(document.location.search.match(/use_prod/)) {
weekJson += "?use_prod";
}
$.getJSON(weekJson, function(data) {
var dayTemplate = $("#day_template");
var today = new Date();
today.setUTCHours(0); today.setUTCMinutes(0); today.setUTCSeconds(0); today.setUTCMilliseconds(0);
$.each(data, function() {
var day = new Date(this.day);
if(day.getTime() == today.getTime()) {
var weekDay = "Today";
} else {
var weekDay = Hummingbird.Weekly.weekDays[day.getUTCDay()];
}
var dateDiv = dayTemplate.clone().attr('id', 'date_' + day.getTime()).attr('style', '');
dateDiv.find('div.date_title').text(weekDay);
if(this.total) {
dateDiv.find('div.all_views').text(this.total.commify()).data('total', this.total);
}
dateDiv.appendTo('#days');
});
});
};