mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-30 13:09:34 +00:00
calendar dates are uniformly capitalized
This is an attempt at standardizing the calendar layout. Currently the calendar times are only partly capitalized, some time phrases start with lower-case letters, some don't (The ones pulled from the TRANSLATIONS folder start with upper-case letters, the others don't). Behavior has been changed to create a more standardized layout.
This commit is contained in:
parent
a481638c03
commit
c1b8fc1233
@ -147,18 +147,14 @@ Module.register("calendar",{
|
|||||||
var one_day = one_hour * 24;
|
var one_day = one_hour * 24;
|
||||||
if (event.fullDayEvent) {
|
if (event.fullDayEvent) {
|
||||||
if (event.today) {
|
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) {
|
} 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) {
|
} 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') {
|
if (this.translate('DAYAFTERTOMORROW') !== 'DAYAFTERTOMORROW') {
|
||||||
timeWrapper.innerHTML = this.translate("DAYAFTERTOMORROW");
|
timeWrapper.innerHTML = this.capFirst(this.translate("DAYAFTERTOMORROW"));
|
||||||
} else {
|
} else {
|
||||||
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
|
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Check to see if the user displays absolute or relative dates with their events
|
/* Check to see if the user displays absolute or relative dates with their events
|
||||||
@ -171,12 +167,12 @@ Module.register("calendar",{
|
|||||||
if (this.config.timeFormat === "absolute") {
|
if (this.config.timeFormat === "absolute") {
|
||||||
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * one_day))) {
|
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
|
// 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 {
|
} else {
|
||||||
timeWrapper.innerHTML = moment(event.startDate, "x").format("MMM Do");
|
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format("MMM Do"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
|
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -185,10 +181,10 @@ Module.register("calendar",{
|
|||||||
// This event is within the next 48 hours (2 days)
|
// This event is within the next 48 hours (2 days)
|
||||||
if (event.startDate - now < 6 * one_hour) {
|
if (event.startDate - now < 6 * one_hour) {
|
||||||
// If event is within 6 hour, display 'in xxx' time format or moment.fromNow()
|
// 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 {
|
} else {
|
||||||
// Otherwise just say 'Today/Tomorrow at such-n-such time'
|
// 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 {
|
} else {
|
||||||
/* Check to see if the user displays absolute or relative dates with their events
|
/* Check to see if the user displays absolute or relative dates with their events
|
||||||
@ -201,16 +197,16 @@ Module.register("calendar",{
|
|||||||
if (this.config.timeFormat === "absolute") {
|
if (this.config.timeFormat === "absolute") {
|
||||||
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * one_day))) {
|
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
|
// 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 {
|
} else {
|
||||||
timeWrapper.innerHTML = moment(event.startDate, "x").format("MMM Do");
|
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").format("MMM Do"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
|
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
timeWrapper.innerHTML = this.translate("RUNNING") + ' ' + moment(event.endDate,"x").fromNow(true);
|
timeWrapper.innerHTML = this.capFirst(this.translate("RUNNING")) + ' ' + this.capFirst(moment(event.endDate,"x").fromNow(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//timeWrapper.innerHTML += ' - '+ moment(event.startDate,'x').format('lll');
|
//timeWrapper.innerHTML += ' - '+ moment(event.startDate,'x').format('lll');
|
||||||
@ -346,6 +342,15 @@ Module.register("calendar",{
|
|||||||
return string;
|
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)
|
/* titleTransform(title)
|
||||||
* Transforms the title of an event for usage.
|
* Transforms the title of an event for usage.
|
||||||
* Replaces parts of the text as defined in config.titleReplace.
|
* Replaces parts of the text as defined in config.titleReplace.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user