mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-05-02 14:36:08 -04:00
Make link clickable again
We need to emulate the click and manually trigger a reload if the hash is already shown in the URL.
This commit is contained in:
parent
366b61c32d
commit
c96dd0836b
4 changed files with 38 additions and 12 deletions
|
@ -1121,6 +1121,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
deleteUrl = helper.scriptLocation() + '?pasteid=' + data.id + '&deletetoken=' + data.deletetoken;
|
||||
controller.showStatus('');
|
||||
controller.errorMessage.addClass('hidden');
|
||||
// show new URL in browser bar
|
||||
history.pushState({type: 'newpaste'}, document.title, url);
|
||||
|
||||
$('#pastelink').html(
|
||||
|
@ -1129,6 +1130,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
url, url
|
||||
) + controller.shortenUrl(url)
|
||||
);
|
||||
// save newly created element
|
||||
controller.pasteUrl = $('#pasteurl');
|
||||
// and add click event
|
||||
controller.pasteUrl.click($.proxy(controller.pasteLinkClick, controller));
|
||||
|
||||
var shortenButton = $('#shortenbutton');
|
||||
if (shortenButton) {
|
||||
shortenButton.click($.proxy(controller.sendToShortener, controller));
|
||||
|
@ -1489,6 +1495,25 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Forces opening the paste if the link does not do this automatically.
|
||||
*
|
||||
* This is necessary as browsers will not reload the page when it is
|
||||
* already loaded (which is fake as it is set via history.pushState()).
|
||||
*
|
||||
* @name controller.pasteLinkClick
|
||||
* @function
|
||||
* @param {Event} event
|
||||
*/
|
||||
pasteLinkClick: function(event)
|
||||
{
|
||||
// check if location is (already) correctly shown in URL bar
|
||||
if (window.location.href === this.pasteUrl.attr('href')) {
|
||||
// if so we need to load link by reloading the site
|
||||
location.reload(true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* create a new paste
|
||||
*
|
||||
|
@ -1689,6 +1714,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
this.passwordForm = $('#passwordform');
|
||||
this.passwordDecrypt = $('#passworddecrypt');
|
||||
this.pasteResult = $('#pasteresult');
|
||||
// this.pasteUrl is saved in sendDataContinue() if/after it is
|
||||
// actually created
|
||||
this.prettyMessage = $('#prettymessage');
|
||||
this.prettyPrint = $('#prettyprint');
|
||||
this.preview = $('#preview');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue