-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (47 loc) · 1.97 KB
/
index.html
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
<html ng-app="app">
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.js"></script>
</head>
<body>
<pre ng-controller="YearWeeks.init">
{{YearWeeks.content}}
</pre>
<script>
//http://stackoverflow.com/questions/25679182/angular-1-3-cant-find-the-controller-function
angular.module('app', []).config(['$controllerProvider', function($controllerProvider) {
$controllerProvider.allowGlobals && $controllerProvider.allowGlobals();
}]);
//
(function(){
var YearWeeks = window.YearWeeks = {
init : function($scope, $filter){
$scope.YearWeeks = window.YearWeeks;
var $date = $filter('date'), out = ["\n"];
// Normally
var today = new Date();
var monday = new Date(today.getTime() - (86400000 * (today.getDay() - 1)));
var startDate = new Date(monday), curMS = +(startDate);
var lastMonth, lastYear;
for(var i = 0; i < 62; ++i){
var date = new Date(curMS), weekEndMS = curMS + 86400000 * 6, weekEndDate = new Date(weekEndMS);
var month = date.getMonth() + 1, year = date.getFullYear();
// Add "◆yyyy年MM月" line beteween weeks if neccessary. eg: "◆2014年11月"
if(lastMonth != month ){
var format = ["◆", year != lastYear ? "yyyy年" : "", "MM月", (month-1)%3 == 0 ? "◆Q" + (month+2)/3 + "======" : "" ];
out.push($date(date, format.join("")), "\n");
}
lastMonth = month, lastYear = year;
// Output format week, eg: "48[24~30],"
out.push($date(date, "ww[dd~") + $date(weekEndDate, "dd],"), "\n");
// Go next week
curMS += 86400000 * 7;
}
YearWeeks.content = out.join("");
}
}
})();
</script>
</body>
</html>