Update ajax handler + indicate status

This commit is contained in:
billz 2020-03-27 09:24:48 +00:00
parent 6299540216
commit ca7bde25c6
3 changed files with 21 additions and 3 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -49,7 +49,7 @@
<div class="row">
<div class="input-group col-md-12 mb-4">
<select class="custom-select custom-select-sm" id="cbxblocklist">
<select class="custom-select custom-select-sm" id="cbxblocklist" onchange="clearBlocklistStatus()">
<option value=""><?php echo _("Choose a blocklist provider") ?></option>
<option disabled="disabled"></option>
<?php echo optionsForSelect(blocklistProviders()) ?>