forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocRootHint.js
More file actions
29 lines (23 loc) · 1002 Bytes
/
docRootHint.js
File metadata and controls
29 lines (23 loc) · 1002 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
26
27
28
29
import { debounce } from './helpers';
// Handle "Custom document root -> Directory" hint on Edit Web Domain page
export default function handleDocRootHint() {
const domainSelect = document.querySelector('.js-custom-docroot-domain');
const dirInput = document.querySelector('.js-custom-docroot-dir');
const prepathHiddenInput = document.querySelector('.js-custom-docroot-prepath');
const docRootHint = document.querySelector('.js-custom-docroot-hint');
if (!domainSelect || !dirInput || !prepathHiddenInput || !docRootHint) {
return;
}
// Set initial hint on page load
updateDocRootHint();
// Add input listeners
dirInput.addEventListener('input', debounce(updateDocRootHint));
domainSelect.addEventListener('change', updateDocRootHint);
// Update hint value
function updateDocRootHint() {
const prepath = prepathHiddenInput.value;
const domain = domainSelect.value;
const folder = dirInput.value;
docRootHint.textContent = `${prepath}${domain}/public_html/${folder}`;
}
}