define([
'jquery',
'/common/cryptpad-common.js',
'/common/cryptget.js',
'/common/mergeDrive.js',
'/bower_components/file-saver/FileSaver.min.js',
'/customize/header.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!/settings/main.less',
], function ($, Cryptpad, Crypt, Merge) {
var saveAs = window.saveAs;
console.log("wut");
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();
});
};
// 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'});
$('