From 79884e2400561e19ee9fdd8b5ffb8b054fadc419 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Sep 2016 17:12:46 +0200 Subject: [PATCH 1/2] Use the same username for all pads --- www/code/main.js | 4 ++-- www/common/cryptpad-common.js | 12 ++++++++++++ www/pad/main.js | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/www/code/main.js b/www/code/main.js index 684a813f1..6fffd26ec 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -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 || ''); }); }; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 125df6a79..3185f462c 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -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 */ diff --git a/www/pad/main.js b/www/pad/main.js index f104b4fc4..02a0e49f4 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -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"); } From d46bd1af5c130577a77504d9fc7efe08b204d6cd Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 22 Sep 2016 17:56:47 +0200 Subject: [PATCH 2/2] Improve the toolbar UI with the username displayed --- customize.dist/toolbar.css | 13 ++++--------- www/common/toolbar.js | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/customize.dist/toolbar.css b/customize.dist/toolbar.css index b03039473..587d45eaf 100644 --- a/customize.dist/toolbar.css +++ b/customize.dist/toolbar.css @@ -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; } @@ -87,4 +79,7 @@ margin-right: 20px; font-weight: bold; text-transform: uppercase; -} \ No newline at end of file +} +.cryptpad-toolbar-username { + font-style: italic; +}; diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 865529d78..b2be2f5ca 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -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 = $('', { id: uid(), }); var $button = $('