Skip to content

Commit 15ad001

Browse files
authored
Refactor Edit Web JS/remove jQuery (hestiacp#3513)
1 parent e09e3d6 commit 15ad001

40 files changed

+461
-411
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ module.exports = {
1919
es2021: true,
2020
},
2121
globals: {
22-
$: 'readonly',
23-
App: 'readonly',
2422
Hestia: 'readonly',
2523
Alpine: 'readonly',
2624
},

web/js/dist/main.min.js

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/js/dist/main.min.js.map

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/js/pages/edit_web.js

Lines changed: 0 additions & 277 deletions
This file was deleted.

web/js/pages/list_rrd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function getChartOptions(unit) {
8989
},
9090
y: {
9191
title: {
92-
display: !!unit,
92+
display: Boolean(unit),
9393
text: unit,
9494
color: labelColor,
9595
},

web/js/src/discardAllMail.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export default function handleDiscardAllMail() {
77
}
88

99
discardAllMailCheckbox.addEventListener('click', () => {
10-
const forwardToTextarea = document.getElementById('v_fwd');
11-
const doNotStoreCheckbox = document.getElementById('v_fwd_for');
10+
// TODO: Use .js- class instead of #id
11+
const forwardToTextarea = document.querySelector('#v_fwd');
12+
const doNotStoreCheckbox = document.querySelector('#v_fwd_for');
1213

1314
if (discardAllMailCheckbox.checked) {
1415
// Disable "Forward to" textarea

web/js/src/docRootHint.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { debounce } from './helpers';
2+
3+
// Handle "Custom document root -> Directory" hint on Edit Web Domain page
4+
export default function handleDocRootHint() {
5+
const domainSelect = document.querySelector('.js-custom-docroot-domain');
6+
const dirInput = document.querySelector('.js-custom-docroot-dir');
7+
const prepathHiddenInput = document.querySelector('.js-custom-docroot-prepath');
8+
const docRootHint = document.querySelector('.js-custom-docroot-hint');
9+
10+
if (!domainSelect || !dirInput || !prepathHiddenInput || !docRootHint) {
11+
return;
12+
}
13+
14+
// Set initial hint on page load
15+
updateDocRootHint();
16+
17+
// Add input listeners
18+
dirInput.addEventListener('input', debounce(updateDocRootHint));
19+
domainSelect.addEventListener('change', updateDocRootHint);
20+
21+
// Update hint value
22+
function updateDocRootHint() {
23+
const prepath = prepathHiddenInput.value;
24+
const domain = domainSelect.value;
25+
const folder = dirInput.value;
26+
27+
docRootHint.textContent = `${prepath}${domain}/public_html/${folder}`;
28+
}
29+
}

0 commit comments

Comments
 (0)