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
|
* @name Helper.reset
|
||||||
* @function
|
* @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;
|
return me;
|
||||||
|
@ -4389,8 +4390,8 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
me.add = function(pasteUrl)
|
me.add = function(pasteUrl)
|
||||||
{
|
{
|
||||||
const url = new URL(pasteUrl);
|
const url = new URL(pasteUrl),
|
||||||
const newPaste = {
|
newPaste = {
|
||||||
'https': url.protocol == 'https:',
|
'https': url.protocol == 'https:',
|
||||||
'service': url.hostname + url.pathname,
|
'service': url.hostname + url.pathname,
|
||||||
'pasteid': url.search.replace(/^\?+/, ''),
|
'pasteid': url.search.replace(/^\?+/, ''),
|
||||||
|
@ -4407,14 +4408,33 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
if (!window.indexedDB || !db) {
|
if (!window.indexedDB || !db) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const memory = db.transaction('pastes', 'readwrite').objectStore('pastes');
|
const memory = db.transaction('pastes', 'readwrite').objectStore('pastes'),
|
||||||
const request = memory.add(newPaste);
|
request = memory.add(newPaste);
|
||||||
request.onsuccess = function(e) {
|
request.onsuccess = function(e) {
|
||||||
me.refreshList();
|
me.refreshList();
|
||||||
}
|
}
|
||||||
return true;
|
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
|
* refresh the state of the remember button
|
||||||
*
|
*
|
||||||
|
@ -4450,6 +4470,9 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
cell.textContent = paste.url;
|
cell.textContent = paste.url;
|
||||||
row.appendChild(cell);
|
row.appendChild(cell);
|
||||||
$tbody.appendChild(row);
|
$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/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/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 -->
|
<!-- icon -->
|
||||||
<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
|
<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" />
|
<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/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/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 -->
|
<!-- icon -->
|
||||||
<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
|
<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" />
|
<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