mirror of
https://github.com/Mibew/java.git
synced 2025-04-11 15:20:13 +03:00
154 lines
4.4 KiB
JavaScript
154 lines
4.4 KiB
JavaScript
/**
|
|
* @preserve This file is part of Mibew Messenger project.
|
|
* http://mibew.org
|
|
*
|
|
* Copyright (c) 2005-2011 Mibew Messenger Community
|
|
* License: http://mibew.org/license.php
|
|
*/
|
|
|
|
(function(Mibew, _){
|
|
|
|
/**
|
|
* Holds thread controls constructors
|
|
* @type Array
|
|
*/
|
|
var controlsConstructors = [];
|
|
|
|
/**
|
|
* Prepresent thread in users queue
|
|
* @class
|
|
*/
|
|
var QueuedThread = Mibew.Models.QueuedThread = Mibew.Models.Thread.extend(
|
|
/** @lends Mibew.Models.QueuedThread.prototype */
|
|
{
|
|
/**
|
|
* A list of default model values.
|
|
* Inherits values from Mibew.Models.Thread
|
|
* @type Object
|
|
*/
|
|
defaults: _.extend(
|
|
{},
|
|
Mibew.Models.Thread.prototype.defaults,
|
|
{
|
|
/**
|
|
* Collection of thread controls
|
|
* @type Mibew.Collections.Controls
|
|
*/
|
|
controls: null,
|
|
|
|
/**
|
|
* Name of the user
|
|
* @type String
|
|
*/
|
|
userName: '',
|
|
|
|
/**
|
|
* Ip address of the user
|
|
* @type String
|
|
*/
|
|
userIp: '',
|
|
|
|
/**
|
|
* Full remote address returned by web server. Generally
|
|
* equals to userIp.
|
|
* @type String
|
|
*/
|
|
remote: '',
|
|
|
|
/**
|
|
* User agent
|
|
* @type String
|
|
*/
|
|
userAgent: '',
|
|
|
|
/**
|
|
* Agent name
|
|
* @type String
|
|
*/
|
|
agentName: '',
|
|
|
|
/**
|
|
* Indicates if agent can open thread
|
|
* @type Boolean
|
|
*/
|
|
canOpen: false,
|
|
|
|
/**
|
|
* Indicates if agent can view thread
|
|
* @type Boolean
|
|
*/
|
|
canView: false,
|
|
|
|
/**
|
|
* Indicates if agent can ban the user
|
|
* @type Boolean
|
|
*/
|
|
canBan: false,
|
|
|
|
/**
|
|
* Contains ban info if user already blocked or boolean
|
|
* false otherwise.
|
|
* @type Boolean|Object
|
|
*/
|
|
ban: false,
|
|
|
|
/**
|
|
* Unix timestamp when thread was started
|
|
* @type Number
|
|
*/
|
|
totalTime: 0,
|
|
|
|
/**
|
|
* Unix timestamp when user begin wait for agent
|
|
* @type Number
|
|
*/
|
|
waitingTime: 0,
|
|
|
|
/**
|
|
* First message from user to operator
|
|
* @type String
|
|
*/
|
|
firstMessage: null
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Model initializer.
|
|
* Create controls collection and store it in the model field.
|
|
*/
|
|
initialize: function() {
|
|
var self = this;
|
|
var controls = [];
|
|
var constructors = QueuedThread.getControls();
|
|
for (var i = 0, l = constructors.length; i < l; i++) {
|
|
controls.push(new constructors[i]({thread: self}));
|
|
}
|
|
this.set({
|
|
controls: new Mibew.Collections.Controls(controls)
|
|
});
|
|
}
|
|
},
|
|
|
|
|
|
/** @lends Mibew.Models.QueuedThread */
|
|
{
|
|
/**
|
|
* Add thread control constructor
|
|
* @static
|
|
* @param {Function} Mibew.Models.Control or inherited constructor
|
|
*/
|
|
addControl: function(control) {
|
|
controlsConstructors.push(control)
|
|
},
|
|
|
|
/**
|
|
* Returns list of thread controls constructors
|
|
* @static
|
|
* @returns {Array} List of controls constructors
|
|
*/
|
|
getControls: function() {
|
|
return controlsConstructors;
|
|
}
|
|
}
|
|
);
|
|
})(Mibew, _); |