From f9a525068bd4480c2edf9c99ba30ef07e46c27e7 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Mon, 5 Feb 2018 18:15:02 +0300 Subject: [PATCH] add variable morning afternoon times --- modules/default/compliments/README.md | 6 ++++++ modules/default/compliments/compliments.js | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/default/compliments/README.md b/modules/default/compliments/README.md index 10a45b8f..2b381b39 100644 --- a/modules/default/compliments/README.md +++ b/modules/default/compliments/README.md @@ -32,6 +32,12 @@ The following properties can be configured: | `compliments` | The list of compliments.

**Possible values:** An object with four arrays: `morning`, `afternoon`, `evening` and `anytime`. See _compliment configuration_ below.
**Default value:** See _compliment configuration_ below. | `remoteFile` | External file from which to load the compliments

**Possible values:** Path to a JSON file containing compliments, configured as per the value of the _compliments configuration_ (see below). An object with four arrays: `morning`, `afternoon`, `evening` and `anytime`. - `compliments.json`
**Default value:** `null` (Do not load from file) | `classes` | Override the CSS classes of the div showing the compliments

**Default value:** `thin xlarge bright` +| `morningStartTime` | Time in hours (in 24 format), after which the mode of "morning" will begin
**Possible values:** `0` - `24`

**Default value:** `3` +| `morningEndTime` | Time in hours (in 24 format), after which the mode of "morning" will end
**Possible values:** `0` - `24`

**Default value:** `12` +| `afternoonStartTime` | Time in hours (in 24 format), after which the mode "afternoon" will begin
**Possible values:** `0` - `24`

**Default value:** `12` +| `afternoonEndTime` | Time in hours (in 24 format), after which the mode "afternoon" will end
**Possible values:** `0` - `24`

**Default value:** `17` + +All the rest of the time that does not fall into the morningStartTime-morningEndTime and afternoonStartTime-afternoonEndTime ranges is considered "evening". ### Compliment configuration diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index a0af458d..5bdc39cb 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -32,7 +32,11 @@ Module.register("compliments", { }, updateInterval: 30000, remoteFile: null, - fadeSpeed: 4000 + fadeSpeed: 4000, + morningStartTime: 3, + morningEndTime: 12, + afternoonStartTime: 12, + afternoonEndTime: 17 }, // Set currentweather from module @@ -98,9 +102,9 @@ Module.register("compliments", { var hour = moment().hour(); var compliments; - if (hour >= 3 && hour < 12 && this.config.compliments.hasOwnProperty("morning")) { + if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) { compliments = this.config.compliments.morning.slice(0); - } else if (hour >= 12 && hour < 17 && this.config.compliments.hasOwnProperty("afternoon")) { + } else if (hour >= this.config.afternoonStartTime && hour < this.config.afternoonEndTime && this.config.compliments.hasOwnProperty("afternoon")) { compliments = this.config.compliments.afternoon.slice(0); } else if(this.config.compliments.hasOwnProperty("evening")) { compliments = this.config.compliments.evening.slice(0);