Merge branch 'rememberName' of github.com:xwiki-labs/cryptpad into rememberName

pull/1/head
ansuz 8 years ago
commit ed9acf1c00

@ -60,14 +60,6 @@
margin-right: 5px;
padding-left: 5px;
}
.cryptpad-changeName {
float: left;
cursor: pointer;
}
.cryptpad-changeName button {
padding: 0;
margin-right: 5px;
}
.cryptpad-toolbar-leftside {
float: left;
}
@ -88,3 +80,6 @@
font-weight: bold;
text-transform: uppercase;
}
.cryptpad-toolbar-username {
font-style: italic;
};

@ -186,7 +186,7 @@ define([
name: myUserName
};
addToUserList(myData);
Cryptpad.setPadAttribute('username', myUserName, function (err, data) {
Cryptpad.setAttribute('username', myUserName, function (err, data) {
if (err) {
console.log("Couldn't set username");
console.error(err);
@ -197,7 +197,7 @@ define([
};
var getLastName = function (cb) {
Cryptpad.getPadAttribute('username', function (err, userName) {
Cryptpad.getAttribute('username', function (err, userName) {
cb(err, userName || '');
});
};

@ -318,6 +318,12 @@ define([
cb(err, data);
});
};
var setAttribute = common.setAttribute = function (attr, value, cb, legacy) {
getStore(legacy).set(["cryptpad", attr].join('.'), value, function (err, data) {
cb(err, data);
});
};
// STORAGE
var getPadAttribute = common.getPadAttribute = function (attr, cb, legacy) {
@ -325,6 +331,12 @@ define([
cb(err, data);
});
};
var getAttribute = common.getAttribute = function (attr, cb, legacy) {
getStore(legacy).get(["cryptpad", attr].join('.'), function (err, data) {
cb(err, data);
});
};
// STORAGE
/* fetch and migrate your pad history from localStorage */

@ -27,6 +27,9 @@ define([
var SPINNER_CLS = Bar.constants.spinner = 'cryptpad-spinner';
var USERNAME_CLS = Bar.constants.username = 'cryptpad-toolbar-username';
var READONLY_CLS = Bar.constants.readonly = 'cryptpad-readonly';
/** Key in the localStore which indicates realtime activity should be disallowed. */
// TODO remove? will never be used in cryptpad
var LOCALSTORAGE_DISALLOW = Bar.constants.localstorageDisallow = 'cryptpad-disallow';
@ -121,16 +124,16 @@ define([
return (i > 0) ? list.slice(0, -2) : list;
};
var createChangeName = function($container, userList, buttonID) {
var createChangeName = function($container, buttonID) {
var $span = $('<span>', {
id: uid(),
});
var $button = $('<button>', {
id: buttonID,
'class': USERNAME_BUTTON_GROUP,
'class': 'rightside-button',
}).text(Messages.changeNameButton);
$(userList).append($button);
$container.append($button);
$button.after($span);
return $span[0];
};
@ -157,7 +160,7 @@ define([
var innerHTML;
var numberOfViewUsers = numberOfUsers - userList.length;
if (readOnly === 1) {
innerHTML = '<span class="cryptpad-readonly">' + Messages.readonly + '</span>';
innerHTML = '<span class="' + READONLY_CLS + '">' + Messages.readonly + '</span>';
if (userList.length === 0) {
innerHTML += Messages.nobodyIsEditing;
} else if (userList.length === 1) {
@ -178,6 +181,9 @@ define([
}
}
innerHTML += getViewers(numberOfViewUsers);
if (userData[myUserName] && userData[myUserName].name) {
innerHTML = '<span class="' + USERNAME_CLS + '">' + userData[myUserName].name + '</span> | ' + innerHTML;
}
listElement.innerHTML = innerHTML;
};
@ -226,7 +232,8 @@ define([
// Check if the user is allowed to change his name
if(changeNameID) {
// Create the button and update the element containing the user list
userListElement = createChangeName($container, userListElement, changeNameID);
//userListElement = createChangeName($container, userListElement, changeNameID);
createChangeName(toolbar.find('.' + RIGHTSIDE_CLS), changeNameID);
}
var connected = false;

@ -269,7 +269,7 @@ define([
};
var getLastName = function (cb) {
Cryptpad.getPadAttribute('username', function (err, userName) {
Cryptpad.getAttribute('username', function (err, userName) {
cb(err, userName || '');
});
};
@ -287,7 +287,7 @@ define([
addToUserList(myData);
editor.fire('change');
Cryptpad.setPadAttribute('username', newName, function (err, data) {
Cryptpad.setAttribute('username', newName, function (err, data) {
if (err) {
console.error("Couldn't set username");
}

Loading…
Cancel
Save