', {id: HEADER_ID}).appendTo(APP.$container);
+ addAvatar($header);
+ var $rightside = $('
', {id: HEADER_RIGHT_ID}).appendTo($header);
+ addDisplayName($rightside);
+ addLink($rightside);
+ addDescription(APP.$container);
+ addPublicKey(APP.$container);
+ APP.initialized = true;
+ }
+ };
+
+ var onInit = function () {
+
+ };
+
+ var onDisconnect = function () {};
+ var onChange = function () {};
+
+ var andThen = function (profileHash) {
+ var secret = Cryptpad.getSecrets('profile', profileHash);
+ var readOnly = APP.readOnly = secret.keys && !secret.keys.editKeyStr;
+ var listmapConfig = {
+ data: {},
+ websocketURL: Cryptpad.getWebsocketURL(),
+ channel: secret.channel,
+ readOnly: readOnly,
+ validateKey: secret.keys.validateKey || undefined,
+ crypto: Crypto.createEncryptor(secret.keys),
+ userName: 'profile',
+ logLevel: 1,
+ };
+ var lm = APP.lm = Listmap.create(listmapConfig);
+ lm.proxy.on('create', onInit)
+ .on('ready', onReady)
+ .on('disconnect', onDisconnect)
+ .on('change', [], onChange);
+ };
+
+ var getOrCreateProfile = function () {
+ var obj = Cryptpad.getStore().getProxy().proxy;
+ if (obj.profile && obj.profile.view && obj.profile.edit) {
+ return void andThen(obj.profile.edit);
+ }
+ // If the user doesn't have a public profile, ask him if he wants to create one
+ var todo = function () {
+ var secret = Cryptpad.getSecrets();
+ obj.profile = {};
+ var channel = Cryptpad.createChannelId();
+ obj.profile.edit = Cryptpad.getEditHashFromKeys(channel, secret.keys);
+ obj.profile.view = Cryptpad.getViewHashFromKeys(channel, secret.keys);
+ obj.profile.name = APP.rt.proxy[Cryptpad.displayNameKey] || '';
+ andThen(obj.profile.edit);
+ };
+
+ // TODO: if not logged in, display a register button here?
+ var $create = $('
', {id: CREATE_ID});
+ var $button = $('