Commit c5893d0d authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

У пользователя добавил метод asc_getView

Доработал обработку view-пользоватей (они не участвуют в редактировании).

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56817 954022d7-b5bf-4e40-9824-e11837661b57
parent 1bf80b0d
......@@ -264,6 +264,7 @@
// Online-пользователи в документе
this._participants = {};
this._countEditUsers = 0;
this._countUsers = 0;
this._locks = {};
this._msgBuffer = [];
......@@ -467,7 +468,7 @@
DocsCoApi.prototype.getUsers = function () {
// Специально для возможности получения после прохождения авторизации (Стоит переделать)
if (this.onAuthParticipantsChanged)
this.onAuthParticipantsChanged(this._participants, this._countEditUsers);
this.onAuthParticipantsChanged(this._participants, this._countUsers);
};
DocsCoApi.prototype.getUser = function (userId) {
......@@ -701,18 +702,21 @@
DocsCoApi.prototype._onAuthParticipantsChanged = function (participants) {
this._participants = {};
this._countEditUsers = 0;
this._countUsers = 0;
if (participants) {
var tmpUser;
for (var i = 0; i < participants.length; ++i) {
tmpUser = new asc_user(participants[i]);
this._participants[tmpUser.asc_getId()] = tmpUser;
// Считаем число всех пользователей (и тех кто просматривает тоже)
++this._countEditUsers;
// Считаем только число редакторов
if (!tmpUser.asc_getView())
++this._countEditUsers;
++this._countUsers;
}
if (this.onAuthParticipantsChanged)
this.onAuthParticipantsChanged(this._participants, this._countEditUsers);
this.onAuthParticipantsChanged(this._participants, this._countUsers);
// Посылаем эвент о совместном редактировании
if (1 < this._countEditUsers)
......@@ -723,18 +727,23 @@
};
DocsCoApi.prototype._onConnectionStateChanged = function (data) {
var userStateChanged = null, userId, stateChanged = false;
var userStateChanged = null, userId, stateChanged = false, isEditUser = true;
if (undefined !== data["state"] && this.onConnectionStateChanged) {
userStateChanged = new asc_user(data);
userId = userStateChanged.asc_getId();
isEditUser = !userStateChanged.asc_getView();
if (userStateChanged.asc_getState()) {
this._participants[userId] = userStateChanged;
++this._countEditUsers;
++this._countUsers;
if (isEditUser)
++this._countEditUsers;
stateChanged = true;
} else if (this._participants.hasOwnProperty(userId)){
delete this._participants[userId];
--this._countEditUsers;
--this._countUsers;
if (isEditUser)
--this._countEditUsers;
stateChanged = true;
}
......@@ -745,7 +754,7 @@
else
this._onEndCoAuthoring(/*isStartEvent*/false);
this.onParticipantsChanged(this._participants, this._countEditUsers);
this.onParticipantsChanged(this._participants, this._countUsers);
this.onConnectionStateChanged(userStateChanged);
}
}
......
"use strict"; /* docscoapicommon.js * * Author: Alexander.Trofimov * Date: 09.11.12 */( /** * @param {Window} window * @param {undefined} undefined */ function (window, undefined) { /* * Import * ----------------------------------------------------------------------------- */ var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {}); var prot; /** * Класс user для совместного редактирования/просмотра документа * ----------------------------------------------------------------------------- * * @constructor * @memberOf Asc */ function asc_CUser (val) { if ( !(this instanceof asc_CUser) ) { return new asc_CUser(val); } this.id = null; // уникальный id - пользователя this.userName = null; // имя пользователя this.state = undefined; // состояние (true - подключен, false - отключился) this.color = null; // цвет пользователя this._setUser(val); return this; } asc_CUser.prototype = { constructor: asc_CUser, _setUser: function (val) { if (val) { this.id = val["id"]; this.userName = val["username"]; this.color = val["color"]; this.state = val["state"]; } else { this.color = asc.generateColor(); } }, asc_getId: function () { return this.id; }, asc_getUserName: function () { return this.userName; }, asc_getState: function () { return this.state; }, asc_getColor: function () { return '#' + ('000000' + this.color.toString(16)).substr(-6); }, asc_getColorValue: function () { return this.color; }, asc_setId: function (val) { this.id = val; }, asc_setUserName: function (val) { this.userName = val; }, asc_setState: function (val) { this.state = val; }, asc_setColor: function (val) { this.color = val; } }; /* * Export * ----------------------------------------------------------------------------- */ window["Asc"]["asc_CUser"] = window["Asc"].asc_CUser = asc_CUser; prot = asc_CUser.prototype; prot["asc_getId"] = prot.asc_getId; prot["asc_getUserName"] = prot.asc_getUserName; prot["asc_getState"] = prot.asc_getState; prot["asc_setId"] = prot.asc_setId; prot["asc_getColor"] = prot.asc_getColor; prot["asc_getColorValue"] = prot.asc_getColorValue; prot["asc_setUserName"] = prot.asc_setUserName; prot["asc_setState"] = prot.asc_setState; prot["asc_setColor"] = prot.asc_setColor; } )(window);
\ No newline at end of file
"use strict"; /* docscoapicommon.js * * Author: Alexander.Trofimov * Date: 09.11.12 */( /** * @param {Window} window * @param {undefined} undefined */ function (window, undefined) { /* * Import * ----------------------------------------------------------------------------- */ var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {}); var prot; /** * Класс user для совместного редактирования/просмотра документа * ----------------------------------------------------------------------------- * * @constructor * @memberOf Asc */ function asc_CUser (val) { if ( !(this instanceof asc_CUser) ) { return new asc_CUser(val); } this.id = null; // уникальный id - пользователя this.userName = null; // имя пользователя this.state = undefined; // состояние (true - подключен, false - отключился) this.color = null; // цвет пользователя this.view = false; // просмотр(true), редактор(false) this._setUser(val); return this; } asc_CUser.prototype = { constructor: asc_CUser, _setUser: function (val) { if (val) { this.id = val["id"]; this.userName = val["username"]; this.color = val["color"]; this.state = val["state"]; this.view = val["view"]; } else { this.color = asc.generateColor(); } }, asc_getId: function () { return this.id; }, asc_getUserName: function () { return this.userName; }, asc_getState: function () { return this.state; }, asc_getColor: function () { return '#' + ('000000' + this.color.toString(16)).substr(-6); }, asc_getColorValue: function () { return this.color; }, asc_getView: function () { return this.view; }, asc_setId: function (val) { this.id = val; }, asc_setUserName: function (val) { this.userName = val; }, asc_setState: function (val) { this.state = val; }, asc_setColor: function (val) { this.color = val; } }; /* * Export * ----------------------------------------------------------------------------- */ window["Asc"]["asc_CUser"] = window["Asc"].asc_CUser = asc_CUser; prot = asc_CUser.prototype; prot["asc_getId"] = prot.asc_getId; prot["asc_getUserName"] = prot.asc_getUserName; prot["asc_getState"] = prot.asc_getState; prot["asc_setId"] = prot.asc_setId; prot["asc_getColor"] = prot.asc_getColor; prot["asc_getColorValue"] = prot.asc_getColorValue; prot["asc_getView"] = prot.asc_getView; prot["asc_setUserName"] = prot.asc_setUserName; prot["asc_setState"] = prot.asc_setState; prot["asc_setColor"] = prot.asc_setColor; } )(window);
\ No newline at end of file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment