-
Notifications
You must be signed in to change notification settings - Fork 0
/
exitDoor.html
384 lines (347 loc) · 13.2 KB
/
exitDoor.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exit Door</title>
<!-- jquery local link replaced with CDN -->
<!--script type="text/javascript" src="js/jquery-1.10.2.min.js"></script-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css" />
<!-- This page doesn't work with local boostrap Javascript. replacing it with CDN -->
<!--script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="css/local.css" />
<link href="assets/css/style.css" rel="stylesheet" />
<script src="assets/js/script.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.0.0/moment.min.js"></script>
<link href="bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet">
<script src="bootstrap-switch/js/bootstrap-switch.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
//Only Directions
function mapsForGoogle(){
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
console.log("inside initailize function");
var mapOptions = {
zoom: 7,
center: new google.maps.LatLng(37.3393857,-121.8949555)
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('directions-panel'));
console.log('loaded the map?');
//Aswin
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
var start = "san jose, ca";
var end = "san francisco, ca";
var request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING,
durationInTraffic: true
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
var timeOfTravel = response.routes[0].legs[0].duration['text'];
sessionStorage.setItem('avgTime', timeOfTravel);
//var minTravelTime = "50 mins";
console.log(timeOfTravel);
/* if(timeOfTravel > minTravelTime){
var msg = "Please start few minutes early to reach work on time!"
document.getElementById("trafficRecommend").innerHTML = msg;
} */
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
} // maps function
</script>
<style>
/* Directions Panel (Traffic) */
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<style>
#directions-panel {
height: 100%;
float: right;
overflow: auto;
float: none;
}
#map-canvas {
min-height:400px;
}
@media print {
#map-canvas {
margin: 0;
}
}
.adp-directions{
background-color: #fff !important;
}
</style>
<style>
input{
color:black;
}
.pager li a{
color:#fff;
}
.padBottom {
padding-bottom:20px;
}
label{
color:white;
}
.demo{
margin-bottom: -10px;
padding-bottom: 10px;
//background-color:#efefef;
}
img.displayed {
display: block;
margin-left: auto;
margin-right: auto }
</style>
</head>
<body>
<div id="wrapper">
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><img src="assets/img/logo-new.png" style="margin-top: -5px;" width="65" height="40"></img></a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav side-nav">
<li><a href="homePage.html"><i class="fa fa-home fa-lg"></i> Home</a></li>
<li><a href="index.html"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li>
<li><a href="demoPage.html"><i class="fa fa-tasks fa-lg"></i> Demo page</a></li>
<li><a href="bedRoom.html"><i class="fa fa-bed fa-lg"></i> Bed Room</a></li>
<li><a href="kitchen.html"><i class="fa fa-cutlery fa-lg"></i> Kitchen</a></li>
<li><a href="livingRoom.html"><i class="fa fa-gamepad fa-lg"></i> Living Room</a></li>
<li class="selected"><a href="exitDoor.html"><i class="fa fa-sign-out fa-lg"></i> Exit Door</a></li>
<li><a href="support.html"><i class="fa fa-question-circle fa-lg"></i> Support</a></li>
</ul>
<ul class="nav navbar-nav navbar-right navbar-user">
<li class="dropdown user-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> Aswin <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#"><i class="fa fa-user"></i> Profile</a></li>
<li><a href="#"><i class="fa fa-gear"></i> Settings</a></li>
<li class="divider"></li>
<li><a href="#"><i class="fa fa-power-off"></i> Log Out</a></li>
</ul>
</li>
</ul>
</div>
</nav>
<div id="page-wrapper">
<!-- Adding Priyanka's code -->
<h2 style="text-align:center;">Exit Home</h2>
<ul class="pager">
<li class="previous"><a href="livingRoom.html">Previous</a></li>
</ul>
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-bar-chart-o"></i>Door with Recommendation</h3>
</div>
<div class="panel-body">
<div class="form-group">
<img class="displayed" src="assets/img/door.jpg" width="250" height="250"></img>
</div>
<div class="form-group">
<h4>Recommendations</h4>
<div class=" well col-sm-12">
<div><h3>Grocery List:</h3>
<table class="table table bordered table striped">
<tr>
<td>Items</td>
<td>Quantity Left</td>
<td>Recommended</td>
</tr>
<tr id="milkRow" style="display:none;">
<td>Milk</td>
<td><input type="text" id="milk"></td>
<td><label id="milkMsg"></label></td>
</tr>
<tr id="prodRow" style="display:none;">
<td>Produce</td>
<td><input type="text" id="prod"></td>
<td><label id="prodMsg"></label></td>
</tr>
<tr id="eggsRow" style="display:none;">
<td>Eggs</td>
<td><input type="text" id="eggs"></td>
<td><label id="eggsMsg"></label></td>
</tr>
<tr id="meatRow" style="display:none;">
<td>Meat</td>
<td><input type="text" id="meat"></td>
<td><label id="meatMsg"></label></td>
</tr>
</table>
</div>
</div>
</div>
<!--div class="form-group">
<label for="company" class="col-sm-6 control-label">Weather</label>
<div class="col-sm-6">
<label for="company" class="col-sm-6 control-label">TBD</label>
</div>
</div-->
<!--div class="form-group">
<label for="company" class="col-sm-6 control-label">Traffic</label>
<div class="col-sm-6">
<label for="company" id="test" class="col-sm-6 control-label"></label>
</div>
</div-->
<div style="background-color:#fff; height:100%; width:100%;">
<h3 style="color:black;">Traffic</h3><div id="text"></div><br/>
<div class="col-lg-8" id="map-canvas"></div>
<div class="col-lg-4" id="directions-panel" style="background-color: #fff !important;"></div>
</div>
</div><!-- body-->
</div>
</div>
</div><!-- row -->
</div>
</div>
</body>
<script>
$(document).ready(function(){
mapsForGoogle();
/*
$.ajax({ //indoor
url: 'kitchen.html',
dataType: 'jsonp',
success: function(result){
var y = result.temperature;
console.log("temp value : ", y);
document.getElementById('temp').innerHTML = y;
}
}); */
var cities = ["San Jose Downtown", "Santa Clara", "Sunnyvale", "Mountain View", "Palo Alto", "Redwood City", "San Carlos", "Belmont", "San Mateo", "Burlingame", "Milbrae", "San Bruno", "Airport", "South San Francisco", "Brisbane", "Bernal Heights", "Mission District", "San Francisco Downtown"];
var incident = ["Construction", "Accident", "Road Closure"];
var randCity = cities[Math.floor(Math.random() * cities.length)];
var randIncident = incident[Math.floor(Math.random() * incident.length)];
var randMins = Math.floor((Math.random() * 21) + 10);
console.log(randCity + " " + randIncident + " " + randMins + " mins");
var msg = randIncident + " near " + randCity + " Please leave in " + randMins + " minutes";
var travelTime = sessionStorage.getItem('avgTime');
var strSlice = travelTime.slice(0,2);
var travelTimeInt = parseInt(strSlice);
var trafficTime = randMins;
var trafficTimeInt = parseInt(trafficTime);
var totalTime = parseInt(travelTimeInt + trafficTimeInt);
console.log("travel time ", totalTime);
var trafficMsg;
if(totalTime > 60){
var mins = totalTime - 60 ;
trafficMsg = "Approximate time to Destination: 1 hour and "+ mins + " mins";
}else{
trafficMsg = "Approximate time to Destination: " + totalTime + " mins";
}
document.getElementById("text").innerHTML = trafficMsg;
$(".machine").bootstrapSwitch();
if(typeof(Storage) !== "undefined") {
var milk_qty = sessionStorage.getItem('milkQuantity');
var prod_qty = sessionStorage.getItem('produceQuantity');
var eggs_qty = sessionStorage.getItem('eggsQuantity');
var meat_qty = sessionStorage.getItem('meatQuantity');
console.log("produce is", eggs_qty);
console.log("produce is", meat_qty);
var milkMsg, eggsMsg, prodMsg, meatMsg;
var milkRow = document.getElementById('milkRow');
var prodRow = document.getElementById('prodRow');
var eggsRow = document.getElementById('eggsRow');
var meatRow = document.getElementById('meatRow');
/** milk **/
if(milk_qty > 40){
milkRow.style.display = "none";
}else if(milk_qty < 15){
milkMsg = "Stock up! Urgent!";
milkRow.style.display = '';
document.getElementById("milk").value = "only " + milk_qty +" %";
document.getElementById("milkMsg").innerHTML = milkMsg;
}else{
milkMsg = "Get 1 Bottle";
milkRow.style.display = '';
document.getElementById("milk").value = "only " + milk_qty +" %";
document.getElementById("milkMsg").innerHTML = milkMsg;
}
/** Produce **/
if(prod_qty > 40){
prodRow.style.display = "none";
}else if(prod_qty < 15){
prodMsg = "Get all Veggies! running short!";
}else{
prodMsg = "Get Cucumbers, Carrots, Bell Peppers and Salad mix";
prodRow.style.display = '';
document.getElementById("prod").value = "only " + prod_qty +" %";
document.getElementById("prodMsg").innerHTML = prodMsg;
}
/** Eggs **/
if(eggs_qty > 7){
eggsRow.style.display = "none";
}else if(eggs_qty < 2){
eggsMsg = "Stock up! Eggs sufficient only for a day!"
}else{
eggsMsg = "Get a Dozen Eggs";
eggsRow.style.display = '';
document.getElementById("eggs").value = "only " + eggs_qty +" %";
document.getElementById("eggsMsg").innerHTML = eggsMsg;
}
/** Meat **/
if(meat_qty >1 ){
meatRow.style.display = "none";
}else if(meat_qty = 1){
meatMsg = "Only 1 serving left";
}else{
meatMsg = "Get 1 serving of Fish";
meatRow.style.display = '';
document.getElementById("meat").value = "only " + meat_qty +" %";
document.getElementById("meatMsg").innerHTML = meatMsg;
}
if(milk_qty > 40 && prod_qty > 40 && eggs_qty > 7 && meat_qty > 1){
console.log("Display that everything is stocked up!");
}
/*document.getElementById("prod").value = pro_qty;
document.getElementById("eggs").value = eggs_qty;
document.getElementById("meat").value = meat_qty;
/* console.log("qty is: ", qty);
document.getElementById("test").value = qty; */
} else {
alert("Sorry! No Web Storage support..");
}
});
</script>
</html>