@@ -857,64 +857,93 @@ function FetchChangelog(startTime)
857857 });
858858}
859859
860+ /* *------------------------------------------**/
861+ /* * Modified by ExtremeFiretop [2025-May-18] **/
862+ /* *------------------------------------------**/
860863function ShowLatestChangelog (e )
861864{
862865 if (e) e .preventDefault ();
863866
864- let loadingMessage = ' <p>Please wait and allow up to 10 seconds for the changelog to load.<br>' +
865- ' Click on "Cancel" button to stop and exit this dialog.</p>' ;
867+ const loadingMessage =
868+ ' <p>Please wait and allow up to 10 seconds for the changelog to load.<br>' +
869+ ' Click on "Cancel" button to stop and exit this dialog.</p>' ;
866870
867- if ($ (' #changelogModal' ).length )
868- {
869- $ (' #changelogData' ).html (loadingMessage);
870- $ (' #closeChangelogModal' ).text (" Cancel" );
871- }
872- else
873- { // Create modal overlay if it doesn't exist //
871+ /* ----- build the modal once ----- */
872+ if (! $ (' #changelogModal' ).length ) {
874873 $ (' body' ).append (
875- ' <div id="changelogModal" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; ' +
876- ' background:rgba(0,0,0,0.8); z-index:10000;">' +
877- ' <div id="changelogContent" style="position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); ' +
878- ' background:#fff; color:#000; padding:20px; max-height:90%; overflow:auto; width:80%; max-width:800px;">' +
879- ' <h2 style="margin-top:0; color:#000;">Latest Changelog</h2>' +
880- ' <button id="closeChangelogModal" style="float:right; font-size:14px; cursor:pointer;">Cancel</button>' +
881- ' <div id="changelogData" style="font-family:monospace; white-space:pre-wrap; margin-top:10px; color:#000;">' +
874+ ' <div id="changelogModal" style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;' +
875+ ' background:rgba(0,0,0,0.8);z-index:10000;">' +
876+ ' <div id="changelogContent" style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);' +
877+ ' background:#fff;color:#000;padding:20px;max-height:90%;overflow:auto;width:80%;max-width:800px;">' +
878+ ' <h2 style="margin-top:0;color:#000;">Latest Changelog</h2>' +
879+ ' <button id="closeChangelogModal" style="float:right;font-size:14px;cursor:pointer;">Cancel</button>' +
880+ ' <div id="changelogData" style="font-family:monospace;white-space:pre-wrap;margin-top:10px;color:#000;">' +
882881 loadingMessage +
883882 ' </div>' +
884883 ' </div>' +
885884 ' </div>'
886885 );
887- $ (' #closeChangelogModal' ).on (' click' , function (){
886+
887+ /* close button */
888+ $ (' #closeChangelogModal' ).on (' click' , function () {
888889 $ (' #changelogModal' ).hide ();
889890 });
891+
892+ /* ---------- NEW: arrow‑key scroll handler (bind once) ---------- */
893+ $ (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 ) {
897+ case ' ArrowDown' :
898+ box .scrollTop += 40 ;
899+ ev .preventDefault ();
900+ break ;
901+ case ' ArrowUp' :
902+ box .scrollTop -= 40 ;
903+ ev .preventDefault ();
904+ break ;
905+ case ' ArrowRight' :
906+ box .scrollTop += 40 ;
907+ ev .preventDefault ();
908+ break ;
909+ case ' ArrowLeft' :
910+ box .scrollTop -= 40 ;
911+ ev .preventDefault ();
912+ break ;
913+ default :
914+ break ;
915+ }
916+ });
917+ /* -------------------------------------------------------------- */
918+ } else {
919+ $ (' #changelogData' ).html (loadingMessage);
920+ $ (' #closeChangelogModal' ).text (" Cancel" );
890921 }
891922
892923 $ (' #changelogModal' ).show ();
893924
894- // Trigger the backend shell script via form submission //
895- var formData = $ (' form[name="form"]' ).serializeArray ();
925+ /* ---------- NEW: focusable + give it focus ---------- */
926+ $ (' #changelogContent' ).attr (' tabindex' , 0 ).focus ();
927+ /* ---------------------------------------------------- */
928+
929+ /* kick the backend */
930+ const formData = $ (' form[name="form"]' ).serializeArray ();
896931 formData .push ({ name: " action_script" , value: " start_MerlinAUdownloadchangelog" });
897- formData .push ({ name: " action_wait" , value: " 10" });
898-
899- $ .post (' start_apply.htm' , formData)
900- .done (function (response ) {
901- console .log (" Changelog trigger submitted successfully." );
902- })
903- .fail (function () {
904- console .error (" Failed to submit changelog trigger." );
905- });
906-
907- // Record the start time and wait 8 seconds before attempting to fetch the changelog //
908- var startTime = new Date ().getTime ();
909- setTimeout (function () {
910- FetchChangelog (startTime);
911- // Once the changelog has loaded, update the button text to "Close"
912- $ (' #closeChangelogModal' ).text (" Close" );
932+ formData .push ({ name: " action_wait" , value: " 10" });
933+
934+ $ .post (' start_apply.htm' , formData);
935+
936+ /* wait 8 s, then fetch the changelog */
937+ const startTime = Date .now ();
938+ setTimeout (function () {
939+ FetchChangelog (startTime);
940+ $ (' #closeChangelogModal' ).text (" Close" );
913941 }, 8000 );
914942
915943 return false ;
916944}
917945
946+
918947// **Control "Approve/Block Changelog" Checkbox State** //
919948function ToggleChangelogApproval (checkboxElem )
920949{
@@ -1544,9 +1573,9 @@ function BlockChangelog()
15441573 document .form .submit ();
15451574}
15461575
1547- /* *----------------------------------------**/
1548- /* * Modified by Martinski W. [2025-Mar-07 ] **/
1549- /* *----------------------------------------**/
1576+ /* *------------------------------------------ **/
1577+ /* * Modified by ExtremeFiretop [2025-May-18 ] **/
1578+ /* *------------------------------------------ **/
15501579function InitializeFields ()
15511580{
15521581 console .log (" Initializing fields..." );
@@ -1642,7 +1671,9 @@ function InitializeFields()
16421671 { tailscaleVPNEnabled .checked = (custom_settings .Allow_Updates_OverVPN === ' ENABLED' ); }
16431672
16441673 if (script_AutoUpdate_Check)
1645- { script_AutoUpdate_Check .checked = (custom_settings .Allow_Script_Auto_Update === ' ENABLED' ); }
1674+ { script_AutoUpdate_Check .checked = (custom_settings .Allow_Script_Auto_Update === ' ENABLED' );
1675+ UpdateForceScriptCheckboxState (script_AutoUpdate_Check? .checked );
1676+ }
16461677
16471678 if (betaToReleaseUpdatesEnabled)
16481679 { betaToReleaseUpdatesEnabled .checked = (custom_settings .FW_Allow_Beta_Production_Up === ' ENABLED' ); }
@@ -2292,29 +2323,55 @@ function Uninstall()
22922323 document .form .submit ();
22932324}
22942325
2295- /* *----------------------------------------**/
2296- /* * Modified by Martinski W. [2025-May-11] **/
2297- /* *----------------------------------------**/
2326+ /** ---------------------------------------**/
2327+ /** Added by ExtremeFiretop [2025-May-18] **/
2328+ /** ---------------------------------------**/
2329+ function UpdateForceScriptCheckboxState (autoUpdatesEnabled ) {
2330+ const forceCB = document .getElementById (' ForceScriptUpdateCheck' );
2331+ if (! forceCB) return ; // safety
2332+ forceCB .disabled = autoUpdatesEnabled; // gray‑out logic
2333+ forceCB .style .opacity = autoUpdatesEnabled ? ' 0.5' : ' 1' ;
2334+ if (autoUpdatesEnabled) forceCB .checked = false ; // clear if now disabled
2335+ }
2336+
2337+ /** ------------------------------------------**/
2338+ /** Modified by ExtremeFiretop [2025-May-18] **/
2339+ /** ------------------------------------------**/
22982340function UpdateMerlinAUScript ()
22992341{
23002342 console .log (" Initiating MerlinAU script update…" );
23012343
23022344 let actionScriptValue;
2303- let forceScriptUpdateCheck = document .getElementById (' ForceScriptUpdateCheck' );
2345+ const forceScriptUpdateCheck = document .getElementById (' ForceScriptUpdateCheck' );
2346+ const autoUpdatesEnabled = document .getElementById (' Script_AutoUpdate_Check' )? .checked ;
2347+
2348+ /* ----- build the appropriate confirmation text ----- */
2349+ let confirmText;
2350+ if (forceScriptUpdateCheck .checked ) {
2351+ /* user explicitly wants to install right now */
2352+ confirmText = " INSTALL UPDATE:\n " +
2353+ " Install the latest available MerlinAU script update now, " +
2354+ " even if the version is already current.\n\n Continue?" ;
2355+ } else {
2356+ /* normal check – message depends on auto‑update setting */
2357+ confirmText = " CHECK AND PROMPT:\n " +
2358+ " Check for a newer version of MerlinAU and prompt if found. " +
2359+ (autoUpdatesEnabled
2360+ ? " It DOES install automatically!" // <‑‑ NEW text
2361+ : " It does NOT install update automatically!" ) +
2362+ " \n\n Continue?" ;
2363+ }
23042364
2305- let confirmOK = confirm (
2306- forceScriptUpdateCheck .checked
2307- ? " INSTALL UPDATE:\n Install the latest available MerlinAU script update now, even if version is current.\n\n Continue?"
2308- : " CHECK AND PROMPT:\n Check for a newer version of MerlinAU and prompt if found. It does NOT install update automatically!\n\n Continue?" );
2309- if (! confirmOK) { return ; }
2365+ if (! confirm (confirmText)) return ; /* user cancelled */
23102366
2311- if ( ! forceScriptUpdateCheck . checked )
2312- { actionScriptValue = ' start_MerlinAUscrptupdate ' ; }
2313- else
2314- { actionScriptValue = ' start_MerlinAUscrptupdate_force ' ; }
2367+ /* choose action script */
2368+ actionScriptValue = forceScriptUpdateCheck . checked
2369+ ? ' start_MerlinAUscrptupdate_force '
2370+ : ' start_MerlinAUscrptupdate ' ;
23152371
2372+ /* submit the form */
23162373 document .form .action_script .value = actionScriptValue;
2317- document .form .action_wait .value = 10 ;
2374+ document .form .action_wait .value = 10 ;
23182375 showLoading ();
23192376 document .form .submit ();
23202377}
@@ -2944,7 +3001,7 @@ function initializeCollapsibleSections()
29443001 < / label>
29453002 < / td>
29463003 < td>
2947- <input type=" checkbox " id=" Script_AutoUpdate_Check " name=" Script_AutoUpdate_Check " />
3004+ < input type= " checkbox" id= " Script_AutoUpdate_Check" name= " Script_AutoUpdate_Check" onchange = " UpdateForceScriptCheckboxState(this.checked) " / >
29483005 < span id= " Script_AutoUpdate_SchedText" name= " Script_AutoUpdate_SchedText"
29493006 style= " vertical-align:bottom; margin-left:15px; display:none; font-size: 12px; font-weight: bolder;" >< / span>
29503007 < / td>
0 commit comments