define([ 'jquery', '/common/cryptpad-common.js', '/common/cryptget.js', '/common/mergeDrive.js', '/common/toolbar2.js', '/bower_components/file-saver/FileSaver.min.js', 'less!/customize/src/less/cryptpad.less', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'less!/customize/src/less/toolbar.less', 'less!/settings/main.less', ], function ($, Cryptpad, Crypt, Merge, Toolbar) { var saveAs = window.saveAs; var USERNAME_KEY = 'cryptpad.username'; var APP = window.APP = { Cryptpad: Cryptpad, _onRefresh: [] }; 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(); }); }; var categories = { 'account': [ 'infoBlock', 'displayName', 'languageSelector', 'logoutEverywhere', 'resetTips', 'userFeedback' ], 'drive': [ 'backupDrive', 'importLocalPads', 'resetDrive' ], 'code': [ 'indentUnit', ] }; var createInfoBlock = function (store) { var obj = store.proxy; var $div = $('
', {'class': 'infoBlock'}); var $account = $('
', {'class': 'element'}).appendTo($div); 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); } $account.append($label).append($name); var publicKey = obj.edPublic; if (publicKey) { var $key = $('
', {'class': 'element'}).appendTo($div); var userHref = Cryptpad.getUserHrefFromKeys(accountName, publicKey); var $pubLabel = $('', {'class': 'label'}) .text(Messages.settings_publicSigningKey); var $pubKey = $('', {type: 'text', readonly: true}) .val(userHref); $key.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 element'}); $('