forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcronGenerator.js
More file actions
25 lines (22 loc) · 810 Bytes
/
cronGenerator.js
File metadata and controls
25 lines (22 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copies values from cron generator fields to main cron fields when "Generate" is clicked
export default function handleCronGenerator() {
document.querySelectorAll('.js-generate-cron').forEach((button) => {
button.addEventListener('click', () => {
const fieldset = button.closest('fieldset');
const inputNames = ['min', 'hour', 'day', 'month', 'wday'];
inputNames.forEach((inputName) => {
const value = fieldset.querySelector(`[name=h_${inputName}]`).value;
const formInput = document.querySelector(`#main-form input[name=v_${inputName}]`);
formInput.value = value;
formInput.classList.add('highlighted');
formInput.addEventListener(
'transitionend',
() => {
formInput.classList.remove('highlighted');
},
{ once: true },
);
});
});
});
}