From 41a91f71d62eb6e441a8a28f51010a3065b7b6aa Mon Sep 17 00:00:00 2001 From: dorian Date: Tue, 16 Jul 2019 17:33:34 +0200 Subject: [PATCH] widgets of type text look better now --- css/dashboard.css | 5 +++++ js/dashboard.js | 52 ++++++++++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/css/dashboard.css b/css/dashboard.css index eb8a386..c364135 100644 --- a/css/dashboard.css +++ b/css/dashboard.css @@ -127,4 +127,9 @@ body { .opacity-animated { -webkit-transition: opacity 1s; /* For Safari 3.1 to 6.0 */ transition: opacity 1s; +} + +.flexFont { + height:100%; + width:100%; } \ No newline at end of file diff --git a/js/dashboard.js b/js/dashboard.js index 563c474..8767e14 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -41,8 +41,8 @@ class BlueWeatherDashboard { var page = this.params.page - if(this.initDone){ - document.getElementById("navbarPage" + page + "Link").classList.add("active") + if (this.initDone) { + document.getElementById("navbarPage" + page + "Link").classList.add("active") } this.blueweather.getLocationData(this.params.loc, { from: this.params.range.from, to: this.params.range.to }, this.params.maxVals, true, function (locationData) { @@ -185,8 +185,7 @@ class BlueWeatherDashboard { case "text": // the widget is pure text thisWidget.classList.add("text-center") - thisBody.innerHTML = '

' + latestVal.measvalue + valueType.valueunit + '

' - + thisBody.innerHTML = '

' + latestVal.measvalue + valueType.valueunit + '

' //thisBody.innerHTML = 'Fit Meeeeeeeeeeee' break @@ -209,7 +208,7 @@ class BlueWeatherDashboard { loader.style = "position: absolute; left: 50%; opacity: 0;" mainContent.classList.add("opacity-animated"); mainContent.style = "opacity: 1;" - + flexFont(); }) } @@ -242,28 +241,28 @@ class BlueWeatherDashboard { } } else { - if(from !== ""){ - from = parseInt(from) + if (from !== "") { + from = parseInt(from) } - if(to !== ""){ - to = parseInt(to) + if (to !== "") { + to = parseInt(to) } } var tmpFrom = from var tmpTo = to - if(tmpFrom === "") { - tmpFrom = Math.round( new Date().getTime() / 1000 - 60 * 60 * 24 ) + if (tmpFrom === "") { + tmpFrom = Math.round(new Date().getTime() / 1000 - 60 * 60 * 24) } - if(tmpTo === "") { + if (tmpTo === "") { tmpTo = Math.round(new Date().getTime() / 1000) } - var dateFromString = this.getDateTimeString(tmpFrom, tmpTo-tmpFrom) - var dateToString = this.getDateTimeString(tmpTo, tmpTo-tmpFrom) - + var dateFromString = this.getDateTimeString(tmpFrom, tmpTo - tmpFrom) + var dateToString = this.getDateTimeString(tmpTo, tmpTo - tmpFrom) + dropdownMenuButton.innerHTML = " " + dateFromString + " - " + dateToString feather.replace() @@ -511,7 +510,7 @@ class BlueWeatherDashboard { getDateTimeString(unixTime, range = 0) { - if(Math.abs(unixTime - new Date().getTime() / 1000) <= 60 ) { + if (Math.abs(unixTime - new Date().getTime() / 1000) <= 60) { return "now" } @@ -520,8 +519,8 @@ class BlueWeatherDashboard { if (range <= 60 * 60 * 24 * 31) { // covers one month or less - datestr = - ("0" + d.getDate()).slice(-2) + "-" + + datestr = + ("0" + d.getDate()).slice(-2) + "-" + ("0" + (d.getMonth() + 1)).slice(-2) + " " + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) @@ -584,6 +583,21 @@ class BlueWeatherDashboard { } } } - +flexFont = function () { + console.log("flexing fonts") + var divs = document.getElementsByClassName("flexFont"); + for (var i = 0; i < divs.length; i++) { + var relFontsize = divs[i].offsetWidth * 0.2; + console.log(relFontsize) + divs[i].style.fontSize = relFontsize + 'px'; + } +}; +flexFont(); +window.onload = function (event) { + flexFont(); +}; +window.onresize = function (event) { + flexFont(); +}; feather.replace() dashboard = new BlueWeatherDashboard() \ No newline at end of file