From 2d9666c5ef1e46454aa25ad1f16e9017da41d37e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 29 Jun 2020 21:22:27 +0200 Subject: [PATCH] refactor button refresh --- js/privatebin.js | 22 +++++++++++++++++----- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 49d1c9c3..3b66d58a 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -4374,9 +4374,6 @@ jQuery.PrivateBin = (function($, RawDeflate) { cursor.continue(); } else { me.refreshList(); - if (isInMemory(window.location.href)) { - $('#rememberbutton').addClass('disabled'); - } } }; } @@ -4413,11 +4410,25 @@ jQuery.PrivateBin = (function($, RawDeflate) { const request = memory.add(newPaste); request.onsuccess = function(e) { me.refreshList(); - $('#rememberbutton').addClass('disabled'); } return true; }; + /** + * refresh the state of the remember button + * + * @name Memory.refreshButton + * @function + */ + me.refreshButton = function() + { + if (isInMemory(window.location.href)) { + $('#rememberbutton').addClass('disabled'); + } else { + $('#rememberbutton').removeClass('disabled'); + } + }; + /** * refresh the displayed list from memory * @@ -4426,6 +4437,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { */ me.refreshList = function() { + me.refreshButton(); const $tbody = $('#sidebar-wrapper table tbody')[0]; if (!$tbody) { return; @@ -4800,7 +4812,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { // show new URL in browser bar history.pushState({type: 'newpaste'}, document.title, url); - $('#rememberbutton').removeClass('disabled'); + Memory.refreshButton(); TopNav.showViewButtons(); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 4a0a282f..f6eeb805 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 3d767cd7..1c040d2f 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ endif; ?> - +