@@ -3,7 +3,7 @@ import { getSocket } from "./bus-shared.js";
3
3
/* globals Messenger */
4
4
var bus = { } ;
5
5
6
- $ ( function ( ) {
6
+ $ ( function ( ) {
7
7
let base_url = window . location . host ;
8
8
9
9
bus . sendUpdate = function ( data ) {
@@ -28,11 +28,11 @@ $(function() {
28
28
bus . StatusGroupModel = Backbone . Model . extend ( ) ;
29
29
30
30
bus . PersonalStatusView = Backbone . View . extend ( {
31
- initialize : function ( ) {
31
+ initialize : function ( ) {
32
32
_ . bindAll ( this , 'render' ) ;
33
33
this . template = _ . template ( $ ( '#personal-status' ) . html ( ) ) ;
34
34
} ,
35
- render : function ( ) {
35
+ render : function ( ) {
36
36
var container = this . $el ,
37
37
renderedContent = this . template ( this . model . toJSON ( ) ) ;
38
38
container . html ( renderedContent ) ;
@@ -84,7 +84,7 @@ $(function() {
84
84
'text' : this . text
85
85
} ;
86
86
this . $el . html ( this . buttonTemplate ( data ) )
87
- . removeClass ( 'search-widget' ) ;
87
+ . removeClass ( 'search-widget' ) ;
88
88
return this ;
89
89
} ,
90
90
renderSearchView : function ( routeList , action ) {
@@ -95,22 +95,9 @@ $(function() {
95
95
let busList = [ ] ;
96
96
if ( action === 'Search for a bus' ) {
97
97
busList = routeList . filter ( bus => bus . attributes . status === 'a' )
98
- . filter ( bus => bus . attributes . route_name . includes ( 'JT' ) )
99
- . map ( bus => bus . attributes ) ;
98
+ . filter ( bus => bus . attributes . route_name . includes ( 'JT' ) )
99
+ . map ( bus => bus . attributes ) ;
100
100
} else if ( action === 'Mark a bus as arrived or on time' ) {
101
- < << << << HEAD
102
- busList = routeList . filter ( bus => ! bus . attributes . route_name . includes ( 'JT' ) )
103
- . map ( bus => {
104
- if ( bus . attributes . status === 'a' ) {
105
- // TODO: less hacky deep copy
106
- let attr = JSON . parse ( JSON . stringify ( bus . attributes ) ) ;
107
- attr . route_name = `Mark ${ bus . attributes . route_name } as on time` ;
108
- return attr ;
109
- } else {
110
- return bus . attributes ;
111
- }
112
- } ) ;
113
- = === ===
114
101
busList = routeList . map ( bus => {
115
102
if ( ( bus . attributes . status === 'a' || bus . attributes . status === 'd' ) && ! bus . attributes . route_name . includes ( 'JT' ) ) {
116
103
let attr = JSON . parse ( JSON . stringify ( bus . attributes ) ) ;
@@ -135,10 +122,9 @@ $(function() {
135
122
136
123
}
137
124
} ) . flat ( ) . filter ( ( element ) => element != null ) ;
138
- > >>> >>> 45142 c57 ( feat ( bus ) : option to mark bus as delayed )
139
125
} else if ( action === 'Assign a bus to this space' ) {
140
126
busList = routeList . filter ( bus => bus . attributes . status !== 'a' )
141
- . map ( bus => bus . attributes ) ;
127
+ . map ( bus => bus . attributes ) ;
142
128
}
143
129
let selectField = container . find ( 'select' ) . selectize ( {
144
130
'options' : busList ,
@@ -186,23 +172,13 @@ $(function() {
186
172
if ( ! this . selected ) {
187
173
return ;
188
174
}
189
- let route = this . model . findWhere ( { route_name : e . target . value } ) . attributes ;
175
+ let route = this . model . findWhere ( { route_name : e . target . value } ) . attributes ;
190
176
route . space = this . selected . id ;
191
177
route . status = 'a' ;
192
178
bus . sendUpdate ( route ) ;
193
179
} else if ( this . action === 'Mark a bus as arrived or on time' ) {
194
180
let route_name = '' ;
195
181
let st = '' ;
196
- < << << << HEAD
197
- // TODO: this is also super hacky
198
- // Essentially, this checks if the selected route has "Mark"
199
- // at the beginning, implying that it's to be marked on time.
200
- if ( e . target . value . indexOf ( 'Mark' ) === 0 ) {
201
- route_name = e . target . value . split ( ' ' ) [ 1 ] ;
202
- st = 'o' ;
203
- } else {
204
- route_name = e . target . value ;
205
- = === ===
206
182
if ( e . target . value . includes ( 'on' ) ) {
207
183
route_name = e . target . value . split ( ' ' ) [ 1 ] ;
208
184
@@ -215,10 +191,9 @@ $(function() {
215
191
}
216
192
else {
217
193
route_name = e . target . value . split ( ' ' ) [ 1 ] ;
218
- > >>> >>> 45142 c57 ( feat ( bus ) : option to mark bus as delayed )
219
194
st = 'a' ;
220
195
}
221
- let route = this . model . findWhere ( { route_name : route_name } ) . attributes ;
196
+ let route = this . model . findWhere ( { route_name : route_name } ) . attributes ;
222
197
route . status = st ;
223
198
bus . sendUpdate ( route ) ;
224
199
}
@@ -392,18 +367,18 @@ $(function() {
392
367
// fallbacks to avoid issues that have appeared in the past with the "sans-serif" default.
393
368
text . font ( "family" , "Helvetica, Arial, 'Open Sans', 'Liberation Sans', sans-serif" ) ;
394
369
395
- if ( window . isSignage ) {
370
+ if ( window . isSignage ) {
396
371
var tspan = $ ( text . node ) . find ( "tspan" ) ;
397
- tspan . attr ( { "x" : 0 , "dy" : 20.5 } ) ;
372
+ tspan . attr ( { "x" : 0 , "dy" : 20.5 } ) ;
398
373
399
374
// If we run this directly, it hasn't rendered yet, so we have to run it after a timeout
400
- setTimeout ( function ( ) {
375
+ setTimeout ( function ( ) {
401
376
var tbox = tspan . get ( 0 ) . getBBox ( ) ;
402
377
var sbox = space . getBBox ( ) ;
403
378
404
379
var offset ;
405
380
var dimenDiff ;
406
- if ( tbox . width > tbox . height ) {
381
+ if ( tbox . width > tbox . height ) {
407
382
dimenDiff = sbox . width - tbox . width ;
408
383
offset = tbox . x - sbox . x ;
409
384
}
@@ -412,9 +387,9 @@ $(function() {
412
387
offset = tbox . y - sbox . y ;
413
388
}
414
389
415
- if ( dimenDiff < offset + 5 ) {
390
+ if ( dimenDiff < offset + 5 ) {
416
391
text . node . classList . add ( "small" ) ;
417
- if ( route . attributes . route_name . length > 5 ) {
392
+ if ( route . attributes . route_name . length > 5 ) {
418
393
text . node . classList . add ( "extra-small" ) ;
419
394
}
420
395
}
@@ -423,21 +398,21 @@ $(function() {
423
398
else {
424
399
var tspan = $ ( text . node ) . find ( "tspan" ) ;
425
400
426
- setTimeout ( function ( ) {
401
+ setTimeout ( function ( ) {
427
402
var tbox = tspan . get ( 0 ) . getBBox ( ) ;
428
403
var sbox = space . getBBox ( ) ;
429
404
430
405
var offset ;
431
406
var dimenDiff ;
432
- if ( tbox . width > tbox . height ) {
407
+ if ( tbox . width > tbox . height ) {
433
408
dimenDiff = sbox . width - tbox . width ;
434
409
offset = tbox . x - sbox . x ;
435
410
}
436
411
else {
437
412
dimenDiff = sbox . height - tbox . height ;
438
413
offset = tbox . y - sbox . y ;
439
414
}
440
- if ( dimenDiff < offset + 5 || route . attributes . route_name . length > 5 ) {
415
+ if ( dimenDiff < offset + 5 || route . attributes . route_name . length > 5 ) {
441
416
text . node . classList . add ( "extra-small" ) ;
442
417
}
443
418
} , 0 ) ;
@@ -602,7 +577,7 @@ $(function() {
602
577
// equatorial radius of Earth = 6,378.1370 km
603
578
// polar radius of Earth = 6,356.7523 km
604
579
605
- // length of 1 deg equatorial longitude
580
+ // length of 1 deg equatorial longitude
606
581
let deg_lng_eq = 6378.1370 * 2 * Math . PI / 360 ;
607
582
// length of 1 deg equatorial latitude
608
583
let deg_lat_eq = 6356.7523 * 2 * Math . PI / 360 ;
@@ -629,7 +604,7 @@ $(function() {
629
604
}*/
630
605
let degrees = ( direction ) * ( 180 / Math . PI ) - 49 + 90 ;
631
606
// let degrees = (direction) * (180 / Math.PI);
632
- this . busDriverEl . css ( { 'transform' : 'rotate(' + degrees + 'deg)' } ) ;
607
+ this . busDriverEl . css ( { 'transform' : 'rotate(' + degrees + 'deg)' } ) ;
633
608
this . mapbox . setCenter ( this . busDriverBus . point . coordinates ) ;
634
609
635
610
this . busDriverBus . lastFrame = time ;
@@ -676,7 +651,7 @@ $(function() {
676
651
container . empty ( ) ;
677
652
container . append ( this . template ( this . model . toJSON ( ) ) ) ;
678
653
_ . each ( this . model . attributes . collection , function ( route ) {
679
- container . append ( new bus . RouteView ( { model : route } ) . render ( ) . el ) ;
654
+ container . append ( new bus . RouteView ( { model : route } ) . render ( ) . el ) ;
680
655
} ) ;
681
656
return this ;
682
657
}
@@ -741,23 +716,23 @@ $(function() {
741
716
}
742
717
} ) ;
743
718
744
- if ( isAdmin ) {
745
- $ ( ".bus-announcement-save" ) . click ( function ( ) {
719
+ if ( isAdmin ) {
720
+ $ ( ".bus-announcement-save" ) . click ( function ( ) {
746
721
bus . sendUpdate ( {
747
722
announcement : $ ( ".bus-announcement" ) . text ( )
748
723
} ) ;
749
724
$ ( ".bus-announcement-save" ) . text ( "Saved!" ) . css ( "color" , "green" ) ;
750
- setTimeout ( function ( ) {
725
+ setTimeout ( function ( ) {
751
726
$ ( ".bus-announcement-save" ) . text ( "Save" ) . css ( "color" , "" ) ;
752
727
} , 1500 ) ;
753
728
} ) ;
754
- $ ( ".bus-announcement-clear" ) . click ( function ( ) {
729
+ $ ( ".bus-announcement-clear" ) . click ( function ( ) {
755
730
$ ( ".bus-announcement" ) . text ( "" ) ;
756
731
bus . sendUpdate ( {
757
732
announcement : "" ,
758
733
} ) ;
759
734
$ ( ".bus-announcement-clear" ) . text ( "Cleared!" ) . css ( "color" , "green" ) ;
760
- setTimeout ( function ( ) {
735
+ setTimeout ( function ( ) {
761
736
$ ( ".bus-announcement-clear" ) . text ( "Clear" ) . css ( "color" , "" ) ;
762
737
} , 1500 ) ;
763
738
} ) ;
@@ -782,7 +757,7 @@ $(function() {
782
757
Backbone . trigger ( 'recordScore' , e ) ;
783
758
} ) ;
784
759
}
785
- // window.personalStatusView = new bus.personalStatusView();
760
+ // window.personalStatusView = new bus.personalStatusView();
786
761
} ) ;
787
762
788
763
/* TODO: flip bus map to be horizontal
0 commit comments