Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit c42a24a

Browse files
code improvements, bugfix, usability adjustments
1 parent d3d29d0 commit c42a24a

File tree

11 files changed

+165
-89
lines changed

11 files changed

+165
-89
lines changed

TODO.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@
3131
* ~~Number counting animation~~
3232
* ~~Auto updater~~
3333

34-
## v0.6.0
34+
## v0.5.1
3535
* forecast offset bug
3636
* endless loading animation bug
37-
* city history
38-
* automatic testing
3937
* open external browser
4038
* providing a starter api key inside the app
4139
* usability improvements
40+
41+
## v0.6.0
42+
* city history
43+
* automatic testing
4244
* Less, ECMAScript 5
4345
* Clean up code
4446

app.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
'use strict'
22

3-
var electron = require('electron')
4-
var app = electron.app
5-
var globalShortcut = electron.globalShortcut
6-
var AutoLaunch = require('auto-launch')
7-
var menubar = require('menubar')
8-
var Menu = electron.Menu
9-
var dialog = electron.dialog
10-
var ipcMain = electron.ipcMain
11-
var shell = electron.shell
3+
const electron = require('electron')
4+
const app = electron.app
5+
const globalShortcut = electron.globalShortcut
6+
const AutoLaunch = require('auto-launch')
7+
const menubar = require('menubar')
8+
const Menu = electron.Menu
9+
const dialog = electron.dialog
10+
const ipcMain = electron.ipcMain
11+
const shell = electron.shell
1212
const superagent = require('superagent')
1313
const semver = require('semver')
1414
const config = require('./package.json')
1515

16-
var autoLaunch = true
16+
let autoLaunch = true
1717

1818
// Quit when all windows are closed.
1919
app.on('window-all-closed', function () {
@@ -29,7 +29,7 @@ app.on('will-quit', function () {
2929
globalShortcut.unregisterAll()
3030
})
3131

32-
var mb = menubar({
32+
const mb = menubar({
3333
index: 'file://' + __dirname + '/index.html',
3434
icon: __dirname + '/assets/IconTemplate.png',
3535
width: 280,
@@ -73,7 +73,7 @@ mb.on('ready', function ready () {
7373
})
7474

7575
ipcMain.on('set-title', function (event, args) {
76-
var temperature = Math.round(args.temperature) + '°'
76+
const temperature = Math.round(args.temperature) + '°'
7777
mb.tray.setToolTip(args.location + ' - ' + temperature)
7878
mb.tray.setTitle(temperature)
7979
if (process.platform === 'darwin') {
@@ -87,6 +87,11 @@ mb.on('ready', function ready () {
8787
app.quit()
8888
})
8989

90+
ipcMain.on('will-navigate', function (event, args) {
91+
const url = args.url
92+
electron.shell.openExternal(url)
93+
})
94+
9095
ipcMain.on('auto-launch', function (event, args) {
9196

9297
// ToDo: appLauncher.isEnabled() not working for now
@@ -114,7 +119,7 @@ mb.on('show', function show () {
114119
mb.window.webContents.send('show')
115120
})
116121

117-
var appLauncher = new AutoLaunch({
122+
const appLauncher = new AutoLaunch({
118123
name: 'temps'
119124
})
120125

@@ -128,7 +133,7 @@ appLauncher.isEnabled().then(function (enabled) {
128133
appLauncher.enable()
129134

130135
// Menu template and shortcuts
131-
var template = [{
136+
const template = [{
132137
label: 'Temps',
133138
submenu: [
134139
{ label: 'About Temps', selector: 'orderFrontStandardAboutPanel:' },

assets/icons/icon-close.png

246 Bytes
Loading

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
<div id="main">
1616
<div class="header">
1717
<div class="settings">
18-
<img src="assets/icons/icon-adjust.png" alt="settings" width="16"/>
18+
<div id="nav-icon">
19+
<span></span>
20+
<span></span>
21+
</div>
1922
</div>
2023
<div class="clock">
2124

src/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "temps",
33
"version": "v0.5.0",
4+
"apikey": "547bbdc38bd641bef6645cd2c4bc613f",
45
"timezone": {
56
"url": "https://maps.googleapis.com/maps/api/timezone/json",
67
"apikey": "AIzaSyD7CnHeMDQV_XCXlimoPwiPSB_83Wfq7LE",

src/main.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,18 @@ var loadEventListener = function () {
9595
refreshWeather()
9696
})
9797

98-
jQuery('#main .settings img').click(function () {
98+
jQuery('#nav-icon').click(function() {
9999
toggleSettings()
100100
})
101101

102+
jQuery('a').click(function (e) {
103+
e.preventDefault()
104+
const target = jQuery(this).attr('href')
105+
ipcRenderer.send('will-navigate', {
106+
url: target
107+
})
108+
})
109+
102110
jQuery('#settings .close').click(function () {
103111
ipcRenderer.send('close')
104112
})
@@ -120,7 +128,7 @@ var init = function () {
120128
if (store.get('actual-city')) {
121129
setCity(store.get('actual-city'))
122130
} else {
123-
setCity('Dresden, DE')
131+
setCity('Berlin, DE')
124132
}
125133

126134
if (store.get('format')) {

src/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var getApiKey = function () {
5555
if (store.get('apikey')) {
5656
return store.get('apikey')
5757
} else {
58-
showErrorMessage('No API Key')
58+
return config.apikey
5959
}
6060
}
6161

src/style.css

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,79 @@ input[type="checkbox"][name="favorite-city"]:checked + span {
530530
100% { opacity: 0; }
531531
}
532532

533+
#nav-icon {
534+
width: 60px;
535+
height: 45px;
536+
position: relative;
537+
margin-left: -20px;
538+
margin-top: -12px;
539+
-webkit-transform: rotate(0deg) scale(.3);
540+
-moz-transform: rotate(0deg) scale(.3);
541+
-o-transform: rotate(0deg) scale(.3);
542+
transform: rotate(0deg) scale(.3);
543+
-webkit-transition: .5s ease-in-out;
544+
-moz-transition: .5s ease-in-out;
545+
-o-transition: .5s ease-in-out;
546+
transition: .5s ease-in-out;
547+
cursor: pointer;
548+
}
549+
550+
#nav-icon span {
551+
display: block;
552+
position: absolute;
553+
height: 7px;
554+
width: 100%;
555+
background: #FFFFFF;
556+
border-radius: 9px;
557+
opacity: 1;
558+
left: 0;
559+
-webkit-transform: rotate(0deg);
560+
-moz-transform: rotate(0deg);
561+
-o-transform: rotate(0deg);
562+
transform: rotate(0deg);
563+
-webkit-transition: .25s ease-in-out;
564+
-moz-transition: .25s ease-in-out;
565+
-o-transition: .25s ease-in-out;
566+
transition: .25s ease-in-out;
567+
}
568+
569+
#nav-icon {
570+
}
571+
572+
#nav-icon span:nth-child(1) {
573+
top: 0px;
574+
-webkit-transform-origin: left center;
575+
-moz-transform-origin: left center;
576+
-o-transform-origin: left center;
577+
transform-origin: left center;
578+
}
579+
580+
#nav-icon span:nth-child(2) {
581+
top: 25px;
582+
-webkit-transform-origin: left center;
583+
-moz-transform-origin: left center;
584+
-o-transform-origin: left center;
585+
transform-origin: left center;
586+
}
587+
588+
#nav-icon.open span:nth-child(1) {
589+
-webkit-transform: rotate(45deg);
590+
-moz-transform: rotate(45deg);
591+
-o-transform: rotate(45deg);
592+
transform: rotate(45deg);
593+
top: -3px;
594+
left: 8px;
595+
}
596+
597+
#nav-icon.open span:nth-child(2) {
598+
-webkit-transform: rotate(-45deg);
599+
-moz-transform: rotate(-45deg);
600+
-o-transform: rotate(-45deg);
601+
transform: rotate(-45deg);
602+
top: 39px;
603+
left: 8px;
604+
}
605+
533606
body {
534607
margin: 0;
535608
}

src/timezone.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
function getTimezone () {
2-
jQuery.get(config.timezone.url + '?location=' + wdata[0].coord.lat + ',' + wdata[0].coord.lon + '&timestamp=1331161200&key=' + config.timezone.apikey, function (data) {
3-
timeoffset = data.rawOffset + 3600
4-
}).done(function () {
5-
jQuery('#details .header .date').html(getTodayDate())
6-
refreshClock()
7-
loading[3] = false
8-
checkLoading()
9-
showHourlyWeatherData()
10-
}).fail(function () {
11-
// showErrorMessage('Failure during data fetching');
12-
})
1+
const getTimezone = function () {
2+
superagent
3+
.get(config.timezone.url)
4+
.query({location: wdata[0].coord.lat + ',' + wdata[0].coord.lon})
5+
.query({timestamp: '1331161200'})
6+
.query({key: config.timezone.apikey})
7+
.end(function (err, res) {
8+
loading[3] = false
9+
if (err || !res.ok) {
10+
showErrorMessage('Failure during data fetching')
11+
} else {
12+
timeoffset = res.body.rawOffset + 3600
13+
jQuery('#details .header .date').html(getTodayDate())
14+
refreshClock()
15+
checkLoading()
16+
showHourlyWeatherData()
17+
}
18+
})
1319
}
1420

1521
function convertDateToUTC (date) {

src/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,16 @@ var toggleSettings = function () {
9696
jQuery('#details').delay(500).fadeIn()
9797
jQuery('#settings').height('0px')
9898
jQuery('#settings .content').fadeOut()
99+
jQuery('#nav-icon').removeClass('open')
99100
} else {
100101
jQuery('#main').height('120px')
101102
jQuery('#main .content').fadeOut()
102103
jQuery('#main .actual-icon').fadeOut()
103104
jQuery('#details').fadeOut()
104105
jQuery('#settings').height('340px')
105106
jQuery('#settings .content').delay(500).fadeIn()
107+
jQuery('#nav-icon').addClass('open')
106108
}
107-
108109
}
109110

110111
var addZero = function (i) {
@@ -151,6 +152,8 @@ var showErrorMessage = function (message) {
151152
numAnim = null
152153
jQuery('#main .content .temp-note').html(message)
153154
jQuery('#main .actual-icon svg').html('<image xlink:href="assets/icons/11d.svg" src="assets/icons/11d.svg" width="80" height="80"/>')
155+
timeoffset = config.timezone.offset
156+
refreshClock()
154157

155158
}
156159

0 commit comments

Comments
 (0)