|
|
@ -8,6 +8,9 @@ define([
|
|
|
|
/** Id of the div containing the user list. */
|
|
|
|
/** Id of the div containing the user list. */
|
|
|
|
var USER_LIST_CLS = 'rtwysiwyg-user-list';
|
|
|
|
var USER_LIST_CLS = 'rtwysiwyg-user-list';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Id of the button to change my username. */
|
|
|
|
|
|
|
|
var USERNAME_BUTTON_ID = 'rtwysiwyg-change-username';
|
|
|
|
|
|
|
|
|
|
|
|
/** Id of the div containing the lag info. */
|
|
|
|
/** Id of the div containing the lag info. */
|
|
|
|
var LAG_ELEM_CLS = 'rtwysiwyg-lag';
|
|
|
|
var LAG_ELEM_CLS = 'rtwysiwyg-lag';
|
|
|
|
|
|
|
|
|
|
|
@ -123,29 +126,37 @@ define([
|
|
|
|
return $container.find('#'+id)[0];
|
|
|
|
return $container.find('#'+id)[0];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var getOtherUsers = function(myUserName, userList) {
|
|
|
|
var getOtherUsers = function(myUserName, userList, userData) {
|
|
|
|
var length = userList.length;
|
|
|
|
var length = userList.length;
|
|
|
|
var list = (length > 1) ? ' : ' : '';
|
|
|
|
var list = (length > 1) ? ' : ' : '';
|
|
|
|
userList.forEach(function(user) {
|
|
|
|
userList.forEach(function(user) {
|
|
|
|
if(user !== myUserName) {
|
|
|
|
if(user !== myUserName) {
|
|
|
|
list += user + ', ';
|
|
|
|
var data = (userData) ? (userData[user] || null) : null;
|
|
|
|
|
|
|
|
var userName = (data) ? data.name : user;
|
|
|
|
|
|
|
|
list += userName + ', ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return (length > 1) ? list.slice(0, -2) : list;
|
|
|
|
return (length > 1) ? list.slice(0, -2) : list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var updateUserList = function (myUserName, listElement, userList) {
|
|
|
|
var createChangeName = function($container, userList, buttonID) {
|
|
|
|
|
|
|
|
var id = uid();
|
|
|
|
|
|
|
|
userList.innerHTML = '<span class="cke_toolgroup" id="' + buttonID + '"><a id="' + USERNAME_BUTTON_ID + '" class="cke_button">Change name</a></span><span id="' + id + '"></span>';
|
|
|
|
|
|
|
|
return $container.find('#'+id)[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updateUserList = function (myUserName, listElement, userList, userData) {
|
|
|
|
var meIdx = userList.indexOf(myUserName);
|
|
|
|
var meIdx = userList.indexOf(myUserName);
|
|
|
|
if (meIdx === -1) {
|
|
|
|
if (meIdx === -1) {
|
|
|
|
listElement.textContent = Messages.synchronizing;
|
|
|
|
listElement.textContent = Messages.synchronizing;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (userList.length === 1) {
|
|
|
|
if (userList.length === 1) {
|
|
|
|
listElement.textContent = Messages.editingAlone;
|
|
|
|
listElement.innerHTML = Messages.editingAlone;
|
|
|
|
} else if (userList.length === 2) {
|
|
|
|
} else if (userList.length === 2) {
|
|
|
|
listElement.textContent = Messages.editingWithOneOtherPerson + getOtherUsers(myUserName, userList);
|
|
|
|
listElement.innerHTML = Messages.editingWithOneOtherPerson + getOtherUsers(myUserName, userList, userData);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
listElement.textContent = Messages.editingWith + ' ' + (userList.length - 1) + ' ' + Messages.otherPeople + getOtherUsers(myUserName, userList);
|
|
|
|
listElement.innerHTML = Messages.editingWith + ' ' + (userList.length - 1) + ' ' + Messages.otherPeople + getOtherUsers(myUserName, userList, userData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -199,22 +210,33 @@ define([
|
|
|
|
localStorage['CryptPad_RECENTPADS'] = JSON.stringify(out);
|
|
|
|
localStorage['CryptPad_RECENTPADS'] = JSON.stringify(out);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var create = function ($container, myUserName, realtime, webChannel, userList) {
|
|
|
|
var create = function ($container, myUserName, realtime, webChannel, userList, config) {
|
|
|
|
var toolbar = createRealtimeToolbar($container);
|
|
|
|
var toolbar = createRealtimeToolbar($container);
|
|
|
|
createEscape(toolbar.find('.rtwysiwyg-toolbar-leftside'));
|
|
|
|
createEscape(toolbar.find('.rtwysiwyg-toolbar-leftside'));
|
|
|
|
var userListElement = createUserList(toolbar.find('.rtwysiwyg-toolbar-leftside'));
|
|
|
|
var userListElement = createUserList(toolbar.find('.rtwysiwyg-toolbar-leftside'));
|
|
|
|
var spinner = createSpinner(toolbar.find('.rtwysiwyg-toolbar-rightside'));
|
|
|
|
var spinner = createSpinner(toolbar.find('.rtwysiwyg-toolbar-rightside'));
|
|
|
|
var lagElement = createLagElement(toolbar.find('.rtwysiwyg-toolbar-rightside'));
|
|
|
|
var lagElement = createLagElement(toolbar.find('.rtwysiwyg-toolbar-rightside'));
|
|
|
|
|
|
|
|
var userData = config.userData;
|
|
|
|
|
|
|
|
var changeNameID = config.changeNameID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the suer is allowed to change his name
|
|
|
|
|
|
|
|
if(changeNameID) {
|
|
|
|
|
|
|
|
// Create the button and update the element containing the user list
|
|
|
|
|
|
|
|
userListElement = createChangeName($container, userListElement, changeNameID);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rememberPad();
|
|
|
|
rememberPad();
|
|
|
|
|
|
|
|
|
|
|
|
var connected = false;
|
|
|
|
var connected = false;
|
|
|
|
|
|
|
|
|
|
|
|
userList.onChange = function() {
|
|
|
|
userList.onChange = function(newUserData) {
|
|
|
|
var users = userList.users;
|
|
|
|
var users = userList.users;
|
|
|
|
if (users.indexOf(myUserName) !== -1) { connected = true; }
|
|
|
|
if (users.indexOf(myUserName) !== -1) { connected = true; }
|
|
|
|
if (!connected) { return; }
|
|
|
|
if (!connected) { return; }
|
|
|
|
updateUserList(myUserName, userListElement, users);
|
|
|
|
if(newUserData) { // Someone has changed his name/color
|
|
|
|
|
|
|
|
userData = newUserData;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
updateUserList(myUserName, userListElement, users, userData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var ks = function () {
|
|
|
|
var ks = function () {
|
|
|
|