@@ -3,7 +3,7 @@ import { getSocket } from "./bus-shared.js";
33/* globals Messenger */
44var bus = { } ;
55
6- $ ( function ( ) {
6+ $ ( function ( ) {
77 let base_url = window . location . host ;
88
99 bus . sendUpdate = function ( data ) {
@@ -28,11 +28,11 @@ $(function() {
2828 bus . StatusGroupModel = Backbone . Model . extend ( ) ;
2929
3030 bus . PersonalStatusView = Backbone . View . extend ( {
31- initialize : function ( ) {
31+ initialize : function ( ) {
3232 _ . bindAll ( this , 'render' ) ;
3333 this . template = _ . template ( $ ( '#personal-status' ) . html ( ) ) ;
3434 } ,
35- render : function ( ) {
35+ render : function ( ) {
3636 var container = this . $el ,
3737 renderedContent = this . template ( this . model . toJSON ( ) ) ;
3838 container . html ( renderedContent ) ;
@@ -84,7 +84,7 @@ $(function() {
8484 'text' : this . text
8585 } ;
8686 this . $el . html ( this . buttonTemplate ( data ) )
87- . removeClass ( 'search-widget' ) ;
87+ . removeClass ( 'search-widget' ) ;
8888 return this ;
8989 } ,
9090 renderSearchView : function ( routeList , action ) {
@@ -95,22 +95,9 @@ $(function() {
9595 let busList = [ ] ;
9696 if ( action === 'Search for a bus' ) {
9797 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 ) ;
100100 } 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- = === ===
114101 busList = routeList . map ( bus => {
115102 if ( ( bus . attributes . status === 'a' || bus . attributes . status === 'd' ) && ! bus . attributes . route_name . includes ( 'JT' ) ) {
116103 let attr = JSON . parse ( JSON . stringify ( bus . attributes ) ) ;
@@ -135,10 +122,9 @@ $(function() {
135122
136123 }
137124 } ) . flat ( ) . filter ( ( element ) => element != null ) ;
138- > >>> >>> 45142 c57 ( feat ( bus ) : option to mark bus as delayed )
139125 } else if ( action === 'Assign a bus to this space' ) {
140126 busList = routeList . filter ( bus => bus . attributes . status !== 'a' )
141- . map ( bus => bus . attributes ) ;
127+ . map ( bus => bus . attributes ) ;
142128 }
143129 let selectField = container . find ( 'select' ) . selectize ( {
144130 'options' : busList ,
@@ -186,23 +172,13 @@ $(function() {
186172 if ( ! this . selected ) {
187173 return ;
188174 }
189- let route = this . model . findWhere ( { route_name : e . target . value } ) . attributes ;
175+ let route = this . model . findWhere ( { route_name : e . target . value } ) . attributes ;
190176 route . space = this . selected . id ;
191177 route . status = 'a' ;
192178 bus . sendUpdate ( route ) ;
193179 } else if ( this . action === 'Mark a bus as arrived or on time' ) {
194180 let route_name = '' ;
195181 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- = === ===
206182 if ( e . target . value . includes ( 'on' ) ) {
207183 route_name = e . target . value . split ( ' ' ) [ 1 ] ;
208184
@@ -215,10 +191,9 @@ $(function() {
215191 }
216192 else {
217193 route_name = e . target . value . split ( ' ' ) [ 1 ] ;
218- > >>> >>> 45142 c57 ( feat ( bus ) : option to mark bus as delayed )
219194 st = 'a' ;
220195 }
221- let route = this . model . findWhere ( { route_name : route_name } ) . attributes ;
196+ let route = this . model . findWhere ( { route_name : route_name } ) . attributes ;
222197 route . status = st ;
223198 bus . sendUpdate ( route ) ;
224199 }
@@ -392,18 +367,18 @@ $(function() {
392367 // fallbacks to avoid issues that have appeared in the past with the "sans-serif" default.
393368 text . font ( "family" , "Helvetica, Arial, 'Open Sans', 'Liberation Sans', sans-serif" ) ;
394369
395- if ( window . isSignage ) {
370+ if ( window . isSignage ) {
396371 var tspan = $ ( text . node ) . find ( "tspan" ) ;
397- tspan . attr ( { "x" : 0 , "dy" : 20.5 } ) ;
372+ tspan . attr ( { "x" : 0 , "dy" : 20.5 } ) ;
398373
399374 // 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 ( ) {
401376 var tbox = tspan . get ( 0 ) . getBBox ( ) ;
402377 var sbox = space . getBBox ( ) ;
403378
404379 var offset ;
405380 var dimenDiff ;
406- if ( tbox . width > tbox . height ) {
381+ if ( tbox . width > tbox . height ) {
407382 dimenDiff = sbox . width - tbox . width ;
408383 offset = tbox . x - sbox . x ;
409384 }
@@ -412,9 +387,9 @@ $(function() {
412387 offset = tbox . y - sbox . y ;
413388 }
414389
415- if ( dimenDiff < offset + 5 ) {
390+ if ( dimenDiff < offset + 5 ) {
416391 text . node . classList . add ( "small" ) ;
417- if ( route . attributes . route_name . length > 5 ) {
392+ if ( route . attributes . route_name . length > 5 ) {
418393 text . node . classList . add ( "extra-small" ) ;
419394 }
420395 }
@@ -423,21 +398,21 @@ $(function() {
423398 else {
424399 var tspan = $ ( text . node ) . find ( "tspan" ) ;
425400
426- setTimeout ( function ( ) {
401+ setTimeout ( function ( ) {
427402 var tbox = tspan . get ( 0 ) . getBBox ( ) ;
428403 var sbox = space . getBBox ( ) ;
429404
430405 var offset ;
431406 var dimenDiff ;
432- if ( tbox . width > tbox . height ) {
407+ if ( tbox . width > tbox . height ) {
433408 dimenDiff = sbox . width - tbox . width ;
434409 offset = tbox . x - sbox . x ;
435410 }
436411 else {
437412 dimenDiff = sbox . height - tbox . height ;
438413 offset = tbox . y - sbox . y ;
439414 }
440- if ( dimenDiff < offset + 5 || route . attributes . route_name . length > 5 ) {
415+ if ( dimenDiff < offset + 5 || route . attributes . route_name . length > 5 ) {
441416 text . node . classList . add ( "extra-small" ) ;
442417 }
443418 } , 0 ) ;
@@ -602,7 +577,7 @@ $(function() {
602577 // equatorial radius of Earth = 6,378.1370 km
603578 // polar radius of Earth = 6,356.7523 km
604579
605- // length of 1 deg equatorial longitude
580+ // length of 1 deg equatorial longitude
606581 let deg_lng_eq = 6378.1370 * 2 * Math . PI / 360 ;
607582 // length of 1 deg equatorial latitude
608583 let deg_lat_eq = 6356.7523 * 2 * Math . PI / 360 ;
@@ -629,7 +604,7 @@ $(function() {
629604 }*/
630605 let degrees = ( direction ) * ( 180 / Math . PI ) - 49 + 90 ;
631606 // let degrees = (direction) * (180 / Math.PI);
632- this . busDriverEl . css ( { 'transform' : 'rotate(' + degrees + 'deg)' } ) ;
607+ this . busDriverEl . css ( { 'transform' : 'rotate(' + degrees + 'deg)' } ) ;
633608 this . mapbox . setCenter ( this . busDriverBus . point . coordinates ) ;
634609
635610 this . busDriverBus . lastFrame = time ;
@@ -676,7 +651,7 @@ $(function() {
676651 container . empty ( ) ;
677652 container . append ( this . template ( this . model . toJSON ( ) ) ) ;
678653 _ . 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 ) ;
680655 } ) ;
681656 return this ;
682657 }
@@ -741,23 +716,23 @@ $(function() {
741716 }
742717 } ) ;
743718
744- if ( isAdmin ) {
745- $ ( ".bus-announcement-save" ) . click ( function ( ) {
719+ if ( isAdmin ) {
720+ $ ( ".bus-announcement-save" ) . click ( function ( ) {
746721 bus . sendUpdate ( {
747722 announcement : $ ( ".bus-announcement" ) . text ( )
748723 } ) ;
749724 $ ( ".bus-announcement-save" ) . text ( "Saved!" ) . css ( "color" , "green" ) ;
750- setTimeout ( function ( ) {
725+ setTimeout ( function ( ) {
751726 $ ( ".bus-announcement-save" ) . text ( "Save" ) . css ( "color" , "" ) ;
752727 } , 1500 ) ;
753728 } ) ;
754- $ ( ".bus-announcement-clear" ) . click ( function ( ) {
729+ $ ( ".bus-announcement-clear" ) . click ( function ( ) {
755730 $ ( ".bus-announcement" ) . text ( "" ) ;
756731 bus . sendUpdate ( {
757732 announcement : "" ,
758733 } ) ;
759734 $ ( ".bus-announcement-clear" ) . text ( "Cleared!" ) . css ( "color" , "green" ) ;
760- setTimeout ( function ( ) {
735+ setTimeout ( function ( ) {
761736 $ ( ".bus-announcement-clear" ) . text ( "Clear" ) . css ( "color" , "" ) ;
762737 } , 1500 ) ;
763738 } ) ;
@@ -782,7 +757,7 @@ $(function() {
782757 Backbone . trigger ( 'recordScore' , e ) ;
783758 } ) ;
784759 }
785- // window.personalStatusView = new bus.personalStatusView();
760+ // window.personalStatusView = new bus.personalStatusView();
786761} ) ;
787762
788763/* TODO: flip bus map to be horizontal
0 commit comments