From a532449261c459248e613d19a233721bc1c5f9a5 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Mon, 21 Jan 2019 18:06:35 +0000 Subject: [PATCH] edits --- src/assets/js/modules/functions.js | 16 ++++++++-------- src/assets/js/modules/message.js | 11 ----------- src/assets/js/modules/utility.js | 11 ++++------- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/assets/js/modules/functions.js b/src/assets/js/modules/functions.js index 057b3ffb..c23150d4 100644 --- a/src/assets/js/modules/functions.js +++ b/src/assets/js/modules/functions.js @@ -1,11 +1,3 @@ -const util = require('./utility.js'); -const message = require('./message.js'); -const quotes = require('./quotes.js'); -const background = require('./background.js'); -const codes = require('./codes.js'); - -let nal = navigator.language; - /* █████████████████████████████████████████████████████████████ ██ ██ @@ -24,6 +16,14 @@ let nal = navigator.language; █████████████████████████████████████████████████████████████ */ +const util = require('./utility.js'); +const message = require('./message.js'); +const quotes = require('./quotes.js'); +const background = require('./background.js'); +const codes = require('./codes.js'); + +let nal = navigator.language; + module.exports = class Functions { static setDaytimeMessage() { if (util.contains.call(codes.itcodes, nal)) message.itMessageSet(); //Italian diff --git a/src/assets/js/modules/message.js b/src/assets/js/modules/message.js index 6c4fbcbf..78a4163a 100644 --- a/src/assets/js/modules/message.js +++ b/src/assets/js/modules/message.js @@ -21,13 +21,10 @@ const { setHTMLContent } = require('./utility.js'); module.exports = class Message { // English static engMessageSet() { - let hour = new Date().getHours(); // Get the current hour let time = 'Good evening'; // Set the default time string to "Good evening" - if (hour < 12) time = 'Good morning'; //If it's before 12am, set the time string to "Good morning" else if (hour > 18) time = 'Good afternoon'; //If it's after 6pm, set the time string to "Good afternoon" - setHTMLContent('.greeting', time); // Write the string contents to the HTML } @@ -35,9 +32,7 @@ module.exports = class Message { static itMessageSet() { let hour = new Date().getHours(); // Get the current hour let time = 'Buongiorno'; - if (hour > 18) time = 'Buonasera'; //In Italian there is just Buongiorno or Buonasera - setHTMLContent('.greeting', time); // Write the string contents to the HTML } @@ -45,10 +40,8 @@ module.exports = class Message { static nlMessageSet() { let hour = new Date().getHours(); // Get the current hour let time = 'Goedemiddag'; // Set the default time string to "Good evening" - if (hour < 12) time = 'Goedemorgen'; //If it's before 12am, set the time string to "Good morning" else if (hour > 18) time = 'Goedenavond'; //If it's after 6pm, set the time string to "Good afternoon" - setHTMLContent('.greeting', time); // Write the string contents to the HTML } @@ -56,10 +49,8 @@ module.exports = class Message { static frMessageSet() { let hour = new Date().getHours(); // Get the current hour let time = 'Bonsoir'; // Set the default time string to "Good evening" - if (hour < 12) time = 'Bonjour'; //If it's before 12am, set the time string to "Good morning" else if (hour > 18) time = 'Bonne après-midi'; //If it's after 6pm, set the time string to "Good afternoon" - setHTMLContent('.greeting', time); // Write the string contents to the HTML } @@ -67,10 +58,8 @@ module.exports = class Message { static spMessageSet() { let hour = new Date().getHours(); // Get the current hour let time = 'Buenas Tardes'; // Set the default time string to "Good evening" - if (hour < 12) time = 'Buenos Días'; // If it's before 12am, set the time string to "Good morning" else if (hour > 20) time = 'Buenas Noches'; // If it's after 6pm, set the time string to "Good afternoon" - setHTMLContent('.greeting', time); // Write the string contents to the HTML } } \ No newline at end of file diff --git a/src/assets/js/modules/utility.js b/src/assets/js/modules/utility.js index 63539a51..cfc26da2 100644 --- a/src/assets/js/modules/utility.js +++ b/src/assets/js/modules/utility.js @@ -19,22 +19,22 @@ module.exports = class Util { // format time static formatTimeUnit(unit) { - return unit < 10 ? '0' + unit : unit + return unit < 10 ? '0' + unit : unit; }; // setHTMLContent is the kind of function that is referred to as a 'wrapper' static setHTMLContent(selector, content) { - return document.querySelector(selector).innerHTML = content + return document.querySelector(selector).innerHTML = content; }; // get random item static getRandIndex(array) { - return Math.floor(Math.random() * (array.length - 1)) + return Math.floor(Math.random() * (array.length - 1)); } // pick random from array static pickFromArray(array) { - return array[Math.floor(Math.random() * (array.length - 1))] + return array[Math.floor(Math.random() * (array.length - 1))]; }; static contains(needle) { @@ -46,16 +46,13 @@ module.exports = class Util { indexOf = (needle) => { let i = -1, index = -1; - for (i = 0; i < this.length; i++) { let item = this[i]; - if ((findNaN && item !== item) || item === needle) { index = i; break; } } - return index; }; }