Initial commit: DMH Patient Registration Flask app
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/* Lightweight $.alert and $.confirm modal implementation */
|
||||
(function($) {
|
||||
if (!$) return;
|
||||
|
||||
function showModal(message, isConfirm, callback) {
|
||||
var overlay = document.createElement("div");
|
||||
overlay.className = "dmh-modal-overlay";
|
||||
var box = document.createElement("div");
|
||||
box.className = "dmh-modal-box";
|
||||
|
||||
var msgEl = document.createElement("p");
|
||||
msgEl.className = "dmh-modal-msg";
|
||||
msgEl.textContent = message;
|
||||
box.appendChild(msgEl);
|
||||
|
||||
var actions = document.createElement("div");
|
||||
actions.className = "dmh-modal-actions";
|
||||
|
||||
var okBtn = document.createElement("button");
|
||||
okBtn.type = "button";
|
||||
okBtn.className = "dmh-modal-btn dmh-modal-ok";
|
||||
okBtn.textContent = "OK";
|
||||
okBtn.onclick = function() {
|
||||
document.body.removeChild(overlay);
|
||||
if (callback) callback(true);
|
||||
};
|
||||
actions.appendChild(okBtn);
|
||||
|
||||
if (isConfirm) {
|
||||
var cancelBtn = document.createElement("button");
|
||||
cancelBtn.type = "button";
|
||||
cancelBtn.className = "dmh-modal-btn dmh-modal-cancel";
|
||||
cancelBtn.textContent = "Cancel";
|
||||
cancelBtn.onclick = function() {
|
||||
document.body.removeChild(overlay);
|
||||
if (callback) callback(false);
|
||||
};
|
||||
actions.appendChild(cancelBtn);
|
||||
}
|
||||
|
||||
box.appendChild(actions);
|
||||
overlay.appendChild(box);
|
||||
document.body.appendChild(overlay);
|
||||
okBtn.focus();
|
||||
}
|
||||
|
||||
$.alert = function(msg) { showModal(msg, false, null); };
|
||||
$.confirm = function(msg, cb) { showModal(msg, true, cb); };
|
||||
})(window.$);
|
||||
Reference in New Issue
Block a user