adding functionality to forget pastes in memory

This commit is contained in:
El RIDO 2020-07-10 21:18:04 +02:00
parent 2b9abb8db4
commit 85943a9ce1
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
3 changed files with 30 additions and 3 deletions

View file

@ -4470,7 +4470,8 @@ jQuery.PrivateBin = (function($, RawDeflate) {
let cell = document.createElement('td');
let input = document.createElement('input');
input.setAttribute('type', 'checkbox');
input.setAttribute('name', 'memoryselect-' + paste.pasteid);
input.setAttribute('name', 'memoryselect');
input.setAttribute('value', paste.pasteid);
cell.appendChild(input);
row.appendChild(cell);
@ -4545,6 +4546,27 @@ jQuery.PrivateBin = (function($, RawDeflate) {
}
updateCacheFromDb();
};
$('#forgetbutton').on('click', function(e) {
const memory = db.transaction('pastes', 'readwrite').objectStore('pastes');
for (const checkbox of document.getElementsByName('memoryselect')) {
if (checkbox.checked) {
const request = memory.delete(checkbox.value);
request.onsuccess = function(e) {
pastes = [];
$('#sidebar-wrapper table tbody').empty();
updateCacheFromDb();
}
}
}
});
$('#memoryselectall').on('click', function(e) {
const checkedState = document.getElementById('memoryselectall').checked;
for (const checkbox of document.getElementsByName('memoryselect')) {
checkbox.checked = checkedState;
}
});
$('#menu-toggle').on('click', function(e) {
$('main').toggleClass('toggled');

View file

@ -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-99ODgpO72fZEvwq2E1NnLbXDotlDRIbzzs7b1f/5lfsp8ncghFKyvhrxjgyv4Z/RIf0oiO0MQ45crOKRAHhOWg==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-nQ7uXojx+snSWAOLTI/kLNlNUL7w14Dm7Uy3hsgF5KQDUFjBb0Sbppg6RbsbjBtTvUnpkiNkK8YOFBTIPpxXZg==" crossorigin="anonymous"></script>
<!-- icon -->
<link rel="apple-touch-icon" href="<?php echo I18n::encode($BASEPATH); ?>img/apple-touch-icon.png" sizes="180x180" />
<link rel="icon" type="image/png" href="img/favicon-32x32.png" sizes="32x32" />
@ -466,6 +466,11 @@ endif;
<tbody>
</tbody>
</table>
<p>
<button id="forgetbutton" type="button" class="btn btn-danger navbar-btn">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <?php echo I18n::_('Forget'), PHP_EOL; ?>
</button>
</p>
</div>
<section class="container">
<?php

View file

@ -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-99ODgpO72fZEvwq2E1NnLbXDotlDRIbzzs7b1f/5lfsp8ncghFKyvhrxjgyv4Z/RIf0oiO0MQ45crOKRAHhOWg==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-nQ7uXojx+snSWAOLTI/kLNlNUL7w14Dm7Uy3hsgF5KQDUFjBb0Sbppg6RbsbjBtTvUnpkiNkK8YOFBTIPpxXZg==" 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" />