From 88bf77c5d1c27fec8b46984b59b2420e69611409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stian=20J=C3=B8rgensrud?= Date: Wed, 22 Jan 2020 21:40:53 +0100 Subject: [PATCH 1/3] Show celcius sign on temp values --- MMM-YrThen.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MMM-YrThen.js b/MMM-YrThen.js index 9c4bdc5..1941f57 100644 --- a/MMM-YrThen.js +++ b/MMM-YrThen.js @@ -157,20 +157,20 @@ Module.register('MMM-YrThen', { } if(this.config.showMaxMin){ if(newData.temperature.min && newData.temperature.max){ - forecastCell.innerHTML += '' + minValue + this.config.maxMinSeparator + maxValue + '
'; + forecastCell.innerHTML += '' + minValue + '°' + this.config.maxMinSeparator + maxValue + '°
'; } - else forecastCell.innerHTML += ' ' + tempValue + '
'; + else forecastCell.innerHTML += ' ' + tempValue + '°
'; } else{ - forecastCell.innerHTML += ' ' + tempValue + ''; + forecastCell.innerHTML += ' ' + tempValue + '°'; if(this.config.showMaxMin){ forecastCell.innerHTML += '
'; } if(newData.temperature.min && newData.temperature.max && this.config.showMaxMin){ - forecastCell.innerHTML += '(' + minValue + '/' + maxValue + ')
'; + forecastCell.innerHTML += '(' + minValue + '°/' + maxValue + '°)
'; } else if(!newData.temperature.min && !newData.temperature.max && this.config.showMaxMin){ - forecastCell.innerHTML += '(' + tempValue + '/' + tempValue + ')
'; + forecastCell.innerHTML += '(' + tempValue + '°/' + tempValue + '°)
'; } } if(this.config.showPrecipitation){ From b368bb1ddec5bb7f6713b9ff8f0fc50ff4a0a64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stian=20J=C3=B8rgensrud?= Date: Wed, 22 Jan 2020 22:27:21 +0100 Subject: [PATCH 2/3] Make font-size a config option --- MMM-YrThen.js | 34 +++++++++++++++++++++++++--------- README.md | 5 +++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/MMM-YrThen.js b/MMM-YrThen.js index 1941f57..ae5b16f 100644 --- a/MMM-YrThen.js +++ b/MMM-YrThen.js @@ -16,7 +16,8 @@ Module.register('MMM-YrThen', { roundTemp: true, roundPrec: false, title: 'Værmelding for Skrubblivegen', - header: false + header: false, + size: "small" }, getTranslations: function() { @@ -65,7 +66,7 @@ Module.register('MMM-YrThen', { var wrapper = document.createElement('div'); if(!this.loaded){ wrapper.innerHTML = this.translate('loading'); - wrapper.className = "dimmed light small"; + wrapper.className = "dimmed light " + this.config.size; return wrapper; } @@ -75,10 +76,17 @@ Module.register('MMM-YrThen', { header.className = 'align-left'; wrapper.appendChild(header); } - wrapper.classList.add = "dimmed light small"; + wrapper.classList.add = "dimmed light " + this.config.size; var table = document.createElement('table'); - table.className = "xsmall yrthen-table"; + + // Find the size one smaller than size + var possibleSizes = ["xsmall", "small", "medium", "large", "xlarge"] + var oneSmallerSize = possibleSizes.indexOf(this.config.size) - 1; + if (oneSmallerSize < 0) { + oneSmallerSize = 0; + } + table.className = possibleSizes[oneSmallerSize] + " yrthen-table"; // SHOWING DETAILED FORECAST if(this.config.showAll == true){ @@ -87,9 +95,17 @@ Module.register('MMM-YrThen', { var first = true; var timeRow = document.createElement('tr'); table.appendChild(timeRow); + + // Find the size one smaller than size + var possibleSizes = ["xsmall", "small", "medium", "large", "xlarge"] + var oneSmallerSize = possibleSizes.indexOf(this.config.size) - 1; + if (oneSmallerSize < 0) { + oneSmallerSize = 0; + } + for(var i = 0; i < 5; i++){ var newCell = document.createElement('td'); - newCell.className = 'align-left bright xsmall yrthen-header'; + newCell.className = 'align-left bright ' + oneSmallerSize + ' yrthen-header'; if(i == 0) newCell.innerHTML = ' '; if(i == 1) newCell.innerHTML = this.translate("night"); if(i == 2) newCell.innerHTML = this.translate("morning"); @@ -157,12 +173,12 @@ Module.register('MMM-YrThen', { } if(this.config.showMaxMin){ if(newData.temperature.min && newData.temperature.max){ - forecastCell.innerHTML += '' + minValue + '°' + this.config.maxMinSeparator + maxValue + '°
'; + forecastCell.innerHTML += '' + minValue + '°' + this.config.maxMinSeparator + maxValue + '°
'; } - else forecastCell.innerHTML += ' ' + tempValue + '°
'; + else forecastCell.innerHTML += ' ' + tempValue + '°
'; } else{ - forecastCell.innerHTML += ' ' + tempValue + '°'; + forecastCell.innerHTML += ' ' + tempValue + '°'; if(this.config.showMaxMin){ forecastCell.innerHTML += '
'; } @@ -236,7 +252,7 @@ Module.register('MMM-YrThen', { var maxTempCell = document.createElement("td"); if(this.config.roundTemp) maxTempCell.innerHTML = this.round(newData.temperature.value, 0); else maxTempCell.innerHTML = this.round(newData.temperature.value, 1); - maxTempCell.className = "align-right bright yrthen-temp small"; + maxTempCell.className = "align-right bright yrthen-temp " + this.config.size; row.appendChild(maxTempCell); var minTempCell = document.createElement("td"); diff --git a/README.md b/README.md index 9490056..cd0fb53 100644 --- a/README.md +++ b/README.md @@ -110,4 +110,9 @@ Find your location using the search form at size - The size of the text. One of the CSS classes defined in main.css of MagicMirror2: xsmall, small, medium, large, xlarge - + The size of the text. One of the CSS classes defined in main.css of MagicMirror2: "xsmall", "small", "medium", "large", "xlarge" + "small"