diff --git a/www/code/main.js b/www/code/main.js index 9841f4511..c9727e1ac 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -151,6 +151,7 @@ define([ var onLocal = config.onLocal = function () { if (initializing) { return; } + if (readOnly) { return; } editor.save(); var textValue = canonicalize($textarea.val()); diff --git a/www/poll/index.html b/www/poll/index.html index 9981f28b8..fd8fe0dab 100644 --- a/www/poll/index.html +++ b/www/poll/index.html @@ -40,7 +40,7 @@
-

CryptPoll

+

CryptPoll

@@ -53,7 +53,7 @@
-

+

diff --git a/www/poll/main.js b/www/poll/main.js index 3ef0292e7..026f25e26 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -39,6 +39,14 @@ define([ */ var secret = Cryptpad.getSecrets(); + var readOnly = secret.keys && !secret.keys.editKeyStr; + if (!secret.keys) { + secret.keys = secret.key; + } + if (readOnly) { + $('#mainTitle').html($('#mainTitle').html() + ' - ' + Messages.readonly); + $('#adduser, #addoption, #howToUse').remove(); + } var module = window.APP = { Cryptpad: Cryptpad, @@ -139,6 +147,7 @@ define([ var table = module.table = Table($('#table'), xy); var setEditable = function (bool) { + if (readOnly && bool) { return; } module.isEditable = bool; items.forEach(function ($item) { @@ -163,6 +172,7 @@ define([ }; var removeRow = function (proxy, uid) { + if (readOnly) { return; } // remove proxy.table.rows[uid] proxy.table.rows[uid] = undefined; @@ -186,6 +196,7 @@ define([ }; var removeColumn = function (proxy, uid) { + if (readOnly) { return; } // remove proxy.table.cols[uid] proxy.table.cols[uid] = undefined; delete proxy.table.rows[uid]; @@ -212,6 +223,7 @@ define([ }; var makeUserEditable = module.makeUserEditable = function (id, bool) { + if (readOnly) { return; } var $name = $('input[type="text"][id="' + id + '"]').attr('disabled', !bool); var $edit = $name.parent().find('.edit'); @@ -289,6 +301,11 @@ define([ }); }); + if (readOnly) { + $edit = ''; + $remove = ''; + } + var $wrapper = $('
', { 'class': 'text-cell', }) @@ -313,6 +330,7 @@ define([ }; var makeOptionEditable = function (id, bool) { + if (readOnly) { return; } if (bool) { module.rt.proxy.table.rowsOrder.forEach(function (rowuid) { $('#' + rowuid) @@ -363,6 +381,11 @@ define([ }); }); + if (readOnly) { + $edit = ''; + $remove = ''; + } + var $wrapper = $('
', { 'class': 'text-cell', }) @@ -715,16 +738,33 @@ define([ }); })); - $toolbar.append(Button({ - id: 'wizard', - 'class': 'wizard button action', - title: Messages.wizardTitle, - }).text(Messages.wizardButton).click(function () { - Wizard.show(); - if (Wizard.hasBeenDisplayed) { return; } - Cryptpad.log(Messages.wizardLog); - Wizard.hasBeenDisplayed = true; - })); + if (!readOnly) { + $toolbar.append(Button({ + id: 'wizard', + 'class': 'wizard button action', + title: Messages.wizardTitle, + }).text(Messages.wizardButton).click(function () { + Wizard.show(); + if (Wizard.hasBeenDisplayed) { return; } + Cryptpad.log(Messages.wizardLog); + Wizard.hasBeenDisplayed = true; + })); + } + + if (!readOnly && module.viewHash) { + /* add a 'links' button */ + var $links = $('