diff --git a/i18n/de.json b/i18n/de.json index d99672c0..74124869 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -80,6 +80,10 @@ ["Dieses Dokument läuft in einem Monat ab.", "Dieses Dokument läuft in %d Monaten ab."], "Please enter the password for this paste:": "Bitte gib das Passwort für diesen Text ein:", + "Decrypt": + "Entschlüsseln", + "Enter password": + "Passwort eingeben", "Could not decrypt data (Wrong key?)": "Konnte Daten nicht entschlüsseln (Falscher Schlüssel?)", "Could not delete the paste, it was not stored in burn after reading mode.": diff --git a/js/privatebin.js b/js/privatebin.js index faf09602..740ea1a5 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -618,16 +618,7 @@ $(function() { */ requestPassword: function() { - var password = prompt(i18n._('Please enter the password for this paste:'), ''); - if (password === null) - { - throw 'password prompt canceled'; - } - if (password.length === 0) - { - return this.requestPassword(); - } - return password; + $("#passwordModal").modal(); }, /** @@ -705,7 +696,7 @@ $(function() { { if (password.length === 0) { - password = this.requestPassword(); + return this.requestPassword(); } attachment = filter.decipher(key, password, paste.attachment); } @@ -740,8 +731,7 @@ $(function() { var cleartext = filter.decipher(key, password, paste.data); if (cleartext.length === 0 && password.length === 0 && !paste.attachment) { - password = this.requestPassword(); - cleartext = filter.decipher(key, password, paste.data); + return this.requestPassword(); } if (cleartext.length === 0 && !paste.attachment) { @@ -1579,6 +1569,23 @@ $(function() { // Show proper elements on screen. this.stateExistingPaste(); + { + // This part of code handles modal password request on decryption + // Inside of event handler, "this" is something different... so we have to save it + var self = this; + $("#passwordModal").on('shown.bs.modal', function() { + $("#decryptPassword").focus(); + }); + $("#passwordForm").submit(function(){ + $("#passwordModal").modal("hide"); + return false; + }); + $("#passwordModal").on("hidden.bs.modal", function(){ + self.passwordInput.val($("#decryptPassword").val()); + self.displayMessages(self.pageKey(), data); + }); + } + this.displayMessages(this.pageKey(), data); } // Display error message from php code. diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 5778ba5c..a778ced0 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -52,7 +52,7 @@ if ($MARKDOWN): - + @@ -66,7 +66,25 @@ endif; -