Merge branch 'yo-less-patch-4' into develop

This commit is contained in:
Michael Teeuw 2016-10-01 11:03:16 +02:00
commit a369dddde8
3 changed files with 37 additions and 20 deletions

View File

@ -6,14 +6,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Finnish translation.
- Danish translation
- Danish translation.
- Method to overwrite the module's header. [See documentation.](https://github.com/MichMich/MagicMirror/tree/develop/modules#getheader)
- Option to limit access to certain IP addresses based on the value of `ipWhitelist` in the `config.js`, default is access from localhost only (Issue [#456](https://github.com/MichMich/MagicMirror/issues/456))
- Option to limit access to certain IP addresses based on the value of `ipWhitelist` in the `config.js`, default is access from localhost only (Issue [#456](https://github.com/MichMich/MagicMirror/issues/456)).
- Added ability to change the point of time when calendar events get relative.
### Updated
- Modified translations for Frysk.
- Updated package.json as a result of Snyk security update.
### Changed
- Calendar times are now uniformly capitalized.
## [2.0.5] - 2016-09-20
### Added

View File

@ -126,6 +126,13 @@ The following properties can be configured:
<br><b>Default value:</b> <code>relative</code>
</td>
</tr>
<tr>
<td><code>getRelative</code></td>
<td>How much time (in hours) should be left until calendar events start getting relative?<br>
<br><b>Possible values:</b> <code>0</code> (events stay absolute) - <code>48</code> (48 hours before the event starts)
<br><b>Default value:</b> <code>6</code>
</td>
</tr>
<tr>
<td><code>urgency</code></td>
<td>When using a timeFormat of <code>absolute</code>, the <code>urgency</code> setting allows you to display events within a specific time frame as <code>relative</code>

View File

@ -23,6 +23,7 @@ Module.register("calendar",{
fade: true,
urgency: 7,
timeFormat: "relative",
getRelative: 6,
fadePoint: 0.25, // Start on 1/4th of the list.
calendars: [
{
@ -147,18 +148,14 @@ Module.register("calendar",{
var one_day = one_hour * 24;
if (event.fullDayEvent) {
if (event.today) {
timeWrapper.innerHTML = this.translate("TODAY");
timeWrapper.innerHTML = this.capFirst(this.translate("TODAY"));
} else if (event.startDate - now < one_day && event.startDate - now > 0) {
timeWrapper.innerHTML = this.translate("TOMORROW");
timeWrapper.innerHTML = this.capFirst(this.translate("TOMORROW"));
} else if (event.startDate - now < 2*one_day && event.startDate - now > 0) {
/*Provide ability to show "the day after tomorrow" instead of "in a day"
*if "DAYAFTERTOMORROW" is configured in a language's translation .json file,
*,which can be found in MagicMirror/translations/
*/
if (this.translate('DAYAFTERTOMORROW') !== 'DAYAFTERTOMORROW') {
timeWrapper.innerHTML = this.translate("DAYAFTERTOMORROW");
timeWrapper.innerHTML = this.capFirst(this.translate("DAYAFTERTOMORROW"));
} else {
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
}
} else {
/* Check to see if the user displays absolute or relative dates with their events
@ -171,24 +168,24 @@ Module.register("calendar",{
if (this.config.timeFormat === "absolute") {
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * one_day))) {
// This event falls within the config.urgency period that the user has set
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} else {
timeWrapper.innerHTML = moment(event.startDate, "x").format("MMM Do");
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format("MMM Do"));
}
} else {
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
}
}
} else {
if (event.startDate >= new Date()) {
if (event.startDate - now < 2 * one_day) {
// This event is within the next 48 hours (2 days)
if (event.startDate - now < 6 * one_hour) {
if (event.startDate - now < this.config.getRelative * one_hour) {
// If event is within 6 hour, display 'in xxx' time format or moment.fromNow()
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} else {
// Otherwise just say 'Today/Tomorrow at such-n-such time'
timeWrapper.innerHTML = moment(event.startDate, "x").calendar();
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar());
}
} else {
/* Check to see if the user displays absolute or relative dates with their events
@ -201,16 +198,16 @@ Module.register("calendar",{
if (this.config.timeFormat === "absolute") {
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * one_day))) {
// This event falls within the config.urgency period that the user has set
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} else {
timeWrapper.innerHTML = moment(event.startDate, "x").format("MMM Do");
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format("MMM Do"));
}
} else {
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
}
}
} else {
timeWrapper.innerHTML = this.translate("RUNNING") + ' ' + moment(event.endDate,"x").fromNow(true);
timeWrapper.innerHTML = this.capFirst(this.translate("RUNNING")) + ' ' + moment(event.endDate,"x").fromNow(true);
}
}
//timeWrapper.innerHTML += ' - '+ moment(event.startDate,'x').format('lll');
@ -348,6 +345,15 @@ Module.register("calendar",{
return string;
},
/* capFirst(string)
* Capitalize the first letter of a string
* Eeturn capitalized string
*/
capFirst: function(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
},
/* titleTransform(title)
* Transforms the title of an event for usage.
* Replaces parts of the text as defined in config.titleReplace.