Files
roi-theme/wp-content/plugins/wp-database-tools/admin/js/main-list-common.js
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

196 lines
5.5 KiB
JavaScript
Executable File

/**!
* wp-color-picker-alpha
*
* This file contains the logic that share the
* list generation between the options|tables|cronjobs
* and between general|details
*
* Version: 1.0.1
*/
/* -------------------------------------------------------------------------- */
/* PERSISTENT FILTERS */
/* -------------------------------------------------------------------------- */
$_GET_details = findGetParameter("details");
$_GET_category = findGetParameter("category");
$_GET_origin = findGetParameter("origin");
$_GET_status = findGetParameter("status");
$_GET_autoload = findGetParameter("autoload");
$_GET_name = findGetParameter("name");
$_GET_page = findGetParameter("page");
function findGetParameter(parameterName) {
var result = null,
tmp = [];
var items = location.search.substr(1).split("&");
for (var index = 0; index < items.length; index++) {
tmp = items[index].split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
}
return result;
}
/* -------------------------------------------------------------------------- */
/* FILTER BY NAME */
/* -------------------------------------------------------------------------- */
input_name.addEventListener(
"keyup",
debounce((e) => {
updateValue(e);
}, 320)
);
function debounce(callback, wait) {
let timeout;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(function () {
callback.apply(this, args);
}, wait);
};
}
function updateValue(e) {
filterAll();
}
/* -------------------------------------------------------------------------- */
/* COMMON FILTERS */
/* -------------------------------------------------------------------------- */
function filterSearchName(item) {
$_GET_name = input_name.value;
if (input_name.value == "") return true;
let search_result = item
.values()
["name"].toLowerCase()
.search($_GET_name.toLowerCase());
return search_result != -1;
}
/* -------------------------------------------------------------------------- */
/* HANDLE LOADER */
/* -------------------------------------------------------------------------- */
function handleLoader(is_loading) {
if (is_loading === true) {
content_list.style.display = "none";
loader.style.display = "block";
} else {
loader.style.display = "none";
content_list.style.display = "block";
}
if (list.visibleItems.length == 0) {
content_list_not_found.style.display = "block";
} else {
content_list_not_found.style.display = "none";
}
}
/* -------------------------------------------------------------------------- */
/* BUILD BACK URL */
/* -------------------------------------------------------------------------- */
function buildBackUrl() {
let available_parameters = [ "details", "name", "origin", "category", "status", "autoload"];
let back_url = window.location.origin + window.location.pathname;
back_url = back_url + '?page=' + $_GET_page;
available_parameters.forEach((element) => {
if(window['$_GET_' + element] != null ){
back_url = back_url + '&' + element + '=' + window['$_GET_' + element];
}
});
input_current_url.value = back_url;
}
/* -------------------------------------------------------------------------- */
/* SELECTORS */
/* -------------------------------------------------------------------------- */
function displaySelection() {
let selected = 0;
let list_items_check = list.get("check", true);
list_items_check.forEach(function (el) {
selected++;
});
span_selected.innerHTML = selected;
}
function resetCheck() {
let list_items_check = list.get("check", true);
list_items_check.forEach(function (el) {
el._values["check"] = false;
let input_select = document.querySelector(
"input[data-" + KEY_ATRIBUTE + '="' + el._values[KEY_ATRIBUTE] + '"]'
);
input_select.checked = false;
});
checkbox_all.checked = false;
// start methods only execute tables|options|cronjobs
updateMultipleUncategorized(list_items_check);
processSelectionsStatus();
// end methods only execute tables|options|cronjobs
displaySelection();
}
/* -------------------------------------------------------------------------- */
/* PAGINATION */
/* -------------------------------------------------------------------------- */
btn_first.addEventListener(
"click",
function (e) {
btn_first.dataset.i = 1;
btn_first.dataset.page = list.page;
},
false
);
btn_last.addEventListener(
"click",
function (e) {
let total = list.matchingItems.length;
let page = Math.ceil(total / list.page);
btn_last.dataset.i = page;
btn_last.dataset.page = list.page;
},
false
);
function updatePagination(pages) {
resetCheck();
list.page = pages;
list.update();
}
selectPagination.addEventListener("change", (event) => {
updatePagination(event.target.value);
});
document.querySelector("ul.pagination").addEventListener("click", (event) => {
resetCheck();
});
document.getElementById("btn-first").addEventListener("click", (event) => {
resetCheck();
});
document.getElementById("btn-last").addEventListener("click", (event) => {
resetCheck();
});