Skip to content

Commit

Permalink
fixed timezone API calls. Shown valid date now. Using google geolocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Ahlhelm authored and Ruben Ahlhelm committed May 8, 2019
1 parent 4ce12af commit dcd2a05
Show file tree
Hide file tree
Showing 177 changed files with 3,096 additions and 22 deletions.
Binary file modified .DS_Store
100644 → 100755
Binary file not shown.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified .vscode/launch.json
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified assets/IconTemplate.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/app.icns
100644 → 100755
Empty file.
Empty file modified assets/app.ico
100644 → 100755
Empty file.
Empty file modified assets/app.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/background.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/checkboxes.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/dropdown.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01d.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01d.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01dTemplate.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01dW.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01n.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01n.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01nTemplate.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/01nW.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/[email protected]
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/02d.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/02d.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/02dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/02dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/02n.png
100644 → 100755
Empty file modified assets/icons/02n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/02nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/02nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/03d.png
100644 → 100755
Empty file modified assets/icons/03d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/03dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/03dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/03n.png
100644 → 100755
Empty file modified assets/icons/03n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/03nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/03nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/04d.png
100644 → 100755
Empty file modified assets/icons/04d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/04dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/04dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/04n.png
100644 → 100755
Empty file modified assets/icons/04n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/04nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/04nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/09d.png
100644 → 100755
Empty file modified assets/icons/09d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/09dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/09dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/09n.png
100644 → 100755
Empty file modified assets/icons/09n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/09nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/09nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/10d.png
100644 → 100755
Empty file modified assets/icons/10d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/10dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/10dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/10n.png
100644 → 100755
Empty file modified assets/icons/10n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/10nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/10nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/11d.png
100644 → 100755
Empty file modified assets/icons/11d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/11dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/11dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/11n.png
100644 → 100755
Empty file modified assets/icons/11n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/11nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/11nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/12d.png
100644 → 100755
Empty file modified assets/icons/12d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/12dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/12dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/12n.png
100644 → 100755
Empty file modified assets/icons/12n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/12nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/12nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/13d.png
100644 → 100755
Empty file modified assets/icons/13d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/13dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/13dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/13n.png
100644 → 100755
Empty file modified assets/icons/13n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/13nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/13nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/50d.png
100644 → 100755
Empty file modified assets/icons/50d.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/50dTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/50dW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/50n.png
100644 → 100755
Empty file modified assets/icons/50n.svg
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/50nTemplate.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/50nW.png
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/icons/[email protected]
100644 → 100755
Empty file modified assets/s1.png
100644 → 100755
Empty file modified assets/s2.png
100644 → 100755
Empty file modified assets/s3.png
100644 → 100755
Empty file modified assets/screenshot-overview.png
100644 → 100755
Empty file modified assets/screenshot.jpg
100644 → 100755
55 changes: 52 additions & 3 deletions package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "temps",
"productName": "Temps",
"website": "https://jackd248.github.io/temps/",
"version": "0.7.2",
"version": "0.7.3",
"icon": "assets/app.png",
"description": "A simple but smart menubar weather app",
"main": "src/app.js",
Expand Down Expand Up @@ -49,17 +49,17 @@
"standard": "^8.3.0"
},
"dependencies": {
"electron": "1.4.12",
"menubar": "^5.1.0",
"auto-launch": "^5.0.1",
"applescript": "^1.0.0",
"auto-launch": "^5.0.1",
"chart.js": "^2.2.1",
"countup.js": "^1.7.1",
"electron": "1.4.12",
"jquery": "^3.1.1",
"json-storage": "^2.1.1",
"localStorage": "^1.0.3",
"chart.js": "^2.2.1",
"countup.js": "^1.7.1",
"menubar": "^5.1.0",
"moment": "^2.17.1",
"semver": "^5.1.0",
"superagent": "^3.3.1",
"moment": "^2.17.1"
"superagent": "^3.3.1"
}
}
Empty file modified src/.DS_Store
100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion src/app.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const path = require('path')
let autoLaunch = true
let iconSetting = 'auto'

process.env.GOOGLE_API_KEY = 'AIzaSyAIyKnnlRNzl4zE8Msjii2YxzBVyquutuk'

// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
Expand All @@ -35,6 +37,7 @@ const mb = menubar({
index: path.join('file://', __dirname, '/main/index.html'),
icon: path.join(__dirname, '/../assets/IconTemplate.png'),
width: 280,
// width: 780,
height: 480,
resizable: false,
showDockIcon: false,
Expand Down Expand Up @@ -225,4 +228,4 @@ const autoUpdater = function () {
}
}
})
}
}
3 changes: 3 additions & 0 deletions src/components/timezone.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ let timeoffset = config.timezone.offset

const getTimezone = function () {
const wdata = store.getWdata()

superagent
.get(config.timezone.url)
.query({location: wdata[0].coord.lat + ',' + wdata[0].coord.lon})
.query({timestamp: Math.floor(Date.now() / 1000)})
.query({key: config.timezone.apikey})
.end(function (err, res) {
console.log(res)
let loading = utils.getLoading()
loading[3] = false
utils.setLoading(loading)
Expand Down Expand Up @@ -46,6 +48,7 @@ const addSeconds = function (date, seconds) {
}

const getDate = function (date) {
// console.log(convertDateToUTC(date))
return addSeconds(convertDateToUTC(date), timeoffset)
}

Expand Down
56 changes: 50 additions & 6 deletions src/components/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const getWeatherByCoord = function (url, lat, lon, option, callback) {
.query({ units: store.getFormat() })
.query({ appid: store.getApiKey() })
.end(function (err, res) {
console.log(err)
console.log(res)
// console.log(err)
// console.log(res)
let loading = utils.getLoading
loading[option] = false
utils.setLoading(loading)
Expand Down Expand Up @@ -86,6 +86,14 @@ const refreshInfo = function () {
}, config.start.interval)
}

const refreshLocationInfo = function () {
setInterval(function () {
// refreshWeather()
getGeolocation();
console.log('refresh location')
}, 2 * 3600000)
}

const refreshWeather = function () {
jQuery('.spinner').fadeIn()
utils.showAll()
Expand All @@ -97,7 +105,7 @@ const refreshWeather = function () {
getWeatherByCity(config.weather.url.hourly, store.getCity(), 2)

window.setTimeout(function () {
// console.log(wdata)

if (store.getMbInfo() && wdata[0].cod !== 404) {
ipcRenderer.send('set-title', {
temperature: utils.roundTemp(wdata[0].main.temp),
Expand All @@ -110,6 +118,7 @@ const refreshWeather = function () {
}
}, 500)


window.setTimeout(color.colorPalette, 1000)
}

Expand Down Expand Up @@ -342,10 +351,43 @@ const getGeolocation = function () {
// }
// )

navigator.geolocation.getCurrentPosition(res => {
console.log(res)
const lat = res.coords.latitude
const lon = res.coords.longitude

utils.reset()
getWeatherByCoord(config.weather.url.actual, lat, lon, 0, showWeatherData)
getWeatherByCoord(config.weather.url.daily, lat, lon, 1, showForecastWeatherData)
getWeatherByCoord(config.weather.url.hourly, lat, lon, 2)

const wdata = store.getWdata()

window.setTimeout(function () {
if (store.getMbInfo() & wdata[0].cod !== 404) {
ipcRenderer.send('set-title', {
temperature: utils.roundTemp(wdata[0].main.temp),
location: store.getCity(),
icon: wdata[0].weather[0].icon
})
}
if (wdata[0].cod !== 404) {
timezone.getTimezone()
}
}, 500)

window.setTimeout(color.colorPalette, 1000)
}, err => {
console.log(err)
utils.showErrorMessage('Failure during location fetching')
});

/*
superagent
.get("http://ip-api.com/json/")
// .query({ browser: 'chromium' })
// .query({ sensor: true })
.get("https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyAIyKnnlRNzl4zE8Msjii2YxzBVyquutuk")
// .get("http://ip-api.com/json/")
.query({ browser: 'chromium' })
.query({ sensor: true })
.end(function (err, res) {
if (err || !res.ok) {
console.log(err)
Expand Down Expand Up @@ -378,6 +420,7 @@ const getGeolocation = function () {
window.setTimeout(color.colorPalette, 1000)
}
})
*/
}

const showRain = function (nbDrop = 100) {
Expand Down Expand Up @@ -410,6 +453,7 @@ const setNumAnimTemp = function (na) {
exports.getWeatherByCity = getWeatherByCity
exports.getWeatherByCoord = getWeatherByCoord
exports.refreshInfo = refreshInfo
exports.refreshLocationInfo = refreshLocationInfo
exports.refreshWeather = refreshWeather
exports.showWeatherData = showWeatherData
exports.showForecastWeatherData = showForecastWeatherData
Expand Down
4 changes: 2 additions & 2 deletions src/main/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"apikey": "547bbdc38bd641bef6645cd2c4bc613f",
"timezone": {
"url": "https://maps.googleapis.com/maps/api/timezone/json",
"apikey": "AIzaSyD7CnHeMDQV_XCXlimoPwiPSB_83Wfq7LE",
"apikey": "AIzaSyAIyKnnlRNzl4zE8Msjii2YxzBVyquutuk",
"offset": 0
},
"weather": {
Expand All @@ -17,7 +17,7 @@
"location": {
"url": "https://maps.googleapis.com/maps/api/browserlocation/json"
},
"color": {
"color": {
"error" : "#444444",
"list": ["#b1695a", "#DB9864", "#E3BB88", "#D0C7A8", "#B1C2A3", "#80BBB2", "#6D9E96", "#8F95A5", "#6F7685"]
},
Expand Down
Empty file modified src/main/index.html
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions src/main/main.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const store = require('./../utilities/store')
const weather = require('./../components/weather')
const utils = require('./../utilities/utils')


window.onload = function () {
init()

Expand All @@ -20,6 +21,7 @@ const loadEventListener = function () {

utils.showDate()
weather.refreshInfo()
weather.refreshLocationInfo()

jQuery('input#city').keypress(function (e) {
if (e.which === 13) {
Expand Down
Empty file modified src/main/style.css
100644 → 100755
Empty file.
Empty file modified src/utilities/color.js
100644 → 100755
Empty file.
Empty file modified src/utilities/store.js
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/utilities/utils.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const toggleDetails = function () {
}

const showDate = function () {
jQuery('#details .header .date').html(getTodayDate())
jQuery('#main .clock').html(getTime())
// jQuery('#details .header .date').html(getTodayDate())
// jQuery('#main .clock').html(getTime())
setInterval(function () {
refreshClock()
}, 60000)
Expand Down
Loading

0 comments on commit dcd2a05

Please sign in to comment.