-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchat.html
287 lines (260 loc) · 13.8 KB
/
chat.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
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Anchor</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" integrity="sha384-i/ZLCOBtDmoxztrtShNvc3vGe1+IbOGDzkZNC4KLXurv/BT7QInnM2AsPnvbgXH/" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css" integrity="sha384-m1fl5JKXaEocK0a/l9MLZd7pvyIwC5VlcXtW8NpMLO/yO5WFDY4fB3/fweZ0niwK" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Bitter:400,700|Source+Sans+Pro:300,400,600" rel="stylesheet">
<link rel="stylesheet" href="css/updates-emergency.css">
</head>
<body>
<div class="ui wide massive sidebar inverted teal vertical menu">
<a class="item">About Anchor</a>
<a class="item" href="tel:911">Call 911</a>
</div>
<div class="pusher">
<header class="ui top fixed massive inverted borderless menu">
<div class="nav-container menu">
<div class="logo item">
<img src="images/anchor-teal-desktop-logo.png" class="hidden-sm-down"/>
<img src="images/anchor-teal-mobile-logo.png" class="hidden-md-up"/>
</div>
<div class="right menu hidden-sm-down">
<a class="item">About Anchor</a>
<a class="item" href="tel:911">Call 911</a>
</div>
<div class="right menu hidden-md-up">
<a class="item" id="sidebar"><i class="material-icons">menu</i></a>
</div>
</div>
</header>
<section class="ui vertical basic very padded segment">
<div class="container">
<h2 class="ui medium primary header">
Immediate Assistance
<div class="sub header">
If this is an emergency call 911 immediately.
</div>
</h2>
<a class="ui circular small secondary button" href="tel:911">
Call 911
</a>
</div>
</section>
<section class="ui vertical basic very padded segment pt-0">
<div class="container">
<h2 class="ui medium primary header">
Chat with <span class="department"></span>
</h2>
<p class="rhythm">
Update: There are black outs in parts of lower Manhattan and parts of Brooklyn. If you are in this location, stay indoors
</p>
<div class="ui divider"></div>
<p class="text-muted" id="static">Only <span class="department"></span> can see your responses.</p>
<div class="ui items" id="responses">
</div>
<div class="ui teal divider"></div>
<p class="text-muted">
Hi! We are online. How can we help you?
</p>
</div>
<div class="container text-center">
<div class="ui vertical text menu mx-auto" id="buttons">
</div>
<div class="ui vertical text menu mx-auto">
<div class="item">
<a class="ui circular small alt button" href="everyday.html">
Back to Home
</a>
</div>
</div>
</div>
</section>
<footer class="ui vertical basic inverted padded segment">
<div class="container">
<div class="row">
<div class="col-6">
MFA IxD 2017 at SVA
</div>
<div class="col-6 text-right">
Elushika Weerakoon
</div>
</div>
</div>
</footer>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" integrity="sha384-bPV3mA2eo3edoq56VzcPBmG1N1QVUfjYMxVIJPPzyFJyFZ8GFfN7Npt06Zr23qts" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js" integrity="sha384-o9KO9jVK1Q4ybtHgJCCHfgQrTRNlkT6SL3j/qMuBMlDw3MmFrgrOHCOaIMJWGgK5" crossorigin="anonymous"></script>
<script async defer src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.js" integrity="sha384-Ail6li4BXa+GztK4v0z2B8vXM69Kl5gw8vj3uPEna+3hHY9wAixO0hLotSJlOjlT" crossorigin="anonymous"></script>
<script async defer src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDdZOHZxUTasVlFnoMk9U55zJN4ZAPfRVY"></script>
<script>
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
function button(text, response) {
return $('<div class="item"><a class="ui circular small secondary message button" data-response="' + response + '">' + text + '</a></div>').appendTo($('#buttons'));
}
function response(text, response) {
$('<div style="display:none;" class="item d-block"><a class="ui circular small disabled button right floated">' + text + '</a></div>').appendTo($('#responses')).slideDown("slow", function() {
$('<div style="display:none;" class="item"><p><strong>' + response + '</strong></p></div>').appendTo($('#responses')).slideDown("slow");
});
}
function getlocation() {
var geocoder = new google.maps.Geocoder;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
// Google Maps API convert to address here
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
geocoder.geocode({'location': pos}, function(results, status) {
if (status === 'OK') {
if (results[1]) {
$('<div id="map" style="max-height:200px;"></div>').appendTo($('#responses'));
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.7590562, lng: -74.0042502},
scrollwheel: false,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
draggable: false,
zoom: 15
});
map.setCenter(pos);
new google.maps.Marker({map: map, position: pos});
$('<div style="display:none;" class="item"><p><strong>We have your location at ' + results[1].formatted_address + '.</strong></p></div>').appendTo($('#responses')).slideDown("slow");
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
});
}, function() {
console.error('Error: The Geolocation service failed.');
});
} else {
console.error('Error: Your browser doesn\'t support geolocation.');
}
}
$(function(){
$('.ui.radio.checkbox').checkbox();
$('#sidebar').click(function() {
$('.ui.sidebar').sidebar('toggle');
});
var depPar = getUrlParameter('dep');
var typePar = getUrlParameter('type');
switch(typePar) {
case 'power':
response('I do not have power', 'Ok, could you please share your location?');
break;
case 'gas':
response('I smell gas', 'Please evacuate the premises, notify your landlord and share your location.');
break;
case 'power':
response('I do not have power', 'Ok, could you please share your location?');
break;
case 'invasion':
response('There was a break-in', 'Could you please share your location?');
break;
case 'safety':
response('Is it safe to go outside?', 'Currently it is not recommended.');
break;
case 'medical':
response('I need medical help', 'Ok, could you please share your location?');
break;
case 'water':
response('Is the water safe to drink?', 'Yes it is! There is no water contamination.');
break;
case 'food':
response('I need food and water', 'Ok, could you please share your location?');
break;
case 'stuck':
response('I am stuck and cannot get out', 'Please remain calm and share your location.');
break;
case 'fire':
response('There is a fire!', 'Ok, could you please share your location?');
break;
case 'correct':
response('Yes', 'We will send an agency over');
break;
case 'incorrect':
response('No', 'Please share your location again');
break;
}
var department = null;
switch(depPar) {
case 'coned':
button('I do not have power', 'Ok, could you please share your location?');
button('I smell gas', 'Leave the building and share your location');
button('Yes', 'We will look in to it');
button('No', 'Please share your location again');
button('Here is my location', 'function-getlocation');
department = 'ConEdison';
break;
case 'nypd':
button('There was a break-in', 'Ok, could you please share your location?');
button('I need medical help', 'Ok, could you please share your location?');
button('Yes', 'We will send the police over');
button('No', 'Please share your location again');
button('Here is my location', 'function-getlocation');
department = 'the New York Police Department';
break;
case 'fdny':
button('I am stuck, cannot get out', 'Please remain calm and share your location.');
button('There is a fire!', 'Ok, could you please share your location?');
button('Here is my location', 'function-getlocation');
department = 'the Fire Department of New York';
break;
case 'oem':
button('I need food and water', 'Ok, could you please share your location?');
button('Is the water safe to drink?', 'Yes it is! There is no water contamination.');
button('Here is my location', 'function-getlocation');
department = 'the Office of Emergency Management';
break;
case undefined:
button('I need food and water', 'Ok, could you please share your location?');
button('Is the water safe to drink?', 'Yes it is! There is no water contamination.');
button('Here is my location', 'function-getlocation');
department = 'the Office of Emergency Management';
break;
}
$('.department').each(function() {
$(this).text(department);
});
$(document).on('click', '.message.button', function () {
var val = $.trim($(this).text());
var data = $.trim($(this).attr('data-response'));
$('#static').fadeIn("slow", function() {
if(data.startsWith('function')) {
response(val, 'One second as I retrieve your location...');
var func = data.substring(data.indexOf('-') + 1);
window[func]();
} else {
response(val, data);
}
});
});
});
</script>
</body>
</html>