define([
'/common/cryptpad-common.js',
'/common/cryptget.js',
'/common/mergeDrive.js',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/jquery/dist/jquery.min.js',
], function (Cryptpad, Crypt, Merge) {
var $ = window.jQuery;
var saveAs = window.saveAs;
var USERNAME_KEY = 'cryptpad.username';
var APP = window.APP = {
Cryptpad: Cryptpad,
_onRefresh: []
};
var Messages = Cryptpad.Messages;
var redirectToMain = function () {
window.location.href = '/';
};
// 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);
return $div;
};
// Create the block containing the display name field
var createDisplayNameInput = function (store) {
var obj = store.proxy;
var $div = $('