@@ -73,29 +73,35 @@ Module.register("MMM-SG-Transport-V2", {
7373
7474 createBusRow : function ( bus ) {
7575
76- // Calculate arrival times
7776 ArrivalTimeArray = [ ] ;
77+ CrowdingLevelArray = [ ]
7878 if ( bus . NextBus . EstimatedArrival !== "" ) {
7979 ArrivalTimeArray . push ( bus . NextBus . EstimatedArrival ) ;
80+ CrowdingLevelArray . push ( bus . NextBus . Load )
8081 }
8182 if ( bus . NextBus2 . EstimatedArrival !== "" ) {
8283 ArrivalTimeArray . push ( bus . NextBus2 . EstimatedArrival ) ;
84+ CrowdingLevelArray . push ( bus . NextBus . Load )
8385 }
8486 if ( bus . NextBus3 . EstimatedArrival !== "" ) {
8587 ArrivalTimeArray . push ( bus . NextBus3 . EstimatedArrival ) ;
88+ CrowdingLevelArray . push ( bus . NextBus . Load )
8689 }
8790
8891 // Don't display if no data
8992 if ( ArrivalTimeArray . length == 0 ) {
90- return document . createElement ( "div" ) ;
93+ return document . createElement ( "div" ) ;
9194 }
9295
9396 var row = document . createElement ( "tr" ) ;
9497 var element = document . createElement ( "td" ) ;
9598 element . innerHTML = bus . ServiceNo + ": "
9699 row . appendChild ( element ) ;
97100
98- ArrivalTimeArray . forEach ( function ( ArrivalTime ) {
101+ for ( var i = 0 ; i < ArrivalTimeArray . length ; i ++ ) {
102+ var ArrivalTime = ArrivalTimeArray [ i ] ;
103+ var CrowdingLevel = CrowdingLevelArray [ i ] ;
104+
99105 var time = new Date ( ArrivalTime ) ;
100106 var now = new Date ( ) ;
101107 var arrivalTimeInMinutes = Math . floor ( ( time - now ) / ( 60 * 1000 ) ) ;
@@ -106,9 +112,34 @@ Module.register("MMM-SG-Transport-V2", {
106112 }
107113
108114 var element = document . createElement ( "td" ) ;
109- element . innerHTML = arrivalTimeInMinutes ;
115+ element . innerHTML = arrivalTimeInMinutes + ": " ;
116+
117+ // Location of stickman image
118+ var pathToImage = "modules/MMM-SG-Transport-V2/images/stickman.png" ;
119+ // Height of image
120+ var height = 17 ;
121+
122+ var image = "<img src='" + pathToImage + "' height='" + height + "'>"
123+
124+ // Seating available
125+ if ( CrowdingLevel == "SEA" ) {
126+ // print once
127+ element . innerHTML += image ;
128+
129+ // Standing available
130+ } else if ( CrowdingLevel == "SDA" ) {
131+ element . innerHTML += image ;
132+ element . innerHTML += image ;
133+
134+ // Limited standing
135+ } else if ( CrowdingLevel == "LSD" ) {
136+ element . innerHTML += image ;
137+ element . innerHTML += image ;
138+ element . innerHTML += image ;
139+ }
140+
110141 row . appendChild ( element ) ;
111- } ) ;
142+ } ;
112143
113144 return row ;
114145 } ,
0 commit comments