';
} else {
resultDiv +=
'
';
}
// Loop through each field in the row
$.each(item, function (q, r) {
var id = q
.replace(" ", "_")
.replace(".", "_")
.toLowerCase();
var prefix = "";
var type = "";
var button_text = "";
var hidden = "no";
$.each(res.output, function (o, p) {
if (q == p.key) {
prefix = p.prefix;
type = p.type;
button_text = p.button_text;
if ("hide" in p) {
hidden = p.hide;
}
}
});
if (hidden == "yes") {
return;
}
if (type == "link_button") {
r =
'
' +
button_text +
"";
} else if (type == "whatsapp_button") {
r =
'
' +
button_text +
"";
} else if (type == "image") {
r =
'

';
}
resultDiv +=
'
';
resultDiv +=
'";
resultDiv +=
'
' +
prefix +
r +
"
";
resultDiv += "
";
});
// Close container div for this row
resultDiv += "
";
});
this_checker
.find(".dw-checker-result")
.find(".dw-checker-results")
.html(resultDiv);
} else if (res.settings.display == "standard-table") {
this_checker.find(".dw-checker-divider:nth-child(3)").hide();
resultDiv =
'
';
var header_color = res.settings.header;
var value_color = res.settings.value;
resultDiv += "";
$.each(res.output, function (header, value) {
var hidden = "no";
if ("hide" in value) {
hidden = value.hide;
}
if (hidden !== "yes") {
resultDiv += "| " + value.key + " | ";
}
});
resultDiv += "
";
resultDiv += "";
$.each(res.rows, function (index, item) {
resultData = item;
resultDiv += "";
$.each(item, function (q, r) {
var id = q
.replace(" ", "_")
.replace(".", "_")
.toLowerCase();
var prefix = "";
var type = "";
var button_text = "";
var hidden = "no";
$.each(res.output, function (o, p) {
if (q == p.key) {
prefix = p.prefix;
type = p.type;
button_text = p.button_text;
if ("hide" in p) {
hidden = p.hide;
}
}
});
if (hidden == "yes") {
return;
}
if (type == "link_button") {
r =
'' +
button_text +
"";
} else if (type == "whatsapp_button") {
r =
'' +
button_text +
"";
} else if (type == "image") {
r =
'
';
}
resultDiv +=
'' +
prefix +
r +
" | ";
});
resultDiv += "
";
});
resultDiv += "";
resultDiv += "
";
this_checker.next(".dw-checker-bottom-results").html(resultDiv);
var stdTable = this_checker
.next(".dw-checker-bottom-results")
.find("table.dw-checker-result-container");
if (stdTable.length && typeof stdTable.DataTable === "function") {
stdTable.DataTable({
paging: true,
pageLength: 10,
searching: false, // Hide search input
info: false, // Hide "Showing X of Y entries"
scrollX: false, // Disable horizontal scrolling by default
responsive: true,
autoWidth: true,
deferRender: true,
columnDefs: [
{
targets: "th",
className: "dt-left",
width: "auto",
},
{
targets: "td",
className: "dt-left",
width: "auto",
},
],
drawCallback: function () {
var api = this.api();
var tableObj = api.table();
if (!tableObj) {
return;
}
var containerEl = tableObj.container();
var tableWidth =
containerEl.clientWidth ||
containerEl.getBoundingClientRect().width;
var contentWidth = tableObj.node().scrollWidth;
if (contentWidth > tableWidth) {
containerEl.style.overflowX = "auto";
} else {
containerEl.style.overflowX = "hidden";
}
},
}).columns.adjust();
}
} else if (res.settings.display == "card") {
this_checker.find(".dw-checker-divider:nth-child(3)").hide();
$.each(res.rows, function (index, item) {
resultData = item;
resultDiv +=
`
`;
resultDiv +=
'
';
$.each(item, function (q, r) {
var id = q
.replace(" ", "_")
.replace(".", "_")
.toLowerCase();
var prefix = "";
var type = "";
var button_text = "";
var hidden = "no";
var bg_color = "#cccccc";
var text_color = "#000000";
$.each(res.output, function (o, p) {
if (q == p.key) {
prefix = p.prefix;
type = p.type;
button_text = p.button_text;
if ("hide" in p) {
hidden = p.hide;
}
if ("bg_color" in p) {
bg_color = p.bg_color;
}
if ("text_color" in p) {
text_color = p.text_color;
}
}
});
if (hidden == "yes") {
return;
}
if (type == "link_button") {
r =
'
' +
button_text +
"";
} else if (type == "whatsapp_button") {
r =
'
' +
button_text +
"";
} else if (type == "image") {
r =
'

';
}
resultDiv +=
`
` +
prefix +
r +
`
`;
});
resultDiv += "
";
this_checker
.next(".dw-checker-bottom-results")
.html(resultDiv);
});
}
}
},
error: function (xhr) {
$this.text($this.attr("data-btn-text")).prop("disabled", false);
handleAjaxError(xhr, $id);
}
});
}; // End of performSearch function
ensureCaptchaReady($id)
.then(function() {
performSearch();
})
.catch(function(err) {
console.error("Captcha refresh failed", err);
showSecurityError($id, checkerSecurity.i18n ? checkerSecurity.i18n.security_error : "Security validation failed.", false);
});
}
}
});
$(document).on("click", ".dw-checker-result-pagination-button", function (e) {
e.preventDefault();
var container = $(this).data("target-pagination");
var page = container - 1;
$(".dw-checker-result-pagination-button").removeClass("active");
$(this).addClass("active");
$(".dw-checker-result-container").hide();
$("[data-pagination=" + page + "]").show();
});
$(".back-button").on("click", function () {
var checker_id = $(this).data("checker");
$("#checker-" + checker_id)
.find(".dw-checker-result")
.hide();
$("#checker-" + checker_id)
.find(".dw-checker-result")
.find(".dw-checker-title")
.html("");
$("#checker-" + checker_id)
.find(".dw-checker-result")
.find(".dw-checker-description")
.html("");
$("#checker-" + checker_id)
.find(".dw-checker-result")
.find(".dw-checker-results")
.html("");
$("#checker-" + checker_id)
.find(".dw-checker-inputs")
.val("");
$("#checker-" + checker_id)
.find(".dw-checker-form")
.show();
$("#checker-" + checker_id)
.find(".dw-checker-divider")
.show();
});
// Frontend clear cache button handler
$(document).on("click", ".dw-checker-clear-cache-btn", function () {
var btn = $(this);
var checkerId = btn.data("checker");
var originalText = btn.html();
btn.prop("disabled", true).html('
' +
(checkerSecurity.i18n && checkerSecurity.i18n.refreshing ? checkerSecurity.i18n.refreshing : 'Refreshing...'));
$.ajax({
url: getAjaxUrl(),
type: "POST",
data: {
action: "checker_clear_cache",
checker_id: checkerId,
security: checkerSecurity.nonce
},
success: function (response) {
if (response.success) {
// Show success message briefly
btn.html('
' +
(response.data.message || 'Refreshed!'));
// Reset button after 2 seconds
setTimeout(function () {
btn.prop("disabled", false).html(originalText);
}, 2000);
} else {
btn.html('
Failed');
setTimeout(function () {
btn.prop("disabled", false).html(originalText);
}, 2000);
}
},
error: function () {
btn.html('
Error');
setTimeout(function () {
btn.prop("disabled", false).html(originalText);
}, 2000);
}
});
});
// Add CSS animation for spinning icon
if (!document.getElementById('dw-checker-spin-animation')) {
var style = document.createElement('style');
style.id = 'dw-checker-spin-animation';
style.textContent = '@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }';
document.head.appendChild(style);
}
});
// Image Lightbox Function
function openImageLightbox(img) {
var fullsizeUrl = img.getAttribute("data-fullsize");
var alt = img.getAttribute("alt");
// Create lightbox overlay
var lightbox = document.createElement("div");
lightbox.id = "dw-checker-lightbox";
lightbox.style.cssText =
"position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.9);z-index:99999;display:flex;align-items:center;justify-content:center;cursor:pointer;";
// Create image element
var lightboxImg = document.createElement("img");
lightboxImg.src = fullsizeUrl;
lightboxImg.alt = alt;
lightboxImg.style.cssText =
"max-width:90%;max-height:90%;object-fit:contain;";
// Create close button
var closeBtn = document.createElement("span");
closeBtn.innerHTML = "×";
closeBtn.style.cssText =
"position:absolute;top:20px;right:40px;color:#fff;font-size:40px;font-weight:bold;cursor:pointer;";
// Append elements
lightbox.appendChild(lightboxImg);
lightbox.appendChild(closeBtn);
document.body.appendChild(lightbox);
// Close on click
lightbox.onclick = function () {
document.body.removeChild(lightbox);
};
// Prevent image click from closing
lightboxImg.onclick = function (e) {
e.stopPropagation();
};
}