Skip to content

Commit ac16ee5

Browse files
authored
Refactor JS (hestiacp#3488)
- Refactor away jQuery from shortcuts JS and fix various issues - Refactor edit MySQL/NGINX/PHP "toggle advanced" JS - Improve password generating and strength checking JS - Change "VE" global to "Hestia" - Upgrade Alpine.js 3.10.5 -> 3.12.0
1 parent 392d23b commit ac16ee5

33 files changed

+466
-479
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"dependencies": {
2222
"@fortawesome/fontawesome-free": "^6.4.0",
2323
"chart.js": "^4.2.1",
24+
"check-password-strength": "^2.0.7",
2425
"nanoid": "^4.0.2",
2526
"normalize.css": "^8.0.1"
2627
},
@@ -30,12 +31,12 @@
3031
"@typescript-eslint/parser": "^5.59.0",
3132
"cssnano": "^6.0.0",
3233
"esbuild": "^0.17.17",
33-
"eslint": "^8.38.0",
34+
"eslint": "^8.39.0",
3435
"eslint-config-prettier": "^8.8.0",
3536
"eslint-plugin-editorconfig": "^4.0.2",
3637
"husky": "^8.0.3",
3738
"lint-staged": "^13.2.1",
38-
"markdownlint-cli2": "^0.6.0",
39+
"markdownlint-cli2": "^0.7.0",
3940
"postcss": "^8.4.23",
4041
"postcss-import": "^15.1.0",
4142
"postcss-path-replace": "^1.0.4",
@@ -48,7 +49,7 @@
4849
"stylelint": "^15.5.0",
4950
"stylelint-config-standard": "^33.0.0",
5051
"typescript": "^5.0.4",
51-
"vitepress": "1.0.0-alpha.72",
52+
"vitepress": "1.0.0-alpha.73",
5253
"vue": "^3.2.47"
5354
},
5455
"browserslist": [

web/css/src/themes/dark.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ strong {
387387
border-left: 2px solid #ff3478;
388388
}
389389

390-
.units.active .l-unit.focus {
390+
.units .l-unit.focus {
391391
background-color: #353535;
392392
}
393393

web/css/src/themes/default.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -969,16 +969,16 @@
969969
border-left: 2px solid #c36;
970970
}
971971

972-
.units.active .l-unit.focus {
972+
.units .l-unit.focus {
973973
border-left: 2px solid #5edad0;
974974
background-color: #eff5fc;
975975
}
976976

977-
.units.active .l-unit.focus .l-unit__name {
977+
.units .l-unit.focus .l-unit__name {
978978
color: #36b3a9;
979979
}
980980

981-
.units.active .l-unit.focus .l-unit-toolbar__col--right {
981+
.units .l-unit.focus .l-unit-toolbar__col--right {
982982
display: block;
983983
}
984984

@@ -1293,7 +1293,7 @@
12931293
display: none;
12941294
}
12951295

1296-
.units.active .l-unit.focus .l-unit-toolbar .shortcut {
1296+
.units .l-unit.focus .l-unit-toolbar .shortcut {
12971297
display: block;
12981298
background-color: #69a298;
12991299
border-radius: 13px;
@@ -1309,20 +1309,20 @@
13091309
top: 3px;
13101310
}
13111311

1312-
.units.active .l-unit.focus .l-unit-toolbar .shortcut.delete {
1312+
.units .l-unit.focus .l-unit-toolbar .shortcut.delete {
13131313
font-size: 10px;
13141314
padding-left: 2px;
13151315
padding-right: 5px;
13161316
text-transform: capitalize;
13171317
}
13181318

1319-
.units.active .l-unit.focus .l-unit-toolbar .shortcut.enter {
1319+
.units .l-unit.focus .l-unit-toolbar .shortcut.enter {
13201320
font-size: 17px;
13211321
padding-left: 1px;
13221322
padding-right: 7px;
13231323
}
13241324

1325-
.units.active .l-unit.focus .l-unit-toolbar i {
1325+
.units .l-unit.focus .l-unit-toolbar i {
13261326
background: none;
13271327
}
13281328

web/css/themes/dark.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/css/themes/default.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/js/dist/main.min.js

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/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/add_mail_acc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ $('#v_blackhole').on('click', function () {
99
}
1010
});
1111

12-
VE.helpers.monitorAndUpdate('.js-account-input', '.js-account-output');
13-
VE.helpers.monitorAndUpdate('.js-password-input', '.js-password-output');
12+
Hestia.helpers.monitorAndUpdate('.js-account-input', '.js-account-output');
13+
Hestia.helpers.monitorAndUpdate('.js-password-input', '.js-password-output');

web/js/pages/edit_mail_acc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ $('#v_blackhole').on('click', function () {
99
}
1010
});
1111

12-
VE.helpers.monitorAndUpdate('.js-account-input', '.js-account-output');
13-
VE.helpers.monitorAndUpdate('.js-password-input', '.js-password-output');
12+
Hestia.helpers.monitorAndUpdate('.js-account-input', '.js-account-output');
13+
Hestia.helpers.monitorAndUpdate('.js-password-input', '.js-password-output');

web/js/pages/edit_server_mysql.js

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
1-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2-
function toggleOptions() {
3-
if ($('#advanced-options').is(':visible')) {
4-
$('#advanced-options').hide();
5-
$('#basic-options').show();
6-
} else {
7-
$('#advanced-options').show();
8-
$('#basic-options').hide();
9-
10-
var advance_options = $('#advanced-options textarea');
11-
12-
$('#vstobjects input[type=text]').each(function (i, elm) {
13-
var search = $(elm).attr('regexp');
14-
var prev_value = $(elm).attr('prev_value');
15-
$(elm).attr('prev_value', $(elm).val());
16-
var regexp = new RegExp('^(' + search + ')(.+)(' + prev_value + ')', 'm');
17-
advance_options.val(advance_options.val().replace(regexp, '$1$2' + $(elm).val()));
18-
});
19-
}
20-
}
21-
22-
$('#vstobjects').submit(function () {
23-
if ($('#basic-options').is(':visible')) {
24-
var advance_options = $('#advanced-options textarea');
25-
26-
$('#vstobjects input[type=text]').each(function (i, elm) {
27-
var search = $(elm).attr('regexp');
28-
var prev_value = $(elm).attr('prev_value');
29-
$(elm).attr('prev_value', $(elm).val());
30-
var regexp = new RegExp('^(' + search + ')(.+)(' + prev_value + ')', 'm');
31-
advance_options.val(advance_options.val().replace(regexp, '$1$2' + $(elm).val()));
32-
});
1+
// Listen to form submit and update textarea if basic options are visible
2+
document.querySelector('#vstobjects').addEventListener('submit', () => {
3+
const basicOptionsWrapper = document.querySelector('.js-basic-options');
4+
if (!basicOptionsWrapper.classList.contains('u-hidden')) {
5+
const advancedTextarea = document.querySelector('.js-advanced-textarea');
6+
const textInputs = document.querySelectorAll('#vstobjects input[type=text]');
7+
Hestia.helpers.updateTextareaWithInputValues(textInputs, advancedTextarea);
338
}
349
});

0 commit comments

Comments
 (0)