mirror of
https://github.com/pi-hole/web.git
synced 2025-12-23 04:08:39 +00:00
Improve Javascript (allow toggling of deletion and highlight "Save and Update" button on deletion) and :codacy:
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -152,21 +152,21 @@ $(document).ready(function(){
|
||||
|
||||
// Handle list deletion
|
||||
$("button[id^='adlist-btn-']").on("click", function (e) {
|
||||
var idstring = $(this).context.id;
|
||||
var id = parseInt(idstring.replace(/[^0-9\.]/g, ''), 10);
|
||||
var id = parseInt($(this).context.id.replace(/[^0-9\.]/g, ""), 10);
|
||||
e.preventDefault();
|
||||
|
||||
var status = $("input[id='adlist-del-"+id+"']").is(":checked");
|
||||
var status = $("input[name=\"adlist-del-"+id+"\"]").is(":checked");
|
||||
var textType = status ? "none" : "line-through";
|
||||
console.log("idstring: "+idstring);
|
||||
console.log("id: "+id);
|
||||
console.log("status: "+status);
|
||||
console.log("textType: "+textType);
|
||||
|
||||
$("input[name='adlist-del-"+id+"']").prop("checked", !status);
|
||||
$("input[name='adlist-enable-"+id+"']").prop("disabled", !status);
|
||||
$("button[id='adlist-btn-"+id+"']").prop("disabled", true);
|
||||
$("a[id='adlist-text-"+id+"']").css("text-decoration", textType);
|
||||
// Check hidden delete box (or reset)
|
||||
$("input[name=\"adlist-del-"+id+"\"]").prop("checked", !status);
|
||||
// Untick and disable check box (or reset)
|
||||
$("input[name=\"adlist-enable-"+id+"\"]").prop("checked", status).prop("disabled", !status);
|
||||
// Strink through text (or reset)
|
||||
$("a[id=\"adlist-text-"+id+"\"]").css("text-decoration", textType);
|
||||
// Highlight that the button has to be clicked in order to make the change live
|
||||
$("button[id=\"blockinglistsaveupdate\"]").addClass("btn-danger").css("font-weight", "bold");
|
||||
|
||||
});
|
||||
|
||||
// Javascript to go to specified tab on save or hyperlink
|
||||
|
||||
Reference in New Issue
Block a user