/**==================================================================
Configuration file for MMOE
Selects and loads...
- Libraries
- Plugins
- Application
* BRIEF DESCRIPTION *
Ideally, the config.js will not be static, and instead will be
generated from an API Application (written in a web language
such as PHP, Perl, ASP, JSP, or Python). This will allow users
to login seperately (which is required by mmoe's auth features),
select custom plugins -- and for the server itself to specify
what game and what libraries are required to load.
* LOADING EXTERNAL FILES *
Because of the way mmoe works to be flexible and easy-to-change,
you often will have to include several default scripts and
stylesheets, at least half a dozen library files for the
application, any user or default selected plugin files, and
the application itself --- all this not included whatever
styles or scripts the individual files load.
HTTP requests could number to about 50 or more on sophisticated
systems. For this reason we recommend you host them on seperate
DNS's to pass through the DNS limit feature of the browser, and
to alleviate load on your servers.
* COMPATIBILITY TESTING *
Works (and tested) in:
- Firefox 2.0 /Gecko
- Safari 3 /WebKit Build 420 or >
- Opera 9
- IE 6
- IE 7
Works (with bugs or workarounds) in:
- Safari 2 /WebKit Build < 420
- Konqueror /KDE (Similar to Safari 2)
* Both browsers are unable to detect when an external file has loaded,
making loading screens and such useless.
* IMPORTANT NOTE *
--------------------------------------------------------------
The configurational file also includes a few library functions
that are necessary, and are not needed to be created elsewhere
--------------------------------------------------------------
- Importing External Files
- Debug function
- Extends the ARRAY Object
.last(): Returns the last object in the array
.forEach(): For browsers without native implementation
- Extends the STRING Object
.extension(): Returns the file extension of a string
- document.head will reference the
element
==================================================================**/
var Config = {
/** Edited by Server ***********************************************/
Libraries: [
/*
{name: "Name of Library",
path: "Path to library",
icon: "icon for splash},"
*/
{name: "Object Oriented Programming",
path: "../libs/lib-oop.js",
icon: "../libs/lib-oop/icon.png"},
{name: "Networking",
path: "../libs/lib-networking.js",
icon: "../libs/lib-networking/icon.png"},
{name: "Storage",
path: "../libs/lib-storage.js",
icon: "../libs/lib-storage/icon.png"}
],
Plugins: [
/*
{name: "Some-Green", path: "../plugins/something.js", icon: "../plugins/something/icon.png"},
{name: "Else-Red", path: "../plugins/else.js", icon: "../plugins/else/icon.png"},
{name: "More-Blue", path: "../plugins/more.js", icon: "../plugins/more/icon.png"}
*/
],
Application: {
name: "MMOE Demo - Web Chat",
version: "0.01 Alpha",
path: "../apps/simple-web-chat.js",
icon: "../apps/simple-web-chat/icon.png"
},
/** === END === Edited by Server ************************************/
Splash: {
Design: "",
Todo: 0,
Did: 0,
/** ==============================================================
@method: Config.Splash.onLoad()
@param: Object
Automatically called whenever a module of the application
loads, automatically giving it the icon as a paramter, the
name of it as a parameter, and the function itself will
calculate a percentage done.
=============================================================== **/
onLoad: function(item){
Config.Splash.Did++;
// Update progress bar
var percentDone = (Math.round((Config.Splash.Did / Config.Splash.Todo) * 100));
Config._dom.progressBar.style.width = percentDone + "%";
// Get Variables
var name = item.name;
var icon = item.icon;
var path = item.path;
// Highlight the icon specified
var icons = Config._dom.splashIconWrapper.childNodes;
for (var i=(Browser.ie) ? 0 : 1;i
@param: Function
Load an external file on-the-fly. Function automatically
parses the extension, and loads accordingly - passing
the function to a sub-function.
@return: Object
=============================================================== **/
file: function(path, func){
switch (path.extension()){
case "js":
var Loading = Config.Import.js(path, func);
break;
case "css":
var Loading = Config.Import.css(path, func);
break;
}
var Loading = Config.Import.image(path, func);
Loading.onload = func;
return Loading;
},
/** ==============================================================
@method: Config.Import.css()
@param: String
@param: Function
Loads an external stylesheet and adds it to the DOM
@return: Object
*NOTE*
If you wish the stylesheet to be disabled upon load,
make sure you set .disabled = true to the returning object.
=============================================================== **/
css: function(path, func){
var link = document.createElement("script");
link.type = "text/css";
link.href = path;
link.rel = "stylesheet";
document.head.appendChild(link);
Config.Import.onLoad(css, func);
return link;
},
/** ==============================================================
@method: Config.Import.js()
@param: String
@param: Function
Loads an external JavaScript and adds it to the DOM
@return: Object
=============================================================== **/
js: function(path, func){
var script = document.createElement("script");
script.type = "text/javascript";
script.src = path;
document.head.appendChild(script);
Config.Import.onLoad(script, func);
return script;
},
/** ==============================================================
@method: Config.Import.images()
@param: Array
@param: Function
Loads a number of image files into memory, running the
callback function when all of them are completed.
(Nothing returned)
=============================================================== **/
images: function(paths, func){
var todo = paths.length;
// Load all images
paths.forEach(function (item){
var img = Config.Import.image(item);
Config.Import.onLoad(img, function(){;
todo--; if (todo == 0) func();
});
});
},
/** ==============================================================
@method: Config.Import.image()
@param: String
@param: Function
Loads an image into memory (preload)
@return: Object
=============================================================== **/
image: function(path, func){
var image = new Image();
image.src = path;
Config.Import.onLoad(image, func);
return image;
},
/** ==============================================================
@method: Config.Import.onLoad()
@param: Object
@param: Function
Helper function for the other Config.Import.* functions,
but can also be used elsewhere.
It's a cross-browser and cross-element callback implementation
for the successful loading of HTML Elements (Script & Link) or
Image objects.
----
Brief Overview of Features:
Gecko Engine and WebKit 420+ (Safari 3):
Uses the