Huge cleanup of white space

This commit is contained in:
Domi-G
2016-04-01 22:52:32 +02:00
committed by Michael Teeuw
parent e448e87252
commit 576c668d84
41 changed files with 127 additions and 175 deletions

View File

@@ -2,24 +2,24 @@
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
// Create a new Class that inherits from this class
Class.extend = function(prop) {
var _super = this.prototype;
// Instantiate a base class (but only create the instance,
// don't run the init constructor)
initializing = true;
var prototype = new this();
initializing = false;
// Copy the properties over onto the new prototype
for (var name in prop) {
// Check if we're overwriting an existing function
@@ -28,42 +28,42 @@
(function(name, fn){
return function() {
var tmp = this._super;
// Add a new ._super() method that is the same method
// but on the super-class
this._super = _super[name];
// The method only need to be bound temporarily, so we
// remove it when we're done executing
var ret = fn.apply(this, arguments);
var ret = fn.apply(this, arguments);
this._super = tmp;
return ret;
};
})(name, prop[name]) :
prop[name];
}
// The dummy class constructor
function Class() {
// All construction is actually done in the init method
if ( !initializing && this.init )
this.init.apply(this, arguments);
}
// Populate our constructed prototype object
Class.prototype = prototype;
// Enforce the constructor to be what we expect
Class.prototype.constructor = Class;
// And make this class extendable
Class.extend = arguments.callee;
return Class;
};
})();
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== 'undefined') {module.exports = Class;}
if (typeof module !== 'undefined') {module.exports = Class;}

View File

@@ -55,4 +55,4 @@ var defaults = {
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== 'undefined') {module.exports = defaults;}
if (typeof module !== 'undefined') {module.exports = defaults;}

View File

@@ -61,7 +61,7 @@ function loadModule(module) {
var elements = module.split('/');
var moduleName = elements[elements.length - 1];
var moduleFolder = __dirname + '/../modules/' + module;
if (defaultModules.indexOf(moduleName) !== -1) {
moduleFolder = __dirname + '/../modules/default/' + module;
}

View File

@@ -41,7 +41,7 @@ var Loader = (function() {
}
};
loadNextModule();
loadNextModule();
};
/* startModules()
@@ -60,7 +60,7 @@ var Loader = (function() {
/* getAllModules()
* Retrieve list of all modules.
*
* return array - module data as configured in config
* return array - module data as configured in config
*/
var getAllModules = function() {
return config.modules;
@@ -82,7 +82,7 @@ var Loader = (function() {
var elements = module.split('/');
var moduleName = elements[elements.length - 1];
var moduleFolder = config.paths.modules + '/' + module;
if (defaultModules.indexOf(moduleName) !== -1) {
moduleFolder = config.paths.modules + '/default/' + module;
}
@@ -130,8 +130,8 @@ var Loader = (function() {
afterLoad();
});
}
};
};
/* bootstrapModule(module, mObj)
* Bootstrap modules by setting the module data and loading the scripts & styles.
@@ -154,8 +154,8 @@ var Loader = (function() {
callback();
});
});
};
/* loadFile(fileName)
@@ -194,7 +194,7 @@ var Loader = (function() {
};
document.getElementsByTagName("head")[0].appendChild(stylesheet);
break;
break;
}
};
@@ -249,10 +249,3 @@ var Loader = (function() {
};
})();

View File

@@ -9,7 +9,7 @@
*/
// This logger is very simple, but needs to be extended.
// This logger is very simple, but needs to be extended.
// This system can eventually be used to push the log messages to an external target.

View File

@@ -15,13 +15,13 @@ var MM = (function() {
/* Private Methods */
/* createDomObjects()
* Create dom objects for all modules that
* Create dom objects for all modules that
* are configured for a specific position.
*/
var createDomObjects = function() {
for (var m in modules) {
var module = modules[m];
if (typeof module.data.position === 'string') {
var wrapper = selectWrapper(module.data.position);
@@ -47,13 +47,11 @@ var MM = (function() {
moduleContent.className = "module-content";
dom.appendChild(moduleContent);
updateDom(module, 0);
}
}
sendNotification('DOM_OBJECTS_CREATED');
sendNotification('DOM_OBJECTS_CREATED');
};
/* selectWrapper(position)
@@ -99,7 +97,6 @@ var MM = (function() {
if (!module.hidden) {
if (!moduleNeedsUpdate(module, newContent)) {
return;
}
@@ -173,7 +170,7 @@ var MM = (function() {
// the .display property.
moduleWrapper.style.position = 'absolute';
if (typeof callback === 'function') { callback(); }
if (typeof callback === 'function') { callback(); }
}, speed);
}
};
@@ -194,10 +191,9 @@ var MM = (function() {
moduleWrapper.style.opacity = 1;
setTimeout(function() {
if (typeof callback === 'function') { callback(); }
if (typeof callback === 'function') { callback(); }
}, speed);
}
};
@@ -216,14 +212,14 @@ var MM = (function() {
/* setSelectionMethodsForModules()
* Adds special selectors on a collection of modules.
*
*
* argument modules array - Array of modules.
*/
var setSelectionMethodsForModules = function(modules) {
/* withClass(className)
* filters a collection of modules based on classname(s).
*
*
* argument className string/array - one or multiple classnames. (array or space devided)
*
* return array - Filtered collection of modules.
@@ -245,7 +241,7 @@ var MM = (function() {
if (classes.indexOf(searchClass.toLowerCase()) !== -1) {
newModules.push(module);
}
}
}
}
setSelectionMethodsForModules(newModules);
@@ -254,7 +250,7 @@ var MM = (function() {
/* exceptWithClass(className)
* filters a collection of modules based on classname(s). (NOT)
*
*
* argument className string/array - one or multiple classnames. (array or space devided)
*
* return array - Filtered collection of modules.
@@ -280,7 +276,7 @@ var MM = (function() {
}
if (!foundClass) {
newModules.push(module);
}
}
}
setSelectionMethodsForModules(newModules);
@@ -289,7 +285,7 @@ var MM = (function() {
/* exceptModule(module)
* Removes a module instance from the collection.
*
*
* argument module Module object - The module instance to remove from the collection.
*
* return array - Filtered collection of modules.
@@ -310,7 +306,7 @@ var MM = (function() {
/* enumerate(callback)
* Walks thru a collection of modules and executes the callback with the module as an argument.
*
*
* argument callback function - The function to execute with the module as an argument.
*/
var enumerate = function(callback) {
@@ -320,8 +316,6 @@ var MM = (function() {
}
};
if (typeof modules.withClass === 'undefined') { Object.defineProperty(modules, 'withClass', {value: withClass, enumerable: false}); }
if (typeof modules.exceptWithClass === 'undefined') { Object.defineProperty(modules, 'exceptWithClass', {value: exceptWithClass, enumerable: false}); }
if (typeof modules.exceptModule === 'undefined') { Object.defineProperty(modules, 'exceptModule', {value: exceptModule, enumerable: false}); }
@@ -329,8 +323,6 @@ var MM = (function() {
};
return {
/* Public Methods */
@@ -399,7 +391,7 @@ var MM = (function() {
Log.error('updateDom: Sender should be a module.');
return;
}
// Further implementation is done in the private method.
updateDom(module, speed);
},
@@ -442,8 +434,3 @@ var MM = (function() {
})();
MM.init();

View File

@@ -57,11 +57,11 @@ var Module = Class.extend({
*/
getDom: function() {
var nameWrapper = document.createElement("div");
var name = document.createTextNode(this.name);
var name = document.createTextNode(this.name);
nameWrapper.appendChild(name);
var identifierWrapper = document.createElement("div");
var identifier = document.createTextNode(this.identifier);
var identifier = document.createTextNode(this.identifier);
identifierWrapper.appendChild(identifier);
identifierWrapper.className = "small dimmed";
@@ -69,7 +69,7 @@ var Module = Class.extend({
div.appendChild(nameWrapper);
div.appendChild(identifierWrapper);
return div;
return div;
},
/* notificationReceived(notification, payload, sender)
@@ -99,7 +99,6 @@ var Module = Class.extend({
},
/*********************************************
* The methods below don't need subclassing. *
*********************************************/
@@ -262,12 +261,12 @@ Module.create = function(name) {
if (obj === null || typeof obj !== 'object') {
return obj;
}
var temp = obj.constructor(); // give temp the original obj's constructor
for (var key in obj) {
temp[key] = cloneObject(obj[key]);
}
return temp;
}
@@ -278,13 +277,10 @@ Module.create = function(name) {
var ModuleClass = Module.extend(clonedDefinition);
return new ModuleClass();
};
Module.register = function(name, moduleDefinition) {
Log.log('Module registered: ' + name);
Module.definitions[name] = moduleDefinition;
};

View File

@@ -31,4 +31,4 @@ var Server = function(config, callback) {
}
};
module.exports = Server;
module.exports = Server;

View File

@@ -7,8 +7,6 @@
* MIT Licensed.
*/
var MMSocket = function(moduleName) {
var self = this;
@@ -18,7 +16,7 @@ var MMSocket = function(moduleName) {
}
self.moduleName = moduleName;
self.socket = io('http://localhost:8080');
self.socket.on('notification', function (data) {
@@ -35,6 +33,4 @@ var MMSocket = function(moduleName) {
});
}
};
};
};

View File

@@ -39,4 +39,4 @@ var MMSocket = function(moduleName) {
}
socket.emit(notification, payload);
};
};
};