-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop-card.html
130 lines (106 loc) · 3.47 KB
/
stop-card.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
<link rel="import" href="components_full/bower_components/polymer/polymer.html">
<link rel="import" href="components_full/bower_components/core-ajax/core-ajax.html">
<link rel="import" href="components_full/bower_components/core-collapse/core-collapse.html">
<link rel="import" href="components_full/bower_components/paper-shadow/paper-shadow.html">
<link rel="import" href="components_full/bower_components/core-icons/iconsets/icons.html">
<polymer-element name="stop-card" attributes="stopID name">
<template>
<style>
.stop_btn {
position: relative;
margin: 0;
width: 100%;
height: 100%;
padding: 5% 0 3% 0;
font-size: 1.75em;
color: #00274c;
border: 0;
background: none;
outline: 0;
}
.route-name {
margin-top: 2%;
font-family: sans-serif;
font-weight: normal;
font-size: 1.4em;
}
.time-list {
margin: -4% 0 7% 3%;
font-size: 1.1em;
font-family: sans-serif;
}
core-icon {
float: left;
margin-right: 0.5em;
margin-top: 0.1em;
color: #00274c;
}
core-icon:first-of-type {
margin-top: 0.35em;
}
.card {
background: white;
width: 20%;
min-width: 250px;
height: auto;
position: relative;
margin: 20px auto;
border-radius: 2px;
padding: 5px 20px;
}
</style>
<!--ajax calls here-->
<!--<core-ajax url="http://141.213.90.22:8001/routes" auto handleAs="json" on-core-response="{{resp2}}"></core-ajax>
<core-ajax url="http://141.213.90.22:8001/eta/stop={{stopID}}" auto handleAs="json" on-core-response="{{resp}}"></core-ajax>
-->
<core-ajax url="http://54.164.44.218:8001/routes" auto handleAs="json" on-core-response="{{resp2}}"></core-ajax>
<core-ajax url="http://54.164.44.218:8001/eta/stop={{stopID}}" auto handleAs="json" on-core-response="{{resp}}"></core-ajax>
<!-- Card Content -->
<div class="card">
<paper-shadow z="1"></paper-shadow>
<button class="stop_btn" on-click="{{toggle}}">{{name}}</button>
<core-collapse opened="true" id="{{name}}">
<template repeat="{{r in routes}}">
<core-icon size="25px" icon="directions-bus"></core-icon>
<h3 class="route-name">{{r.name}}</h3>
<ul class="time-list">
<template repeat="{{s in stops}}">
<template bind if="{{s.route == r.route}}">
<li>{{s.time}} minutes</li>
</template>
</template>
</ul>
</template>
</core-collapse>
</div>
</template>
<script>
Polymer('stop-card', {
stopID: "91",
name: "Pierpont",
toggle: function() {
this.$[this.name].toggle();
},
resp2: function(event, res){
this.routes = [];
var routes = res.response;
for(r in routes){
for(s in routes[r].stops)
if(routes[r].stops[s] == this.stopID){
this.routes.push({name: routes[r].name, route: routes[r].id})
}
}
},
resp: function(event, res) {
this.stops = [];
var stop = res.response.etas[this.stopID].etas;
for(s in stop){
var avg = stop[s].avg
if(avg < 61){
this.stops.push({time: avg, route: stop[s].route})
}
}
}
});
</script>
</polymer-element>