mirror of
https://github.com/Mibew/mibew.git
synced 2025-06-06 09:06:15 +03:00
Clean code with PhpStorm
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
bbb5072130
commit
72d80d5762
@ -8,4 +8,4 @@ function mkwidth(){
|
|||||||
if(document.getElementById("wrap400")) {
|
if(document.getElementById("wrap400")) {
|
||||||
document.getElementById("wrap400").style.width = document.documentElement.clientWidth < 450 ? "450px" : "100%";
|
document.getElementById("wrap400").style.width = document.documentElement.clientWidth < 450 ? "450px" : "100%";
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
eventArgs = {
|
eventArgs = {
|
||||||
'messageData': messageData,
|
'messageData': messageData,
|
||||||
'model': false
|
'model': false
|
||||||
}
|
};
|
||||||
|
|
||||||
// Trigger event. See description of eventName and eventArgs
|
// Trigger event. See description of eventName and eventArgs
|
||||||
// above.
|
// above.
|
||||||
|
@ -31,5 +31,5 @@ MibewAPIChatInteraction = function() {
|
|||||||
'result'
|
'result'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
MibewAPIChatInteraction.prototype = new MibewAPIInteraction();
|
MibewAPIChatInteraction.prototype = new MibewAPIInteraction();
|
@ -38,7 +38,7 @@
|
|||||||
* Move to secure chat
|
* Move to secure chat
|
||||||
*/
|
*/
|
||||||
secure: function() {
|
secure: function() {
|
||||||
var link = this.model.get('link')
|
var link = this.model.get('link');
|
||||||
if (link) {
|
if (link) {
|
||||||
var style = Mibew.Objects.Models.page.get('style');
|
var style = Mibew.Objects.Models.page.get('style');
|
||||||
window.location.href = link.replace(/\&\;/g, '&')
|
window.location.href = link.replace(/\&\;/g, '&')
|
||||||
|
@ -230,7 +230,7 @@
|
|||||||
// Restart server updater because module just started and there are no
|
// Restart server updater because module just started and there are no
|
||||||
// reasons to wait refresh time to get results of previous request
|
// reasons to wait refresh time to get results of previous request
|
||||||
Mibew.Objects.server.restartUpdater();
|
Mibew.Objects.server.restartUpdater();
|
||||||
})
|
});
|
||||||
|
|
||||||
// Add module finalizer
|
// Add module finalizer
|
||||||
chat.addFinalizer(function() {
|
chat.addFinalizer(function() {
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
// Restart server updater because module just started and there are no
|
// Restart server updater because module just started and there are no
|
||||||
// reasons to wait refresh time to get results of previous request
|
// reasons to wait refresh time to get results of previous request
|
||||||
Mibew.Objects.server.restartUpdater();
|
Mibew.Objects.server.restartUpdater();
|
||||||
})
|
});
|
||||||
|
|
||||||
// Add module finalizer
|
// Add module finalizer
|
||||||
invitation.addFinalizer(function() {
|
invitation.addFinalizer(function() {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
} else {
|
} else {
|
||||||
return new ItemViewType(options);
|
return new ItemViewType(options);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Represents base collection view
|
* @class Represents base collection view
|
||||||
|
@ -16,7 +16,7 @@ var Mibew = {};
|
|||||||
// Use Backbone.Marionette with handlebars.js
|
// Use Backbone.Marionette with handlebars.js
|
||||||
Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) {
|
Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) {
|
||||||
return Handlebars.compile(rawTemplate);
|
return Handlebars.compile(rawTemplate);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Use all handlebars template as partials too
|
// Use all handlebars template as partials too
|
||||||
// We does not use Handlebars.partials property because of it can be changed
|
// We does not use Handlebars.partials property because of it can be changed
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return localStrings[str];
|
return localStrings[str];
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store localization object. Can be call multiple times, localization
|
* Store localization object. Can be call multiple times, localization
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
'"': """,
|
'"': """,
|
||||||
"'": "'",
|
"'": "'",
|
||||||
"`": "`"
|
"`": "`"
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regular expression for characters that must be replaced by HTML entities
|
* Regular expression for characters that must be replaced by HTML entities
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
* @type Object
|
* @type Object
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.functions = {}
|
this.functions = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id of the last registered function
|
* Id of the last registered function
|
||||||
@ -97,7 +97,7 @@
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.mibewAPI = new MibewAPI(new this.options['interactionType']());
|
this.mibewAPI = new MibewAPI(new this.options['interactionType']());
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make call to the server
|
* Make call to the server
|
||||||
@ -138,7 +138,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call function at every request to build functions list
|
* Call function at every request to build functions list
|
||||||
@ -155,7 +155,7 @@
|
|||||||
callbackFunction: callbackFunction
|
callbackFunction: callbackFunction
|
||||||
};
|
};
|
||||||
return this.callPeriodicallyLastId;
|
return this.callPeriodicallyLastId;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop calling function at every request.
|
* Stop calling function at every request.
|
||||||
@ -167,7 +167,7 @@
|
|||||||
if (id in this.callPeriodically) {
|
if (id in this.callPeriodically) {
|
||||||
delete this.callPeriodically[id];
|
delete this.callPeriodically[id];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates unique request token
|
* Generates unique request token
|
||||||
@ -185,7 +185,7 @@
|
|||||||
// Check token uniqueness
|
// Check token uniqueness
|
||||||
} while(token in this.callbacks);
|
} while(token in this.callbacks);
|
||||||
return token;
|
return token;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process request
|
* Process request
|
||||||
@ -226,7 +226,7 @@
|
|||||||
delete this.callbacks[requestObject.token];
|
delete this.callbacks[requestObject.token];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process function
|
* Process function
|
||||||
@ -256,7 +256,7 @@
|
|||||||
|
|
||||||
// Add function results to the execution context
|
// Add function results to the execution context
|
||||||
context.storeFunctionResults(functionObject, results);
|
context.storeFunctionResults(functionObject, results);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the request to the server
|
* Send the request to the server
|
||||||
@ -281,14 +281,14 @@
|
|||||||
success: _.bind(self.receiveResponse, self),
|
success: _.bind(self.receiveResponse, self),
|
||||||
error: _.bind(self.onError, self)
|
error: _.bind(self.onError, self)
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start automatic updater
|
* Start automatic updater
|
||||||
*/
|
*/
|
||||||
Mibew.Server.prototype.runUpdater = function() {
|
Mibew.Server.prototype.runUpdater = function() {
|
||||||
this.update();
|
this.update();
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call Mibew.Server.update after specified timeout
|
* Call Mibew.Server.update after specified timeout
|
||||||
@ -300,7 +300,7 @@
|
|||||||
_.bind(this.update, this),
|
_.bind(this.update, this),
|
||||||
time * 1000
|
time * 1000
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restarts the automatic updater
|
* Restarts the automatic updater
|
||||||
@ -316,7 +316,7 @@
|
|||||||
}
|
}
|
||||||
// Restart updater. Try to reconnect after a while
|
// Restart updater. Try to reconnect after a while
|
||||||
this.updateAfter(this.options.reconnectPause);
|
this.updateAfter(this.options.reconnectPause);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send request to server
|
* Send request to server
|
||||||
@ -350,7 +350,7 @@
|
|||||||
// Handle errors
|
// Handle errors
|
||||||
this.options.onUpdateError(e);
|
this.options.onUpdateError(e);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process response from the Server
|
* Process response from the Server
|
||||||
@ -377,7 +377,7 @@
|
|||||||
} finally {
|
} finally {
|
||||||
this.updateAfter(this.options.requestsFrequency);
|
this.updateAfter(this.options.requestsFrequency);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add function that can be called by the Server
|
* Add function that can be called by the Server
|
||||||
@ -393,7 +393,7 @@
|
|||||||
}
|
}
|
||||||
this.functions[functionName][this.functionsLastId] = handler;
|
this.functions[functionName][this.functionsLastId] = handler;
|
||||||
return this.functionsLastId;
|
return this.functionsLastId;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove function that can be called by Server
|
* Remove function that can be called by Server
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast string in camel case to dash format.
|
* Cast string in camel case to dash format.
|
||||||
@ -44,7 +44,7 @@
|
|||||||
parts[i] = parts[i].toLowerCase();
|
parts[i] = parts[i].toLowerCase();
|
||||||
}
|
}
|
||||||
return parts.join('-');
|
return parts.join('-');
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if email address valid or not
|
* Check if email address valid or not
|
||||||
@ -53,7 +53,7 @@
|
|||||||
*/
|
*/
|
||||||
Mibew.Utils.checkEmail = function(email) {
|
Mibew.Utils.checkEmail = function(email) {
|
||||||
return /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email);
|
return /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play .wav sound file
|
* Play .wav sound file
|
||||||
|
@ -90,7 +90,7 @@ MibewAPI.prototype.checkFunction = function(functionObject, filterReservedFuncti
|
|||||||
functionObject["function"] + "' function"
|
functionObject["function"] + "' function"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate request
|
* Validate request
|
||||||
@ -124,7 +124,7 @@ MibewAPI.prototype.checkRequest = function(requestObject) {
|
|||||||
for (var i = 0; i < requestObject.functions.length; i++) {
|
for (var i = 0; i < requestObject.functions.length; i++) {
|
||||||
this.checkFunction(requestObject.functions[i]);
|
this.checkFunction(requestObject.functions[i]);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate package.
|
* Validate package.
|
||||||
@ -167,7 +167,7 @@ MibewAPI.prototype.checkPackage = function (packageObject) {
|
|||||||
for (var i = 0; i < packageObject.requests.length; i++) {
|
for (var i = 0; i < packageObject.requests.length; i++) {
|
||||||
this.checkRequest(packageObject.requests[i]);
|
this.checkRequest(packageObject.requests[i]);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search 'result' function in functionsList. If request contains more than
|
* Search 'result' function in functionsList. If request contains more than
|
||||||
@ -212,7 +212,7 @@ MibewAPI.prototype.getResultFunction = function(functionsList, existance){
|
|||||||
throw new Error("There is 'result' function in functions list");
|
throw new Error("There is 'result' function in functions list");
|
||||||
}
|
}
|
||||||
return resultFunction;
|
return resultFunction;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds result package
|
* Builds result package
|
||||||
@ -239,7 +239,7 @@ MibewAPI.prototype.buildResult = function(resultArguments, token) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes package
|
* Encodes package
|
||||||
@ -255,7 +255,7 @@ MibewAPI.prototype.encodePackage = function(requests) {
|
|||||||
packageObject.async = true;
|
packageObject.async = true;
|
||||||
packageObject.requests = requests;
|
packageObject.requests = requests;
|
||||||
return encodeURIComponent(JSON.stringify(packageObject)).replace(/\%20/gi, '+');
|
return encodeURIComponent(JSON.stringify(packageObject)).replace(/\%20/gi, '+');
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes package and validate package structure
|
* Decodes package and validate package structure
|
||||||
@ -270,7 +270,7 @@ MibewAPI.prototype.decodePackage = function(encodedPackage){
|
|||||||
var decodedPackage = JSON.parse(decodeURIComponent(encodedPackage.replace(/\+/gi, ' ')));
|
var decodedPackage = JSON.parse(decodeURIComponent(encodedPackage.replace(/\+/gi, ' ')));
|
||||||
this.checkPackage(decodedPackage);
|
this.checkPackage(decodedPackage);
|
||||||
return decodedPackage;
|
return decodedPackage;
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* End of MibewAPI Class
|
* End of MibewAPI Class
|
||||||
*/
|
*/
|
||||||
@ -308,7 +308,7 @@ function MibewAPIInteraction(){
|
|||||||
*/
|
*/
|
||||||
this.mandatoryArguments = function() {
|
this.mandatoryArguments = function() {
|
||||||
return {};
|
return {};
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns reserved (system) functions' names
|
* Returns reserved (system) functions' names
|
||||||
@ -352,7 +352,7 @@ MibewAPIInteraction.prototype.getMandatoryArguments = function(functionName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mandatoryArguments;
|
return mandatoryArguments;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns default values of mandatory arguments for the functionName function
|
* Returns default values of mandatory arguments for the functionName function
|
||||||
@ -383,7 +383,7 @@ MibewAPIInteraction.prototype.getMandatoryArgumentsDefaults = function(functionN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mandatoryArguments;
|
return mandatoryArguments;
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* End of MibewAPIInteraction class
|
* End of MibewAPIInteraction class
|
||||||
*/
|
*/
|
||||||
@ -460,7 +460,7 @@ MibewAPIExecutionContext.prototype.getArgumentsList = function(functionObject) {
|
|||||||
argumentsList[variableName] = this.functionsResults[funcNum - 1][referenceTo];
|
argumentsList[variableName] = this.functionsResults[funcNum - 1][referenceTo];
|
||||||
}
|
}
|
||||||
return argumentsList;
|
return argumentsList;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns requets results
|
* Returns requets results
|
||||||
@ -469,7 +469,7 @@ MibewAPIExecutionContext.prototype.getArgumentsList = function(functionObject) {
|
|||||||
*/
|
*/
|
||||||
MibewAPIExecutionContext.prototype.getResults = function(){
|
MibewAPIExecutionContext.prototype.getResults = function(){
|
||||||
return this.returnValues;
|
return this.returnValues;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores functions results in execution context and add values to request
|
* Stores functions results in execution context and add values to request
|
||||||
@ -506,7 +506,7 @@ MibewAPIExecutionContext.prototype.storeFunctionResults = function(functionObjec
|
|||||||
}
|
}
|
||||||
// Store function results in execution context
|
// Store function results in execution context
|
||||||
this.functionsResults.push(results);
|
this.functionsResults.push(results);
|
||||||
}
|
};
|
||||||
/**
|
/**
|
||||||
* End of MibewAPIExecutionContext class
|
* End of MibewAPIExecutionContext class
|
||||||
*/
|
*/
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
alert(Mibew.Localization.get('pending.errors.network'));
|
alert(Mibew.Localization.get('pending.errors.network'));
|
||||||
badRequestsCount = 0;
|
badRequestsCount = 0;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Create application instance
|
// Create application instance
|
||||||
var App = new Backbone.Marionette.Application();
|
var App = new Backbone.Marionette.Application();
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
// Create default sort field
|
// Create default sort field
|
||||||
var sort = {
|
var sort = {
|
||||||
field: thread.get('waitingTime').toString()
|
field: thread.get('waitingTime').toString()
|
||||||
}
|
};
|
||||||
|
|
||||||
// Trigger event to provide an ability to change sorting order
|
// Trigger event to provide an ability to change sorting order
|
||||||
this.trigger('sort:field', thread, sort);
|
this.trigger('sort:field', thread, sort);
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
// Create default sort field
|
// Create default sort field
|
||||||
var sort = {
|
var sort = {
|
||||||
field: visitor.get('firstTime').toString()
|
field: visitor.get('firstTime').toString()
|
||||||
}
|
};
|
||||||
|
|
||||||
// Trigger event to provide an ability to change sorting order
|
// Trigger event to provide an ability to change sorting order
|
||||||
this.trigger('sort:field', visitor, sort);
|
this.trigger('sort:field', visitor, sort);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
newWindow.focus();
|
newWindow.focus();
|
||||||
newWindow.opener = window;
|
newWindow.opener = window;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update time in timers
|
* Update time in timers
|
||||||
|
@ -23,12 +23,12 @@ MibewAPIUsersInteraction = function() {
|
|||||||
'errorCode': 0
|
'errorCode': 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
this.getReservedFunctionsNames = function() {
|
this.getReservedFunctionsNames = function() {
|
||||||
return [
|
return [
|
||||||
'result'
|
'result'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
MibewAPIUsersInteraction.prototype = new MibewAPIInteraction();
|
MibewAPIUsersInteraction.prototype = new MibewAPIInteraction();
|
@ -86,7 +86,7 @@
|
|||||||
* @returns {Object} Template data
|
* @returns {Object} Template data
|
||||||
*/
|
*/
|
||||||
serializeData: function() {
|
serializeData: function() {
|
||||||
var thread = this.model
|
var thread = this.model;
|
||||||
var page = Mibew.Objects.Models.page;
|
var page = Mibew.Objects.Models.page;
|
||||||
var data = thread.toJSON();
|
var data = thread.toJSON();
|
||||||
data.stateDesc = this.stateToDesc(thread.get('state'));
|
data.stateDesc = this.stateToDesc(thread.get('state'));
|
||||||
|
@ -88,7 +88,7 @@ var Mibew = {};
|
|||||||
styleSheet.setAttribute('type', 'text/css');
|
styleSheet.setAttribute('type', 'text/css');
|
||||||
styleSheet.setAttribute('href', options.inviteStyle);
|
styleSheet.setAttribute('href', options.inviteStyle);
|
||||||
document.getElementsByTagName('head')[0].appendChild(styleSheet);
|
document.getElementsByTagName('head')[0].appendChild(styleSheet);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make request to the server.
|
* Make request to the server.
|
||||||
@ -119,7 +119,7 @@ var Mibew = {};
|
|||||||
|
|
||||||
// Clean up request data
|
// Clean up request data
|
||||||
this.dataToSend = {};
|
this.dataToSend = {};
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build GET request params list
|
* Build GET request params list
|
||||||
@ -135,7 +135,7 @@ var Mibew = {};
|
|||||||
query.push(index + '=' + this.dataToSend[index]);
|
query.push(index + '=' + this.dataToSend[index]);
|
||||||
}
|
}
|
||||||
return query.join('&');
|
return query.join('&');
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send arbitrary data to the Server as GET params
|
* Send arbitrary data to the Server as GET params
|
||||||
@ -165,7 +165,7 @@ var Mibew = {};
|
|||||||
|
|
||||||
this.dataToSend[index] = value;
|
this.dataToSend[index] = value;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse server response. Called as JSONP callback function
|
* Parse server response. Called as JSONP callback function
|
||||||
@ -230,7 +230,7 @@ var Mibew = {};
|
|||||||
context.makeRequest();
|
context.makeRequest();
|
||||||
},
|
},
|
||||||
this.requestTimeout);
|
this.requestTimeout);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove dynamically loaded request script from DOM
|
* Remove dynamically loaded request script from DOM
|
||||||
@ -239,7 +239,7 @@ var Mibew = {};
|
|||||||
Mibew.Widget.prototype.cleanUpAfterRequest = function() {
|
Mibew.Widget.prototype.cleanUpAfterRequest = function() {
|
||||||
document.getElementsByTagName('head')[0]
|
document.getElementsByTagName('head')[0]
|
||||||
.removeChild(document.getElementById('responseScript'));
|
.removeChild(document.getElementById('responseScript'));
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load script and add handler for script onLoad event
|
* Load script and add handler for script onLoad event
|
||||||
@ -255,14 +255,14 @@ var Mibew = {};
|
|||||||
// Check if script loaded
|
// Check if script loaded
|
||||||
script.onload = function(){
|
script.onload = function(){
|
||||||
context.scriptReady(id);
|
context.scriptReady(id);
|
||||||
}
|
};
|
||||||
// Do it in crossbrowser way
|
// Do it in crossbrowser way
|
||||||
script.onreadystatechange = function(){
|
script.onreadystatechange = function(){
|
||||||
if (this.readyState == 'complete' || this.readyState == 'loaded') {
|
if (this.readyState == 'complete' || this.readyState == 'loaded') {
|
||||||
context.scriptReady(id);
|
context.scriptReady(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamically add script tag to DOM
|
* Dynamically add script tag to DOM
|
||||||
@ -277,7 +277,7 @@ var Mibew = {};
|
|||||||
script.setAttribute('id', id);
|
script.setAttribute('id', id);
|
||||||
document.getElementsByTagName('head')[0].appendChild(script);
|
document.getElementsByTagName('head')[0].appendChild(script);
|
||||||
return script;
|
return script;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event listener for script onLoad event. Run handlers which have no
|
* Event listener for script onLoad event. Run handlers which have no
|
||||||
@ -295,7 +295,7 @@ var Mibew = {};
|
|||||||
delete this.handlers[handlerName];
|
delete this.handlers[handlerName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if handler can be run
|
* Check if handler can be run
|
||||||
@ -309,7 +309,7 @@ var Mibew = {};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function which create new widget object, store it into
|
* Helper function which create new widget object, store it into
|
||||||
@ -318,7 +318,7 @@ var Mibew = {};
|
|||||||
Mibew.Widget.init = function(options) {
|
Mibew.Widget.init = function(options) {
|
||||||
Mibew.Objects.widget = new Mibew.Widget(options);
|
Mibew.Objects.widget = new Mibew.Widget(options);
|
||||||
Mibew.Objects.widget.makeRequest();
|
Mibew.Objects.widget.makeRequest();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -338,7 +338,7 @@ var Mibew = {};
|
|||||||
document.cookie = "" + name + "=" + value + "; "
|
document.cookie = "" + name + "=" + value + "; "
|
||||||
+ "path=/; "
|
+ "path=/; "
|
||||||
+ (domain ? ("domain=" + domain + ";") : '');
|
+ (domain ? ("domain=" + domain + ";") : '');
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to read cookie.
|
* Try to read cookie.
|
||||||
@ -358,7 +358,7 @@ var Mibew = {};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -423,7 +423,7 @@ var Mibew = {};
|
|||||||
if (invitationdiv) {
|
if (invitationdiv) {
|
||||||
invitationdiv.innerHTML = popuptext;
|
invitationdiv.innerHTML = popuptext;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display invitation popup
|
* Display invitation popup
|
||||||
@ -433,7 +433,7 @@ var Mibew = {};
|
|||||||
if (invitationPopup) {
|
if (invitationPopup) {
|
||||||
invitationPopup.style.display = 'block';
|
invitationPopup.style.display = 'block';
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide invitation popup and remove it from DOM
|
* Hide invitation popup and remove it from DOM
|
||||||
@ -443,7 +443,7 @@ var Mibew = {};
|
|||||||
if (invitationPopup) {
|
if (invitationPopup) {
|
||||||
invitationPopup.parentNode.removeChild(invitationPopup);
|
invitationPopup.parentNode.removeChild(invitationPopup);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept invitation and open chat window
|
* Accept invitation and open chat window
|
||||||
@ -453,7 +453,7 @@ var Mibew = {};
|
|||||||
document.getElementById('mibewAgentButton').onclick();
|
document.getElementById('mibewAgentButton').onclick();
|
||||||
Mibew.Invitation.hide();
|
Mibew.Invitation.hide();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visitor rejects invitation
|
* Visitor rejects invitation
|
||||||
@ -461,7 +461,7 @@ var Mibew = {};
|
|||||||
Mibew.Invitation.reject = function() {
|
Mibew.Invitation.reject = function() {
|
||||||
Mibew.Objects.widget.sendToServer({'invitation_rejected': 1});
|
Mibew.Objects.widget.sendToServer({'invitation_rejected': 1});
|
||||||
Mibew.Invitation.hide();
|
Mibew.Invitation.hide();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -478,7 +478,7 @@ var Mibew = {};
|
|||||||
Mibew.Objects.widget.visitorCookieName,
|
Mibew.Objects.widget.visitorCookieName,
|
||||||
response.user.id
|
response.user.id
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show invitation popup
|
* Show invitation popup
|
||||||
@ -486,7 +486,7 @@ var Mibew = {};
|
|||||||
*/
|
*/
|
||||||
Mibew.APIFunctions.invitationCreate = function(data) {
|
Mibew.APIFunctions.invitationCreate = function(data) {
|
||||||
Mibew.Invitation.create(data.invitation);
|
Mibew.Invitation.create(data.invitation);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close invitation popup
|
* Close invitation popup
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
if ($ava.size() > 0) {
|
if ($ava.size() > 0) {
|
||||||
$ava.height($msgs.innerHeight());
|
$ava.height($msgs.innerHeight());
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix bug with window resize event
|
* Fix bug with window resize event
|
||||||
@ -70,7 +70,7 @@
|
|||||||
clearTimeout(t);
|
clearTimeout(t);
|
||||||
}
|
}
|
||||||
t = setTimeout(updateHeight, 0);
|
t = setTimeout(updateHeight, 0);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Stretch messages region after chat page initialize
|
// Stretch messages region after chat page initialize
|
||||||
Mibew.Application.Chat.addInitializer(function() {
|
Mibew.Application.Chat.addInitializer(function() {
|
||||||
@ -101,7 +101,7 @@
|
|||||||
// Stretch messages region on resize
|
// Stretch messages region on resize
|
||||||
$(window).resize(updateHeightWrapper);
|
$(window).resize(updateHeightWrapper);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Change size of message region only after all images will be loaded
|
// Change size of message region only after all images will be loaded
|
||||||
$('img').each(function(){
|
$('img').each(function(){
|
||||||
|
@ -18,7 +18,7 @@ function MibewAPITestInteraction() {
|
|||||||
'bar': 127
|
'bar': 127
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
this.getReservedFunctionsNames = function() {
|
this.getReservedFunctionsNames = function() {
|
||||||
return [
|
return [
|
||||||
@ -181,7 +181,7 @@ test("checkRequest", function() {
|
|||||||
"references" : [],
|
"references" : [],
|
||||||
"testArgument" : "testValue"
|
"testArgument" : "testValue"
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Try to check request without token
|
// Try to check request without token
|
||||||
try {
|
try {
|
||||||
@ -274,7 +274,7 @@ test("checkPackage", function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
|
||||||
// Try to check package with no signature
|
// Try to check package with no signature
|
||||||
try {
|
try {
|
||||||
@ -407,7 +407,7 @@ test("getResult", function() {
|
|||||||
var resultFunction = {
|
var resultFunction = {
|
||||||
"function" : "result",
|
"function" : "result",
|
||||||
"test_field" : "test_value"
|
"test_field" : "test_value"
|
||||||
}
|
};
|
||||||
|
|
||||||
// Try to get result function from function list, but it contains more than
|
// Try to get result function from function list, but it contains more than
|
||||||
// one 'result' function
|
// one 'result' function
|
||||||
@ -483,7 +483,7 @@ test("buildResult", function() {
|
|||||||
var testArguments = {
|
var testArguments = {
|
||||||
"first" : "test_value",
|
"first" : "test_value",
|
||||||
"second" : "test_value"
|
"second" : "test_value"
|
||||||
}
|
};
|
||||||
var token = "some token";
|
var token = "some token";
|
||||||
var testPackage = {
|
var testPackage = {
|
||||||
"token" : token,
|
"token" : token,
|
||||||
@ -498,7 +498,7 @@ test("buildResult", function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
|
||||||
// Compare result package
|
// Compare result package
|
||||||
deepEqual(
|
deepEqual(
|
||||||
@ -517,7 +517,7 @@ test("encodePackage", function() {
|
|||||||
"proto" : mibewAPI.protocolVersion,
|
"proto" : mibewAPI.protocolVersion,
|
||||||
"async" : true,
|
"async" : true,
|
||||||
"requests" : [testRequest]
|
"requests" : [testRequest]
|
||||||
}
|
};
|
||||||
|
|
||||||
// Compare encoded packages
|
// Compare encoded packages
|
||||||
equal(
|
equal(
|
||||||
@ -536,7 +536,7 @@ test("decodePackage", function() {
|
|||||||
"proto" : mibewAPI.protocolVersion,
|
"proto" : mibewAPI.protocolVersion,
|
||||||
"async" : true,
|
"async" : true,
|
||||||
"requests" : [testRequest]
|
"requests" : [testRequest]
|
||||||
}
|
};
|
||||||
var encodedPackage = mibewAPI.encodePackage([testRequest]);
|
var encodedPackage = mibewAPI.encodePackage([testRequest]);
|
||||||
|
|
||||||
// Try to decode broken package
|
// Try to decode broken package
|
||||||
|
Loading…
Reference in New Issue
Block a user