From 5e4d25b957a142f1ee8af3312955e6c908b91a79 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 8 Dec 2019 08:50:00 -0600 Subject: [PATCH 1/4] add support for newline (\n) in compliment text --- modules/default/compliments/compliments.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 05200af8..59e11853 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -153,13 +153,25 @@ Module.register("compliments", { return compliments[index]; }, - // Override dom generator. +// Override dom generator. getDom: function() { - var complimentText = this.randomCompliment(); - - var compliment = document.createTextNode(complimentText); var wrapper = document.createElement("div"); wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright pre-line"; + // get the compliment text + var complimentText = this.randomCompliment(); + // split it into parts on newline text + var parts= complimentText.split('\n') + // create a span to hold it all + var compliment=document.createElement('span') + // process all the parts of the compliment text + for (part of parts){ + // create a text element for each part + compliment.appendChild(document.createTextNode(part)) + // add a break ` + compliment.appendChild(document.createElement('BR')) + } + // remove the last break + compliment.lastElementChild.remove(); wrapper.appendChild(compliment); return wrapper; From 0cb377618e18baabb52b8e7bdef7a7dea15a3ec2 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 8 Dec 2019 09:28:50 -0600 Subject: [PATCH 2/4] add support for sequential compliments usage --- modules/default/compliments/compliments.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 59e11853..57675d19 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -36,9 +36,10 @@ Module.register("compliments", { morningStartTime: 3, morningEndTime: 12, afternoonStartTime: 12, - afternoonEndTime: 17 + afternoonEndTime: 17, + random: true }, - + lastIndexUsed:-1, // Set currentweather from module currentWeatherType: "", @@ -147,8 +148,20 @@ Module.register("compliments", { * return compliment string - A compliment. */ randomCompliment: function() { + // get the current time of day compliments list var compliments = this.complimentArray(); - var index = this.randomIndex(compliments); + variable for index to next message to display + let index=0 + // are we randomizing + if(this.config.random){ + // yes + index = this.randomIndex(compliments); + } + else{ + // no, sequetial + // if doing sequential, don't fall off the end + index = (this.lastIndexUsed >= (compliments.length-1))?0: ++this.lastIndexUsed + } return compliments[index]; }, From 42bab052e024b8541d12509d5dfdedab3c9222ab Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 8 Dec 2019 10:07:55 -0600 Subject: [PATCH 3/4] fix comment --- modules/default/compliments/compliments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 57675d19..198664b7 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -150,7 +150,7 @@ Module.register("compliments", { randomCompliment: function() { // get the current time of day compliments list var compliments = this.complimentArray(); - variable for index to next message to display + // variable for index to next message to display let index=0 // are we randomizing if(this.config.random){ From 460a383ffca949ae9e2cda731a837cbd00311c2f Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 9 Dec 2019 09:46:45 -0600 Subject: [PATCH 4/4] add changelog --- CHANGELOG.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b1543f..28af2f9f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,8 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -### Added -- new upgrade script to help users consume regular updates installers/upgrade-script.sh -- new script to help setup pm2, without install installers/fixuppm2.sh - ### Updated -- updated raspberry.sh installer script to handle new platform issues, split node/npm, pm2, and screen saver changes -- improve handling for armv6l devices, where electron support has gone away, add optional serveronly config option +- updated compliments.js to handle newline in text, as textfields to not interpolate contents ---