From f957a1868fc99b7b4dc084d72bd254a205619e0e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 16 Aug 2016 09:51:36 +0200 Subject: [PATCH] push state to history when displaying raw text to allow use of back button, fixes #7 --- js/privatebin.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/privatebin.js b/js/privatebin.js index d8aa56e0..ad294afe 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -1240,6 +1240,12 @@ $(function() { event.preventDefault(); var paste = $('#pasteFormatter').val() === 'markdown' ? this.prettyPrint.text() : this.clearText.text(); + history.pushState( + null, document.title, this.scriptLocation() + '?' + + this.pasteID() + '#' + this.pageKey() + ); + // we use text/html instead of text/plain to avoid a bug when + // reloading the raw text view (it reverts to type text/html) var newDoc = document.open('text/html', 'replace'); newDoc.write('
' + paste + '
'); newDoc.close(); @@ -1256,7 +1262,7 @@ $(function() { this.stateNewPaste(); // Erase the id and the key in url - history.replaceState(document.title, document.title, this.scriptLocation()); + history.replaceState(null, document.title, this.scriptLocation()); this.showStatus('', false); if (this.attachmentLink.attr('href'))