Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the alertdlg to not use on* event handlers #65

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions www/js/alertdlg.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
//alert dialog
function alertdlg(titledlg, textdlg, closefunc) {
var modal = setactiveModal('alertdlg.html', closefunc);
if (modal == null) return;
var title = modal.element.getElementsByClassName("modal-title")[0];
var body = modal.element.getElementsByClassName("modal-text")[0];
title.innerHTML = titledlg;
body.innerHTML = textdlg;
showModal();
}
// This uses: closeModal, setactiveModal, showModal, id

/** alert dialog */
const alertdlg = (titledlg, textdlg, closefunc) => {
const modal = setactiveModal("alertdlg.html", closefunc);
if (modal === null) {
return;
}

id("cancelAlertDlg").addEventListener("click", (event) =>
closeModal("cancel"),
);
id("closeAlertDlg").addEventListener("click", (event) => closeModal("Ok"));

const title = modal.element.getElementsByClassName("modal-title")[0];
const body = modal.element.getElementsByClassName("modal-text")[0];
title.innerHTML = titledlg;
body.innerHTML = textdlg;
showModal();
};
12 changes: 8 additions & 4 deletions www/sub/alertdlg.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- alert content -->
<div class="modal-content">
<div class="modal-header">
<span class="close" onclick="closeModal('cancel')"><b>&times;</b></span>
<span id="cancelAlertDlg" class="close"><b>&times;</b></span>
<h3>
<div class="modal-title"></div>
</h3>
Expand All @@ -13,7 +13,9 @@ <h3>
<span>
<svg width='26px' height='24px' viewBox='0 0 1300 1200'>
<g transform='translate(50,1200) scale(1, -1)'>
<path fill='red' d='M-90 100l642 1066q20 31 48 28.5t48 -35.5l642 -1056q21 -32 7.5 -67.5t-50.5 -35.5h-1294q-37 0 -50.5 34t7.5 66zM155 200h345v75q0 10 7.5 17.5t17.5 7.5h150q10 0 17.5 -7.5t7.5 -17.5v-75h345l-445 723zM496 700h208q20 0 32 -14.5t8 -34.5l-58 -252 q-4 -20 -21.5 -34.5t-37.5 -14.5h-54q-20 0 -37.5 14.5t-21.5 34.5l-58 252q-4 20 8 34.5t32 14.5z'></path>
<path fill='red'
d='M-90 100l642 1066q20 31 48 28.5t48 -35.5l642 -1056q21 -32 7.5 -67.5t-50.5 -35.5h-1294q-37 0 -50.5 34t7.5 66zM155 200h345v75q0 10 7.5 17.5t17.5 7.5h150q10 0 17.5 -7.5t7.5 -17.5v-75h345l-445 723zM496 700h208q20 0 32 -14.5t8 -34.5l-58 -252 q-4 -20 -21.5 -34.5t-37.5 -14.5h-54q-20 0 -37.5 14.5t-21.5 34.5l-58 252q-4 20 8 34.5t32 14.5z'>
</path>
</g>
</svg>
</span>
Expand All @@ -22,9 +24,11 @@ <h3>
</span>
</div>
<div class="modal-footer">
<span class="pull-right"><button class="btn btn-primary" onclick="closeModal('Ok') " translate>Ok</button></span>
<span class="pull-right">
<button id="closeAlertDlg" class="btn btn-primary" translate>Ok</button>
</span>
</div>
</div>
<!-- /alert content -->
</div>
<!-- /alert Modal -->
<!-- /alert Modal -->
Loading