Skip to content

Commit

Permalink
enable testing & code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jackd248 committed Oct 10, 2016
1 parent b1d5fec commit 4f39437
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 25 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"package:win64": "electron-builder dist/Temps-win32-x64/ --platform=win --out=dist --config=config.json && mv 'dist/Temps Setup.exe' dist/Temps_Windows64.exe",
"package:win32": "electron-builder dist/Temps-win32-ia32/ --platform=win --out=dist --config=config.json && mv 'dist/Temps Setup.exe' dist/Temps_Windows32.exe",
"package:osx": "hdiutil create -format UDZO -srcfolder dist/Temps-darwin-x64/Temps.app dist/Temps_Mac.dmg",
"package:linux": "cd dist/ && zip -r Temps_Linux_x64.zip Temps-linux-x64 && zip -r Temps_Linux_ia32.zip Temps-linux-ia32 && cd ../"
"package:linux": "cd dist/ && zip -r Temps_Linux_x64.zip Temps-linux-x64 && zip -r Temps_Linux_ia32.zip Temps-linux-ia32 && cd ../",
"test": "npm run lint",
"lint": "standard"
},
"author": "Konrad Michalik <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ app.on('will-quit', function () {
const mb = menubar({
index: path.join('file://', __dirname, '/../index.html'),
icon: path.join(__dirname, '/../assets/IconTemplate.png'),
width: 580,
width: 280,
height: 480,
resizable: false,
'show-dock-icon': false,
Expand Down
9 changes: 7 additions & 2 deletions src/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ const getColor = function () {
return color
}

const errorColor = function() {
setColor(config.color.error)
}

const colorPalette = function () {
const wdata = store.getWdata()
if (wdata[0].cod === 404) {
setColor('#444444')
errorColor()
return
}
var temp = utils.roundTemp(wdata[0].main.temp)
var colors = config.colors
var colors = config.color.list

if (store.getFormat() === 'metric') {
if (temp > 30) {
Expand Down Expand Up @@ -71,3 +75,4 @@ const colorPalette = function () {
exports.setColor = setColor
exports.getColor = getColor
exports.colorPalette = colorPalette
exports.errorColor = errorColor
14 changes: 13 additions & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@
"location": {
"url": "https://maps.googleapis.com/maps/api/browserlocation/json"
},
"colors": ["#b1695a", "#DB9864", "#E3BB88", "#D0C7A8", "#B1C2A3", "#80BBB2", "#6D9E96", "#8F95A5", "#6F7685"],
"color": {
"error" : "#444444",
"list": ["#b1695a", "#DB9864", "#E3BB88", "#D0C7A8", "#B1C2A3", "#80BBB2", "#6D9E96", "#8F95A5", "#6F7685"]
},
"date": {
"days": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"],
"months": ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
},
"start": {
"city": "Berlin, DE",
"format": "metric",
"interval": 300000
},
"random": {
"cities": [
"London, UK",
Expand Down
11 changes: 0 additions & 11 deletions src/libs/animate.min.css

This file was deleted.

4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ const init = function () {
if (store.getCity()) {
store.setCity(store.getCity())
} else {
store.setCity('Berlin, DE')
store.setCity(config.start.city)
}

if (store.getFormat()) {
store.setFormat(store.getFormat())
} else {
store.setFormat('metric')
store.setFormat(config.start.format)
}

if (store.getApiKey()) {
Expand Down
2 changes: 1 addition & 1 deletion src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const getFormat = function () {
if (localStore.get('format')) {
return localStore.get('format')
} else {
return 'metric'
return config.start.format
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ipcRenderer = require('electron').ipcRenderer
const jQuery = require('jquery')

let loading = [false, false, false, false]
const months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
const months = config.date.months

const getTodayDay = function () {
var days = [
Expand All @@ -29,9 +29,7 @@ const getTime = function () {
}

const getStyledDate = function (num) {
var days = [
'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'
]
var days = config.date.days
var date = new Date()
return days[(date.getDay() + num) % 7]
}
Expand Down Expand Up @@ -92,7 +90,7 @@ const refreshClock = function () {
}

const showErrorMessage = function (message) {
color.setColor('#444444')
color.errorColor()
ipcRenderer.send('no-title')
jQuery('#main .actual-icon svg').html('')
jQuery('#details .location').html('')
Expand Down
2 changes: 1 addition & 1 deletion src/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const refreshInfo = function () {
setInterval(function () {
refreshWeather()
console.log('refresh info')
}, 300000)
}, config.start.interval)
}

const refreshWeather = function () {
Expand Down

0 comments on commit 4f39437

Please sign in to comment.