Skip to content

Commit

Permalink
Small visual and internal improvements to weather
Browse files Browse the repository at this point in the history
  • Loading branch information
z------------- committed Oct 2, 2019
1 parent 06c02e2 commit 25bcf62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ntp.js
Expand Up @@ -1008,27 +1008,27 @@ xhr(chrome.extension.getURL("/consts/default_settings.json"), function(res) {
temperatureElem.textContent = Math.round(temperature).toString()
conditionElem.textContent = conditionData.summary

// document.body.classList.add("visible")
weatherDivElem.classList.add("loaded")
}

var dontUseCache

function gotCoords() {
var requestUrl = "https://nntp-server-redux.netlify.com/.netlify/functions/wx?foo=bar"
var requestUrl = new URL("https://nntp-server-redux.netlify.com/.netlify/functions/wx")

if (overrideWxLocation) {
requestUrl += `&coords=${wxCoordsLat},${wxCoordsLong}`
requestUrl.searchParams.append("coords", `${wxCoordsLat},${wxCoordsLong}`)
}

var chromeUILang = chrome.i18n.getUILanguage()
if (chromeUILang.toLowerCase() === "zh-tw") {
requestUrl += "&lang=zh-tw"
requestUrl.searchParams.append("lang", "zh-tw")
} else if (availableLocales.indexOf(chromeUILang.split("-")[0]) !== -1) {
requestUrl += `&lang=${chromeUILang.split("-")[0]}`
requestUrl.searchParams.append("lang", `${chromeUILang.split("-")[0]}`)
}

if (dontUseCache) {
// console.log("getting fresh weather")
xhr(requestUrl, function(data) {
xhr(requestUrl.href, function(data) {
data = JSON.parse(data)

displayWeather(data)
Expand All @@ -1037,7 +1037,6 @@ xhr(chrome.extension.getURL("/consts/default_settings.json"), function(res) {
localStorage.setItem("last_weather", JSON.stringify(data))
})
} else if (localStorage.last_weather) {
// console.log("using cached weather")
displayWeather(JSON.parse(localStorage.getItem("last_weather")))
}
}
Expand Down
7 changes: 7 additions & 0 deletions style.css
Expand Up @@ -423,6 +423,13 @@ button {

#weatherdiv {
margin-top: 20px;
opacity: 0;
min-height: 100px;
transition-property: opacity;
}

#weatherdiv.loaded {
opacity: 1;
}

#weatherdiv #weather {
Expand Down

0 comments on commit 25bcf62

Please sign in to comment.