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,17 +5,17 @@
* MIT Licensed.
*/
var Class = require('../../../js/class.js');
var express = require('express');
var path = require('path');
var Class = require("../../../js/class.js");
var express = require("express");
var path = require("path");
NodeHelper = Class.extend({
init: function() {
console.log('Initializing new module helper ...');
console.log("Initializing new module helper ...");
},
start: function() {
console.log('Staring module helper: ' + this.name);
console.log("Staring module helper: " + this.name);
},
/* socketNotificationReceived(notification, payload)
@@ -25,7 +25,7 @@ NodeHelper = Class.extend({
* argument payload mixed - The payload of the notification.
*/
socketNotificationReceived: function(notification, payload) {
console.log(this.name + ' received a socket notification: ' + notification + ' - Payload: ' + payload);
console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
},
/* setName(name)
@@ -56,7 +56,6 @@ NodeHelper = Class.extend({
this.io.of(this.name).emit(notification, payload);
},
/* setExpressApp(app)
* Sets the express app object for this module.
* This allows you to host files from the created webserver.
@@ -66,8 +65,8 @@ NodeHelper = Class.extend({
setExpressApp: function(app) {
this.expressApp = app;
var publicPath = this.path + '/public';
app.use('/' + this.name, express.static(publicPath));
var publicPath = this.path + "/public";
app.use("/" + this.name, express.static(publicPath));
},
/* setSocketIO(io)
@@ -80,21 +79,21 @@ NodeHelper = Class.extend({
var self = this;
self.io = io;
console.log('Connecting socket for: ' + this.name);
console.log("Connecting socket for: " + this.name);
var namespace = this.name;
io.of(namespace).on('connection', function (socket) {
io.of(namespace).on("connection", function(socket) {
// add a catch all event.
var onevent = socket.onevent;
socket.onevent = function (packet) {
socket.onevent = function(packet) {
var args = packet.data || [];
onevent.call (this, packet); // original call
onevent.call(this, packet); // original call
packet.data = ["*"].concat(args);
onevent.call(this, packet); // additional call to catch-all
};
// register catch all.
socket.on('*', function (notification, payload) {
if (notification !== '*')
socket.on("*", function(notification, payload) {
if (notification !== "*")
//console.log('received message in namespace: ' + namespace);
self.socketNotificationReceived(notification, payload);
});
@@ -107,4 +106,4 @@ NodeHelper.create = function(moduleDefinition) {
return NodeHelper.extend(moduleDefinition);
};
module.exports = NodeHelper;
module.exports = NodeHelper;