Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·411 lines (389 loc) · 15.4 KB
/
Copy pathindex.php
File metadata and controls
executable file
·411 lines (389 loc) · 15.4 KB
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>
<html>
<head>
<title>Belldandy - the Logos bell system!</title>
<link rel = "stylesheet" type="text/css" href="css/styles.css"/>
<script src="js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.jeditable.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.jeditable.time.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.jeditable.ajaxupload.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.jeditable.checkbox.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.ajaxFileUpload.js" type="text/javascript" charset="utf-8"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link href='http://fonts.googleapis.com/css?family=Lato:400,900' rel='stylesheet' type='text/css'>
<script type="text/javascript">
$(document).ready(function() {
$('.edit').editable('save.php', {
indicator : 'Saving...',
tooltip : 'Click to edit...'
});
$('.edit_area').editable('save.php', {
onblur:'submit',
tooltip : 'Click to edit...',
width:200+'px',
height:30+'px',
});
$(".timepicker").editable("save.php", {
indicator : "<img src='img/indicator.gif'>",
type : 'time',
submit : 'OK',
tooltip : "Click to edit..."
});
$(".ajaxupload").editable("upload.php", {
indicator : "<img src='img/indicator.gif'>",
type : 'ajaxupload',
fileElementId: 'upload',
submit : 'Upload',
name: 'upload',
cancel : 'Cancel',
tooltip : "Click to upload..."
});
// $(".cbox").editable("save.php", {
// type : 'checkbox',
// submit : 'OK',
// cancel : 'Cancel',
// checkbox: { trueValue: 'true', falseValue: 'false'}
// });
});
</script>
<script type="text/javascript">
<!--
function updateTime() {
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
// var day = currentTime.getDay();
var weekday = new Array(7);
weekday[0] = "SUNDAY";
weekday[1] = "MONDAY";
weekday[2] = "TUESDAY";
weekday[3] = "WEDNESDAY";
weekday[4] = "THURSDAY";
weekday[5] = "FRIDAY";
weekday[6] = "SATURDAY";
var d = new Date();
var months = new Array();
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var month = months[currentTime.getMonth()];
var day = weekday[currentTime.getDay()];
var date = currentTime.getDate();
var year = currentTime.getFullYear();
if (minutes < 10){
minutes = "0" + minutes;
}
if (seconds < 10){
seconds = "0" + seconds;
}
// var v = hours ;
if(hours > 11){
hours+="";
} else {
hours+=""
}
if(hours < 10){
hours= "0" + hours;
}
var x;
if(date==1 || date == 21 || date == 31){
x="st";
}
if(date==2 || date == 22){
x="nd";
}
else{
x="th";
}
setTimeout("updateTime()",1000);
document.getElementById('time').innerHTML=hours;
document.getElementById('minutes').innerHTML=minutes;
document.getElementById('day').innerHTML=day;
document.getElementById('date').innerHTML=date;
document.getElementById('month').innerHTML=month;
document.getElementById('year').innerHTML=year;
document.getElementById('x').innerHTML=x;
}
updateTime();
//-->
</script>
</head>
<body>
<div class="hole">
<div class="time" id="changebg"/>
<div class="clock">
<div class="date">
<span id="day"></span>
<p><span id="month"></span> <span id="date"></span><span id="x"></span> <span id="year"></span></p>
</div>
<div class="clock_left">
<h1><span id="time"/></h1>
</div>
<div class="divider"></div>
<div class="clock_right">
<h1><span id="minutes"/></h1>
</div>
<div class="sms">
<p id="message">International slap a pencake day in Sweden<p>
</div>
</div>
</div>
<p id="audio">
<a href="bell.mp3">Listen »</a>
</p>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script type="text/javascript">
$(function () {
var audioElement = $('#audio'),
href = audioElement.children('a').attr('href');
$.template('audioTemplate', '<audio src="${src}" controls>');
if (Modernizr.audio.mp3) {
audioElement.empty();
$.tmpl('audioTemplate', {src: href}).appendTo(audioElement);
}
});
</script>
<?php
include("func.php");
$prepend = 0;
$schedules= get_all_schedules();
while ($schedule = $schedules->fetchArray()) {
$sid =$schedule['ID'].".0";
print("<div class=\"container\">");
$true="false";
if($schedule['ACTIVE']=='true'){
$true="true";
}
print("<h1 class=\"\">");
print("<span class=\"cboxactive ".$true."\" id=\"$sid.ACTIVE\">".$schedule['NAME']."</span>");
$true="false";
print(" <span id=\"".$schedule['ID']."\" class='glyphicon glyphicon-pencil pen'></span> <a href=\"delete.php?sid=" . $schedule['ID'] ."&title=schedule\" onclick=\"return confirm('Are you sure you want to delete schedule?');\"><span class='glyphicon glyphicon-trash'></span></a>");
print("</h1>");
print("<div id=\"edithide".$schedule['ID']."\" style=\"padding:10px 0px 10px 0px; display:none;\">");
print("<table class=\"tbladd\">");
print("<tr>");
print("<form action=\"addperiod_schedule.php\" method=\"POST\">");
print("<td>Schedule Name</td><td>:</td>");
print("<td><input type=\"text\" name=\"sname\" value=\"".$schedule['NAME']."\"/><input type=\"hidden\" name=\"sid\" value=\"".$schedule['ID']."\"></input></td>");
print("<td><button name=\"updateschedule\" type='submit' class='btn btn-warning'><span class=\"glyphicon glyphicon-pencil\"></span> Edit schedule</button></td>");
print("</form>");
print("</tr>");
print("</table>");
print("</div>");
print("<table class=\"table table-striped table-bordered table-condensed table-hover\">");
print("<thead>");
print("<tr class=\"h\"><th><span class='glyphicon glyphicon-trash'></span></th><th>Period</th><th>Start</th><th>End</th><th>DoW</th><th>Sound</th></tr>");
$periods=get_all_periods($schedule['ID']);
while($period = $periods->fetchArray()){
$elementID=$schedule['ID'].".".$period['ID'];
print("</thead>");
print("<tbody>");
print("<tr class=\"c$prepend\">");
print("<td><a href=\"delete.php?pid=" . $period['ID'] ."&title=period\" onclick=\"return confirm('Are you sure you want to delete period?');\"><span class='glyphicon glyphicon-trash'></span></a></td>");
print("<td class=\"edit_area period_name\" id=\"$elementID.NAME\">".$period['NAME']."</td>");
print("<td class=\"timepicker start_date\"id=\"$elementID.START_DATE\">".$period['START_DATE']."</td>");
print("<td class=\"timepicker end_date\" id=\"$elementID.END_DATE\">".$period['END_DATE']."</td>");
print("<td>");
print("<div class=\"dow\" style=\"display:none;\">".trim($period['DOW'],',')."</div>");
generateDOWSelect($period['NAME'],$period['DOW'],$elementID);
print("</td>");
print("<td class=\"ajaxupload\"id=\"$elementID.SOUND\">".$period['SOUND']."</td>");
print("</tr>");
$prepend++;
$prepend=$prepend%2;
}
echo "
<script type=\"text/javascript\">
function updatebgcolor() {
var weekday = new Array(7);
weekday[0] = 'SUN';
weekday[1] = 'MON';
weekday[2] = 'TUE';
weekday[3] = 'WED';
weekday[4] = 'THU';
weekday[5] = 'FRI';
weekday[6] = 'SAT';
var start_date= document.getElementsByClassName('start_date');
var end_date= document.getElementsByClassName('end_date');
var dow= document.getElementsByClassName('dow');
var period_name= document.getElementsByClassName('period_name');
var currentTime = new Date();
var chours = currentTime.getHours();
var cminute = currentTime.getMinutes();
var cday = weekday[currentTime.getDay()];
for (var i = 0; i < start_date.length; i++) {
var start_dates = start_date[i].innerHTML.split(':');
var end_dates = end_date[i].innerHTML.split(':');
var start_h = start_dates[0];
var start_m = start_dates[1];
var end_h = end_dates[0];
var end_m = end_dates[1];
var dows = dow[i].innerHTML;
var pname =period_name[i].innerHTML.toLowerCase();
var bgcolor='#00BFFF';
if(pname=='pink'){
bgcolor='#FF69B4';
}
else if(pname=='purple'){
bgcolor='#800080';
}
else if(pname=='gray'){
bgcolor='#A9A9A9';
}
else if(pname=='blue'){
bgcolor='#00BFFF';
}
else if(pname=='red'){
bgcolor='#FF0000';
}
else if(pname=='green'){
bgcolor='#00FF00';
}
else if(pname=='orange'){
bgcolor='#FF8C00';
}
else if(pname=='yellow'){
bgcolor='#FFFF00';
}
else if(pname=='black'){
bgcolor='#000000';
}
else if(pname=='brown'){
bgcolor='#8B4513';
}
if(chours>=start_h && chours<=end_h && cminute>=start_m && cminute<=end_m && dows.indexOf(cday) >= 0){
document.getElementById('changebg').style.backgroundColor =bgcolor;
}
console.log(chours);
}
}
setInterval(function(){updatebgcolor()},1000);
</script>
";
print("</tbody>");
print("</table>");
$prepend = 0;
print("<table style=\"text-align:right; float:right;\" class=\"tbladd\">");
print("<tr style=\"display:none;\" class=\"hideaddperiod\" id=\"show".$schedule['ID']."\">");
print("<form action=\"addperiod_schedule.php\" method=\"POST\">");
print("<td>Period Name</td><td>:</td>");
print("<td><input type=\"text\" name=\"period_name\" value=\"\"/><input type=\"hidden\" name=\"sid\" value=\"".$schedule['ID']."\"></input></td>");
print("<td><button name=\"addperiod\" type='submit' class='btn btn-primary'>Save</button></td>");
print("</form>");
print("</tr>");
print("<tr>");
print("<td><button id=\"".$schedule['ID']."\" class='btn btn-success addperiod'><span class=\"glyphicon glyphicon-plus addperiod\"></span> Add period</button></td>");;
print("<tr>");
print("</table>");
print("</div>");
}
print("<div class=\"container\">");
print("<table class=\"tbladdschedule\">");
print("<tr id=\"hide\">");
print("<form action=\"addperiod_schedule.php\" method=\"POST\">");
print("<td>Schedule Name</td><td>:</td>");
print("<td><input type=\"text\" name=\"schedule_name\" value=\"\"/></td>");
print("<td><button name=\"addschedule\" type='submit' class='btn btn-primary'>Save</button></td>");
print("</form>");
print("</tr>");
print("<tr>");
print("<td><button type='submit' id=\"button\" onclick=\"show()\" class='btn btn-success'><span class=\"glyphicon glyphicon-plus\"></span> Add schedule</button></td>");;
print("<tr>");
print("</table>");
print("</div>");
?>
</div>
<script type="text/javascript">
function show() {
document.getElementById("hide").style.display="block";
document.getElementById("button").style.display="none";
}
function showPeriod(){
document.getElementById("hide").style.display="block";
document.getElementById("button").style.display="none";
}
$(document).ready(function() {
$('.pen').click(function() {
var thisid =$(this).attr('id');
// console.log("got a click!");
$('#edithide'+thisid).slideDown('slow');
});
$('.addperiod').click(function() {
var thisid =$(this).attr('id');
$(this).hide();
$('#show'+thisid).slideDown('slow');
});
$('.cbox').click(function(e){
// $(this).toggleClass('check');
var elem = $(this)
if (elem.hasClass('check')) {
elem.removeClass('check').addClass("uncheck");
} else {
elem.removeClass().addClass("check" )
}
var e = $(this).css("color");
var id = $(this).attr("id");
var value = $(this).html();
var i = true;
if($(this).css("color")=='rgb(220, 220, 220)'){
i=false;
}
else{
i=true;
}
$.ajax({
url: "save.php", //This is the page where you will handle your SQL insert
type: "POST",
data: {'id': id, 'value': value,'i':i},
// data: "id=" + id +'&value='+value+'&i='+i, //The data your sending to some-page.php
success: function(){
console.log(e+i);
},
error:function(){
console.log("AJAX request was a failure");
}
});
});
$('.cboxactive').click(function(e){
var elem = $(this)
if (elem.hasClass('true')) {
elem.removeClass('true').addClass("false");
} else {
elem.removeClass().addClass("true" )
}
var id = $(this).attr("id");
var value = $(this).html();
var i = false;
if($(this).css("color")=='rgb(0, 128, 0)'){
i=true;
}
else{
i=false;
}
$.ajax({
url: "save.php",
type: "POST",
data: {'id': id,'value': value,'i':i},
success: function(){
console.log();
},
error:function(){
console.log("AJAX request was a failure");
}
});
});
});
</script>
</body>
</html>