File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 10
10
</div >
11
11
<div >
12
12
<h1 >Shuttles <span class =" material-icons" >airport_shuttle</span ></h1 >
13
+ <h2 v-if =" info.size === 0" >No shuttles are currently being tracked.</h2 >
14
+ <table >
15
+ <tbody >
16
+ <tr v-for =" item in info.values()" >
17
+ <td style =" text-align : left ;" ><h2 >{{ item.title }}</h2 ></td >
18
+ <td ><h2 >{{ item.prediction + ' ' + (item.prediction === '1' ? 'minute' : 'minutes') }}</h2 ></td >
19
+ </tr >
20
+ </tbody >
21
+ </table >
13
22
</div >
14
23
</div >
15
24
</div >
@@ -30,12 +39,33 @@ import './app.css'
30
39
components: {}
31
40
})
32
41
export default class App extends Vue {
42
+ private error: boolean = false
43
+ private info: Map <string , { prediction: string , title: string }> = new Map ()
33
44
private time: string = ' '
34
45
35
46
private mounted (): void {
36
47
setInterval (() => {
37
48
this .time = new Date ().toLocaleString ()
38
49
}, 1000 )
50
+
51
+ fetch (' http://webservices.nextbus.com/service/publicJSONFeed?command=predictionsForMultiStops&a=mit' +
52
+ ' &stops=tech|tangwest&stops=saferidecampshut|tangwest' ).then ((data ) => {
53
+ return data .json ()
54
+ }).then ((data ) => {
55
+ const info = new Map ()
56
+ for (const route of data .predictions ) {
57
+ if (route .direction !== undefined ) {
58
+ info .set (route .routeTag , {
59
+ prediction: route .direction .prediction [0 ].minutes ,
60
+ title: route .routeTitle
61
+ })
62
+ }
63
+ }
64
+ this .info = info
65
+ }).catch ((error ) => {
66
+ this .error = true
67
+ console .log (error )
68
+ })
39
69
}
40
70
}
41
71
</script >
50
80
font-size : 2.5em ;
51
81
}
52
82
83
+ table {
84
+ width : 100% ;
85
+ }
86
+
53
87
#app {
54
88
font-family : ' Avenir' , Helvetica , Arial , sans-serif ;
55
89
-webkit-font-smoothing : antialiased ;
You can’t perform that action at this time.
0 commit comments