@@ -796,6 +796,82 @@ const fwUpdateDirPath =
796796 }
797797};
798798
799+ function ShowLatestChangelog () {
800+ document .form .action_script .value = ' start_MerlinAUdownloadchangelog' ;
801+ document .form .action_wait .value = 10 ;
802+
803+ // Open popup **before** form submission to avoid browser popup blocking
804+ var changelogWindow = window .open (" " , " ChangelogPopup" , " width=800,height=600,scrollbars=1,resizable=1" );
805+
806+ if (! changelogWindow) {
807+ alert (" Popup blocked! Please allow popups for this site to view the changelog." );
808+ return ;
809+ }
810+
811+ changelogWindow .document .open ();
812+ changelogWindow .document .write (" <html><head><title>Latest Changelog</title></head>" );
813+ changelogWindow .document .write (" <body style='font-family:monospace; white-space:pre-wrap;'>" );
814+ changelogWindow .document .write (" <p>Loading latest changelog...</p>" );
815+ changelogWindow .document .write (" </body></html>" );
816+ changelogWindow .document .close ();
817+
818+ // Now submit the form (which might trigger a page refresh)
819+ showLoading ();
820+ document .form .submit ();
821+
822+ // Delay the AJAX request slightly (but make sure it runs before page refresh)
823+ setTimeout (function () {
824+ $ .ajax ({
825+ url: ' /ext/MerlinAU/changelog.htm' ,
826+ dataType: ' text' ,
827+ timeout: 9000 ,
828+ success : function (data ) {
829+ // Ensure the popup is still open before modifying it
830+ if (changelogWindow && ! changelogWindow .closed ) {
831+ changelogWindow .document .open ();
832+ changelogWindow .document .write (" <html><head><title>Latest Changelog</title></head>" );
833+ changelogWindow .document .write (" <body style='font-family:monospace; white-space:pre-wrap;'>" );
834+ changelogWindow .document .write (" <pre>" + data + " </pre>" );
835+ changelogWindow .document .write (" </body></html>" );
836+ changelogWindow .document .close ();
837+ }
838+ },
839+ error : function () {
840+ if (changelogWindow && ! changelogWindow .closed ) {
841+ changelogWindow .document .open ();
842+ changelogWindow .document .write (" <html><head><title>Changelog Error</title></head>" );
843+ changelogWindow .document .write (" <body style='font-family:monospace; white-space:pre-wrap;'>" );
844+ changelogWindow .document .write (" <p>Failed to load the changelog.</p>" );
845+ changelogWindow .document .write (" </body></html>" );
846+ changelogWindow .document .close ();
847+ }
848+ }
849+ });
850+ }, 8000 ); // Delay slightly to allow form processing, but not too much
851+ }
852+
853+ // **Control "Approve/Block Changelog" Checkbox State** //
854+ function ToggleChangelogApproval (checkboxElem ) {
855+ if (checkboxElem .checked ) {
856+ // They are approving
857+ if (! confirm (approveChangelogMsge)) {
858+ // If user cancels at the confirm prompt, revert checkbox
859+ checkboxElem .checked = false ;
860+ return ;
861+ }
862+ ApproveChangelog ();
863+ }
864+ else {
865+ // They are blocking
866+ if (! confirm (blockChangelogMsge)) {
867+ // If user cancels at the confirm prompt, revert checkbox
868+ checkboxElem .checked = true ;
869+ return ;
870+ }
871+ BlockChangelog ();
872+ }
873+ }
874+
799875/* *----------------------------------------**/
800876/* * Modified by Martinski W. [2025-Feb-23] **/
801877/* *----------------------------------------**/
@@ -1378,7 +1454,6 @@ function ApproveChangelog()
13781454{
13791455 console .log (" Approving Changelog..." );
13801456
1381- if (! confirm (approveChangelogMsge)) { return ; }
13821457 document .form .action_script .value = ' start_MerlinAUapprovechangelog' ;
13831458 document .form .action_wait .value = 10 ;
13841459 showLoading ();
@@ -1392,7 +1467,6 @@ function BlockChangelog()
13921467{
13931468 console .log (" Blocking Changelog..." );
13941469
1395- if (! confirm (blockChangelogMsge)) { return ; }
13961470 document .form .action_script .value = ' start_MerlinAUblockchangelog' ;
13971471 document .form .action_wait .value = 10 ;
13981472 showLoading ();
@@ -1577,66 +1651,34 @@ function InitializeFields()
15771651 }
15781652
15791653 // **Handle Changelog Approval Display** //
1654+ // Now we handle the new Approve Changelog checkbox
15801655 var changelogApprovalElement = document .getElementById (' changelogApproval' );
15811656 if (changelogApprovalElement)
15821657 { // Default to "Disabled" if missing //
15831658 var approvalStatus = custom_settings .hasOwnProperty (' FW_New_Update_Changelog_Approval' ) ? custom_settings .FW_New_Update_Changelog_Approval : " Disabled" ;
15841659 SetStatusForGUI (' changelogApproval' , approvalStatus);
15851660 }
15861661
1587- // **Control "Approve/Block Changelog" Button State** //
1588- var approveBlockChangelogBtn = document .getElementById (' approveBlockChangeLogBtn' );
1589- if (approveBlockChangelogBtn)
1590- {
1662+ var approveChangelogCheck = document .getElementById (' approveChangelogCheck' );
1663+ if (approveChangelogCheck) {
15911664 var isChangelogCheckEnabled = (custom_settings .CheckChangeLog === ' ENABLED' );
1592- var changelogApprovalValue = custom_settings .FW_New_Update_Changelog_Approval ;
1593-
1594- approveBlockChangelogBtn .style .display = ' inline-block' ;
1595-
1596- // Decide whether we want "Approve" or "Block" //
1597- if (changelogApprovalValue === ' APPROVED' )
1598- { // Toggle functionality //
1599- approveBlockChangelogBtn .value = " Block Changelog" ;
1600- approveBlockChangelogBtn .title = blockChangelogHint;
1601- approveBlockChangelogBtn .onclick = function () {
1602- BlockChangelog ();
1603- return false ; // Prevent default form submission
1604- };
1605-
1606- approveBlockChangelogBtn .disabled = false ;
1607- approveBlockChangelogBtn .style .opacity = ' 1' ;
1608- approveBlockChangelogBtn .style .cursor = ' pointer' ;
1609- }
1610- else if (changelogApprovalValue === ' BLOCKED' )
1611- { // Toggle functionality //
1612- approveBlockChangelogBtn .value = " Approve Changelog" ;
1613- approveBlockChangelogBtn .title = approveChangelogHint;
1614- approveBlockChangelogBtn .onclick = function () {
1615- ApproveChangelog ();
1616- return false ;
1617- };
1618- approveBlockChangelogBtn .disabled = false ;
1665+ var approvalValue = custom_settings .FW_New_Update_Changelog_Approval ; // e.g. "APPROVED" or "BLOCKED"
1666+
1667+ // If Changelog Check is disabled, also disable our checkbox
1668+ if (! isChangelogCheckEnabled || ! approvalValue || approvalValue === ' TBD' ) {
1669+ approveChangelogCheck .disabled = true ;
1670+ approveChangelogCheck .checked = false ;
16191671 }
1620- else
1621- {
1622- approveBlockChangelogBtn .value = " Approve Changelog" ;
1672+ else {
1673+ approveChangelogCheck .disabled = false ;
16231674
1624- // Condition: Enable button only if
1625- // 1. Changelog Check is enabled
1626- // 2. Changelog Approval is neither empty nor "TBD"
1627- if (isChangelogCheckEnabled && changelogApprovalValue && changelogApprovalValue !== ' TBD' )
1628- {
1629- approveBlockChangelogBtn .title = approveChangelogHint;
1630- approveBlockChangelogBtn .disabled = false ;
1631- approveBlockChangelogBtn .style .opacity = ' 1' ;
1632- approveBlockChangelogBtn .style .cursor = ' pointer' ;
1675+ // If the stored approval is "APPROVED", default to checked
1676+ if (approvalValue === ' APPROVED' ) {
1677+ approveChangelogCheck .checked = true ;
16331678 }
1634- else
1635- {
1636- approveBlockChangelogBtn .title = ' ' ;
1637- approveBlockChangelogBtn .disabled = true ;
1638- approveBlockChangelogBtn .style .opacity = ' 0.5' ;
1639- approveBlockChangelogBtn .style .cursor = ' not-allowed' ;
1679+ // Otherwise, set as unchecked for "BLOCKED," "Disabled," etc.
1680+ else {
1681+ approveChangelogCheck .checked = false ;
16401682 }
16411683 }
16421684 }
@@ -2566,10 +2608,13 @@ function initializeCollapsibleSections()
25662608 </br>
25672609</td>
25682610<td style=" text-align: center; border: none; " id=" approveChangelogCell " >
2569- <input type=" submit " class=" button_gen savebutton " id=" approveBlockChangeLogBtn "
2570- onclick=" ApproveChangelog(); return false; "
2571- value=" Approve Changelog " title=" " name=" button " >
2572- <br><label style=" margin-top: 5px; margin-bottom:8x " ></br>
2611+ <input type=" submit " id=" LatestChangelogButton " onclick=" ShowLatestChangelog();
2612+ return false; " value=" Latest Changelog " class=" button_gen savebutton " title=" View the latest changelog " name=" button " >
2613+ <br>
2614+ <label style=" color:#FFCC00; margin-top: 5px; margin-bottom:8x " >
2615+ <input type=" checkbox " id=" approveChangelogCheck " name=" approveChangelogCheck " onclick=" ToggleChangelogApproval(this); "
2616+ style=" padding:0; vertical-align:middle; position:relative; margin-left:-5px; margin-top:5px; margin-bottom:8px " />Approve Changelog</label>
2617+ </br>
25732618</td>
25742619<td style=" text-align: left; border: none; " >
25752620 <input type=" submit " id=" UninstallButton " onclick=" Uninstall(); return false; "
0 commit comments