mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
allow switching to a memorized paste by clicking it
This commit is contained in:
parent
4e3348795c
commit
d027cb188d
|
@ -562,10 +562,11 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
*
|
||||
* @name Helper.reset
|
||||
* @function
|
||||
* @param {string} uri - (optional) URI to reset to
|
||||
*/
|
||||
me.reset = function()
|
||||
me.reset = function(uri)
|
||||
{
|
||||
baseUri = null;
|
||||
baseUri = typeof uri === 'string' ? uri : null;
|
||||
};
|
||||
|
||||
return me;
|
||||
|
@ -4389,16 +4390,16 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
*/
|
||||
me.add = function(pasteUrl)
|
||||
{
|
||||
const url = new URL(pasteUrl);
|
||||
const newPaste = {
|
||||
'https': url.protocol == 'https:',
|
||||
'service': url.hostname + url.pathname,
|
||||
'pasteid': url.search.replace(/^\?+/, ''),
|
||||
'key': url.hash.replace(/^#+/, ''),
|
||||
// we store the full URL as it may contain additonal information
|
||||
// required to open the paste, like port, username and password
|
||||
'url': pasteUrl
|
||||
};
|
||||
const url = new URL(pasteUrl),
|
||||
newPaste = {
|
||||
'https': url.protocol == 'https:',
|
||||
'service': url.hostname + url.pathname,
|
||||
'pasteid': url.search.replace(/^\?+/, ''),
|
||||
'key': url.hash.replace(/^#+/, ''),
|
||||
// we store the full URL as it may contain additonal information
|
||||
// required to open the paste, like port, username and password
|
||||
'url': pasteUrl
|
||||
};
|
||||
// don't add an already memorized paste
|
||||
if (isInMemory(pasteUrl)) {
|
||||
return false;
|
||||
|
@ -4407,14 +4408,33 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
if (!window.indexedDB || !db) {
|
||||
return false;
|
||||
}
|
||||
const memory = db.transaction('pastes', 'readwrite').objectStore('pastes');
|
||||
const request = memory.add(newPaste);
|
||||
const memory = db.transaction('pastes', 'readwrite').objectStore('pastes'),
|
||||
request = memory.add(newPaste);
|
||||
request.onsuccess = function(e) {
|
||||
me.refreshList();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* open a given paste URL using the current instance
|
||||
*
|
||||
* @name Memory.open
|
||||
* @function
|
||||
* @param {string} pasteUrl
|
||||
*/
|
||||
me.open = function(pasteUrl)
|
||||
{
|
||||
// parse URL
|
||||
const url = new URL(pasteUrl);
|
||||
const baseUri = Helper.baseUri();
|
||||
history.pushState({type: 'viewpaste'}, document.title, url.search + url.hash);
|
||||
Helper.reset(url.origin);
|
||||
Model.reset();
|
||||
PasteDecrypter.run();
|
||||
Helper.reset(baseUri);
|
||||
};
|
||||
|
||||
/**
|
||||
* refresh the state of the remember button
|
||||
*
|
||||
|
@ -4450,6 +4470,9 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
cell.textContent = paste.url;
|
||||
row.appendChild(cell);
|
||||
$tbody.appendChild(row);
|
||||
row.addEventListener('click', function () {
|
||||
me.open(paste.url);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ endif;
|
|||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-SZkPr3E6r0pExLw3xxKtJP6m5kGBSPd3zGhHlVzipEo+muVLaEoucdK6TyaAsxsk2dnwMVfitWfooXdSHeaBEg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-qSwODMjBG5A1mG2x18DCdjCSBjS9JSLaqKtnMQ+wIjJdsuY6Eb603N4Sw2PhN1uJHaL0fAXBg+KOp6t9/lvvfw==" crossorigin="anonymous"></script>
|
||||
<!-- icon -->
|
||||
<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
|
||||
<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
|
||||
|
|
|
@ -50,7 +50,7 @@ endif;
|
|||
?>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-SZkPr3E6r0pExLw3xxKtJP6m5kGBSPd3zGhHlVzipEo+muVLaEoucdK6TyaAsxsk2dnwMVfitWfooXdSHeaBEg==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-qSwODMjBG5A1mG2x18DCdjCSBjS9JSLaqKtnMQ+wIjJdsuY6Eb603N4Sw2PhN1uJHaL0fAXBg+KOp6t9/lvvfw==" crossorigin="anonymous"></script>
|
||||
<!-- icon -->
|
||||
<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
|
||||
<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user