-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
124 lines (117 loc) · 3.51 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Calendar | Home</title>
<script src="js/react.min.js"></script>
<script src="js/JSXTransformer.js"></script>
<script src="js/eventLayout.js"></script>
</head>
<body>
<div id="container"></div>
<script type="text/jsx">
// The JSX file can't be loaded by JSXTransformer locally
// due to browse security, so I have to place it inline this file.
var Timeline = React.createClass({
render: function() {
var scales = [];
for(var hour=9; hour<21; hour++) {
scales.push(
<TimelineScale hour={hour} minute={0} />
);
scales.push(
<TimelineScale hour={hour} minute={30} />
);
}
scales.push(
<TimelineScale hour={21} minute={0} />
);
return (
<div className="timeline">
{scales}
</div>
);
}
});
var TimelineScale = React.createClass({
render: function() {
var className= this.props.minute === 0 ? "hourly" : "half";
var hour = this.props.hour > 12 ?
this.props.hour - 12 : this.props.hour;
var APM = this.props.hour > 12 ? "PM" : "AM";
var minute = ("0" + this.props.minute).slice(-2);
return (
<div className={className}>
<span className="time">{hour}:{minute}</span>
<span className="apm">{APM}</span>
</div>
)
}
});
var EventPanel = React.createClass({
render: function() {
var events = this.props.events.map(function(event) {
return (
<Event top={event.top} left={event.left}
height={event.height} width={event.width} id={event.id} />
);
});
return (
<div className="eventpanel">
<div className="eventpool">
{events}
</div>
</div>
);
}
});
var Event = React.createClass({
render: function() {
var style = {
top: this.props.top + 'px',
left: this.props.left + 'px',
height: this.props.height + 'px',
width: this.props.width + 'px'
};
return (
<div className="event" style={style} >
<div className="vbar"></div>
<div className="contentWrapper">
<div className="content">
<h1>Sample Item</h1>
<p>Sample Location</p>
</div>
</div>
</div>
);
}
});
var Calendar = React.createClass({
render: function() {
var eventLayouts = EventLayout.arrange(this.props.events);
return (
<div>
<Timeline />
<EventPanel events = {eventLayouts}/>
</div>
);
}
});
function layOutDay(events) {
React.render(
<Calendar events={events}/>,
document.getElementById('container')
);
}
var events = [
{start: 30, end: 150},
{start: 540, end: 600},
{start: 550, end: 620},
{start: 560, end: 650},
{start: 630, end: 690},
];
layOutDay(events);
</script>
</body>
</html>