define([ 'jquery', '/common/cryptpad-common.js', '/common/cryptget.js', '/common/mergeDrive.js', '/api/config', '/bower_components/file-saver/FileSaver.min.js', ], function ($, Cryptpad, Crypt, Merge, ApiConfig) { var saveAs = window.saveAs; var USERNAME_KEY = 'cryptpad.username'; var APP = window.APP = { Cryptpad: Cryptpad, _onRefresh: [] }; var $upgrade = $('#upgrade'); var showUpgrade = function (text) { if (ApiConfig.removeDonateButton) { return; } if (localStorage.plan) { return; } if (!text) { return; } $upgrade.text(text).show(); }; var Messages = Cryptpad.Messages; // Manage changes in the realtime object made from another page var onRefresh = function (h) { if (typeof(h) !== "function") { return; } if (APP._onRefresh.indexOf(h) !== -1) { return; } APP._onRefresh.push(h); }; var refresh = APP.refresh = function () { APP._onRefresh.forEach(function (h) { h(); }); }; // Title block var createTitle = function () { return $('

').text(Messages.settings_title); }; var createInfoBlock = function (store) { var obj = store.proxy; var $div = $('
', {'class': 'infoBlock'}); var accountName = obj.login_name || localStorage[Cryptpad.userNameKey]; var $label = $('', {'class': 'label'}).text(Messages.user_accountName + ':'); var $name = $('').text(accountName || ''); if (!accountName) { $label.text(''); $name.text(Messages.settings_anonymous); } $div.append($label).append($name); var publicKey = obj.edPublic; if (publicKey) { var userHref = Cryptpad.getUserHrefFromKeys(accountName, publicKey); var $pubLabel = $('', {'class': 'label'}) .text(Messages.settings_publicSigningKey + ':'); var $pubKey = $('', {type: 'text', readonly: true}) .css({ width: '28em' }) .val(userHref); $div.append('
').append($pubLabel).append($pubKey); } return $div; }; // Create the block containing the display name field var createDisplayNameInput = function (store) { var obj = store.proxy; var $div = $('
', {'class': 'displayName'}); $('