From 0090b9da794d66f26ddd5745bdac8976cecdcc3d Mon Sep 17 00:00:00 2001 From: xmodulus Date: Sun, 5 Aug 2018 16:09:39 +1200 Subject: [PATCH] Initial weather widget. --- .gitignore | 1 + manifest.json | 2 +- src/components/widgets/weather.vue | 125 ++++++++++++++++++----------- src/main.js | 10 +-- src/secret.example.js | 3 + 5 files changed, 87 insertions(+), 54 deletions(-) create mode 100644 src/secret.example.js diff --git a/.gitignore b/.gitignore index 541a820..c297f5d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* +/src/secret.js # Editor directories and files .idea diff --git a/manifest.json b/manifest.json index 2b1aed0..679d6d2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "mdash", "description": "A sleek customisable dashboard", - "version": "0.1.0", + "version": "0.1.1", "manifest_version": 2, "permissions": ["geolocation"], "chrome_url_overrides": { diff --git a/src/components/widgets/weather.vue b/src/components/widgets/weather.vue index f6250a5..dbf1979 100644 --- a/src/components/widgets/weather.vue +++ b/src/components/widgets/weather.vue @@ -1,52 +1,59 @@ diff --git a/src/main.js b/src/main.js index a338e40..5e15f26 100644 --- a/src/main.js +++ b/src/main.js @@ -32,8 +32,8 @@ else bg = config.default_bg; storage.set('mdash-background', bg); console.log('mdash: Background images loaded.'); -storage.set('installed-0.1.0', true); -console.log('mdash: Current version: 0.1.0'); +storage.set('installed-0.1.1', true); +console.log('mdash: Current version: 0.1.1'); @@ -45,7 +45,7 @@ new Vue({ mounted() { //get user location if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition(function (pos) { + navigator.geolocation.getCurrentPosition(pos => { let saved_pos = storage.get('mdash-location'); let url = `https://maps.googleapis.com/maps/api/geocode/json?latlng=${pos.coords.latitude},${pos.coords.longitude}`; let obj = { @@ -57,10 +57,10 @@ new Vue({ (saved_pos.latitude !== pos.coords.latitude || saved_pos.longitude !== pos.coords.longitude || !saved_pos.city_long)){ axios.get(url) .then(res => { - let locality = res.data.results[0].address_components.filter(function(o){ + let locality = res.data.results[0].address_components.filter(o => { return o.types.indexOf('locality') > -1; }); - let country = res.data.results[0].address_components.filter(function(o){ + let country = res.data.results[0].address_components.filter(o => { return o.types.indexOf('country') > -1; }); if(locality.length > 0){ diff --git a/src/secret.example.js b/src/secret.example.js new file mode 100644 index 0000000..582b0dd --- /dev/null +++ b/src/secret.example.js @@ -0,0 +1,3 @@ +module.exports = { + weather_api_key : '' //api key from openweathermap.com +};