Skip to content

Commit

Permalink
Added icons based on transport type
Browse files Browse the repository at this point in the history
  • Loading branch information
nixnuex committed May 1, 2020
1 parent 62762b9 commit 57347e5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# MMM-SwissCommute Change Log
# MMM-SwissCommute Changelog

## [1.1.0] - May 1st 2020

- Added icons based on transport type
- Fixed CSS for multiple instaces

## [1.0.0] - Dec 10th 2017

Initial Release
Initial Release
31 changes: 28 additions & 3 deletions MMM-SwissCommute.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Module.register("MMM-SwissCommute",{
}

if (!this.loaded) {
wrapper.innerHTML = "Loading trains ...";
wrapper.innerHTML = "Loading connections ...";
wrapper.className = "dimmed light small";
return wrapper;
}
Expand All @@ -104,9 +104,33 @@ Module.register("MMM-SwissCommute",{
var row = document.createElement("tr");
table.appendChild(row);

// Number
// Number & Icon
var icon = "";
switch(trains.type) {
case "train":
icon = "fa-train";
break;
case "strain":
icon = "fa-train";
break;
case "bus":
icon = "fa-bus";
break;
case "tram":
icon = "fa-subway";
break;
case "ship":
icon = "fa-ship";
break;
case "cableway":
icon = "fa-tram";
break;
default:
icon = "fa-train";
}

var trainNumberCell = document.createElement("td");
trainNumberCell.innerHTML = "<i class=\"fa fa-train\"></i> " + trains.number;
trainNumberCell.innerHTML = "<i class=\"fa " + icon + "\"></i> " + trains.number;
trainNumberCell.className = "align-left";
row.appendChild(trainNumberCell);

Expand Down Expand Up @@ -230,6 +254,7 @@ Module.register("MMM-SwissCommute",{
departureTimestamp: moment(trains.departure).format("HH:mm"),
delay: parseInt(trains.dep_delay),
to: trains.legs[0].terminal,
type: trains.legs[0].type,
number: trains.legs[0].line,
track: trains.legs[0].track
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MMM-SwissCommute",
"version": "1.0.0",
"version": "1.1.0",
"description": "A MagicMirror Module to display the next departures for your favorite (train) connection in Switzerland",
"main": "MMM-SwissCommute.js",
"author": "nixnuex",
Expand Down

0 comments on commit 57347e5

Please sign in to comment.