-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar.html
411 lines (357 loc) · 17.2 KB
/
calendar.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Vipie - Kalender</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/normalize.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<style>
body{
background: url('img/calendar-bg.jpg');
background-size: cover;
background-position: 0%;
background-attachment: fixed;
overflow: hidden;
}
.home-button-wrapper{
position: absolute;
bottom: 21px;
height: 120px;
padding-top: 21px;
padding-left: 21px;
float: left;
}
.calendar-wrapper, .event-wrapper{
background: rgba(0,0,0,0.5);
color: white;
width: 40%;
max-height: 70%;
overflow-x: hidden;
overflow-y: auto;
padding: 17px 17px;
/*border-bottom: 17px solid rgba(0,0,0,0);*/
/*border-top: 17px solid rgba(0,0,0,0);*/
position: absolute;
top: 7%;
left: 50%;
margin-left: -40%;
margin-bottom: 20px;
}
.event-wrapper{
overflow: hidden;
left: auto;
width: 30%;
margin-left: auto;
left: 50%;
margin-left: 10%;
display: none;
}
.cal-header, .cal-days, .cal-numbers{
width: 100%;
text-align: center;
}
.cal-header{
font-size: 2em;
}
.button{
font-weight: bold;
}
.event, .birthday{
font-weight: bold;
background: rgba(255,255,255,0.3);
}
.event:hover, .birthday:hover{
cursor: pointer;
}
.button:hover{
/*background: rgba(255,255,255,0.5);*/
color: black;
cursor: pointer;
}
.cal-header{
margin-bottom: 10px;
}
.cal-numbers tr{
height: 16%;
}
.cal-numbers tr td:hover{
color: black;
background: rgba(255,255,255,0.6);
}
article .title{
font-weight: bold;
font-size: 28px;
}
article p{
font-size: 20px;
}
</style>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<!--<article>
<div class="title">Retrospect: Hanne's avonturen in Portugal.</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis in sagittis urna. Vestibulum gravida id ante ut elementum. Quisque lectus tortor, cursus at ligula nec, lobortis blandit quam. Fusce iaculis arcu mi. Fusce fermentum, dui ut congue bibendum, lectus mi varius nisl, ut venenatis neque lacus nec sapien. Cras suscipit quam nulla, ac adipiscing nulla consectetur a. Curabitur ultrices sit amet ante in fermentum. Aliquam erat volutpat. Suspendisse et lobortis leo, sit amet vestibulum mauris. Nunc lacinia aliquam odio.
</p><p>
In hac habitasse platea dictumst. Suspendisse potenti. Sed vel velit lacus. Integer et leo vitae est tristique vehicula at eu magna. Donec rhoncus semper justo, eu varius felis ornare blandit. Curabitur purus purus, porta nec quam sed, ultrices pulvinar metus. Donec eget libero imperdiet, viverra massa at, pretium nunc. Cras tincidunt tortor vitae nisl facilisis, mattis suscipit metus cursus. Ut pellentesque dictum diam, vel suscipit nisl egestas non. Suspendisse non augue at justo fringilla fermentum. Nullam euismod libero a neque mollis elementum.</p><p>
In hac habitasse platea dictumst. Suspendisse potenti. Sed vel velit lacus. Integer et leo vitae est tristique vehicula at eu magna. Donec rhoncus semper justo, eu varius felis ornare blandit. Curabitur purus purus, porta nec quam sed, ultrices pulvinar metus. Donec eget libero imperdiet, viverra massa at, pretium nunc. Cras tincidunt tortor vitae nisl facilisis, mattis suscipit metus cursus. Ut pellentesque dictum diam, vel suscipit nisl egestas non. Suspendisse non augue at justo fringilla fermentum. Nullam euismod libero a neque mollis elementum.</p>
</article>-->
<div class="calendar-wrapper">
<div class="calendar">
<table class="cal-header">
<tr>
<td class="button" id="prev">⟨</td>
<td colspan=3 id="month">Mei 2013</td>
<td class="button" id="next">⟩</td>
</tr>
</table>
<table class="cal-days">
<tr>
<td>Ma</td>
<td>Di</td>
<td>Wo</td>
<td>Do</td>
<td>Vr</td>
<td>Za</td>
<td>Zo</td>
</tr>
</table>
<table class="cal-numbers">
<tbody>
<tr><td class="nil"></td><td class="nil"></td><td>1</td><td>2</td><td>3</td><td>4</td><td class="event">5</td></tr>
<tr><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td class="today">11</td><td>12</td></tr>
<tr><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td class="event">19</td></tr>
<tr><td>20</td><td>21</td><td>22</td><td class="event">23</td><td>24</td><td>25</td><td>26</td></tr>
<tr><td>27</td><td>28</td><td>29</td><td>30</td><td class="nil"></td><td class="nil"></td><td class="nil"></td></tr>
</tbody>
</table>
</div>
</div>
<div class="event-wrapper">
</div>
<div class="home-button-wrapper">
<a href="#"><img src="img/vipie120.png" /></a>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script>
theDate = new Date();
//Define months
var month=new Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
//Define Days
var day=new Array();
day[0]="Sunday";
day[1]="Monday";
day[2]="Tuesday";
day[3]="Wednesday";
day[4]="Thursday";
day[5]="Friday";
day[6]="Sunday";
//Define test Events
//%TODO% Events should come from server
//var events=new Array();
//events[0]= {date: new Date(), eventID: 1, message:"feestje"};
//events[1]= {date: new Date(new Date(events[0].date).setDate(new Date(events[0].date).getDate() + 14)), eventID: 2, message:"verjaardag"};
//events[2]= {date: new Date(new Date(events[0].date).setMonth(new Date(events[0].date).getMonth() + 1)), eventID: 3, message:"feestje"};
//Define test Birthdays
//%TODO% Birthdays should come from server
var birthdays=new Array();
birthdays[0]= {date: new Date("1991-08-27"), birthdayID: 1, voornaam:"An", naam:"Meersman"};
birthdays[1]= {date: new Date("1993-08-17"), birthdayID: 2, voornaam:"Hanne", naam:"Bortels"};
birthdays[2]= {date: new Date("1990-09-19"), birthdayID: 3, voornaam:"Kobe", naam:"Swennen"};
birthdays[3]= {date: new Date("1990-02-16"), birthdayID: 4, voornaam:"Michèle", naam:"Keunen"};
birthdays[4]= {date: new Date("1993-11-19"), birthdayID: 5, voornaam:"Lisa", naam:"Morrhey"};
//%TODO% birthdays and events collide when on same day.
//get the days in a month
function getDaysInMonth(date) {
var month = date.getMonth() + 1;
var year = date.getFullYear();
return new Date(year, month, 0).getDate();
}
//Get the HTML of the selected month
function calendarRender(date){
monthText = month[date.getMonth()];
firstDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1);
daysInMonth = getDaysInMonth(date);
$("#month").html(monthText + " " + date.getFullYear());
//First week, can start with empty slots
var nils= 0;
var daysIn = 0;
if (firstDayOfMonth.getDay()==0) {
nils=6
}else{
nils = firstDayOfMonth.getDay() - 1;
}
var weeks=new Array();
weeks[0]="<tr>";
for (i=0;i<nils;i++) {
weeks[0]+="<td class=\"nil\"></td>";
}
for(i=nils;i<7;i++){
daysIn++;
weeks[0]+="<td>"+ daysIn+"</td>";
}
weeks[0]+="</tr>\n";
//end of first week
//the second, third and fourth week (weeks 1, 2 and 3) are ALWAYS full weeks without empty slots
//Even when february starts on a monday and has only 28 days.
for(i=1;i<=3;i++){
weeks[i]="<tr>";
for(j=0;j<7;j++){
daysIn++;
weeks[i]+="<td>" + daysIn + "</td>";
}
weeks[i]+="</tr>\n";
}
//Week number 4 (fifth week) is not always full, so we check if 7 or more days are available
//Else we fill the number of days left and then start "nilling" the last ones
weeks[4]="<tr>";
if (daysInMonth - daysIn >= 7) {
for(i=0;i<7;i++){
daysIn++;
weeks[4]+="<td>" + daysIn + "</td>";
}
}else{
remainingNilDays = 7;
for(i=daysIn;i<daysInMonth;i++){
daysIn++;
remainingNilDays--;
weeks[4]+="<td>" + daysIn + "</td>";
}
while(remainingNilDays>0){
remainingNilDays--;
weeks[4]+="<td class=\"nil\"></td>";
}
}
weeks[4]+="</tr>\n";
//Week number 5 (6th week) is never full.
weeks[5]="<tr>";
remainingNilDays = 7;
if (daysIn < daysInMonth) {
for(i=daysIn;i<daysInMonth;i++){
daysIn++;
remainingNilDays--;
weeks[5]+="<td>" + daysIn + "</td>";
}
}
while(remainingNilDays>0){
remainingNilDays--;
weeks[5]+="<td class=\"nil\"></td>";
}
weeks[5]+="</tr>\n";
return weeks;
}
//Add Events to the current Calendar
function addEvents(date){
for ( var i = 0, l = events.length; i < l; i++ ) {
//if same year and same month
if (events[i].date.getFullYear() == date.getFullYear() && events[i].date.getMonth() == date.getMonth()) {
//search the right day and add a class to it's td
$(".cal-numbers tbody tr td").each(function(){
day = $(this);
if(day.html() == events[i].date.getDate()){
day.addClass("event");
day.attr("eventID",i);
}
})
}
}
}
//Add Birthdays to the current Calendar
function addBirthdays(date){
for ( var i = 0, l = birthdays.length; i < l; i++ ) {
//if same month
if (birthdays[i].date.getMonth() == date.getMonth()) {
console.log(birthdays[i]);
//search the right day and add a class to it's td
$(".cal-numbers tbody tr td").each(function(){
day = $(this);
if(day.html() == birthdays[i].date.getDate()){
day.addClass("birthday");
day.attr("birthdayID",i);
}
})
}
}
}
$(document).ready(function(){
//Fix the view
$(".cal-header").css("height", $(window).height()*0.1 + "px");
$(".cal-numbers").css("height", $(window).height()*0.5 + "px");
//Get todays date and render the calendar
calendarBody = calendarRender(theDate);
$(".cal-numbers tbody").html(calendarBody);
addEvents(theDate);
addBirthdays(theDate);
})
//month picker
$(".button").click(function(event){
event.preventDefault();
if(this.id=="next"){
currentDate = new Date(new Date(theDate).setDate(1));
theDate = new Date(new Date(currentDate).setMonth(currentDate.getMonth()+1));
calendarBody = calendarRender(theDate);
$(".cal-numbers tbody").html(calendarBody);
addEvents(theDate);
addBirthdays(theDate);
}else{
currentDate = new Date(new Date(theDate).setDate(1));
theDate = new Date(new Date(currentDate).setMonth(currentDate.getMonth()-1));
calendarBody = calendarRender(theDate);
$(".cal-numbers tbody").html(calendarBody);
addEvents(theDate);
addBirthdays(theDate);
}
});
$(".cal-numbers tbody").on("click", "tr td.event", function() {
//find out what id that event has and get it's message
eventID = $(this).attr("eventID");
eventMessage = events[eventID].message;
//slideUp, change content then slide down
$(".event-wrapper").slideUp(function(){
$(this).html(eventMessage).slideDown();
})
});
$(".cal-numbers tbody").on("click", "tr td.birthday", function() {
//find out what id that birthday has and get it's message
birthdayID = $(this).attr("birthdayID");
birthyear = birthdays[birthdayID].date.getFullYear();
age = theDate.getFullYear() - birthyear;
birthdayMessage = birthdays[birthdayID].voornaam + " " + birthdays[birthdayID].naam + " wordt " + age + "!" ;
//slideUp, change content then slide down
$(".event-wrapper").slideUp(function(){
$(this).html(birthdayMessage).slideDown();
})
});
</script>
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src='//www.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
</body>
</html>