-
Notifications
You must be signed in to change notification settings - Fork 0
/
Route2.html
279 lines (266 loc) · 12.5 KB
/
Route2.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
<!doctype html>
<html lang="en-US">
<head>
<!-- <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<title>Summer student portal <code>setPanel()</code></title>
<link rel="stylesheet" type="text/css" media="all" href="style.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
</head>
<body>
<div id="topbar"><a href="https://sites.google.com/view/toront">Back to Sharp Bus Lines Site</a>
</div>
<table class="hop">
<tbody>
<tr id="nav">
<td><button id="search" type="button"><a href="student.html">Search portal</button>
</td>
<td><button id="return" type="button"><a href="javascript:history.go(-1)"onMouseOver="self.status.referrer;return true"><< Return</button>
</td>
<td><span title="Print Route copy" class="ui-icon ui-icon-print" onclick="window.print();">
</td>
<td><!-- <input id="submit" type="submit" value="Get Directions"> -->
<button title="Highly suggested if you want to view directions" id="openDlg3">View Directions here</button>
<div id="dialog3" title="Maps with directions" hidden="hidden">
<div id="right-panel" style="width:50%;"></div>
<div id="map" style="width:50%; height: 400px"></div>
</div>
</td>
<td>
<div class="main">
<ul class="mainnav">
<li class="hassubs"><a href="#">Routes</a>
<ul class="dropdown">
<li class="subs hassubs"><a href="#">Route 1</a>
<ul class="dropdown">
<li class="subs"><a href="Route1.html">AM</a></li>
<li class="subs"><a href="Route2.html">PM</a></li>
</ul>
</li>
<li class="subs hassubs"><a href="#">Route 2</a>
<ul class="dropdown">
<li class="subs"><a href="Route1.html">AM</a></li>
<li class="subs"><a href="Route2.html">PM</a></li>
</ul>
</li>
<li class="subs hassubs"><a href="#">Route 3</a>
<ul class="dropdown">
<li class="subs"><a href="Route1.html">AM</a></li>
<li class="subs"><a href="Route2.html">PM</a></li>
</ul>
</li>
<li class="subs hassubs"><a href="#">Route 4</a>
<ul class="dropdown">
<li class="subs"><a href="Route1.html">AM</a></li>
<li class="subs"><a href="Route2.html">PM</a></li>
</ul>
</li>
<li class="subs hassubs"><a href="#">Route 5</a>
<ul class="dropdown">
<li class="subs"><a href="Route1.html">AM</a></li>
<li class="subs"><a href="Route2.html">PM</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<br style="clear: both;">
</div>
</td>
</tr>
</tbody>
</table>
<center>
<table id="table" style="border-bottom: 1px solid #ccc;">
<div class="stop"><font size="3"><b>Route: 1 - In Bound</b></font>
</div>
<thead>
<tr>
<th id="objid">id</th>
<th>Pick-up time</th>
<th>Student Name</th>
<th>Home Address</th>
<th>Drop off</th>
<th>Contact at Home</th>
</tr>
</thead>
<br></br>
<tbody id="tbdata">
<tr class="school" style="background-color: green;color: white;">
<td>9:00 AM</td>
<td>St. Dominic Savio Catholic School</td>
<td>50 Tideswell Blvd, Toronto</td>
</tr>
</tbody>
</table>
</center>
</div>
</div>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> -->
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( document ).tooltip();
var $TABLE = $('#table');
// Confirmation of deletion
function tempAlert(msg,duration)
{
var el = document.createElement("div");
el.setAttribute("style","position:absolute;top:10%;left:10%;font-size:3em;background-color:red;color:white;");
el.innerHTML = msg;
setTimeout(function(){
el.parentNode.removeChild(el);
},duration);
document.body.appendChild(el);
}
//Confirmation of update
function updateAlert(msg,duration)
{
var el = document.createElement("div");
el.setAttribute("style","position:absolute;top:10%;left:10%;font-size:3em;background-color:green;color:white;");
el.innerHTML = msg;
setTimeout(function(){
el.parentNode.removeChild(el);
},duration);
document.body.appendChild(el);
}
//initialize Alglolia to get objects/individual student data
var client = algoliasearch('APP-ID', 'Admin-API');
var index = client.initIndex('students');
$(document).ready(function () {
index.getObjects(['7718711', '7718701', '7718691', '7718681', '7718671', '7718661', '7718651', '7718641'], function(err, content) {
if (err) throw err;
// var thehtml = $("#tbdata");
// thehtml.append('<td>'+content.StudentName + '</td> <td> ' + content.HomeAddress + ' </td><td>' + content.Dropoff +'</td> + <td>' + content.ContactatHome +'</td>');
// $.each(content, function (key, item) {
// html += formatItem(item);
// });
console.log(content);
var $tblbody = $('#tbdata');
students = content.results;
for (var i = 0; i < students.length; i++){
var student = students[i];
// $tblbody.append('<td>'+student.StudentName + '</td> <td> ' + student.HomeAddress + ' </td><td>' + student.Dropoff +'</td> + <td>' + student.ContactatHome +'</td>');
$('<tr>', { html: '<td id="obj">'+student.objectID + '</td><td id="tim">'+student.StartTime + '</td><td id="name">'+student.StudentName + '</td> <td id="add"> ' + student.HomeAddress + ' </td><td id="drop">' + student.Dropoff +'</td><td id="cell">' + student.ContactatHome +'</td>' + '<td><input class="edit" type="button" value="Edit"/><input class="save" type="button" value="Save"/><input class="cancel" type="button" value="Cancel"/></td>'}).prependTo($("#tbdata")).css('border', '3px solid black');
//open directions in google maps
var $nav = $('#nav');
var waypts = [];
var city = ",Toronto";
$('#tbdata tr:gt(0):lt(-1)').not([0]).each(function(){
var $wptArray = $(this).find('td:eq(3)').html() + '%7C';
waypts.push($wptArray);
});
var start = student.HomeAddress;
var end = $('.school').find('td:gt(1)').html();
$nav.append('<a title="Highly suggested if you want to print directions" href="https://www.google.com/maps/dir/?api=1&origin=' + start + '&destination=' + end + '&travelmode=driving&waypoints=' + waypts +'" target="_blank" class="btn">View directions on google maps</a>');
};
//edit click event
$(document).on("click", ".edit", function(){
$(this).hide();
$(this).closest('tr').find("td:lt(6)").addClass('editable');
$(this).closest('tr').find("td:lt(6)").attr('contenteditable', 'true');
$(this).siblings('.save, .cancel').show();
});
//cancel click event
$(document).on("click", ".cancel", function(){
$(this).siblings('.edit').show();
$(this).siblings('.save').hide();
$(this).closest('tr').find("td:lt(6)").removeClass('editable');
$(this).closest('tr').find("td:lt(6)").removeAttr('contenteditable');
$(this).hide();
});
function updateAlert(msg,duration)
{
var el = document.createElement("div");
el.setAttribute("style","position:absolute;top:80%;left:10%;font-size:3em;background-color:green;color:white;");
el.innerHTML = msg;
setTimeout(function(){
el.parentNode.removeChild(el);
},duration);
document.body.appendChild(el);
}
function update(){
var $obj = $("#obj").html();
var $name = $("#name").html();
var $time = $("#tim").html();
var $adress = $("#add").html();
var $drop = $("#drop").html();
var $cell = $("#cell").html()
var client = algoliasearch('4WXFSMU72L', 'd01dbed1228630b91c0f312d81b98718');
var index = client.initIndex('students');
index.partialUpdateObject({
StudentName: $name,
objectID: $obj,
ContactatHome: $cell,
HomeAddress: $adress,
Dropoff: $drop,
StartTime: $time
}, function(err, content) {
if (err) throw err;
console.log(content);
});
}
//save click event
$(document).on("click", ".save", function(){
update();
var nom = $(this).closest('tr').find("td:eq(2)").text();
$(this).siblings('.edit').show();
$(this).siblings('.cancel').hide();
$(this).closest('tr').find("td:lt(6)").removeClass('editable');
$(this).closest('tr').find("td:lt(6)").removeAttr('contenteditable');
$(this).hide();
updateAlert(nom + "'s information has been updated",3000);
});
});
});
//open map in jquery-ui dialog
$(function () {
$( "#dialog3" ).dialog({
autoOpen: false,
closeOnEscape: true,
draggable: false,
modal: true,
height: 700,
width: 1200,
buttons: [
{
text: "Close",
click: function(){
$(this).dialog("close");
}
}
]
});
$("#openDlg3").click(function() {
$("#dialog3").dialog("open");
return false
});
});
</script>
<script type="text/javascript" src="js/student.js"></script>
<script src="https://form.jotform.com/static/feedback2.js" type="text/javascript">
new JotformFeedback({
formId: "81509096884267",
buttonText: "Feedback",
base: "https://form.jotform.com/",
background: "#F59202",
fontColor: "#FFFFFF",
buttonSide: "left",
buttonAlign: "center",
type: false,
width: 700,
height: 500,
isCardForm: false
});
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?libraries=places&key=API-KEY&callback=initMap">
</script>
</body>
</html>