Improve the UI in read-only mode

pull/1/head
yflory 8 years ago
parent 202925302e
commit 83705ae058

@ -65,10 +65,9 @@ define(function () {
out.commitButton = 'VALIDER';
out.linksButton = 'LIENS';
out.linksButtonTitle = 'Obtenir les liens disponibles pour accéder à ce document';
out.readonlyUrl = 'Lien de lecture seule';
out.editUrl = "Lien d'édition";
out.getViewButton = 'LECTURE SEULE';
out.getViewButtonTitle = "Obtenir l'adresse d'accès à ce document en lecture seule";
out.readonlyUrl = 'URL de lecture seule';
out.disconnectAlert = 'Perte de la connexion au réseau !';

@ -64,11 +64,10 @@ define(function () {
out.presentSuccess = 'Hit ESC to exit presentation mode';
out.commitButton = 'COMMIT';
out.linksButton = 'LINKS';
out.linksButtonTitle = 'Get the available links for this document';
out.getViewButton = 'READ-ONLY URL';
out.getViewButtonTitle = 'Get the read-only URL for this document';
out.readonlyUrl = 'Read only URL';
out.editUrl = 'Edit URL';
out.disconnectAlert = 'Network connection lost!';

@ -39,7 +39,10 @@ define([
toolbar;
var secret = Cryptpad.getSecrets();
var readOnly = !secret.keys.editKeyStr;
var readOnly = secret.keys && !secret.keys.editKeyStr;
if (!secret.keys) {
secret.keys = secret.key;
}
var andThen = function (CMeditor) {
var CodeMirror = module.CodeMirror = CMeditor;
@ -398,21 +401,20 @@ define([
});
$rightside.append($forgetPad);
/* add a 'links' button */
var $links = $('<button>', {
title: Messages.linksButtonTitle
})
.text(Messages.linksButton)
.addClass('rightside-button')
.click(function () {
var baseUrl = window.location.origin + window.location.pathname + '#';
var content = '<b>' + Messages.readonlyUrl + '</b> : <a target="_blank">' + baseUrl + viewHash + '</a>';
if (!readOnly) {
content += '<br><b>' + Messages.editUrl + '</b> : <a target="_blank">' + baseUrl + editHash + '</a>';
}
Cryptpad.alert(content);
});
$rightside.append($links);
if (!readOnly && viewHash) {
/* add a 'links' button */
var $links = $('<button>', {
title: Messages.getViewButtonTitle
})
.text(Messages.getViewButton)
.addClass('rightside-button')
.click(function () {
var baseUrl = window.location.origin + window.location.pathname + '#';
var content = '<b>' + Messages.readonlyUrl + '</b><br><a target="_blank">' + baseUrl + viewHash + '</a><br>';
Cryptpad.alert(content);
});
$rightside.append($links);
}
var configureLanguage = function (cb) {
// FIXME this is async so make it happen as early as possible

@ -139,11 +139,14 @@ define([
var getEditHashFromKeys = common.getEditHashFromKeys = function (chanKey, keys) {
if (typeof keys === 'string') {
return chanKey + Crypto.b64RemoveSlashes(keys);
return chanKey + keys;
}
return '/1/edit/' + hexToBase64(chanKey) + '/' + Crypto.b64RemoveSlashes(keys.editKeyStr);
};
var getViewHashFromKeys = common.getViewHashFromKeys = function (chanKey, keys) {
if (typeof keys === 'string') {
return;
}
return '/1/view/' + hexToBase64(chanKey) + '/' + Crypto.b64RemoveSlashes(keys.viewKeyStr);
};
var getHashFromKeys = common.getHashFromKeys = getEditHashFromKeys;
@ -178,7 +181,7 @@ define([
var version = hashArray[1];
/*if (version === "1") {
secret.channel = base64ToHex(hashArray[2]);
secret.key = hashArray[3].replace(/-/g, '/'); //TODO replace / by -
secret.key = hashArray[3].replace(/-/g, '/');
if (secret.channel.length !== 32 || secret.key.length !== 24) {
common.alert("The channel key and/or the encryption key is invalid");
throw new Error("The channel key and/or the encryption key is invalid");

@ -65,7 +65,10 @@ define([
var andThen = function (Ckeditor) {
var secret = Cryptpad.getSecrets();
var readOnly = !secret.keys.editKeyStr;
var readOnly = secret.keys && !secret.keys.editKeyStr;
if (!secret.keys) {
secret.keys = secret.key;
}
var fixThings = false;
@ -566,21 +569,20 @@ define([
});
$rightside.append($forgetPad);
/* add a 'links' button */
var $links = $('<button>', {
title: Messages.linksButtonTitle
})
.text(Messages.linksButton)
.addClass('rightside-button')
.click(function () {
var baseUrl = window.location.origin + window.location.pathname + '#';
var content = '<b>' + Messages.readonlyUrl + '</b> : <a target="_blank">' + baseUrl + viewHash + '</a>';
if (!readOnly) {
content += '<br><b>' + Messages.editUrl + '</b> : <a target="_blank">' + baseUrl + editHash + '</a>';
}
Cryptpad.alert(content);
});
$rightside.append($links);
if (!readOnly && viewHash) {
/* add a 'links' button */
var $links = $('<button>', {
title: Messages.getViewButtonTitle
})
.text(Messages.getViewButton)
.addClass('rightside-button')
.click(function () {
var baseUrl = window.location.origin + window.location.pathname + '#';
var content = '<b>' + Messages.readonlyUrl + '</b><br><a target="_blank">' + baseUrl + viewHash + '</a><br>';
Cryptpad.alert(content);
});
$rightside.append($links);
}
// set the hash
if (!readOnly) {

Loading…
Cancel
Save