Skip to content

Commit 42d99ec

Browse files
Merge pull request #479 from Martinski4GitHub/dev
Fixes and Improvements
2 parents d956d2a + 4f0533b commit 42d99ec

File tree

1 file changed

+79
-69
lines changed

1 file changed

+79
-69
lines changed

MerlinAU.asp

Lines changed: 79 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<script language="JavaScript" type="text/javascript">
3030
3131
/**----------------------------**/
32-
/** Last Modified: 2025-May-11 **/
32+
/** Last Modified: 2025-Jun-01 **/
3333
/**----------------------------**/
3434
3535
// Separate variables for shared and AJAX settings //
@@ -869,7 +869,8 @@ function ShowLatestChangelog(e)
869869
'Click on "Cancel" button to stop and exit this dialog.</p>';
870870
871871
/* ----- build the modal once ----- */
872-
if (!$('#changelogModal').length) {
872+
if (!$('#changelogModal').length)
873+
{
873874
$('body').append(
874875
'<div id="changelogModal" style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;' +
875876
'background:rgba(0,0,0,0.8);z-index:10000;">' +
@@ -891,9 +892,10 @@ function ShowLatestChangelog(e)
891892
892893
/* ---------- NEW: arrow‑key scroll handler (bind once) ---------- */
893894
$(document).on('keydown', function (ev) {
894-
if (!$('#changelogModal').is(':visible')) return; // ignore if dialog not open
895-
const box = $('#changelogContent')[0]; // the scrollable div
896-
switch (ev.key) {
895+
if (!$('#changelogModal').is(':visible')) { return; }
896+
const box = $('#changelogContent')[0]; // the scrollable box //
897+
switch (ev.key)
898+
{
897899
case 'ArrowDown':
898900
box.scrollTop += 40;
899901
ev.preventDefault();
@@ -915,7 +917,9 @@ function ShowLatestChangelog(e)
915917
}
916918
});
917919
/* -------------------------------------------------------------- */
918-
} else {
920+
}
921+
else
922+
{
919923
$('#changelogData').html(loadingMessage);
920924
$('#closeChangelogModal').text("Cancel");
921925
}
@@ -933,7 +937,7 @@ function ShowLatestChangelog(e)
933937
934938
$.post('start_apply.htm', formData);
935939
936-
/* wait 8 s, then fetch the changelog */
940+
/* wait 8s, then fetch the changelog */
937941
const startTime = Date.now();
938942
setTimeout(function () {
939943
FetchChangelog(startTime);
@@ -943,7 +947,6 @@ function ShowLatestChangelog(e)
943947
return false;
944948
}
945949
946-
947950
// **Control "Approve/Block Changelog" Checkbox State** //
948951
function ToggleChangelogApproval (checkboxElem)
949952
{
@@ -1062,15 +1065,15 @@ function GetExternalCheckResults()
10621065
});
10631066
}
10641067
1065-
/**------------------------------------------**/
1066-
/** Modified by ExtremeFiretop [2025-May-22] **/
1067-
/**------------------------------------------**/
1068+
/**----------------------------------------**/
1069+
/** Modified by Martinski W. [2025-Jun-01] **/
1070+
/**----------------------------------------**/
10681071
// To support 'routerPassword' element //
10691072
const loginPassword =
10701073
{
10711074
minLen: 5, maxLen: 64, pswdLen: 0, pswdStr: '',
10721075
pswdInvalid: false, pswdVerified: false, pswdUnverified: false,
1073-
allBlankCharsRegExp: '^[ ]+$',
1076+
pswdFocus: false, allBlankCharsRegExp: '^[ ]+$',
10741077
10751078
ErrorMsg: function()
10761079
{
@@ -1085,7 +1088,7 @@ const loginPassword =
10851088
const excMaxLen = (this.maxLen + 1);
10861089
return (`${errStr} The string length must be less than ${excMaxLen} characters.`);
10871090
}
1088-
if (this.pswdStr.match (`${this.allBlankCharsRegExp}`) !== null)
1091+
if (this.pswdStr.match (this.allBlankCharsRegExp) !== null)
10891092
{ return (`${errStr} The string cannot be all blank spaces.`); }
10901093
if (this.pswdInvalid) { return loginPswdInvalidMsge; }
10911094
},
@@ -1102,7 +1105,7 @@ const loginPassword =
11021105
const excMaxLen = (this.maxLen + 1);
11031106
return (`${errStr}<br>The string length must be less than <b>${excMaxLen}</b> characters.</br>`);
11041107
}
1105-
if (this.pswdStr.match (`${this.allBlankCharsRegExp}`) !== null)
1108+
if (this.pswdStr.match (this.allBlankCharsRegExp) !== null)
11061109
{ return (`${errStr}<br>The string cannot be all blank spaces.<br>`); }
11071110
if (this.pswdInvalid) { return loginPswdInvalidHint; }
11081111
if (this.pswdVerified) { return loginPswdVerifiedMsg; }
@@ -1113,55 +1116,59 @@ const loginPassword =
11131116
const pswdStr = formField.value;
11141117
if (this.pswdStr !== pswdStr && eventID === 'onKEYUP')
11151118
{
1119+
this.pswdFocus = false;
11161120
this.pswdInvalid = false;
11171121
this.pswdVerified = false;
11181122
this.pswdUnverified = false;
11191123
}
11201124
this.pswdStr = pswdStr;
11211125
this.pswdLen = pswdStr.length;
1122-
if ( this.pswdInvalid ||
1123-
this.pswdLen < this.minLen || this.pswdLen > this.maxLen ||
1124-
this.pswdStr.match(this.allBlankCharsRegExp) !== null )
1126+
1127+
if (this.pswdLen < this.minLen || this.pswdLen > this.maxLen ||
1128+
this.pswdStr.match (this.allBlankCharsRegExp) !== null)
1129+
{ this.pswdFocus = true; return false; }
1130+
else if (this.pswdInvalid || this.pswdVerified || this.pswdUnverified)
11251131
{ return false; }
11261132
else
11271133
{ return true; }
11281134
}
11291135
};
11301136
1131-
/**------------------------------------------**/
1132-
/** Modified by ExtremeFiretop [2025-May-22] **/
1133-
/**------------------------------------------**/
1137+
/**----------------------------------------**/
1138+
/** Modified by Martinski W. [2025-Jun-01] **/
1139+
/**----------------------------------------**/
11341140
function ValidatePasswordString (formField, eventID)
11351141
{
1136-
// clear old server invalid flag as soon as they type
1137-
if (eventID === 'onKEYUP') { loginPassword.pswdInvalid = false; }
1138-
1139-
// if the server has already said “invalid,” keep it red
1140-
if (loginPassword.pswdInvalid)
1141-
{
1142-
formField.focus();
1143-
$(formField).addClass('Invalid');
1144-
$(formField).off('mouseover');
1145-
$(formField).on('mouseover',function(){return overlib(loginPassword.ErrorHint(),0,0);});
1146-
$(formField)[0].onmouseout = nd;
1147-
return false;
1148-
}
1149-
11501142
if (loginPassword.ValidateString(formField, eventID))
11511143
{
11521144
$(formField).removeClass('Invalid');
11531145
$(formField).off('mouseover');
11541146
return true;
11551147
}
1148+
1149+
let retStatus;
1150+
1151+
if (eventID === 'onSAVE')
1152+
{ loginPassword.pswdFocus = true; }
1153+
else if (eventID === 'onKEYUP')
1154+
{ loginPassword.pswdFocus = false; }
1155+
1156+
if (loginPassword.pswdVerified || loginPassword.pswdUnverified)
1157+
{ retStatus = true; }
11561158
else
1157-
{
1159+
{ /** Set focus and red box ONLY when INVALID **/
1160+
retStatus = false;
1161+
if (loginPassword.pswdFocus)
1162+
{ formField.focus(); }
1163+
else
1164+
{ formField.blur(); }
11581165
$(formField).addClass('Invalid');
1159-
formField.focus();
1160-
$(formField).off('mouseover');
1161-
$(formField).on('mouseover',function(){return overlib(loginPassword.ErrorHint(),0,0);});
1162-
$(formField)[0].onmouseout = nd;
1163-
return false;
11641166
}
1167+
1168+
/** Show tooltip message for ALL 3 statuses **/
1169+
$(formField).on('mouseover',function(){return overlib(loginPassword.ErrorHint(),0,0);});
1170+
$(formField)[0].onmouseout = nd;
1171+
return retStatus;
11651172
}
11661173
11671174
function togglePassword()
@@ -1469,9 +1476,9 @@ function ShowHintMsg (formField)
14691476
}
14701477
}
14711478
1472-
/**------------------------------------------**/
1473-
/** Modified by ExtremeFiretop [2025-May-22] **/
1474-
/**------------------------------------------**/
1479+
/**----------------------------------------**/
1480+
/** Modified by Martinski W. [2025-Jun-01] **/
1481+
/**----------------------------------------**/
14751482
function GetLoginPswdCheckStatus()
14761483
{
14771484
$.ajax({
@@ -1514,12 +1521,12 @@ function GetLoginPswdCheckStatus()
15141521
loginPassword.pswdUnverified = true;
15151522
break;
15161523
case 5: //Failure//
1517-
// mark invalid and only steal focus on real failure
1518-
loginPassword.pswdInvalid = true;
15191524
passwordFailed = true;
15201525
pswdStatusText = 'Status:\n' + loginPswdCheckMsgStr;
15211526
pswdStatusHint0 = loginPswdInvalidHint;
15221527
pswdStatusHint1 = loginPswdInvalidHint;
1528+
loginPassword.pswdInvalid = true;
1529+
loginPassword.pswdFocus = true;
15231530
break;
15241531
case 6: //Unknown//
15251532
pswdStatusText = 'Status:\n' + loginPswdCheckMsgStr;
@@ -1535,14 +1542,16 @@ function GetLoginPswdCheckStatus()
15351542
loginPswdHint = loginPswdHint.replace (/PswdSTATUS/, pswdStatusHint1);
15361543
15371544
pswdField = document.getElementById('routerPassword');
1538-
1539-
// only refocus when passwordFailed is true
1540-
if (passwordFailed)
1545+
if (passwordFailed || pswdVerified || pswdUnverified)
15411546
{
1542-
alert(`**ERROR**\n${loginPswdInvalidMsge}`);
1543-
$(pswdField).addClass('Invalid');
1544-
pswdField.focus();
1545-
$(pswdField).on('mouseover',function(){return overlib(loginPassword.ErrorHint(),0,0);});
1547+
if (passwordFailed)
1548+
{ /** Set focus and red box ONLY when INVALID **/
1549+
alert(`**ERROR**\n${loginPswdInvalidMsge}`);
1550+
pswdField.focus();
1551+
$(pswdField).addClass('Invalid');
1552+
}
1553+
/** Show tooltip message for ALL 3 statuses **/
1554+
$(pswdField).on('mouseover',function(){return overlib(pswdStatusHint0,0,0);});
15461555
$(pswdField)[0].onmouseout = nd;
15471556
}
15481557
else
@@ -1679,9 +1688,10 @@ function InitializeFields()
16791688
{ tailscaleVPNEnabled.checked = (custom_settings.Allow_Updates_OverVPN === 'ENABLED'); }
16801689
16811690
if (script_AutoUpdate_Check)
1682-
{ script_AutoUpdate_Check.checked = (custom_settings.Allow_Script_Auto_Update === 'ENABLED');
1691+
{
1692+
script_AutoUpdate_Check.checked = (custom_settings.Allow_Script_Auto_Update === 'ENABLED');
16831693
UpdateForceScriptCheckboxState(script_AutoUpdate_Check?.checked);
1684-
}
1694+
}
16851695
16861696
if (betaToReleaseUpdatesEnabled)
16871697
{ betaToReleaseUpdatesEnabled.checked = (custom_settings.FW_Allow_Beta_Production_Up === 'ENABLED'); }
@@ -2334,12 +2344,14 @@ function Uninstall()
23342344
/**---------------------------------------**/
23352345
/** Added by ExtremeFiretop [2025-May-18] **/
23362346
/**---------------------------------------**/
2337-
function UpdateForceScriptCheckboxState(autoUpdatesEnabled) {
2347+
function UpdateForceScriptCheckboxState (autoUpdatesEnabled)
2348+
{
23382349
const forceCB = document.getElementById('ForceScriptUpdateCheck');
2339-
if (!forceCB) return; // safety
2340-
forceCB.disabled = autoUpdatesEnabled; // gray‑out logic
2350+
if (!forceCB) { return; }
2351+
forceCB.disabled = autoUpdatesEnabled;
23412352
forceCB.style.opacity = autoUpdatesEnabled ? '0.5' : '1';
2342-
if (autoUpdatesEnabled) forceCB.checked = false; // clear if now disabled
2353+
// Clear "Force Script Update" if needed //
2354+
if (autoUpdatesEnabled) { forceCB.checked = false; }
23432355
}
23442356
23452357
/**------------------------------------------**/
@@ -2353,31 +2365,29 @@ function UpdateMerlinAUScript()
23532365
const forceScriptUpdateCheck = document.getElementById('ForceScriptUpdateCheck');
23542366
const autoUpdatesEnabled = document.getElementById('Script_AutoUpdate_Check')?.checked;
23552367
2356-
/* ----- build the appropriate confirmation text ----- */
23572368
let confirmText;
2358-
if (forceScriptUpdateCheck.checked) {
2359-
/* user explicitly wants to install right now */
2369+
if (forceScriptUpdateCheck.checked)
2370+
{ /* user explicitly wants to install right now */
23602371
confirmText = "INSTALL UPDATE:\n" +
23612372
"Install the latest available MerlinAU script update now, " +
23622373
"even if the version is already current.\n\nContinue?";
2363-
} else {
2364-
/* normal check – message depends on auto‑update setting */
2374+
}
2375+
else
2376+
{ /* normal check – message depends on auto‑update setting */
23652377
confirmText = "CHECK AND PROMPT:\n" +
23662378
"Check for a newer version of MerlinAU and prompt if found. " +
23672379
(autoUpdatesEnabled
2368-
? "It DOES install automatically!" // <‑‑ NEW text
2380+
? "It DOES install automatically!"
23692381
: "It does NOT install update automatically!") +
23702382
"\n\nContinue?";
23712383
}
23722384
2373-
if (!confirm(confirmText)) return; /* user cancelled */
2385+
if (!confirm(confirmText)) { return; }
23742386
2375-
/* choose action script */
23762387
actionScriptValue = forceScriptUpdateCheck.checked
2377-
? 'start_MerlinAUscrptupdate_force'
2378-
: 'start_MerlinAUscrptupdate';
2388+
? 'start_MerlinAUscrptupdate_force'
2389+
: 'start_MerlinAUscrptupdate';
23792390
2380-
/* submit the form */
23812391
document.form.action_script.value = actionScriptValue;
23822392
document.form.action_wait.value = 10;
23832393
showLoading();

0 commit comments

Comments
 (0)