-
Notifications
You must be signed in to change notification settings - Fork 170
/
calendar.php
84 lines (76 loc) · 2.25 KB
/
calendar.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
<?php
# LGPL javascript calendar is optional, but very nice.
# Snag it from http://www.dynarch.com/demos/jscalendar/
# and install in jscalendar-1.0/ inside this web dir.
$calendar_head = '
<script type="text/javascript">
function ganglia_submit(clearonly) {
document.getElementById("cs").value = "";
document.getElementById("ce").value = "";
if (! clearonly)
document.ganglia_form.submit();
}
</script>
';
if ( ! is_readable('./jscalendar-1.0/calendar.js') ) {
$calendar = '';
} else {
$calendar_head .= '
<link rel="stylesheet" type="text/css" media="all" href="./jscalendar-1.0/calendar-system.css" title="calendar-system" />
<script type="text/javascript" src="./jscalendar-1.0/calendar.js"></script>
<script type="text/javascript" src="./jscalendar-1.0/lang/calendar-en.js"></script>
<script type="text/javascript" src="./jscalendar-1.0/calendar-setup.js"></script>
<script type="text/javascript">
var fmt = "%b %d %Y %H:%M"; // must be a format that RRDtool likes
function isDisabled(date, y, m, d) {
var today = new Date();
return (today.getTime() - date.getTime()) < -1 * Date.DAY;
}
function checkcal(cal) { // ensure cs < ce
var date = cal.date;
var time = date.getTime();
var field = document.getElementById("cs");
if (field == cal.params.inputField) {
// cs was changed: change ce
field = document.getElementById("ce");
var other = new Date(Date.parseDate(field.value, fmt));
if (time >= other) {
date = new Date(time + Date.HOUR);
field.value = date.print(fmt);
}
} else {
// ce was changed: change cs
field = document.getElementById("cs");
var other = new Date(Date.parseDate(field.value, fmt));
if (other >= time) {
date = new Date(time - Date.HOUR);
field.value = date.print(fmt);
}
}
}
</script>
';
$calendar = '
<script type="text/javascript">
Calendar.setup({
inputField : "cs",
ifFormat : fmt,
showsTime : true,
step : 1,
weekNumbers : false,
onUpdate : checkcal,
dateStatusFunc : isDisabled
});
Calendar.setup({
inputField : "ce",
ifFormat : fmt,
showsTime : true,
step : 1,
weekNumbers : false,
onUpdate : checkcal,
dateStatusFunc : isDisabled
});
</script>
';
}
?>