2012-02-06 22:00:24 +00:00
|
|
|
/*
|
2012-02-02 22:47:23 +00:00
|
|
|
* Copyright (c) 2012, Andy Janata
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
|
|
* provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
|
|
* and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
|
|
* conditions and the following disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
|
|
|
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2012-02-06 22:00:24 +00:00
|
|
|
/**
|
|
|
|
* Global data and helper functions.
|
|
|
|
*
|
|
|
|
* @author Andy Janata (ajanata@socialgamer.net)
|
|
|
|
*/
|
|
|
|
|
2011-12-17 00:39:52 +00:00
|
|
|
var cah = {};
|
|
|
|
|
2012-01-23 07:58:36 +00:00
|
|
|
/**
|
|
|
|
* This client's nickname.
|
|
|
|
*
|
|
|
|
* @type {string}
|
|
|
|
*/
|
2011-12-23 02:48:20 +00:00
|
|
|
cah.nickname = "";
|
2012-01-18 04:36:34 +00:00
|
|
|
|
2012-01-23 07:58:36 +00:00
|
|
|
/**
|
2012-01-23 21:20:15 +00:00
|
|
|
* The games this client is playing in. Key is game id.
|
2012-01-23 07:58:36 +00:00
|
|
|
*
|
2012-01-23 21:20:15 +00:00
|
|
|
* @type {Object}
|
2012-01-23 07:58:36 +00:00
|
|
|
*/
|
2012-01-23 21:20:15 +00:00
|
|
|
cah.currentGames = {};
|
2012-01-23 07:58:36 +00:00
|
|
|
|
2012-10-12 05:18:40 +01:00
|
|
|
/**
|
|
|
|
* User's ignore list. Map of nickname -> true. If a nickname is present, it is ignored.
|
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
cah.ignoreList = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to hide connect/disconnect messages.
|
|
|
|
*
|
|
|
|
* @type {Boolean}
|
|
|
|
*/
|
|
|
|
cah.hideConnectQuit = false;
|
|
|
|
|
2013-04-28 18:11:28 +01:00
|
|
|
/**
|
|
|
|
* Whether the game's browser window has focus, so we don't update the game list when we're not
|
|
|
|
* active.
|
|
|
|
*
|
|
|
|
* @type {Boolean}
|
|
|
|
*/
|
|
|
|
cah.windowActive = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether we've missed a game list refresh due to not being the active window.
|
|
|
|
*
|
|
|
|
* @type {Boolean}
|
|
|
|
*/
|
|
|
|
cah.missedGameListRefresh = false;
|
|
|
|
|
2012-01-18 04:36:34 +00:00
|
|
|
/**
|
|
|
|
* Binds a function to a "this object". Result is a new function that will do the right thing across
|
|
|
|
* contexts.
|
|
|
|
*
|
|
|
|
* @param {Object}
|
|
|
|
* selfObj Object for "this" when calling the returned function.
|
|
|
|
* @param {Function}
|
|
|
|
* func Function to call with selfObjc as "this".
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
cah.bind = function(selfObj, func) {
|
|
|
|
return function() {
|
|
|
|
func.apply(selfObj, arguments);
|
|
|
|
};
|
|
|
|
};
|
2012-01-20 05:19:55 +00:00
|
|
|
|
|
|
|
/**
|
2012-01-22 01:34:18 +00:00
|
|
|
* Inherit the proto methods from one constructor to another.
|
2012-01-20 05:19:55 +00:00
|
|
|
*
|
|
|
|
* @param {Function}
|
|
|
|
* childCtor Child class.
|
|
|
|
* @param {Function}
|
|
|
|
* parentCtor Parent class.
|
|
|
|
*/
|
|
|
|
cah.inherits = function(childCtor, parentCtor) {
|
|
|
|
/** @constructor */
|
|
|
|
function tempCtor() {
|
|
|
|
// pass
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
tempCtor.prototype = parentCtor.prototype;
|
|
|
|
childCtor.superClass_ = parentCtor.prototype;
|
|
|
|
childCtor.prototype = new tempCtor();
|
|
|
|
childCtor.prototype.constructor = childCtor;
|
|
|
|
};
|