|
|
@ -176,7 +176,7 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var setName = module.setName = function (newName) {
|
|
|
|
var setName = module.setName = function (newName) {
|
|
|
|
if (!(typeof(newName) === 'string' && newName.trim())) { return; }
|
|
|
|
if (typeof(newName) !== 'string') { return; }
|
|
|
|
var myUserNameTemp = newName.trim();
|
|
|
|
var myUserNameTemp = newName.trim();
|
|
|
|
if(newName.trim().length > 32) {
|
|
|
|
if(newName.trim().length > 32) {
|
|
|
|
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
|
|
|
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
|
|
@ -202,18 +202,6 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var createChangeName = function(id, $container) {
|
|
|
|
|
|
|
|
var buttonElmt = $container.find('#'+id)[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getLastName(function (err, lastName) {
|
|
|
|
|
|
|
|
buttonElmt.addEventListener("click", function() {
|
|
|
|
|
|
|
|
Cryptpad.prompt(Messages.changeNamePrompt, lastName, function (newName) {
|
|
|
|
|
|
|
|
setName(newName);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getHeadingText = function () {
|
|
|
|
var getHeadingText = function () {
|
|
|
|
var lines = editor.getValue().split(/\n/);
|
|
|
|
var lines = editor.getValue().split(/\n/);
|
|
|
|
|
|
|
|
|
|
|
@ -283,12 +271,10 @@ define([
|
|
|
|
toolbarList = info.userList;
|
|
|
|
toolbarList = info.userList;
|
|
|
|
var config = {
|
|
|
|
var config = {
|
|
|
|
userData: userList,
|
|
|
|
userData: userList,
|
|
|
|
changeNameID: Toolbar.constants.changeName,
|
|
|
|
|
|
|
|
readOnly: readOnly
|
|
|
|
readOnly: readOnly
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (readOnly) {delete config.changeNameID; }
|
|
|
|
if (readOnly) {delete config.changeNameID; }
|
|
|
|
toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, info.userList, config);
|
|
|
|
toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, info.userList, config);
|
|
|
|
if (!readOnly) { createChangeName(Toolbar.constants.changeName, $bar); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
|
|
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
|
|
|
|
|
|
|
|
|
|
@ -299,22 +285,23 @@ define([
|
|
|
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
|
|
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getLastName(function (err, lastName) {
|
|
|
|
|
|
|
|
var $username = Cryptpad.createButton('username', true)
|
|
|
|
|
|
|
|
.click(function() {
|
|
|
|
|
|
|
|
Cryptpad.prompt(Messages.changeNamePrompt, lastName, function (newName) {
|
|
|
|
|
|
|
|
setName(newName);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$rightside.append($username);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/* add an export button */
|
|
|
|
/* add an export button */
|
|
|
|
var $export = $('<button>', {
|
|
|
|
var $export = Cryptpad.createButton('export', true).click(exportText);
|
|
|
|
title: Messages.exportButtonTitle,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.text(Messages.exportButton)
|
|
|
|
|
|
|
|
.addClass('rightside-button')
|
|
|
|
|
|
|
|
.click(exportText);
|
|
|
|
|
|
|
|
$rightside.append($export);
|
|
|
|
$rightside.append($export);
|
|
|
|
|
|
|
|
|
|
|
|
if (!readOnly) {
|
|
|
|
if (!readOnly) {
|
|
|
|
/* add an import button */
|
|
|
|
/* add an import button */
|
|
|
|
var $import = $('<button>',{
|
|
|
|
var $import = Cryptpad.createButton('import', true)
|
|
|
|
title: Messages.importButtonTitle
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.text(Messages.importButton)
|
|
|
|
|
|
|
|
.addClass('rightside-button')
|
|
|
|
|
|
|
|
.click(Cryptpad.importContent('text/plain', function (content, file) {
|
|
|
|
.click(Cryptpad.importContent('text/plain', function (content, file) {
|
|
|
|
var mode;
|
|
|
|
var mode;
|
|
|
|
var mime = CodeMirror.findModeByMIME(file.type);
|
|
|
|
var mime = CodeMirror.findModeByMIME(file.type);
|
|
|
@ -344,12 +331,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* add a rename button */
|
|
|
|
/* add a rename button */
|
|
|
|
var $setTitle = $('<button>', {
|
|
|
|
var $setTitle = Cryptpad.createButton('rename', true)
|
|
|
|
id: 'name-pad',
|
|
|
|
|
|
|
|
title: Messages.renameButtonTitle,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.addClass('rightside-button')
|
|
|
|
|
|
|
|
.text(Messages.renameButton)
|
|
|
|
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
var suggestion = suggestName();
|
|
|
|
var suggestion = suggestName();
|
|
|
|
|
|
|
|
|
|
|
@ -384,12 +366,7 @@ define([
|
|
|
|
$rightside.append($setTitle);
|
|
|
|
$rightside.append($setTitle);
|
|
|
|
|
|
|
|
|
|
|
|
/* add a forget button */
|
|
|
|
/* add a forget button */
|
|
|
|
var $forgetPad = $('<button>', {
|
|
|
|
var $forgetPad = Cryptpad.createButton('forget', true)
|
|
|
|
id: 'cryptpad-forget',
|
|
|
|
|
|
|
|
title: Messages.forgetButtonTitle,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.text(Messages.forgetButton)
|
|
|
|
|
|
|
|
.addClass('cryptpad-forget rightside-button')
|
|
|
|
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
var href = window.location.href;
|
|
|
|
var href = window.location.href;
|
|
|
|
Cryptpad.confirm(Messages.forgetPrompt, function (yes) {
|
|
|
|
Cryptpad.confirm(Messages.forgetPrompt, function (yes) {
|
|
|
@ -409,11 +386,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
if (!readOnly && viewHash) {
|
|
|
|
if (!readOnly && viewHash) {
|
|
|
|
/* add a 'links' button */
|
|
|
|
/* add a 'links' button */
|
|
|
|
var $links = $('<button>', {
|
|
|
|
var $links = Cryptpad.createButton('readonly', true)
|
|
|
|
title: Messages.getViewButtonTitle
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.text(Messages.getViewButton)
|
|
|
|
|
|
|
|
.addClass('rightside-button')
|
|
|
|
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
var baseUrl = window.location.origin + window.location.pathname + '#';
|
|
|
|
var baseUrl = window.location.origin + window.location.pathname + '#';
|
|
|
|
var content = '<b>' + Messages.readonlyUrl + '</b><br><a>' + baseUrl + viewHash + '</a><br>';
|
|
|
|
var content = '<b>' + Messages.readonlyUrl + '</b><br><a>' + baseUrl + viewHash + '</a><br>';
|
|
|
|