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

delete asc_getColorValue

move from constructor to method

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66671 954022d7-b5bf-4e40-9824-e11837661b57
parent 3bac8671
"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) { this.id = null; // уникальный id - пользователя this.userName = null; // имя пользователя this.state = undefined; // состояние (true - подключен, false - отключился) this.indexUser = -1; // Индекс пользователя (фактически равно числу заходов в документ на сервере) this.color = null; // цвет пользователя this.view = false; // просмотр(true), редактор(false) this._setUser(val); return this; } asc_CUser.prototype._setUser = function (val) { if (val) { this.id = val['id']; this.userName = val['username']; this.indexUser = val['indexUser']; this.color = getUserColorById(this.id, this.userName, false, true); this.state = val['state']; this.view = val['view']; } }; asc_CUser.prototype.asc_getId = function () { return this.id; }; asc_CUser.prototype.asc_getUserName = function () { return this.userName; }; asc_CUser.prototype.asc_getState = function () { return this.state; }; asc_CUser.prototype.asc_getColor = function () { return '#' + ('000000' + this.color.toString(16)).substr(-6); }; asc_CUser.prototype.asc_getColorValue = function () { return this.color; }; asc_CUser.prototype.asc_getView = function () { return this.view; }; asc_CUser.prototype.asc_setId = function (val) { this.id = val; }; asc_CUser.prototype.asc_setUserName = function (val) { this.userName = val; }; asc_CUser.prototype.asc_setState = function (val) { this.state = val; }; asc_CUser.prototype.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); var ConnectionState = { Reconnect: -1, // reconnect state None: 0, // not initialized WaitAuth: 1, // waiting session id Authorized: 2, // authorized ClosedCoAuth: 3, // closed coauthoring ClosedAll: 4, // closed all SaveChanges: 10 // save };
\ 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) { this.id = null; // уникальный id - пользователя this.userName = null; // имя пользователя this.state = undefined; // состояние (true - подключен, false - отключился) this.indexUser = -1; // Индекс пользователя (фактически равно числу заходов в документ на сервере) this.color = null; // цвет пользователя this.view = false; // просмотр(true), редактор(false) this._setUser(val); return this; } asc_CUser.prototype._setUser = function (val) { if (val) { this.id = val['id']; this.userName = val['username']; this.indexUser = val['indexUser']; this.color = getUserColorById(this.id, this.userName, false, true); this.state = val['state']; this.view = val['view']; } }; asc_CUser.prototype.asc_getId = function () { return this.id; }; asc_CUser.prototype.asc_getUserName = function () { return this.userName; }; asc_CUser.prototype.asc_getState = function () { return this.state; }; asc_CUser.prototype.asc_getColor = function () { return '#' + ('000000' + this.color.toString(16)).substr(-6); }; asc_CUser.prototype.asc_getView = function () { return this.view; }; asc_CUser.prototype.asc_setId = function (val) { this.id = val; }; asc_CUser.prototype.asc_setUserName = function (val) { this.userName = val; }; asc_CUser.prototype.asc_setState = function (val) { this.state = val; }; asc_CUser.prototype.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_getView"] = prot.asc_getView; prot["asc_setUserName"] = prot.asc_setUserName; prot["asc_setState"] = prot.asc_setState; prot["asc_setColor"] = prot.asc_setColor; } )(window); var ConnectionState = { Reconnect: -1, // reconnect state None: 0, // not initialized WaitAuth: 1, // waiting session id Authorized: 2, // authorized ClosedCoAuth: 3, // closed coauthoring ClosedAll: 4, // closed all SaveChanges: 10 // save };
\ No newline at end of file
......
......@@ -2172,14 +2172,7 @@ function getUserColorById(userId, userName, isDark, isNumericValue)
var nColor = c_oAscArrUserColors[g_oUserNextColorIndex % c_oAscArrUserColors.length];
++g_oUserNextColorIndex;
if (userId)
{
res = g_oUserColorById[userId] = new CUserCacheColor(nColor);
}
else
{
res = g_oUserColorById[userName] = new CUserCacheColor(nColor);
}
res = g_oUserColorById[userId|userName] = new CUserCacheColor(nColor);
}
if (!res)
......@@ -2190,24 +2183,29 @@ function getUserColorById(userId, userName, isDark, isNumericValue)
}
function CUserCacheColor(nColor)
{
var r = (nColor >> 16) & 0xFF;
var g = (nColor >> 8) & 0xFF;
var b = nColor & 0xFF;
this.Light = null;
this.Dark = null;
this.init(nColor);
}
CUserCacheColor.prototype.init = function(nColor) {
var r = (nColor >> 16) & 0xFF;
var g = (nColor >> 8) & 0xFF;
var b = nColor & 0xFF;
var Y = Math.max(0, Math.min(255, 0.299 * r + 0.587 * g + 0.114 * b));
var Cb = Math.max(0, Math.min(255, 128 - 0.168736 * r - 0.331264 * g + 0.5 * b));
var Cr = Math.max(0, Math.min(255, 128 + 0.5 * r - 0.418688 * g - 0.081312 * b));
var Y = Math.max(0, Math.min(255, 0.299 * r + 0.587 * g + 0.114 * b));
var Cb = Math.max(0, Math.min(255, 128 - 0.168736 * r - 0.331264 * g + 0.5 * b));
var Cr = Math.max(0, Math.min(255, 128 + 0.5 * r - 0.418688 * g - 0.081312 * b));
if (Y > 63)
Y = 63;
if (Y > 63)
Y = 63;
var R = Math.max(0, Math.min(255, Y + 1.402 * (Cr - 128))) | 0;
var G = Math.max(0, Math.min(255, Y - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128))) | 0;
var B = Math.max(0, Math.min(255, Y + 1.772 * (Cb - 128) )) | 0;
var R = Math.max(0, Math.min(255, Y + 1.402 * (Cr - 128))) | 0;
var G = Math.max(0, Math.min(255, Y - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128))) | 0;
var B = Math.max(0, Math.min(255, Y + 1.772 * (Cb - 128) )) | 0;
this.Light = new CColor(r, g, b, 255);
this.Dark = new CColor(R, G, B, 255);
}
this.Light = new CColor(r, g, b, 255);
this.Dark = new CColor(R, G, B, 255);
};
var g_oIdCounter = new CIdCounter();
var g_oTableId = null;
\ 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