From 85943a9ce121f7f43508c24768b436e4bd399b02 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 10 Jul 2020 21:18:04 +0200 Subject: [PATCH] adding functionality to forget pastes in memory --- js/privatebin.js | 24 +++++++++++++++++++++++- tpl/bootstrap.php | 7 ++++++- tpl/page.php | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 87fe55f1..bb26c47f 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -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'); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 7ff0ba35..0d056c73 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + @@ -466,6 +466,11 @@ endif; +

+ +

- +