| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/test20.chuangfenglink.xyz/wp-content/themes/woodmart/inc/admin/assets/js/ |
Upload File : |
/* global woodmartConfig, woodmartAdminModule */
function updateConditions(ruleRow) {
let dateTypeSelect = ruleRow.querySelector('.xts-condition-date-type select');
let removeRowBtn = ruleRow.querySelector('.xts-close .xts-remove-item');
dateTypeSelect.addEventListener( 'change', function(e) {
if ( 'single' === dateTypeSelect.value ) {
ruleRow.querySelector('.xts-condition-day-single').classList.remove('xts-hidden');
ruleRow.querySelector('.xts-condition-day-first').classList.add('xts-hidden');
ruleRow.querySelector('.xts-condition-day-last').classList.add('xts-hidden');
} else if ( 'period' === dateTypeSelect.value ) {
ruleRow.querySelector('.xts-condition-day-single').classList.add('xts-hidden');
ruleRow.querySelector('.xts-condition-empty').classList.add('xts-hidden');
ruleRow.querySelector('.xts-condition-day-first').classList.remove('xts-hidden');
ruleRow.querySelector('.xts-condition-day-last').classList.remove('xts-hidden');
}
let allFirstDayInputs = ruleRow.parentNode.querySelectorAll('.xts-table-controls:not(.xts-table-heading) .xts-condition-day-first:not(.xts-hidden)');
let allSingeDayInputs = ruleRow.parentNode.querySelectorAll('.xts-table-controls:not(.xts-table-heading) .xts-condition-day-single:not(.xts-hidden)');
if ( allFirstDayInputs.length > 0 ) {
allSingeDayInputs.forEach(function (singleDayRow) {
singleDayRow.parentNode.querySelector('.xts-condition-empty').classList.remove('xts-hidden');
});
} else {
allSingeDayInputs.forEach(function (singleDayRow) {
singleDayRow.parentNode.querySelector('.xts-condition-empty').classList.add('xts-hidden');
});
}
});
removeRowBtn.addEventListener( 'click', function(e) {
e.preventDefault();
let allFirstDayInputs = ruleRow.parentNode.querySelectorAll('.xts-table-controls:not(.xts-table-heading) .xts-condition-day-first:not(.xts-hidden)');
let allSingeDayInputs = ruleRow.parentNode.querySelectorAll('.xts-table-controls:not(.xts-table-heading) .xts-condition-day-single:not(.xts-hidden)');
let isSingleRow = this.closest('.xts-table-controls').querySelector('.xts-condition-day-single:not(.xts-hidden)');
if ( ! isSingleRow && allFirstDayInputs.length === 1 ) {
allSingeDayInputs.forEach(function (singleDayRow) {
singleDayRow.parentNode.querySelector('.xts-condition-empty').classList.add('xts-hidden');
});
}
});
}
function validate() {
let isValid = true;
let timetable = jQuery('.xts-timetable-control');
let ruleRows = document.querySelectorAll('.xts-timetable-control .xts-controls-wrapper > .xts-table-controls:not(.xts-table-heading)');
if (ruleRows.length === 0) {
woodmartAdminModule.woodmartAdmin.addNotice(timetable, 'warning', woodmartConfig.no_rows_msg);
isValid = false;
}
ruleRows.forEach((ruleRow) => {
let dateType = ruleRow.querySelector('select.xts-condition-date-type').value;
if (dateType === 'single') {
return;
}
let dayFirst = ruleRow.querySelector('.xts-condition-day-first input').value;
let dayLast = ruleRow.querySelector('.xts-condition-day-last input').value;
if ( ( ! dayFirst && dayLast ) || ( dayFirst && ! dayLast ) ) {
woodmartAdminModule.woodmartAdmin.addNotice(timetable, 'warning', woodmartConfig.empty_date_field_msg);
isValid = false;
}
if (new Date(dayFirst) > new Date(dayLast)) {
woodmartAdminModule.woodmartAdmin.addNotice(timetable, 'warning', woodmartConfig.invalid_date_order_msg);
isValid = false;
}
});
return isValid;
}
jQuery('#post:has(.xts-options)').on('submit', function(e){
if ( ! validate() ) {
e.preventDefault();
}
});
window.addEventListener('load', function() {
let ruleRows = document.querySelectorAll('.xts-timetable-control .xts-controls-wrapper > .xts-table-controls:not(.xts-table-heading)');
if ( ruleRows.length > 0 ) {
ruleRows.forEach(function(ruleRow) {
updateConditions(ruleRow);
});
}
});
document.addEventListener('click', function(event) {
if (event.target.closest('.xts-timetable-control .xts-add-row')) {
event.preventDefault();
let ruleRows = document.querySelectorAll('.xts-timetable-control .xts-controls-wrapper > .xts-table-controls:not(.xts-table-heading)');
let lastRow = ruleRows[ruleRows.length - 1];
if ( ruleRows.length > 0 ) {
updateConditions( lastRow );
}
if ( event.target.parentNode.parentNode.querySelectorAll('.xts-condition-day-first:not(.xts-hidden)').length > 0 ) {
lastRow.querySelector('.xts-condition-empty').classList.remove('xts-hidden');
}
}
});
jQuery(document).on('xts_select_with_table_control_row_removed', function( e, $control ) {
if ( ! $control.hasClass('xts-timetable-control') ) {
return;
}
let $row = $control.find('.xts-controls-wrapper > .xts-table-controls:not(.xts-table-heading)');
if (1 === $row.length ) {
updateConditions($row[0]);
}
});