summaryrefslogtreecommitdiff
path: root/templates/themes/calendar/calendar.html
blob: 4b5c99ae3bfada9aba30206f303f838c3f6a251c (plain)
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
<!doctype html>
<html>
<head>
	<link rel="stylesheet" media="screen" href="/stylesheets/style.css">
	<meta charset="utf-8">
	{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
	<link rel='stylesheet' href='/stylesheets/fullcalendar.min.css' />
	<script type='text/javascript'>
		var active_page = "news";
	</script>
    <title>{{ settings.title }}</title>
	{% include 'header.html' %}
	<script src='/js/moment.min.js'></script>
	<script src='/js/fullcalendar.min.js'></script>
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
	<div class="bar top">
		{{ boardlist.top }}
	</div>
	<header>
		<h1 class="glitch" data-text="{{ settings.title }}"> {{ settings.title }}</h1>
		<div class="subtitle">{{ settings.subtitle }}</div>
	</header>
	<div class="ban">
		<div id='calendar'></div>
	</div>
	
	<hr/>
        <footer>
		<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> + 
			<a href='https://int.vichan.net/devel/'>vichan</a> + 
			<a href='https://github.com/lainchan/lainchan'>lainchan</a> {{ config.version }} -
		<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
		<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel
		<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p>
        </footer>
	<div class="pages"></div>
	<script type='text/javascript'>
		$(document).ready(function() {

			var calendar = $('#calendar').fullCalendar({
				editable: true,
				header: {
					left: 'prev,next today',
					center: 'title',
					right: 'month,agendaWeek,agendaDay'
				},

				events: "calendarpost.php",

				eventRender: function(event, element, view) {
					if (event.allDay === 'true') {
						event.allDay = true;
					} else {
						event.allDay = false;
					}

					var _url = new URL(event.url, window.location.href);
					var _scheme = _url.protocol.toLowerCase();

					// Replace stored javascript/data URI attempts
					if(_scheme === 'javascript:' || _scheme === 'data:') {
						event.url = "#removed";
					}

					// Only accept #a-zA-Z to avoid CSS injection.
					if (/^[#a-zA-Z]+$/.test(event.color) == false) {
						event.color = "#removed";
					}

					element.find('.fc-title').append("<br/>" + event.description);
				        element.css('background-color',event.color);	
				},
				selectable: true,
				selectHelper: true,
				select: function(start, end, allDay) {
					var title = prompt('Event Title:');
					var description = prompt('Event Description:');
					var url = prompt("Event URL");
					var color = prompt("Event Color");
					var starttime = prompt("Event Start Time");
					var endtime = prompt("Event End Time");
					if (title) {
						var startmoment = moment(start);
						var endmoment = moment(end);
						var start = startmoment.format('YYYY-MM-DD HH:mm:ss');
						var end = endmoment.format('YYYY-MM-DD HH:mm:ss');
						if (starttime && endtime){
							var starttimemoment = moment(starttime,'HH:mm');
							var endtimemoment = moment(endtime,'HH:mm');
							startmoment.hour(starttimemoment.hour());
							startmoment.minute(starttimemoment.minute());
							endmoment.hour(endtimemoment.hour());
							endmoment.minute(endtimemoment.minute());
							endmoment.subtract(1, "days");
						        allday = false;
							start = startmoment.format('YYYY-MM-DD HH:mm:ss');
							end = endmoment.format('YYYY-MM-DD HH:mm:ss');
						}
						$.ajax({
							url: 'calendarpost.php',
							data: 'type=add&title='+ title+'&description='+ description +'&start='+ start +'&end='+ end + '&url='+url+'&color='+color,
							type: "POST",
							success: function(json) {
								alert('Added Successfully');
							}
						});
						calendar.fullCalendar('renderEvent',
								{
									title: title,
									description: description,
									start: start,
									end: end,
									allDay: allDay,
									url: url,
									color:color,
								},
								true 
								);
					}
					calendar.fullCalendar('unselect');
				},

				editable: true,
				eventDrop: function(event, delta) {
					var startmoment = moment(start);
					var endmoment = moment(end);
					var start = startmoment.format('YYYY-MM-DD HH:mm:ss');
					var end = endmoment.format('YYYY-MM-DD HH:mm:ss');
					var starttime = prompt("Event Start Time");
					var endtime = prompt("Event End Time");
					if (starttime && endtime){
						var starttimemoment = moment(starttime,'HH:mm');
						var endtimemoment = moment(endtime,'HH:mm');
						startmoment.hour(starttimemoment.hour());
						startmoment.minute(starttimemoment.minute());
						endmoment.hour(endtimemoment.hour());
						endmoment.minute(endtimemoment.minute());
						allday = false;
						endmoment.subtract(1, "days");
						start = startmoment.format('YYYY-MM-DD HH:mm:ss');
						end = endmoment.format('YYYY-MM-DD HH:mm:ss');
					}
					$.ajax({
						url: 'calendarpost.php',
						data: 'type=update&title='+ event.title+'&description='+ event.description + '&start='+ start +'&end='+ end +'&id='+ event.id +'&color=' + event.color +'&url=' + event.url  ,
						type: "POST",
						success: function(json) {
							alert("Updated Successfully");
						}
					});
				},
				eventClick: function(event) {
					var decision = confirm("Do you really want to do that?"); 
					if (decision) {
						$.ajax({
							type: "POST",
							url: 'calendarpost.php',
							data: "type=delete&id=" + event.id,
							success: function(json) {
								$('#calendar').fullCalendar('removeEvents', event.id);
								alert("Updated Successfully");}
						});
						return false;

					}
				},
				eventResize: function(event) {
					var startmoment = moment(start);
					var endmoment = moment(end);
					var start = moment(start).format('YYYY-MM-DD HH:mm:ss');
					var end = moment(end).format('YYYY-MM-DD HH:mm:ss');
					var starttime = prompt("Event Start Time");
					var endtime = prompt("Event End Time");
					if (starttime && endtime){
						var starttimemoment = moment(starttime,'HH:mm');
						var endtimemoment = moment(endtime,'HH:mm');
						startmoment.hour(starttimemoment.hour());
						startmoment.minute(starttimemoment.minute());
						endmoment.hour(endtimemoment.hour());
						endmoment.minute(endtimemoment.minute());
						allday = false;
						endmoment.subtract(1, "days");
						start = startmoment.format('YYYY-MM-DD HH:mm:ss');
						end = endmoment.format('YYYY-MM-DD HH:mm:ss');
					}
					$.ajax({
						url: 'calendarpost.php',
						data: 'type=update&title='+ event.title+'&description='+ event.description + '&start='+ start +'&end='+ end +'&id='+ event.id +'&color=' + event.color +'&url=' + event.url  ,
						type: "POST",
						success: function(json) {
							alert("Updated Successfully");
						}
					});
				}

			});

		});
	</script>
	<script type="text/javascript">{% verbatim %}
		ready();
	{% endverbatim %}</script>
</body>
</html>