Skip to content

Commit

Permalink
Replace xo with jscs, more easily customized
Browse files Browse the repository at this point in the history
Also fix all the style complaints.
  • Loading branch information
cheshire137 committed Jun 2, 2016
1 parent 6bf3b77 commit 2e62826
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 69 deletions.
7 changes: 5 additions & 2 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"preset": "airbnb",
"preset": "google",
"excludeFiles": ["dist/**", "node_modules/**"],
"validateQuoteMarks": null
"validateQuoteMarks": null,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"disallowSpacesInsideObjectBrackets": false,
"requireSpacesInsideObjectBrackets": "all"
}
6 changes: 3 additions & 3 deletions index/index-page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const {ipcRenderer} = require('electron');
const { ipcRenderer } = require('electron');
const Soma = require('../models/soma');
const Settings = require('../models/settings');
const DefaultStations = require('../defaultStations.json');
Expand Down Expand Up @@ -263,7 +263,7 @@ module.exports = class IndexPage extends Eventful {
this.soma.getStationInfo(station).
then(this.onStationInfoLoaded.bind(this)).
catch(this.onStationInfoError.bind(this));
}
};
const seconds = 5 * 60;
this.stationInfoInterval = setInterval(getter, seconds * 1000);
getter();
Expand Down Expand Up @@ -599,4 +599,4 @@ module.exports = class IndexPage extends Eventful {
}
}
}
}
};
76 changes: 38 additions & 38 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,60 @@ require('electron-debug')();
let mainWindow;

function onClosed() {
// dereference the window
// for multiple windows store them in an array
mainWindow = null;
// dereference the window
// for multiple windows store them in an array
mainWindow = null;
}

function createMainWindow() {
let win;
const windowProperties = {
icon: __dirname+'/images/icon128.png',
title: 'HuxleyFM',
resizable: false
};
if (process.env.NODE_ENV === 'development') {
windowProperties.width = 900;
windowProperties.height = 370;
win = new BrowserWindow(windowProperties);
win.webContents.openDevTools();
} else {
windowProperties.width = 400;
windowProperties.height = 370;
win = new BrowserWindow(windowProperties);
}
win.loadURL(`file://${__dirname}/page/page.html`);
win.on('closed', onClosed);
return win;
let win;
const windowProperties = {
icon: __dirname + '/images/icon128.png',
title: 'HuxleyFM',
resizable: false
};
if (process.env.NODE_ENV === 'development') {
windowProperties.width = 900;
windowProperties.height = 370;
win = new BrowserWindow(windowProperties);
win.webContents.openDevTools();
} else {
windowProperties.width = 400;
windowProperties.height = 370;
win = new BrowserWindow(windowProperties);
}
win.loadURL(`file://${__dirname}/page/page.html`);
win.on('closed', onClosed);
return win;
}

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
globalShortcut.unregisterAll();
app.quit();
}
if (process.platform !== 'darwin') {
globalShortcut.unregisterAll();
app.quit();
}
});

app.on('activate', () => {
if (!mainWindow) {
mainWindow = createMainWindow();
}
if (!mainWindow) {
mainWindow = createMainWindow();
}
});

app.on('ready', () => {
mainWindow = createMainWindow();
['MediaPlayPause', 'MediaStop'].forEach(registerMediaKey);
mainWindow = createMainWindow();
['MediaPlayPause', 'MediaStop'].forEach(registerMediaKey);
});

app.on('before-quit', () => {
mainWindow.webContents.send('quit');
mainWindow.webContents.send('quit');
});

function registerMediaKey(key) {
const success = globalShortcut.register(key, () => {
mainWindow.webContents.send('media-key', key);
});
if (!success) {
process.stderr.write('failed to bind key ' + key + '\n');
}
const success = globalShortcut.register(key, () => {
mainWindow.webContents.send('media-key', key);
});
if (!success) {
process.stderr.write('failed to bind key ' + key + '\n');
}
}
6 changes: 3 additions & 3 deletions models/appMenu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {remote} = require('electron');
const {Menu, MenuItem} = remote;
const { remote } = require('electron');
const { Menu, MenuItem } = remote;
const Eventful = require('./eventful');

module.exports = class AppMenu extends Eventful {
Expand Down Expand Up @@ -53,4 +53,4 @@ module.exports = class AppMenu extends Eventful {
});
}
}
}
};
2 changes: 1 addition & 1 deletion models/chromecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ module.exports = class Chromecast extends Eventful {
console.debug('Chromecast closed');
this.emit('close');
}
}
};
2 changes: 1 addition & 1 deletion models/chromecastScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ module.exports = class ChromecastScanner extends Eventful {
clearTimeout(this.timer);
this.m.destroy();
}
}
};
2 changes: 1 addition & 1 deletion models/eventful.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ module.exports = class Eventful {
}
return false;
}
}
};
2 changes: 1 addition & 1 deletion models/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ module.exports = class Fetcher {
getStatus(response) {
return response.status + ' ' + response.statusText;
}
}
};
2 changes: 1 addition & 1 deletion models/flashMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ module.exports = class FlashMessages {
}, false);
return link;
}
}
};
2 changes: 1 addition & 1 deletion models/lastfm.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ module.exports = class Lastfm extends Fetcher {
md5(str) {
return crypto.createHash('md5').update(str, 'utf8').digest('hex');
}
}
};
2 changes: 1 addition & 1 deletion models/linkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ class LinkHandler extends Eventful {
}
}

module.exports = LinkHandler
module.exports = LinkHandler;
2 changes: 1 addition & 1 deletion models/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ class Router extends Eventful {
}
}

module.exports = Router
module.exports = Router;
2 changes: 1 addition & 1 deletion models/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ module.exports = class Settings {
static save(settings) {
return this.store('settings', settings);
}
}
};
2 changes: 1 addition & 1 deletion models/soma.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ module.exports = class Soma extends Fetcher {
}).catch(reject);
});
}
}
};
13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "3till7.net"
},
"scripts": {
"test": "xo",
"test": "node_modules/jscs/bin/jscs -c .jscsrc .",
"postinstall": "if [ ! -f config.json ]; then cp config.json.example config.json; fi",
"start": "electron .",
"build": "npm run-script build-osx",
Expand Down Expand Up @@ -65,21 +65,14 @@
"crypto": "0.0.3",
"electron-debug": "^1.0.0",
"electron-json-storage": "^2.0.0",
"jscs": "^3.0.3",
"multicast-dns": "^6.0.1",
"node-fetch": "^1.5.2",
"socket.io-client": "^1.4.6"
},
"devDependencies": {
"devtron": "^1.1.0",
"electron-packager": "7.0.2",
"electron-prebuilt": "1.1.3",
"xo": "^0.15.0"
},
"xo": {
"esnext": true,
"envs": [
"node",
"browser"
]
"electron-prebuilt": "1.1.3"
}
}
7 changes: 5 additions & 2 deletions page/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const FlashMessages = require('../models/flashMessages');
const AppMenu = require('../models/appMenu');
const ChromecastScanner = require('../models/chromecastScanner');
const Chromecast = require('../models/chromecast');
const {ipcRenderer} = require('electron');
const { ipcRenderer } = require('electron');

const __bind = function(fn, me) {
return function() {
Expand Down Expand Up @@ -339,7 +339,10 @@ class PageLoader {
}

onChromecastStatus(status) {
console.debug('Chromecast', status.playerState, status.media ? status.media.contentId : 'unknown URL', 'volume ' + status.volume.level, status.volume.muted ? 'muted' : 'not muted');
console.debug('Chromecast', status.playerState,
status.media ? status.media.contentId : 'unknown URL',
'volume ' + status.volume.level,
status.volume.muted ? 'muted' : 'not muted');
if (status.playerState !== 'BUFFERING') {
this.chromecastLink.classList.remove('pulse');
}
Expand Down
2 changes: 1 addition & 1 deletion settings/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,4 @@ class SettingsPage extends Eventful {
}
}

module.exports = SettingsPage
module.exports = SettingsPage;

0 comments on commit 2e62826

Please sign in to comment.