Standardize: TO JSCS!

This commit is contained in:
Nicholas Hubbard
2016-04-05 14:35:11 -04:00
parent 18390503b5
commit 426728058c
28 changed files with 623 additions and 653 deletions

View File

@@ -5,21 +5,21 @@
* MIT Licensed.
*/
var NodeHelper = require('node_helper');
var validUrl = require('valid-url');
var Fetcher = require('./fetcher.js');
var NodeHelper = require("node_helper");
var validUrl = require("valid-url");
var Fetcher = require("./fetcher.js");
module.exports = NodeHelper.create({
// Subclass start method.
start: function() {
console.log('Starting module: ' + this.name);
console.log("Starting module: " + this.name);
this.fetchers = [];
},
// Subclass socketNotificationReceived received.
socketNotificationReceived: function(notification, payload) {
if(notification === 'ADD_FEED') {
if (notification === "ADD_FEED") {
this.createFetcher(payload.url, payload.reloadInterval, payload.encoding);
}
},
@@ -35,25 +35,25 @@ module.exports = NodeHelper.create({
createFetcher: function(url, reloadInterval, encoding) {
var self = this;
if (!validUrl.isUri(url)){
self.sendSocketNotification('INCORRECT_URL', url);
if (!validUrl.isUri(url)) {
self.sendSocketNotification("INCORRECT_URL", url);
return;
}
var fetcher;
if (typeof self.fetchers[url] === 'undefined') {
console.log('Create new news fetcher for url: ' + url + ' - Interval: ' + reloadInterval);
if (typeof self.fetchers[url] === "undefined") {
console.log("Create new news fetcher for url: " + url + " - Interval: " + reloadInterval);
fetcher = new Fetcher(url, reloadInterval, encoding);
fetcher.onReceive(function(fetcher) {
self.sendSocketNotification('NEWS_ITEMS', {
self.sendSocketNotification("NEWS_ITEMS", {
url: fetcher.url(),
items: fetcher.items()
});
});
fetcher.onError(function(fetcher, error) {
self.sendSocketNotification('FETCH_ERROR', {
self.sendSocketNotification("FETCH_ERROR", {
url: fetcher.url(),
error: error
});
@@ -61,7 +61,7 @@ module.exports = NodeHelper.create({
self.fetchers[url] = fetcher;
} else {
console.log('Use exsisting news fetcher for url: ' + url);
console.log("Use exsisting news fetcher for url: " + url);
fetcher = self.fetchers[url];
fetcher.setReloadInterval(reloadInterval);
fetcher.broadcastItems();