/js/DemoCircles/DemoApp.js
JavaScript | 44 lines | 19 code | 3 blank | 22 comment | 3 complexity | f96f08e0591b482adb051fc36a453869 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
- /**
- File:
- RealtimeMultiplayerGame.js
- Created By:
- Mario Gonzalez
- Project:
- RealtimeMultiplayerNodeJS
- Abstract:
- This is the core module for RealtimeMultiplayerGame contains the namespace, and extend method
- Basic Usage:
- This class is not instantiated
- Version:
- 1.0
- */
- DemoApp = (typeof DemoApp === 'undefined') ? {} : DemoApp;
- /**
- * Allows a package to create a namespace within RealtimeMultiplayerGame
- * From Javascript Patterns book
- * @param ns_string
- */
- DemoApp.namespace = function (ns_string) {
- var parts = ns_string.split('.'),
- parent = DemoApp,
- i = 0;
- // strip redundant leading global
- if (parts[0] === "DemoApp") {
- parts = parts.slice(1);
- }
- var len = parts.length,
- aPackage = null;
- for (i = 0; i < len; i += 1) {
- var singlePart = parts[i];
- // create a property if it doesn't exist
- if (typeof parent[singlePart] === "undefined") {
- parent[singlePart] = {};
- }
- parent = parent[singlePart];
- }
- return parent;
- };