upload files
This commit is contained in:
parent
4bfaf8d3c6
commit
d672bf4c0b
1594 changed files with 17495 additions and 0 deletions
721
custom_lobby/static/js/coherent.js
Normal file
721
custom_lobby/static/js/coherent.js
Normal file
|
@ -0,0 +1,721 @@
|
|||
/*jslint browser: true, nomen: true, plusplus: true */
|
||||
|
||||
/// @file coherent.js
|
||||
/// @namespace engine
|
||||
|
||||
/// Coherent UI JavaScript interface.
|
||||
/// The `engine` module contains all functions for communication between the UI and the game / application.
|
||||
(function (factory) {
|
||||
if (typeof module === 'object' && module.exports) {
|
||||
module.exports = factory(global, global.engine, false);
|
||||
} else {
|
||||
window.engine = factory(window, window.engine, true);
|
||||
}
|
||||
})(function (global, engine, hasOnLoad) {
|
||||
'use strict';
|
||||
|
||||
var VERSION = [1, 10, 2, 0];
|
||||
|
||||
/**
|
||||
* Event emitter
|
||||
*
|
||||
* @class Emitter
|
||||
*/
|
||||
function Emitter() {
|
||||
this.events = {};
|
||||
}
|
||||
|
||||
function Handler(code, context) {
|
||||
this.code = code;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
Emitter.prototype._createClear = function (object, name, handler) {
|
||||
return function() {
|
||||
var handlers = object.events[name];
|
||||
if (handlers) {
|
||||
var index = -1;
|
||||
// this was in native previously
|
||||
if(handler === undefined)
|
||||
{
|
||||
for(var i = 0; i < handlers.length; ++i)
|
||||
{
|
||||
if(handlers[i].wasInCPP !== undefined)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
index = handlers.indexOf(handler);
|
||||
}
|
||||
if (index != -1) {
|
||||
handlers.splice(index, 1);
|
||||
if (handlers.length === 0) {
|
||||
delete object.events[name];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(engine.RemoveOnHandler !== undefined) {
|
||||
engine.RemoveOnHandler(name);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/// @file coherent.js
|
||||
|
||||
/**
|
||||
* Add a handler for an event
|
||||
*
|
||||
* @method on
|
||||
* @param name the event name
|
||||
* @param callback function to be called when the event is triggered
|
||||
* @param context this binding for executing the handler, defaults to the Emitter
|
||||
* @return connection object
|
||||
*/
|
||||
Emitter.prototype.on = function (name, callback, context) {
|
||||
var handlers = this.events[name];
|
||||
if (handlers === undefined)
|
||||
handlers = this.events[name] = [];
|
||||
|
||||
var handler = new Handler(callback, context || this);
|
||||
handlers.push(handler);
|
||||
return { clear: this._createClear(this, name, handler) };
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a handler from an event
|
||||
*
|
||||
* @method off
|
||||
* @param name the event name
|
||||
* @param callback function to be called when the event is triggered
|
||||
* @param context this binding for executing the handler, defaults to the Emitter
|
||||
* @return connection object
|
||||
*/
|
||||
Emitter.prototype.off = function (name, handler, context) {
|
||||
var handlers = this.events[name];
|
||||
|
||||
if (handlers !== undefined) {
|
||||
context = context || this;
|
||||
|
||||
var index;
|
||||
var length = handlers.length;
|
||||
for (index = 0; index < length; ++index) {
|
||||
var reg = handlers[index];
|
||||
if (reg.code == handler && reg.context == context) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < length) {
|
||||
handlers.splice(index, 1);
|
||||
if (handlers.length === 0) {
|
||||
delete this.events[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
engine.RemoveOnHandler(name);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var isAttached = engine !== undefined;
|
||||
engine = engine || {};
|
||||
/// @var engine.isAttached
|
||||
/// Indicates whether the script is currently running inside Coherent GT
|
||||
engine.isAttached = isAttached;
|
||||
|
||||
/// @var engine.forceEnableMocking
|
||||
/// Indicates whether mocking should be enabled despite running inside Coherent GT
|
||||
engine.forceEnableMocking = global.engineForceEnableMocking || false;
|
||||
|
||||
/// @var engine.IsAttached
|
||||
/// [DEPRECATED] Indicates whether the script is currently running inside Coherent GT
|
||||
/// @warning This property is deprecated, please use engine.isAttached (with camelCase)
|
||||
engine.IsAttached = engine.isAttached;
|
||||
|
||||
engine.onEventsReplayed = null;
|
||||
Emitter.prototype.trigger = function(name) {
|
||||
var handlers = this.events[name];
|
||||
|
||||
if (handlers !== undefined) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
handlers.forEach(function (handler) {
|
||||
handler.code.apply(handler.context, args);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Emitter.prototype.merge = function (emitter) {
|
||||
var lhs = this.events,
|
||||
rhs = emitter.events,
|
||||
push = Array.prototype.push,
|
||||
events;
|
||||
|
||||
for (var e in rhs) {
|
||||
events = lhs[e] = lhs[e] || [];
|
||||
push.apply(events, rhs[e]);
|
||||
}
|
||||
};
|
||||
|
||||
var pending = 'pending';
|
||||
var fulfilled = 'fulfilled';
|
||||
var broken = 'broken';
|
||||
|
||||
function callAsync(code, context, argument) {
|
||||
var async = function () {
|
||||
code.call(context, argument);
|
||||
};
|
||||
setTimeout(async);
|
||||
}
|
||||
|
||||
function Promise () {
|
||||
this.emitter = new Emitter();
|
||||
this.state = pending;
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
Promise.prototype.resolve = function (result) {
|
||||
this.state = fulfilled;
|
||||
this.result = result;
|
||||
|
||||
this.emitter.trigger(fulfilled, result);
|
||||
};
|
||||
|
||||
Promise.prototype.reject = function (result) {
|
||||
this.state = broken;
|
||||
this.result = result;
|
||||
|
||||
this.emitter.trigger(broken, result);
|
||||
};
|
||||
|
||||
Promise.prototype.success = function (code, context) {
|
||||
if (this.state !== fulfilled) {
|
||||
this.emitter.on(fulfilled, code, context);
|
||||
} else {
|
||||
callAsync(code, context || this, this.result);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Promise.prototype.always = function (code, context) {
|
||||
this.success(code, context);
|
||||
this.otherwise(code, context);
|
||||
return this;
|
||||
};
|
||||
|
||||
Promise.prototype.otherwise = function (code, context) {
|
||||
if (this.state !== broken) {
|
||||
this.emitter.on(broken, code, context);
|
||||
} else {
|
||||
callAsync(code, context || this, this.result);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Promise.prototype.merge = function (other) {
|
||||
if (this.state === pending) {
|
||||
this.emitter.merge(other.emitter);
|
||||
} else {
|
||||
var handlers = other.emitter.events[this.state];
|
||||
var self = this;
|
||||
if (handlers !== undefined) {
|
||||
handlers.forEach(function (handler) {
|
||||
handler.code.call(handler.context, self.result);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype.make_chain = function (handler, promise, ok) {
|
||||
return function (result) {
|
||||
var handlerResult;
|
||||
try {
|
||||
handlerResult = handler.code.call(handler.context, result);
|
||||
if (handlerResult instanceof Promise) {
|
||||
handlerResult.merge(promise);
|
||||
} else if (this.state === ok) {
|
||||
promise.resolve(handlerResult);
|
||||
} else {
|
||||
promise.reject(handlerResult);
|
||||
}
|
||||
} catch (error) {
|
||||
promise.reject(error);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function makeDefaultHandler(promise) {
|
||||
return function () {
|
||||
return promise;
|
||||
};
|
||||
}
|
||||
|
||||
Promise.prototype.then = function (callback, errback) {
|
||||
var promise = new Promise();
|
||||
|
||||
var handler = new Handler(callback || makeDefaultHandler(this), this);
|
||||
|
||||
this.success(this.make_chain(handler, promise, fulfilled), this);
|
||||
|
||||
var errorHandler = new Handler(errback || makeDefaultHandler(this), this);
|
||||
this.otherwise(this.make_chain(errorHandler, promise, broken), this);
|
||||
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
if (!engine.isAttached || engine.forceEnableMocking) {
|
||||
Emitter.prototype.on = function (name, callback, context) {
|
||||
var handlers = this.events[name];
|
||||
if (this.browserCallbackOn) {
|
||||
this.browserCallbackOn(name, callback, context);
|
||||
}
|
||||
|
||||
if (handlers === undefined) {
|
||||
handlers = this.events[name] = [];
|
||||
}
|
||||
|
||||
var handler = new Handler(callback, context || this);
|
||||
handlers.push(handler);
|
||||
return { clear: this._createClear(this, name, handler) };
|
||||
};
|
||||
Emitter.prototype.off = function (name, handler, context) {
|
||||
var handlers = this.events[name];
|
||||
|
||||
if (handlers !== undefined) {
|
||||
context = context || this;
|
||||
|
||||
var index;
|
||||
var length = handlers.length;
|
||||
for (index = 0; index < length; ++index) {
|
||||
var reg = handlers[index];
|
||||
if (reg.code == handler && reg.context == context) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < length) {
|
||||
handlers.splice(index, 1);
|
||||
if (handlers.length === 0) {
|
||||
delete this.events[name];
|
||||
|
||||
if (this.browserCallbackOff) {
|
||||
this.browserCallbackOff(name, handler, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
engine.SendMessage = function (name, id) {
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
var deferred = engine._ActiveRequests[id];
|
||||
|
||||
delete engine._ActiveRequests[id];
|
||||
var call = function () {
|
||||
var mock = engine._mocks[name];
|
||||
|
||||
if (mock !== undefined) {
|
||||
deferred.resolve(mock.apply(engine, args));
|
||||
}
|
||||
};
|
||||
|
||||
window.setTimeout(call, 16);
|
||||
};
|
||||
|
||||
engine.TriggerEvent = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
var trigger = function () {
|
||||
var mock = engine._mocks[args[0]];
|
||||
|
||||
if (mock !== undefined) {
|
||||
mock.apply(engine, args.slice(1));
|
||||
}
|
||||
};
|
||||
window.setTimeout(trigger, 16);
|
||||
};
|
||||
|
||||
engine.BindingsReady = function () {
|
||||
engine._OnReady();
|
||||
};
|
||||
|
||||
engine.__observeLifetime = function () {
|
||||
};
|
||||
|
||||
engine.beginEventRecording =
|
||||
engine.endEventRecording =
|
||||
engine.saveEventRecord = function() {
|
||||
console.warning("Event recording will not work in the browser!");
|
||||
};
|
||||
|
||||
engine._mocks = {};
|
||||
engine._mockImpl = function (name, mock, isCppCall, isEvent) {
|
||||
if (mock && isCppCall) {
|
||||
this._mocks[name] = mock;
|
||||
}
|
||||
// Extract the name of the arguments from Function.prototype.toString
|
||||
var functionStripped = mock.toString().replace("function " + mock.name + "(", "");
|
||||
var rightParanthesis = functionStripped.indexOf(")");
|
||||
var args = functionStripped.substr(0, rightParanthesis);
|
||||
if (this.browserCallbackMock) {
|
||||
this.browserCallbackMock(name,
|
||||
args,
|
||||
isCppCall,
|
||||
Boolean(isEvent));
|
||||
}
|
||||
}
|
||||
engine.mock = function (name, mock, isEvent) {
|
||||
this._mockImpl(name, mock, true, isEvent);
|
||||
};
|
||||
// Mock the call to translate to always return the key
|
||||
engine.translate = function (text) {
|
||||
return text;
|
||||
};
|
||||
}
|
||||
|
||||
engine.events = {};
|
||||
for (var property in Emitter.prototype) {
|
||||
engine[property] = Emitter.prototype[property];
|
||||
}
|
||||
|
||||
if (engine.isAttached && !engine.forceEnableMocking) {
|
||||
engine.on = function (name, callback, context) {
|
||||
var handlers = this.events[name];
|
||||
|
||||
if (handlers === undefined && engine.AddOrRemoveOnHandler !== undefined) {
|
||||
// Check where to cache the handler
|
||||
var prevEvent = engine.AddOrRemoveOnHandler(name, callback, context);
|
||||
|
||||
// handler cached in C++
|
||||
if(prevEvent === undefined) {
|
||||
return { clear: this._createClear(this, name, undefined) };
|
||||
}
|
||||
|
||||
handlers = this.events[name] = [];
|
||||
|
||||
// Add the previous handler
|
||||
var prevHandler = new Handler(prevEvent[0], prevEvent[1] || this);
|
||||
prevHandler.wasInCPP = true;
|
||||
handlers.push(prevHandler);
|
||||
} else if (handlers === undefined) {
|
||||
handlers = this.events[name] = [];
|
||||
}
|
||||
|
||||
var handler = new Handler(callback, context || this);
|
||||
handlers.push(handler);
|
||||
return { clear: this._createClear(this, name, handler) };
|
||||
}
|
||||
}
|
||||
|
||||
/// @function engine.on
|
||||
/// Register handler for and event
|
||||
/// @param {String} name name of the event
|
||||
/// @param {Function} callback callback function to be executed when the event has been triggered
|
||||
/// @param context *this* context for the function, by default the engine object
|
||||
|
||||
/// @function engine.beginEventRecording
|
||||
/// Begins recording all events triggered using View::TriggerEvent from the game
|
||||
|
||||
/// @function engine.endEventRecording
|
||||
/// Ends event recording
|
||||
|
||||
/// @function engine.saveEventRecord
|
||||
/// Saves the events recorded in between the last calls to engine.beginEventRecording and engine.endEventRecording to a file
|
||||
/// @param {String} path The path to the file where to save the recorded events. Optional. Defaults to "eventRecord.json"
|
||||
|
||||
/// @function engine.replayEvents
|
||||
/// Replays the events previously recorded and stored in path. If you need to be notified when all events
|
||||
/// are replayed, assign a callback to engine.onEventsReplayed
|
||||
/// @param {Number} timeScale The speed at which to replay the events (e.g. pass 2 to double the speed). Optional. Defaults to 1.
|
||||
/// @param {String} path The path to the file the recorded events are stored. Optional. Defaults to "eventRecord.json"
|
||||
|
||||
/// @function engine.translate
|
||||
/// Translates the given text by invoking the system's localization manager if one exists.
|
||||
/// @param {text} text The text to translate.
|
||||
/// @return {String} undefined if no localization manager is set or no translation exists, else returns the translated string
|
||||
|
||||
/// @function engine.reloadLocalization
|
||||
/// Updates the text on all elements with the data-l10n-id attribute by calling engine.translate
|
||||
|
||||
/// @function engine.off
|
||||
/// Remove handler for an event
|
||||
/// @param {String} name name of the event, by default removes all events
|
||||
/// @param {Function} callback the callback function to be removed, by default removes all callbacks for a given event
|
||||
/// @param context *this* context for the function, by default all removes all callbacks, regardless of context
|
||||
/// @warning Removing all handlers for `engine` will remove some *Coherent UI* internal events, breaking some functionality.
|
||||
|
||||
/// @function engine.trigger
|
||||
/// Trigger an event
|
||||
/// This function will trigger any C++ handler registered for this event with `Coherent::UI::View::RegisterForEvent`
|
||||
/// @param {String} name name of the event
|
||||
/// @param ... any extra arguments to be passed to the event handlers
|
||||
|
||||
engine._trigger = Emitter.prototype.trigger;
|
||||
var concatArguments = Array.prototype.concat;
|
||||
engine.trigger = function (name) {
|
||||
this._trigger.apply(this, arguments);
|
||||
this.TriggerEvent.apply(this, arguments);
|
||||
|
||||
if (this.events['all'] !== undefined) {
|
||||
var allArguments = concatArguments.apply(['all'], arguments);
|
||||
this._trigger.apply(this, allArguments);
|
||||
}
|
||||
};
|
||||
/// @function engine.showOverlay
|
||||
/// Shows the debugging overlay in the browser.
|
||||
/// Will also work in Coherent GT only if *engineForceEnableMocking* is set to *true*.
|
||||
engine.showOverlay = function () {};
|
||||
|
||||
|
||||
/// @function engine.hideOverlay
|
||||
/// Hides the debugging overlay in the browser.
|
||||
/// Will also work in Coherent GT only if *engineForceEnableMocking* is set to *true*.
|
||||
engine.hideOverlay = function () {};
|
||||
|
||||
/// @function engine.mock
|
||||
/// Mocks a C++ function call with the specified function.
|
||||
/// Will also work in Coherent GT only if *engineForceEnableMocking* is set to *true*.
|
||||
/// @param {String} name name of the event
|
||||
/// @param {Function} mock a function to be called in-place of your native binding
|
||||
/// @param {Boolean} isEvent whether you are mocking an event or function call
|
||||
if (engine.isAttached && !engine.forceEnableMocking) {
|
||||
engine.mock = function (name, mock, isEvent) { };
|
||||
}
|
||||
|
||||
engine._BindingsReady = false;
|
||||
engine._WindowLoaded = false;
|
||||
engine._RequestId = 0;
|
||||
engine._ActiveRequests = {};
|
||||
|
||||
/// @function engine.createDeferred
|
||||
/// Create a new deferred object.
|
||||
/// Use this to create deferred / promises that can be used together with `engine.call`.
|
||||
/// @return {Deferred} a new deferred object
|
||||
/// @see @ref CustomizingPromises
|
||||
engine.createDeferred = (global.engineCreateDeferred === undefined) ?
|
||||
function () { return new Promise(); }
|
||||
: global.engineCreateDeferred;
|
||||
|
||||
/// @function engine.call
|
||||
/// Call asynchronously a C++ handler and retrieve the result
|
||||
/// The C++ handler must have been registered with `Coherent::UI::View::BindCall`
|
||||
/// @param {String} name name of the C++ handler to be called
|
||||
/// @param ... any extra parameters to be passed to the C++ handler
|
||||
/// @return {Deferred} deferred object whose promise is resolved with the result of the C++ handler
|
||||
engine.call = function () {
|
||||
engine._RequestId++;
|
||||
var id = engine._RequestId;
|
||||
|
||||
var deferred = engine.createDeferred();
|
||||
engine._ActiveRequests[id] = deferred;
|
||||
var messageArguments = Array.prototype.slice.call(arguments);
|
||||
messageArguments.splice(1, 0, id);
|
||||
engine.SendMessage.apply(this, messageArguments);
|
||||
return deferred;
|
||||
};
|
||||
|
||||
engine._Result = function (requestId) {
|
||||
var deferred = engine._ActiveRequests[requestId];
|
||||
if (deferred !== undefined)
|
||||
{
|
||||
delete engine._ActiveRequests[requestId];
|
||||
|
||||
var resultArguments = Array.prototype.slice.call(arguments);
|
||||
resultArguments.shift();
|
||||
deferred.resolve.apply(deferred, resultArguments);
|
||||
}
|
||||
};
|
||||
|
||||
engine._Errors = [ 'Success', 'ArgumentType', 'NoSuchMethod', 'NoResult' ];
|
||||
|
||||
engine._ForEachError = function (errors, callback) {
|
||||
var length = errors.length;
|
||||
|
||||
for (var i = 0; i < length; ++i) {
|
||||
callback(errors[i].first, errors[i].second);
|
||||
}
|
||||
};
|
||||
|
||||
engine._MapErrors = function (errors) {
|
||||
var length = errors.length;
|
||||
|
||||
for (var i = 0; i < length; ++i) {
|
||||
errors[i].first = engine._Errors[errors[i].first];
|
||||
}
|
||||
};
|
||||
|
||||
engine._TriggerError = function (type, message) {
|
||||
engine.trigger('Error', type, message);
|
||||
};
|
||||
|
||||
engine._OnError = function (requestId, errors) {
|
||||
engine._MapErrors(errors);
|
||||
|
||||
if (requestId === null || requestId === 0) {
|
||||
engine._ForEachError(errors, engine._TriggerError);
|
||||
}
|
||||
else {
|
||||
var deferred = engine._ActiveRequests[requestId];
|
||||
|
||||
delete engine._ActiveRequests[requestId];
|
||||
|
||||
deferred.reject(errors);
|
||||
}
|
||||
};
|
||||
|
||||
engine._eventHandles = {};
|
||||
|
||||
engine._Register = function (eventName) {
|
||||
var trigger = (function (name, engine) {
|
||||
return function () {
|
||||
var eventArguments = [name];
|
||||
eventArguments.push.apply(eventArguments, arguments);
|
||||
engine.TriggerEvent.apply(this, eventArguments);
|
||||
};
|
||||
}(eventName, engine));
|
||||
|
||||
engine._eventHandles[eventName] = engine.on(eventName, trigger);
|
||||
};
|
||||
|
||||
engine._removeEventThunk = function (name) {
|
||||
var handle = engine._eventHandles[name];
|
||||
handle.clear();
|
||||
delete engine._eventHandles[name];
|
||||
};
|
||||
|
||||
engine._Unregister = function (name) {
|
||||
if (typeof name === 'string') {
|
||||
engine._removeEventThunk(name);
|
||||
} else {
|
||||
name.forEach(engine._removeEventThunk, engine);
|
||||
}
|
||||
};
|
||||
|
||||
function createMethodStub(name) {
|
||||
var stub = function() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.splice(0, 0, name, this._id);
|
||||
return engine.call.apply(engine, args);
|
||||
};
|
||||
return stub;
|
||||
}
|
||||
|
||||
engine._boundTypes = {};
|
||||
|
||||
engine._createInstance = function (args) {
|
||||
var type = args[0],
|
||||
id = args[1],
|
||||
methods = args[2],
|
||||
constructor = engine._boundTypes[type];
|
||||
|
||||
if (constructor === undefined) {
|
||||
constructor = function (id) {
|
||||
this._id = id;
|
||||
};
|
||||
constructor.prototype.__Type = type;
|
||||
methods.forEach(function (name) {
|
||||
constructor.prototype[name] = createMethodStub(type + '_' + name);
|
||||
});
|
||||
engine._boundTypes[type] = constructor;
|
||||
}
|
||||
|
||||
var instance = new constructor(id);
|
||||
engine.__observeLifetime(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
engine._OnReady = function () {
|
||||
engine._BindingsReady = true;
|
||||
if (engine._WindowLoaded) {
|
||||
engine.trigger('Ready');
|
||||
}
|
||||
};
|
||||
|
||||
engine._OnWindowLoaded = function () {
|
||||
engine._WindowLoaded = true;
|
||||
if (engine._BindingsReady) {
|
||||
engine.trigger('Ready');
|
||||
}
|
||||
};
|
||||
|
||||
engine._ThrowError = function (error) {
|
||||
var prependTab = function (s) { return "\t" + s; };
|
||||
var errorString = error.name + ": " + error.message + "\n" +
|
||||
error.stack.split("\n").map(prependTab).join("\n");
|
||||
console.error(errorString);
|
||||
};
|
||||
|
||||
if (hasOnLoad) {
|
||||
global.addEventListener("load", function () {
|
||||
engine._OnWindowLoaded();
|
||||
});
|
||||
} else {
|
||||
engine._WindowLoaded = true;
|
||||
}
|
||||
|
||||
engine._coherentGlobalCanvas = document.createElement('canvas');
|
||||
engine._coherentGlobalCanvas.id = "coherentGlobalCanvas";
|
||||
engine._coherentGlobalCanvas.width = 1;
|
||||
engine._coherentGlobalCanvas.height = 1;
|
||||
engine._coherentGlobalCanvas.style.zIndex = 0;
|
||||
engine._coherentGlobalCanvas.style.position = "absolute";
|
||||
engine._coherentGlobalCanvas.style.border = "0px solid";
|
||||
|
||||
engine._coherentLiveImageData = new Array();
|
||||
engine._coherentCreateImageData = function(name, guid) {
|
||||
var ctx = engine._coherentGlobalCanvas.getContext("2d");
|
||||
|
||||
var coherentImage = ctx.coherentCreateImageData(guid);
|
||||
engine._coherentLiveImageData[name] = coherentImage;
|
||||
}
|
||||
engine._coherentUpdatedImageData = function(name) {
|
||||
engine._coherentLiveImageData[name].coherentUpdate();
|
||||
var canvases = document.getElementsByTagName('canvas');
|
||||
for(var i = 0; i < canvases.length; ++i) {
|
||||
if(canvases[i].onEngineImageDataUpdated != null) {
|
||||
canvases[i].onEngineImageDataUpdated(name,
|
||||
engine._coherentLiveImageData[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
engine.reloadLocalization = function () {
|
||||
var localizedElements = document.querySelectorAll('[data-l10n-id]');
|
||||
for (var i = 0; i < localizedElements.length; i++) {
|
||||
var element = localizedElements.item(i);
|
||||
var translated = engine.translate(element.dataset.l10nId);
|
||||
if (!translated) {
|
||||
var warning = "Failed to find translation for key: " + element.dataset.l10nId;
|
||||
console.warn(warning);
|
||||
} else {
|
||||
element.textContent = translated;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
engine.on("_coherentCreateImageData", engine._coherentCreateImageData);
|
||||
engine.on("_coherentUpdatedImageData", engine._coherentUpdatedImageData);
|
||||
|
||||
engine.on('_Result', engine._Result, engine);
|
||||
engine.on('_Register', engine._Register, engine);
|
||||
engine.on('_Unregister', engine._Unregister, engine);
|
||||
engine.on('_OnReady', engine._OnReady, engine);
|
||||
engine.on('_OnError', engine._OnError, engine);
|
||||
|
||||
engine.on('__OnReplayRecordCompleted', function(jsonRecords) {
|
||||
if (engine.onEventsReplayed) {
|
||||
engine.onEventsReplayed();
|
||||
}
|
||||
});
|
||||
|
||||
engine.BindingsReady(VERSION[0], VERSION[1], VERSION[2], VERSION[3]);
|
||||
|
||||
return engine;
|
||||
});
|
||||
|
166
custom_lobby/static/js/coherent.mock.js
Normal file
166
custom_lobby/static/js/coherent.mock.js
Normal file
|
@ -0,0 +1,166 @@
|
|||
(function (engine) {
|
||||
if (engine.isAttached && !engine.forceEnableMocking) {
|
||||
return;
|
||||
}
|
||||
var OVERLAY_ID = "coherent-browser-debug-overlay",
|
||||
JS_CALLS_LIST_ID = "coherent-browser-debug-js-list",
|
||||
CPP_CALLS_LIST_ID = 'coherent-browser-debug-cpp-list';
|
||||
|
||||
var logoDataUrl = "data:image/png;base64,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";
|
||||
var docsLink = "http://coherent-labs.com/Documentation/cpp/db/dbc/_java_script.html";
|
||||
|
||||
var createBrowserOverlay = function () {
|
||||
var overlay = document.createElement("nav");
|
||||
overlay.id = OVERLAY_ID;
|
||||
overlay.classList.add("open");
|
||||
var html = "<div class='contents'>" +
|
||||
"<img src='" + logoDataUrl + "'></img>" +
|
||||
"<h1>Mocker</h1>" +
|
||||
"<hr>" +
|
||||
"<p>" +
|
||||
"Click the buttons below or hit "+
|
||||
"<strong>ENTER</strong> to " +
|
||||
"mock interaction with the engine. Type " +
|
||||
"<code>engine.hideOverlay()</code> " +
|
||||
"in the console to hide this overlay. See " +
|
||||
"the " +
|
||||
"<a target='_blank' href='" + docsLink + "'>" +
|
||||
"docs</a> for details." +
|
||||
"</p>" +
|
||||
"<h2 class='left'>" +
|
||||
"Call / trigger this <em>UI</em> " +
|
||||
"function / event:" +
|
||||
"</h2>" +
|
||||
"<h2 class='right'>with arguments:</h2>" +
|
||||
"<ul id='" + JS_CALLS_LIST_ID + "'></ul>" +
|
||||
"<hr>" +
|
||||
"<h2 class='left'>"+
|
||||
"Call / trigger this <em>Engine</em> " +
|
||||
"function / event:" +
|
||||
"</h2>" +
|
||||
"<h2 class='right'>with arguments:</h2>" +
|
||||
"<ul id='" + CPP_CALLS_LIST_ID + "'></ul>" +
|
||||
"</div>" +
|
||||
"<div class='docked-contents'>" +
|
||||
"<button id='coherent-dock-overlay-button'>" +
|
||||
"Dock me!" +
|
||||
"</button>" +
|
||||
"</div>";
|
||||
|
||||
overlay.innerHTML = html;
|
||||
var OverlayState = {
|
||||
Open: 0,
|
||||
Docked: 1,
|
||||
Hidden: 2
|
||||
};
|
||||
overlay.state = OverlayState.Open;
|
||||
overlay.querySelector("#coherent-dock-overlay-button")
|
||||
.addEventListener("click", function () {
|
||||
if (overlay.state == OverlayState.Open) {
|
||||
overlay.state = OverlayState.Docked;
|
||||
overlay.classList.remove("open");
|
||||
overlay.classList.add("docked");
|
||||
}
|
||||
else if (overlay.state == OverlayState.Docked) {
|
||||
overlay.state = OverlayState.Open;
|
||||
overlay.classList.remove("docked");
|
||||
overlay.classList.add("open");
|
||||
}
|
||||
});
|
||||
return overlay;
|
||||
};
|
||||
var executeMock = function (name, isCppCall, isEvent, argsInput) {
|
||||
var functionArgs = "'" + name + "'";
|
||||
if (argsInput.value.length !== 0) {
|
||||
functionArgs += ", " + argsInput.value;
|
||||
}
|
||||
var command = (isCppCall && !isEvent) ? "call" : "trigger";
|
||||
try {
|
||||
eval("engine." + command + "(" + functionArgs + ")");
|
||||
}
|
||||
catch (e) {
|
||||
var text = "An error occured while executing mock function: ";
|
||||
console.warn(text, e);
|
||||
};
|
||||
};
|
||||
|
||||
var LI_ID_PREFIX = "COHERENT_MOCKING_";
|
||||
var addMockButton = function (name, args, isCppCall, isEvent) {
|
||||
var id = LI_ID_PREFIX + name;
|
||||
if (document.getElementById(id) !== null) {
|
||||
// Button has already been created
|
||||
return;
|
||||
}
|
||||
var li = document.createElement("li");
|
||||
li.id = id;
|
||||
var button = document.createElement("button");
|
||||
button.textContent = name;
|
||||
button.classList.add("left");
|
||||
li.appendChild(button);
|
||||
var argsInput = document.createElement("input");
|
||||
argsInput.placeholder = args;
|
||||
argsInput.classList.add("right");
|
||||
argsInput.addEventListener("keyup", function (eventArgs) {
|
||||
if (eventArgs.keyCode === 13) { // Enter
|
||||
button.onclick();
|
||||
}
|
||||
}, false);
|
||||
li.appendChild(argsInput);
|
||||
|
||||
button.onclick = executeMock.bind(undefined,
|
||||
name,
|
||||
isCppCall,
|
||||
isEvent,
|
||||
argsInput);
|
||||
|
||||
var parentId = isCppCall ? CPP_CALLS_LIST_ID : JS_CALLS_LIST_ID;
|
||||
var parentSelector = "#" + OVERLAY_ID + " #" + parentId;
|
||||
var menu = document.querySelector(parentSelector);
|
||||
menu.appendChild(li);
|
||||
};
|
||||
|
||||
|
||||
var removeMockButton = function (name, isFunctionCall) {
|
||||
var li = document.getElementById(LI_ID_PREFIX + name);
|
||||
if (li && li.parentNode) {
|
||||
li.parentNode.removeChild(li);
|
||||
}
|
||||
};
|
||||
|
||||
var systemEvents = [
|
||||
"_coherentCreateImageData",
|
||||
"_coherentUpdatedImageData",
|
||||
'_Result',
|
||||
'_Register',
|
||||
'_Unregister',
|
||||
'_OnReady',
|
||||
'_OnError',
|
||||
'replayEventsRecord'
|
||||
]
|
||||
|
||||
|
||||
engine.browserCallbackOn = function (name, callback) {
|
||||
if (systemEvents.indexOf(name) === -1)
|
||||
this._mockImpl(name, callback, false, true);
|
||||
};
|
||||
|
||||
engine.browserCallbackOff = function (name) {
|
||||
if (systemEvents.indexOf(name) === -1)
|
||||
removeMockButton(name);
|
||||
};
|
||||
|
||||
engine.browserCallbackMock = addMockButton;
|
||||
|
||||
var overlay = createBrowserOverlay();
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
|
||||
engine.hideOverlay = function () {
|
||||
overlay.classList.add("hidden");
|
||||
overlay.classList.remove("shown");
|
||||
};
|
||||
engine.showOverlay = function () {
|
||||
overlay.classList.add("shown");
|
||||
overlay.classList.remove("hidden");
|
||||
};
|
||||
})(engine || {});
|
4
custom_lobby/static/js/jquery-2.2.0.min.js
vendored
Normal file
4
custom_lobby/static/js/jquery-2.2.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
13
custom_lobby/static/js/jquery-ui-1.11.4.min.js
vendored
Normal file
13
custom_lobby/static/js/jquery-ui-1.11.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
172
custom_lobby/static/js/jquery.selectBoxIt-3.8.1.min.js
vendored
Normal file
172
custom_lobby/static/js/jquery.selectBoxIt-3.8.1.min.js
vendored
Normal file
|
@ -0,0 +1,172 @@
|
|||
(function (c) { c(window.jQuery, window, document) })(function (c, q, x, y) {
|
||||
c.widget("selectBox.selectBoxIt", {
|
||||
VERSION: "3.8.1", options: {
|
||||
showEffect: "none", showEffectOptions: {}, showEffectSpeed: "medium", hideEffect: "none", hideEffectOptions: {}, hideEffectSpeed: "medium", showFirstOption: !0, defaultText: "", defaultIcon: "", downArrowIcon: "", theme: "default", keydownOpen: !0, isMobile: function () { return /iPhone|iPod|iPad|Silk|Android|BlackBerry|Opera Mini|IEMobile/.test(navigator.userAgent || navigator.vendor || q.opera) }, "native": !1,
|
||||
aggressiveChange: !1, selectWhenHidden: !0, viewport: c(q), similarSearch: !1, copyAttributes: ["title", "rel"], copyClasses: "button", nativeMousedown: !1, customShowHideEvent: !1, autoWidth: !0, html: !0, populate: "", dynamicPositioning: !0, hideCurrent: !1
|
||||
}, getThemes: function () {
|
||||
var a = c(this.element).attr("data-theme") || "c"; return {
|
||||
bootstrap: { focus: "active", hover: "", enabled: "enabled", disabled: "disabled", arrow: "caret", button: "btn", list: "dropdown-menu", container: "bootstrap", open: "open" }, jqueryui: {
|
||||
focus: "ui-state-focus", hover: "ui-state-hover",
|
||||
enabled: "ui-state-enabled", disabled: "ui-state-disabled", arrow: "ui-icon ui-icon-triangle-1-s", button: "ui-widget ui-state-default", list: "ui-widget ui-widget-content", container: "jqueryui", open: "selectboxit-open"
|
||||
}, jquerymobile: {
|
||||
focus: "ui-btn-down-" + a, hover: "ui-btn-hover-" + a, enabled: "ui-enabled", disabled: "ui-disabled", arrow: "ui-icon ui-icon-arrow-d ui-icon-shadow", button: "ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-" + a, list: "ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-" +
|
||||
a, container: "jquerymobile", open: "selectboxit-open"
|
||||
}, "default": { focus: "selectboxit-focus", hover: "selectboxit-hover", enabled: "selectboxit-enabled", disabled: "selectboxit-disabled", arrow: "selectboxit-default-arrow", button: "selectboxit-btn", list: "selectboxit-list", container: "selectboxit-container", open: "selectboxit-open" }
|
||||
}
|
||||
}, isDeferred: function (a) { return c.isPlainObject(a) && a.promise && a.done }, _create: function (a) {
|
||||
var b = this.options.populate, d = this.options.theme; if (this.element.is("select")) return this.widgetProto =
|
||||
c.Widget.prototype, this.originalElem = this.element[0], this.selectBox = this.element, this.options.populate && this.add && !a && this.add(b), this.selectItems = this.element.find("option"), this.firstSelectItem = this.selectItems.slice(0, 1), this.documentHeight = c(x).height(), this.theme = c.isPlainObject(d) ? c.extend({}, this.getThemes()["default"], d) : this.getThemes()[d] ? this.getThemes()[d] : this.getThemes()["default"], this.currentFocus = 0, this.blur = !0, this.textArray = [], this.currentIndex = 0, this.currentText = "", this.flipped =
|
||||
!1, a || (this.selectBoxStyles = this.selectBox.attr("style")), this._createDropdownButton()._createUnorderedList()._copyAttributes()._replaceSelectBox()._addClasses(this.theme)._eventHandlers(), this.originalElem.disabled && this.disable && this.disable(), this._ariaAccessibility && this._ariaAccessibility(), this.isMobile = this.options.isMobile(), this._mobile && this._mobile(), this.options["native"] && this._applyNativeSelect(), this.triggerEvent("create"), this
|
||||
}, _createDropdownButton: function () {
|
||||
var a = this.originalElemId =
|
||||
this.originalElem.id || "", b = this.originalElemValue = this.originalElem.value || "", d = this.originalElemName = this.originalElem.name || "", f = this.options.copyClasses, h = this.selectBox.attr("class") || ""; this.dropdownText = c("<span/>", { id: a && a + "SelectBoxItText", "class": "selectboxit-text", unselectable: "on", text: this.firstSelectItem.text() }).attr("data-val", b); this.dropdownImageContainer = c("<span/>", { "class": "selectboxit-option-icon-container" }); this.dropdownImage = c("<i/>", {
|
||||
id: a && a + "SelectBoxItDefaultIcon", "class": "selectboxit-default-icon",
|
||||
unselectable: "on"
|
||||
}); this.dropdown = c("<span/>", { id: a && a + "SelectBoxIt", "class": "selectboxit " + ("button" === f ? h : "") + " " + (this.selectBox.prop("disabled") ? this.theme.disabled : this.theme.enabled), name: d, tabindex: this.selectBox.attr("tabindex") || "0", unselectable: "on" }).append(this.dropdownImageContainer.append(this.dropdownImage)).append(this.dropdownText); this.dropdownContainer = c("<span/>", { id: a && a + "SelectBoxItContainer", "class": "selectboxit-container " + this.theme.container + " " + ("container" === f ? h : "") }).append(this.dropdown);
|
||||
return this
|
||||
}, _createUnorderedList: function () {
|
||||
var a = this, b, d, f, h, g, e, l, k = "", p = a.originalElemId || "", p = c("<ul/>", { id: p && p + "SelectBoxItOptions", "class": "selectboxit-options", tabindex: -1 }), v, w, u, r, m, t; a.options.showFirstOption || (a.selectItems.first().attr("disabled", "disabled"), a.selectItems = a.selectBox.find("option").slice(1)); a.selectItems.each(function (p) {
|
||||
m = c(this); f = d = ""; b = m.prop("disabled"); h = m.attr("data-icon") || ""; e = (g = m.attr("data-iconurl") || "") ? "selectboxit-option-icon-url" : ""; l = g ? "style=\"background-image:url('" +
|
||||
g + "');\"" : ""; v = m.attr("data-selectedtext"); r = (w = m.attr("data-text")) ? w : m.text(); t = m.parent(); t.is("optgroup") && (d = "selectboxit-optgroup-option", 0 === m.index() && (f = '<span class="selectboxit-optgroup-header ' + t.first().attr("class") + '"data-disabled="true">' + t.first().attr("label") + "</span>")); m.attr("value", this.value); k += f + '<li data-id="' + p + '" data-val="' + this.value + '" data-disabled="' + b + '" class="' + d + " selectboxit-option " + (c(this).attr("class") || "") + '"><a class="selectboxit-option-anchor"><span class="selectboxit-option-icon-container"><i class="selectboxit-option-icon ' +
|
||||
h + " " + (e || a.theme.container) + '"' + l + "></i></span>" + (a.options.html ? r : a.htmlEscape(r)) + "</a></li>"; u = m.attr("data-search"); a.textArray[p] = b ? "" : u ? u : r; this.selected && (a._setText(a.dropdownText, v || r), a.currentFocus = p)
|
||||
}); if (a.options.defaultText || a.selectBox.attr("data-text")) { var q = a.options.defaultText || a.selectBox.attr("data-text"); a._setText(a.dropdownText, q); a.options.defaultText = q } p.append(k); a.list = p; a.dropdownContainer.append(a.list); a.listItems = a.list.children("li"); a.listAnchors = a.list.find("a");
|
||||
a.listItems.first().addClass("selectboxit-option-first"); a.listItems.last().addClass("selectboxit-option-last"); a.list.find("li[data-disabled='true']").not(".optgroupHeader").addClass(a.theme.disabled); a.dropdownImage.addClass(a.selectBox.attr("data-icon") || a.options.defaultIcon || a.listItems.eq(a.currentFocus).find("i").attr("class")); a.dropdownImage.attr("style", a.listItems.eq(a.currentFocus).find("i").attr("style")); return a
|
||||
}, _replaceSelectBox: function () {
|
||||
var a = this.originalElem.id || "", b = this.selectBox.attr("data-size"),
|
||||
b = this.listSize = b === y ? "auto" : "0" === b ? "auto" : +b, d; this.selectBox.css("display", "none").after(this.dropdownContainer); this.dropdownContainer.appendTo("body").addClass("selectboxit-rendering"); this.dropdown.height(); this.downArrow = c("<i/>", { id: a && a + "SelectBoxItArrow", "class": "selectboxit-arrow", unselectable: "on" }); this.downArrowContainer = c("<span/>", { id: a && a + "SelectBoxItArrowContainer", "class": "selectboxit-arrow-container", unselectable: "on" }).append(this.downArrow); this.dropdown.append(this.downArrowContainer);
|
||||
this.listItems.removeClass("selectboxit-selected").eq(this.currentFocus).addClass("selectboxit-selected"); a = this.downArrowContainer.outerWidth(!0); d = this.dropdownImage.outerWidth(!0); this.options.autoWidth && (this.dropdown.css({ width: "auto" }).css({ width: this.list.outerWidth(!0) + a + d }), this.list.css({ "min-width": this.dropdown.width() })); this.dropdownText.css({ "max-width": this.dropdownContainer.outerWidth(!0) - (a + d) }); this.selectBox.after(this.dropdownContainer); this.dropdownContainer.removeClass("selectboxit-rendering");
|
||||
"number" === c.type(b) && (this.maxHeight = this.listAnchors.outerHeight(!0) * b); return this
|
||||
}, _scrollToView: function (a) { var b = this.listItems.eq(this.currentFocus), d = this.list.scrollTop(), f = b.height(), b = b.position().top, c = Math.abs(b), g = this.list.height(); "search" === a ? g - b < f ? this.list.scrollTop(d + (b - (g - f))) : -1 > b && this.list.scrollTop(b - f) : "up" === a ? -1 > b && this.list.scrollTop(d - c) : "down" === a && g - b < f && this.list.scrollTop(d + (c - g + f)); return this }, _callbackSupport: function (a) {
|
||||
c.isFunction(a) && a.call(this, this.dropdown);
|
||||
return this
|
||||
}, _setText: function (a, b) { this.options.html ? a.html(b) : a.text(b); return this }, open: function (a) {
|
||||
var b = this, d = b.options.showEffect, c = b.options.showEffectSpeed, h = b.options.showEffectOptions, g = b.options["native"], e = b.isMobile; if (!b.listItems.length || b.dropdown.hasClass(b.theme.disabled)) return b; if (!g && !e && !this.list.is(":visible")) {
|
||||
b.triggerEvent("open"); b._dynamicPositioning && b.options.dynamicPositioning && b._dynamicPositioning(); if ("none" === d) b.list.show(); else if ("show" === d || "slideDown" ===
|
||||
d || "fadeIn" === d) b.list[d](c); else b.list.show(d, h, c); b.list.promise().done(function () { b._scrollToView("search"); b.triggerEvent("opened") })
|
||||
} b._callbackSupport(a); return b
|
||||
}, close: function (a) {
|
||||
var b = this, d = b.options.hideEffect, c = b.options.hideEffectSpeed, h = b.options.hideEffectOptions, g = b.isMobile; if (!b.options["native"] && !g && b.list.is(":visible")) { b.triggerEvent("close"); if ("none" === d) b.list.hide(); else if ("hide" === d || "slideUp" === d || "fadeOut" === d) b.list[d](c); else b.list.hide(d, h, c); b.list.promise().done(function () { b.triggerEvent("closed") }) } b._callbackSupport(a);
|
||||
return b
|
||||
}, toggle: function () { var a = this.list.is(":visible"); a ? this.close() : a || this.open() }, _keyMappings: { 38: "up", 40: "down", 13: "enter", 8: "backspace", 9: "tab", 32: "space", 27: "esc" }, _keydownMethods: function () {
|
||||
var a = this, b = a.list.is(":visible") || !a.options.keydownOpen; return {
|
||||
down: function () { a.moveDown && b && a.moveDown() }, up: function () { a.moveUp && b && a.moveUp() }, enter: function () { var b = a.listItems.eq(a.currentFocus); a._update(b); "true" !== b.attr("data-preventclose") && a.close(); a.triggerEvent("enter") }, tab: function () {
|
||||
a.triggerEvent("tab-blur");
|
||||
a.close()
|
||||
}, backspace: function () { a.triggerEvent("backspace") }, esc: function () { a.close() }
|
||||
}
|
||||
}, _eventHandlers: function () {
|
||||
var a = this, b = a.options.nativeMousedown, d = a.options.customShowHideEvent, f, h, g = a.focusClass, e = a.hoverClass, l = a.openClass; this.dropdown.on({
|
||||
"click.selectBoxIt": function () { a.dropdown.trigger("focus", !0); a.originalElem.disabled || (a.triggerEvent("click"), b || d || a.toggle()) }, "mousedown.selectBoxIt": function () { c(this).data("mdown", !0); a.triggerEvent("mousedown"); b && !d && a.toggle() }, "mouseup.selectBoxIt": function () { a.triggerEvent("mouseup") },
|
||||
"blur.selectBoxIt": function () { a.blur && (a.triggerEvent("blur"), a.close(), c(this).removeClass(g)) }, "focus.selectBoxIt": function (b, d) { var f = c(this).data("mdown"); c(this).removeData("mdown"); f || d || setTimeout(function () { a.triggerEvent("tab-focus") }, 0); d || (c(this).hasClass(a.theme.disabled) || c(this).addClass(g), a.triggerEvent("focus")) }, "keydown.selectBoxIt": function (b) {
|
||||
var d = a._keyMappings[b.keyCode], c = a._keydownMethods()[d]; c && (c(), !a.options.keydownOpen || "up" !== d && "down" !== d || a.open()); c && "tab" !== d &&
|
||||
b.preventDefault()
|
||||
}, "keypress.selectBoxIt": function (b) { var d = a._keyMappings[b.charCode || b.keyCode], c = String.fromCharCode(b.charCode || b.keyCode); a.search && (!d || d && "space" === d) && a.search(c, !0, !0); "space" === d && b.preventDefault() }, "mouseenter.selectBoxIt": function () { a.triggerEvent("mouseenter") }, "mouseleave.selectBoxIt": function () { a.triggerEvent("mouseleave") }
|
||||
}); a.list.on({
|
||||
"mouseover.selectBoxIt": function () { a.blur = !1 }, "mouseout.selectBoxIt": function () { a.blur = !0 }, "focusin.selectBoxIt": function () {
|
||||
a.dropdown.trigger("focus",
|
||||
!0)
|
||||
}
|
||||
}); a.list.on({
|
||||
"mousedown.selectBoxIt": function () { a._update(c(this)); a.triggerEvent("option-click"); "false" === c(this).attr("data-disabled") && "true" !== c(this).attr("data-preventclose") && a.close(); setTimeout(function () { a.dropdown.trigger("focus", !0) }, 0) }, "focusin.selectBoxIt": function () {
|
||||
a.listItems.not(c(this)).removeAttr("data-active"); c(this).attr("data-active", ""); var b = a.list.is(":hidden"); (a.options.searchWhenHidden && b || a.options.aggressiveChange || b && a.options.selectWhenHidden) && a._update(c(this));
|
||||
c(this).addClass(g)
|
||||
}, "mouseup.selectBoxIt": function () { b && !d && (a._update(c(this)), a.triggerEvent("option-mouseup"), "false" === c(this).attr("data-disabled") && "true" !== c(this).attr("data-preventclose") && a.close()) }, "mouseenter.selectBoxIt": function () { "false" === c(this).attr("data-disabled") && (a.listItems.removeAttr("data-active"), c(this).addClass(g).attr("data-active", ""), a.listItems.not(c(this)).removeClass(g), c(this).addClass(g), a.currentFocus = +c(this).attr("data-id")) }, "mouseleave.selectBoxIt": function () {
|
||||
"false" ===
|
||||
c(this).attr("data-disabled") && (a.listItems.not(c(this)).removeClass(g).removeAttr("data-active"), c(this).addClass(g), a.currentFocus = +c(this).attr("data-id"))
|
||||
}, "blur.selectBoxIt": function () { c(this).removeClass(g) }
|
||||
}, ".selectboxit-option"); a.list.on({ "click.selectBoxIt": function (a) { a.preventDefault() } }, "a"); a.selectBox.on({
|
||||
"change.selectBoxIt, internal-change.selectBoxIt": function (b, d) {
|
||||
var c, g; d || (c = a.list.find('li[data-val="' + a.originalElem.value + '"]'), c.length && (a.listItems.eq(a.currentFocus).removeClass(a.focusClass),
|
||||
a.currentFocus = +c.attr("data-id"))); c = a.listItems.eq(a.currentFocus); g = c.attr("data-selectedtext"); h = (f = c.attr("data-text")) ? f : c.find("a").text(); a._setText(a.dropdownText, g || h); a.dropdownText.attr("data-val", a.originalElem.value); c.find("i").attr("class") && (a.dropdownImage.attr("class", c.find("i").attr("class")).addClass("selectboxit-default-icon"), a.dropdownImage.attr("style", c.find("i").attr("style"))); a.triggerEvent("changed")
|
||||
}, "disable.selectBoxIt": function () { a.dropdown.addClass(a.theme.disabled) },
|
||||
"enable.selectBoxIt": function () { a.dropdown.removeClass(a.theme.disabled) }, "open.selectBoxIt": function () {
|
||||
var b = a.list.find("li[data-val='" + a.dropdownText.attr("data-val") + "']"); b.length || (b = a.listItems.not("[data-disabled=true]").first()); a.currentFocus = +b.attr("data-id"); b = a.listItems.eq(a.currentFocus); a.dropdown.addClass(l).removeClass(e).addClass(g); a.listItems.removeClass(a.selectedClass).removeAttr("data-active").not(b).removeClass(g); b.addClass(a.selectedClass).addClass(g); a.options.hideCurrent &&
|
||||
(a.listItems.show(), b.hide())
|
||||
}, "close.selectBoxIt": function () { a.dropdown.removeClass(l) }, "blur.selectBoxIt": function () { a.dropdown.removeClass(g) }, "mouseenter.selectBoxIt": function () { c(this).hasClass(a.theme.disabled) || a.dropdown.addClass(e) }, "mouseleave.selectBoxIt": function () { a.dropdown.removeClass(e) }, destroy: function (a) { a.preventDefault(); a.stopPropagation() }
|
||||
}); return a
|
||||
}, _update: function (a) {
|
||||
var b, d = this.options.defaultText || this.selectBox.attr("data-text"), c = this.listItems.eq(this.currentFocus);
|
||||
"false" === a.attr("data-disabled") && (this.listItems.eq(this.currentFocus).attr("data-selectedtext"), (b = c.attr("data-text")) || c.text(), (d && this.options.html ? this.dropdownText.html() === d : this.dropdownText.text() === d) && this.selectBox.val() === a.attr("data-val") ? this.triggerEvent("change") : (this.selectBox.val(a.attr("data-val")), this.currentFocus = +a.attr("data-id"), this.originalElem.value !== this.dropdownText.attr("data-val") && this.triggerEvent("change")))
|
||||
}, _addClasses: function (a) {
|
||||
this.focusClass = a.focus;
|
||||
this.hoverClass = a.hover; var b = a.button, d = a.list, c = a.arrow, h = a.container; this.openClass = a.open; this.selectedClass = "selectboxit-selected"; this.downArrow.addClass(this.selectBox.attr("data-downarrow") || this.options.downArrowIcon || c); this.dropdownContainer.addClass(h); this.dropdown.addClass(b); this.list.addClass(d); return this
|
||||
}, refresh: function (a, b) { this._destroySelectBoxIt()._create(!0); b || this.triggerEvent("refresh"); this._callbackSupport(a); return this }, htmlEscape: function (a) {
|
||||
return String(a).replace(/&/g,
|
||||
"&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">")
|
||||
}, triggerEvent: function (a) { this.selectBox.trigger(a, { selectbox: this.selectBox, selectboxOption: this.selectItems.eq(this.options.showFirstOption ? this.currentFocus : 0 <= this.currentFocus - 1 ? this.currentFocus : 0), dropdown: this.dropdown, dropdownOption: this.listItems.eq(this.currentFocus) }); return this }, _copyAttributes: function () { this._addSelectBoxAttributes && this._addSelectBoxAttributes(); return this }, _realOuterWidth: function (a) {
|
||||
if (a.is(":visible")) return a.outerWidth(!0);
|
||||
a = a.clone(); var b; a.css({ visibility: "hidden", display: "block", position: "absolute" }).appendTo("body"); b = a.outerWidth(!0); a.remove(); return b
|
||||
}
|
||||
}); var e = c.selectBox.selectBoxIt.prototype; e._ariaAccessibility = function () {
|
||||
var a = this, b = c("label[for='" + a.originalElem.id + "']"); a.dropdownContainer.attr({ role: "combobox", "aria-autocomplete": "list", "aria-haspopup": "true", "aria-expanded": "false", "aria-owns": a.list[0].id }); a.dropdownText.attr({ "aria-live": "polite" }); a.dropdown.on({
|
||||
"disable.selectBoxIt": function () {
|
||||
a.dropdownContainer.attr("aria-disabled",
|
||||
"true")
|
||||
}, "enable.selectBoxIt": function () { a.dropdownContainer.attr("aria-disabled", "false") }
|
||||
}); b.length && a.dropdownContainer.attr("aria-labelledby", b[0].id); a.list.attr({ role: "listbox", "aria-hidden": "true" }); a.listItems.attr({ role: "option" }); a.selectBox.on({ "open.selectBoxIt": function () { a.list.attr("aria-hidden", "false"); a.dropdownContainer.attr("aria-expanded", "true") }, "close.selectBoxIt": function () { a.list.attr("aria-hidden", "true"); a.dropdownContainer.attr("aria-expanded", "false") } }); return a
|
||||
}; e._addSelectBoxAttributes =
|
||||
function () { var a = this; a._addAttributes(a.selectBox.prop("attributes"), a.dropdown); a.selectItems.each(function (b) { a._addAttributes(c(this).prop("attributes"), a.listItems.eq(b)) }); return a }; e._addAttributes = function (a, b) { var d = this.options.copyAttributes; a.length && c.each(a, function (a, h) { var g = h.name.toLowerCase(), e = h.value; "null" === e || -1 === c.inArray(g, d) && -1 === g.indexOf("data") || b.attr(g, e) }); return this }; e.destroy = function (a) {
|
||||
this._destroySelectBoxIt(); this.widgetProto.destroy.call(this); this._callbackSupport(a);
|
||||
return this
|
||||
}; e._destroySelectBoxIt = function () { this.dropdown.off(".selectBoxIt"); c.contains(this.dropdownContainer[0], this.originalElem) && this.dropdownContainer.before(this.selectBox); this.dropdownContainer.remove(); this.selectBox.removeAttr("style").attr("style", this.selectBoxStyles); this.triggerEvent("destroy"); return this }; e.disable = function (a) {
|
||||
this.options.disabled || (this.close(), this.selectBox.attr("disabled", "disabled"), this.dropdown.removeAttr("tabindex").removeClass(this.theme.enabled).addClass(this.theme.disabled),
|
||||
this.setOption("disabled", !0), this.triggerEvent("disable")); this._callbackSupport(a); return this
|
||||
}; e.disableOption = function (a, b) {
|
||||
var d, f; "number" === c.type(a) && (this.close(), d = this.selectBox.find("option").eq(a), this.triggerEvent("disable-option"), d.attr("disabled", "disabled"), this.listItems.eq(a).attr("data-disabled", "true").addClass(this.theme.disabled), this.currentFocus === a && (d = this.listItems.eq(this.currentFocus).nextAll("li").not("[data-disabled='true']").first().length, f = this.listItems.eq(this.currentFocus).prevAll("li").not("[data-disabled='true']").first().length,
|
||||
d ? this.moveDown() : f ? this.moveUp() : this.disable())); this._callbackSupport(b); return this
|
||||
}; e._isDisabled = function (a) { this.originalElem.disabled && this.disable(); return this }; e._dynamicPositioning = function () {
|
||||
if ("number" === c.type(this.listSize)) this.list.css("max-height", this.maxHeight || "none"); else {
|
||||
var a = this.dropdown.offset().top, b = this.list.data("max-height") || this.list.outerHeight(), d = this.dropdown.outerHeight(), f = this.options.viewport, h = f.height(), f = c.isWindow(f.get(0)) ? f.scrollTop() : f.offset().top,
|
||||
g = !(a + d + b <= h + f); this.list.data("max-height") || this.list.data("max-height", this.list.outerHeight()); g ? this.dropdown.offset().top - f >= b ? (this.list.css("max-height", b), this.list.css("top", this.dropdown.position().top - this.list.outerHeight())) : (a = Math.abs(a + d + b - (h + f)), h = Math.abs(this.dropdown.offset().top - f - b), a < h ? (this.list.css("max-height", b - a - d / 2), this.list.css("top", "auto")) : (this.list.css("max-height", b - h - d / 2), this.list.css("top", this.dropdown.position().top - this.list.outerHeight()))) : (this.list.css("max-height",
|
||||
b), this.list.css("top", "auto"))
|
||||
} return this
|
||||
}; e.enable = function (a) { this.options.disabled && (this.triggerEvent("enable"), this.selectBox.removeAttr("disabled"), this.dropdown.attr("tabindex", 0).removeClass(this.theme.disabled).addClass(this.theme.enabled), this.setOption("disabled", !1), this._callbackSupport(a)); return this }; e.enableOption = function (a, b) {
|
||||
var d; "number" === c.type(a) && (d = this.selectBox.find("option").eq(a), this.triggerEvent("enable-option"), d.removeAttr("disabled"), this.listItems.eq(a).attr("data-disabled",
|
||||
"false").removeClass(this.theme.disabled)); this._callbackSupport(b); return this
|
||||
}; e.moveDown = function (a) {
|
||||
this.currentFocus += 1; var b = "true" === this.listItems.eq(this.currentFocus).attr("data-disabled") ? !0 : !1, d = this.listItems.eq(this.currentFocus).nextAll("li").not("[data-disabled='true']").first().length; if (this.currentFocus === this.listItems.length)--this.currentFocus; else {
|
||||
if (b && d) { this.listItems.eq(this.currentFocus - 1).blur(); this.moveDown(); return } b && !d ? --this.currentFocus : (this.listItems.eq(this.currentFocus -
|
||||
1).blur().end().eq(this.currentFocus).focusin(), this._scrollToView("down"), this.triggerEvent("moveDown"))
|
||||
} this._callbackSupport(a); return this
|
||||
}; e.moveUp = function (a) {
|
||||
--this.currentFocus; var b = "true" === this.listItems.eq(this.currentFocus).attr("data-disabled") ? !0 : !1, d = this.listItems.eq(this.currentFocus).prevAll("li").not("[data-disabled='true']").first().length; if (-1 === this.currentFocus) this.currentFocus += 1; else {
|
||||
if (b && d) { this.listItems.eq(this.currentFocus + 1).blur(); this.moveUp(); return } b && !d ? this.currentFocus +=
|
||||
1 : (this.listItems.eq(this.currentFocus + 1).blur().end().eq(this.currentFocus).focusin(), this._scrollToView("up"), this.triggerEvent("moveUp"))
|
||||
} this._callbackSupport(a); return this
|
||||
}; e._setCurrentSearchOption = function (a) {
|
||||
(this.options.aggressiveChange || this.options.selectWhenHidden || this.listItems.eq(a).is(":visible")) && !0 !== this.listItems.eq(a).data("disabled") && (this.listItems.eq(this.currentFocus).blur(), this.currentFocus = this.currentIndex = a, this.listItems.eq(this.currentFocus).focusin(), this._scrollToView("search"),
|
||||
this.triggerEvent("search")); return this
|
||||
}; e._searchAlgorithm = function (a, b) {
|
||||
var d = !1, c, h, g, e, l = this.textArray, k = this.currentText; c = a; for (g = l.length; c < g; c += 1) {
|
||||
e = l[c]; for (h = 0; h < g; h += 1) -1 !== l[h].search(b) && (d = !0, h = g); d || (k = this.currentText = this.currentText.charAt(this.currentText.length - 1).replace(/[|()\[{.+*?$\\]/g, "\\$0")); b = new RegExp(k, "gi"); if (3 > k.length) {
|
||||
if (b = new RegExp(k.charAt(0), "gi"), -1 !== e.charAt(0).search(b)) {
|
||||
this._setCurrentSearchOption(c); if (e.substring(0, k.length).toLowerCase() !== k.toLowerCase() ||
|
||||
this.options.similarSearch) this.currentIndex += 1; return !1
|
||||
}
|
||||
} else if (-1 !== e.search(b)) return this._setCurrentSearchOption(c), !1; if (e.toLowerCase() === this.currentText.toLowerCase()) return this._setCurrentSearchOption(c), this.currentText = "", !1
|
||||
} return !0
|
||||
}; e.search = function (a, b, d) {
|
||||
this.currentText = d ? this.currentText + a.replace(/[|()\[{.+*?$\\]/g, "\\$0") : a.replace(/[|()\[{.+*?$\\]/g, "\\$0"); this._searchAlgorithm(this.currentIndex, new RegExp(this.currentText, "gi")) && this._searchAlgorithm(0, this.currentText);
|
||||
this._callbackSupport(b); return this
|
||||
}; e._updateMobileText = function () { var a, b; a = this.selectBox.find("option").filter(":selected"); b = (b = a.attr("data-text")) ? b : a.text(); this._setText(this.dropdownText, b); this.list.find('li[data-val="' + a.val() + '"]').find("i").attr("class") && this.dropdownImage.attr("class", this.list.find('li[data-val="' + a.val() + '"]').find("i").attr("class")).addClass("selectboxit-default-icon") }; e._applyNativeSelect = function () {
|
||||
this.dropdownContainer.append(this.selectBox); this.dropdown.attr("tabindex",
|
||||
"-1"); this.selectBox.css({ display: "block", visibility: "visible", width: this._realOuterWidth(this.dropdown), height: this.dropdown.outerHeight(), opacity: "0", position: "absolute", top: "0", left: "0", cursor: "pointer", "z-index": "999999", margin: this.dropdown.css("margin"), padding: "0", "-webkit-appearance": "menulist-button" }); this.originalElem.disabled && this.triggerEvent("disable"); return this
|
||||
}; e._mobileEvents = function () {
|
||||
var a = this; a.selectBox.on({
|
||||
"changed.selectBoxIt": function () {
|
||||
a.hasChanged = !0; a._updateMobileText();
|
||||
a.triggerEvent("option-click")
|
||||
}, "mousedown.selectBoxIt": function () { a.hasChanged || !a.options.defaultText || a.originalElem.disabled || (a._updateMobileText(), a.triggerEvent("option-click")) }, "enable.selectBoxIt": function () { a.selectBox.removeClass("selectboxit-rendering") }, "disable.selectBoxIt": function () { a.selectBox.addClass("selectboxit-rendering") }
|
||||
})
|
||||
}; e._mobile = function (a) { this.isMobile && (this._applyNativeSelect(), this._mobileEvents()); return this }; e.selectOption = function (a, b) {
|
||||
var d = c.type(a); "number" ===
|
||||
d ? this.selectBox.val(this.selectItems.eq(a).val()).change() : "string" === d && this.selectBox.val(a).change(); this._callbackSupport(b); return this
|
||||
}; e.setOption = function (a, b, d) { var f = this; "string" === c.type(a) && (f.options[a] = b); f.refresh(function () { f._callbackSupport(d) }, !0); return f }; e.setOptions = function (a, b) { var d = this; c.isPlainObject(a) && (d.options = c.extend({}, d.options, a)); d.refresh(function () { d._callbackSupport(b) }, !0); return d }; e.wait = function (a, b) { this.widgetProto._delay.call(this, b, a); return this };
|
||||
e.add = function (a, b) {
|
||||
this._populate(a, function (a) {
|
||||
var f = this, e = c.type(a), g = 0, n, l = [], k = (n = f._isJSON(a)) && f._parseJSON(a); if (a && ("array" === e || n && k.data && "array" === c.type(k.data)) || "object" === e && a.data && "array" === c.type(a.data)) { f._isJSON(a) && (a = k); a.data && (a = a.data); for (n = a.length; g <= n - 1; g += 1) e = a[g], c.isPlainObject(e) ? l.push(c("<option/>", e)) : "string" === c.type(e) && l.push(c("<option/>", { text: e, value: e })); f.selectBox.append(l) } else a && "string" === e && !f._isJSON(a) ? f.selectBox.append(a) : a && "object" === e ? f.selectBox.append(c("<option/>",
|
||||
a)) : a && f._isJSON(a) && c.isPlainObject(f._parseJSON(a)) && f.selectBox.append(c("<option/>", f._parseJSON(a))); f.dropdown ? f.refresh(function () { f._callbackSupport(b) }, !0) : f._callbackSupport(b); return f
|
||||
})
|
||||
}; e._parseJSON = function (a) { return JSON && JSON.parse && JSON.parse(a) || c.parseJSON(a) }; e._isJSON = function (a) { try { return this._parseJSON(a), !0 } catch (b) { return !1 } }; e._populate = function (a, b) { var d = this; a = c.isFunction(a) ? a.call() : a; d.isDeferred(a) ? a.done(function (a) { b.call(d, a) }) : b.call(d, a); return d }; e.remove =
|
||||
function (a, b) { var d = this, f = c.type(a), e = 0, g, n = ""; if ("array" === f) { for (g = a.length; e <= g - 1; e += 1) f = a[e], "number" === c.type(f) && (n = n.length ? n + (", option:eq(" + f + ")") : n + ("option:eq(" + f + ")")); d.selectBox.find(n).remove() } else "number" === f ? d.selectBox.find("option").eq(a).remove() : d.selectBox.find("option").remove(); d.dropdown ? d.refresh(function () { d._callbackSupport(b) }, !0) : d._callbackSupport(b); return d }
|
||||
});
|
1071
custom_lobby/static/js/main_lobby.js
Normal file
1071
custom_lobby/static/js/main_lobby.js
Normal file
File diff suppressed because it is too large
Load diff
142
custom_lobby/static/js/mock.entry.js
Normal file
142
custom_lobby/static/js/mock.entry.js
Normal file
|
@ -0,0 +1,142 @@
|
|||
|
||||
// Entry 에 대한 mock API.
|
||||
// 브라우저에서 테스트를 위해서 사용한다.
|
||||
// 세번째 인자로 true가 들어가면 function call이라는 의미고, 아니면 trigger이다.
|
||||
|
||||
engine.mock('GetLobbyUrl', function () {
|
||||
return "http://localhost:23847";
|
||||
}, true);
|
||||
|
||||
engine.mock('GetClientAuthData', function () {
|
||||
return {
|
||||
platformType:"None",
|
||||
userSerial:"UserId",
|
||||
accessToken:"abcde",
|
||||
playerNetId:"UserId_abcde",
|
||||
};
|
||||
}, true);
|
||||
|
||||
engine.mock('GetDisplayResoultions', function () {
|
||||
return [
|
||||
{ X: 1024, Y: 768 },
|
||||
{ X: 1280, Y: 1024},
|
||||
{ X: 1920, Y: 1024 },
|
||||
];
|
||||
}, true);
|
||||
|
||||
engine.mock('GetCurrentOptions', function () {
|
||||
return {
|
||||
resolution: '1280x1024',
|
||||
//resolution: '1280x124',
|
||||
quality: 'Low',
|
||||
fullscreen: 'true',
|
||||
gamma: '20',
|
||||
aim: '20',
|
||||
invertY:'false',
|
||||
};
|
||||
}, true);
|
||||
|
||||
engine.mock('GetMapNames', function () {
|
||||
return ['Sanctuary', 'Highrise'];
|
||||
}, true);
|
||||
|
||||
engine.mock('GetJoinMapNames', function () {
|
||||
return ['Any', 'Sanctuary', 'Highrise'];
|
||||
}, true);
|
||||
|
||||
engine.mock('GetSearchServerResult', function () {
|
||||
return {
|
||||
bFinish: true,
|
||||
statusText: "Status message",
|
||||
entryList: [
|
||||
{
|
||||
serverName: 'Server1',
|
||||
currentPlayers: 5,
|
||||
maxPlayers: 12,
|
||||
gameType: 'FFA',
|
||||
mapName: 'TestMap',
|
||||
ping: 201,
|
||||
searchResultsIndex: 0,
|
||||
},
|
||||
{
|
||||
serverName: 'Server2',
|
||||
currentPlayers: 15,
|
||||
maxPlayers: 22,
|
||||
gameType: 'FFA',
|
||||
mapName: 'TestMap2',
|
||||
ping: 101,
|
||||
searchResultsIndex: 1,
|
||||
},
|
||||
],
|
||||
};
|
||||
}, true);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// WebSocket wrapping 함수 이벤트 들.
|
||||
engine.mock('Ws_NewWebsocket', function (name, url, cookie) {
|
||||
window.setTimeout(function () {
|
||||
engine.trigger('Ws_OnConnected', 1);
|
||||
}, 1000);
|
||||
windows.setTimeout(function () {
|
||||
engine.trigger('Ws_OnReceived', 1, 'null-json-data');
|
||||
engine.trigger('Ws_OnError', 1, 'unknown');
|
||||
engine.trigger('Ws_OnDisconnected', 1);
|
||||
}, 2000);
|
||||
return 1; // return new WebSocket Id. (0 means failed to create)
|
||||
}, true)
|
||||
|
||||
engine.mock('Ws_GetWebsocket', function (name) {
|
||||
return 0; // return connected WebSocket Id, if 0, fail to find.
|
||||
}, true)
|
||||
|
||||
engine.mock('Ws_Send', function (socketId, data) {
|
||||
console.log("call Ws_Send");
|
||||
})
|
||||
engine.mock('Ws_Close', function (socketId) {
|
||||
console.log("call Ws_Close");
|
||||
})
|
||||
|
||||
//engine.mock('Ws_OnDisconnect', function (socketId) { })
|
||||
//engine.mock('Ws_OnError', function (socketId, error) { })
|
||||
//engine.mock('Ws_OnReceived', function (socketId, data) { })
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 여기서 부터 이벤트.
|
||||
engine.mock('Quit', function () {
|
||||
console.log('engine received Quit!!!!');
|
||||
});
|
||||
|
||||
engine.mock('UpdateOptions', function (options) {
|
||||
console.log('engine received options');
|
||||
console.log(options);
|
||||
});
|
||||
|
||||
engine.mock('StartHost', function (options) {
|
||||
console.log('engine received StartHost');
|
||||
console.log(options);
|
||||
});
|
||||
|
||||
engine.mock('StartSearchJoin', function (options) {
|
||||
console.log('engine received StartSearchJoin');
|
||||
console.log(options);
|
||||
|
||||
window.setTimeout(function () { engine.trigger('BeginServerSearch'); }, 1000);
|
||||
});
|
||||
|
||||
engine.mock('JoinToServer', function (serverIndex) {
|
||||
console.log('engine received JoinToServer');
|
||||
console.log(serverIndex);
|
||||
});
|
||||
|
||||
engine.mock('JoinToDedicatedServer', function (serverAddress) {
|
||||
console.log('engine received JoinToDedicatedServer:' + serverAddress);
|
||||
});
|
||||
|
||||
engine.mock('InputFocusChange', function (isFocusIn) {
|
||||
console.log('engine received InputFocusChange:' + isFocusIn);
|
||||
});
|
||||
|
||||
engine.mock('ReadFriendList', function (contextId) {
|
||||
engine.trigger('ReadFriendListResult', contextId, 'not supproted');
|
||||
});
|
3
custom_lobby/static/js/socket.io.min.js
vendored
Normal file
3
custom_lobby/static/js/socket.io.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11932
custom_lobby/static/js/vue.js
Normal file
11932
custom_lobby/static/js/vue.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue