diff --git a/.github/preview.png b/.github/preview.png deleted file mode 100644 index 2cdeeae..0000000 Binary files a/.github/preview.png and /dev/null differ diff --git a/README.md b/README.md index 49d2bc6..2d4d5eb 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ Add module configuration to config.js. |`destination`|The target location.

**Example:** `Frankfurt HBF`
This value is **REQUIRED**| |`maxConnections`|How many connections should be displayed?

**Default value:** `3`| |`updateInterval`|How often does the content needs to be fetched? (Minutes)

**Default value:** `5`| +|`absoluteTime`|If `true` displays the departure time as 'at hh:mm', if `false` displays 'in xx mins'

**Default value:** `false`| +|`showDuration`|If `true` displays the trip duration following the departure time

**Default value:** `false`| |`animationSpeed`|Speed of the update animation. (Seconds)

**Default value:** `1`| ## Special Thanks diff --git a/i18n/.AppleDouble/.Parent b/i18n/.AppleDouble/.Parent new file mode 100644 index 0000000..7eac7fe Binary files /dev/null and b/i18n/.AppleDouble/.Parent differ diff --git a/i18n/.AppleDouble/en.json b/i18n/.AppleDouble/en.json new file mode 100644 index 0000000..886b1c8 Binary files /dev/null and b/i18n/.AppleDouble/en.json differ diff --git a/i18n/de.json b/i18n/de.json index e041d2b..1ddf272 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -1,3 +1,4 @@ { - "LOADING_CONNECTIONS": "Lade Verbindungen ..." + "LOADING_CONNECTIONS": "Lade Verbindungen ...", + "ABSOLUTE_PREFIX": "um " } diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..1f2f21f --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,4 @@ +{ + "LOADING_CONNECTIONS": "Loading Connections...", + "ABSOLUTE_PREFIX": "at " +} diff --git a/localtransport.js b/localtransport.js index 48b2bb2..67dc435 100644 --- a/localtransport.js +++ b/localtransport.js @@ -16,6 +16,8 @@ Module.register('localtransport', { units: 'metric', alternatives: true, maxAlternatives: 3, + absoluteTime: false, + showDuration: false, apiBase: 'https://maps.googleapis.com/', apiEndpoint: 'maps/api/directions/json' }, @@ -41,16 +43,26 @@ Module.register('localtransport', { params += '&destination=' + this.config.destination; params += '&key=' + this.config.api_key; params += '&traffic_model=' + this.config.traffic_model; - params += '&departure_time=now'; - params += '&alternatives=true'; + params += '&departure_time=' + this.config.departure_time; + params += '&alternatives=' + this.config.alternatives; return params; }, renderLeg: function(wrapper, leg){ var depature = leg.departure_time.value * 1000; var arrival = leg.arrival_time.value * 1000; var span = document.createElement("div"); - span.innerHTML = - moment(depature).fromNow() + if (!this.config.absoluteTime) { + span.innerHTML = moment(depature).fromNow() + } else { + if (config.timeFormat !== 24) { + span.innerHTML = this.translate('ABSOLUTE_PREFIX') + moment(depature).format('h:mm A') + } else { + span.innerHTML = this.translate('ABSOLUTE_PREFIX') + moment(depature).format('HH:mm') + } + } + if (this.config.showDuration) { + span.innerHTML += "(" + moment.duration(moment(arrival).diff(depature, 'minutes'), 'minutes').humanize() + ")"; + } // + this.translate('TRAVEL_TIME') + ": " // + moment.duration(moment(arrival).diff(depature, 'minutes'), 'minutes').humanize() ; @@ -89,7 +101,8 @@ Module.register('localtransport', { }, getTranslations: function() { return { - de: "i18n/de.json" + de: "i18n/de.json", + en: "i18n/en.json" }; }, getDom: function() {