/js/BubbleDots/BubbleDotsApp.js
JavaScript | 44 lines | 19 code | 3 blank | 22 comment | 3 complexity | 8f4667500850b9c941fa6a6b1a69429f MD5 | raw file
1/** 2 File: 3 RealtimeMultiplayerGame.js 4 Created By: 5 Mario Gonzalez 6 Project: 7 RealtimeMultiplayerNodeJS 8 Abstract: 9 This is the core module for RealtimeMultiplayerGame contains the namespace, and extend method 10 11 Basic Usage: 12 This class is not instantiated 13 Version: 14 1.0 15 */ 16BubbleDots = (typeof BubbleDots === 'undefined') ? {} : BubbleDots; 17/** 18 * Allows a package to create a namespace within RealtimeMultiplayerGame 19 * From Javascript Patterns book 20 * @param ns_string 21 */ 22BubbleDots.namespace = function (ns_string) { 23 var parts = ns_string.split('.'), 24 parent = BubbleDots, 25 i = 0; 26 27 // strip redundant leading global 28 if (parts[0] === "BubbleDots") { 29 parts = parts.slice(1); 30 } 31 32 var len = parts.length, 33 aPackage = null; 34 for (i = 0; i < len; i += 1) { 35 var singlePart = parts[i]; 36 // create a property if it doesn't exist 37 if (typeof parent[singlePart] === "undefined") { 38 parent[singlePart] = {}; 39 } 40 parent = parent[singlePart]; 41 42 } 43 return parent; 44};