fix some modals not working in bootstrap

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Oct 24, 2024 at 18:31 UTC 0d885e6fa040e0e9d216bbe0c268d602a50e535c
1 file changed +11 -7
views/default3.handlebars
+11 -7
@@ -1957,7 +1957,7 @@
1957 onclick="setDialogMode()" onkeypress="if (event.key == 'Enter') setDialogMode()"></button>
1958 </div>
1959 <div class="modal-body" id="xxAddAgentBody">
1960 - <!-- The body content is dynamically populated -->
1960 + <!-- The default dialog is 2 but possible to specify others -->
1961 <div id=dialog1>
1962 <div id=id_dialogMessage style=""></div>
1963 </div>
@@ -6428,14 +6428,18 @@
6428 // Check if the modal elements exist
6429 var modalConfigurableElement = document.getElementById('xxAddAgentModalConf');
6430 var modalTitleElement = document.getElementById(modalId + 'Title');
6431 - var modalBodyElement = document.getElementById(modalId + 'Body');
6431
6433 - if (modalTitleElement && modalBodyElement) {
6432 + if (modalConfigurableElement && modalTitleElement) {
6433 // Set the modal title
6434 modalTitleElement.innerHTML = title;
6435
6437 - // Set the modal body content
6438 - modalBodyElement.innerHTML = bodyContent;
6436 + // Set the modal body content based on the bodyContent Type
6437 + if (typeof bodyContent == 'number') {
6438 + for (var i = 1; i < 24; i++) { QV('dialog' + i, i == bodyContent); } // Edit this line when more dialogs are added
6439 + } else if (typeof bodyContent == 'string'){
6440 + Q('dialog2').innerHTML = bodyContent;
6441 + for (var i = 1; i < 24; i++) { QV('dialog' + i, i == 2); } // Edit this line when more dialogs are added
6442 + }
6443 // If size is provided, set the modal size class
6444 if (size) {
6445 modalConfigurableElement.classList.remove('modal-sm', 'modal-lg', 'modal-xl'); // Remove any existing size classes
@@ -10638,7 +10642,7 @@
10642 }
10643
10644 xxdialogButtons = 3;
10641 - setModalContent('xxAddAgent', 'Remote Desktop Settings', x);
10645 + setModalContent('xxAddAgent', 'Remote Desktop Settings', 7);
10646 showModal('xxAddAgentModal', 'idx_dlgOkButton', showDesktopSettingsChanged);
10647 }
10648
@@ -20660,7 +20664,7 @@
20664
20665 // Make the dialog box movable
20666 function dialogBoxDrag() {
20663 - var elmnt = Q('dialog');
20667 + var elmnt = Q('xxAddAgentModal');
20668 var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
20669 Q('dialogHeader').onmousedown = dragMouseDown;
20670 function dragMouseDown(e) {