From ca7bde25c6501992276353e6dc856a104839e3e9 Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 27 Mar 2020 09:24:48 +0000 Subject: [PATCH] Update ajax handler + indicate status --- ajax/adblock/update_blocklist.php | 4 ++-- app/js/custom.js | 18 ++++++++++++++++++ templates/adblock.php | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ajax/adblock/update_blocklist.php b/ajax/adblock/update_blocklist.php index 40c87c95..4f5d2062 100644 --- a/ajax/adblock/update_blocklist.php +++ b/ajax/adblock/update_blocklist.php @@ -19,7 +19,7 @@ if (isset($_POST['blocklist_id'])) { $blocklist = $notracking_url . $file; exec("sudo /etc/raspap/adblock/update_blocklist.sh $blocklist $file $dnsmasq_config", $return); - - echo json_encode($return); + $jsonData = ['return'=>$return]; + echo json_encode($jsonData); } diff --git a/app/js/custom.js b/app/js/custom.js index 73adfa06..1fd5e6bf 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -291,6 +291,24 @@ function loadChannelSelect(selected) { }); } +/* Updates the selected ad blocklist + * Request is passed to an ajax handler to download the associated list + * + */ +function updateBlocklist() { + var blocklist_id = $('#cbxblocklist').val(); + if (blocklist_id == '') { return; } + $.post('ajax/adblock/update_blocklist.php',{ 'blocklist_id':blocklist_id },function(data){ + var jsonData = JSON.parse(data); + if (jsonData['return'] == '0') { + $('#cbxblocklist-status').removeClass('check-hidden').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700); + } + }) +} + +function clearBlocklistStatus() { + $('#cbxblocklist-status').addClass('check-hidden'); +} // Static Array method Array.range = (start, end) => Array.from({length: (end - start)}, (v, k) => k + start); diff --git a/templates/adblock.php b/templates/adblock.php index 64b61ea1..0b11f073 100755 --- a/templates/adblock.php +++ b/templates/adblock.php @@ -49,7 +49,7 @@
-