-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
100 lines (92 loc) · 3.37 KB
/
index.php
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Calender Auto</title>
<script type="text/javascript" src="script/jquery-1.7.1.js"></script>
<script type="text/javascript">
var calNum, calToday;
/**
* Initialize interactive actions.
*/
function initAct(){
$('.close').click(function(){
$('.mask').hide();
});
$('td.active').click(function(){
$('.mask').show();
$('.dialog > h2').text('Date selected ' + $(this).data('value'));
});
$('.info').click(function(){
alert('haha');
return false;
});
// Today button state
if(calToday == calNum){
$('button#cal-today').attr('disabled','');
} else {
$('button#cal-today').removeAttr('disabled');
}
};
/**
* Load calender.
* @param nav "prev" or "next"
* @param nw cal current date
*/
function loadCal(nav,nw){
$.get('ajax.php', {action:'loadcal', calnav:nav, now:nw}, function(data){
$('.cal-menu span').text(data.title);
$('div#cal-struct').html(data.table);
calNum = data.numb;
if(!calToday){calToday = calNum;}
loadEvent(calNum);
}, 'json');
};
/**
*
*/
function loadEvent(date){
console.debug(this);
$.getJSON('ajax.php', {action: 'get-data', now:date}, function(data){
$.each(data, function(key,value){
$('td#'+key).append('<div class=info>'+value.title+'</div>');
});
});
initAct();
};
$(document).ready(function(){
// Load calender
loadCal();
// Load next month
$('button#cal-next').click(function(){
loadCal('next', calNum);
});
$('button#cal-prev').click(function(){
loadCal('prev', calNum);
});
$('button#cal-today').click(function(){
loadCal('today', calToday);
});
});
</script>
<link type="text/css" rel="stylesheet" href="style/calender.css" />
</head>
<body>
<div class="mask">
<div class="dialog">
<div class="close"></div>
<h2>Form will go here</h2>
</div>
</div>
<div id="calender">
<div class="cal-menu">
<button id="cal-prev" title="Previous month">«</button>
<button id="cal-today">Today</button>
<button id="cal-next" title="Next month">»</button>
<span>January 2012</span>
</div>
<div id="cal-struct">
</div>
</div>
</body>
</html>