cda1904f5a784ef6a94ee2ad8cfbcc3c0d0d4bef
chmalee
Fri May 19 11:23:11 2023 -0700
Temporary commit generalizing the notification box
diff --git src/hg/js/utils.js src/hg/js/utils.js
index 85cf92e..26a8296 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -783,37 +783,73 @@
var sectionBegin = "'nonce-";
var sectionEnd = "'";
var ix = content.indexOf(sectionBegin);
if (ix < 0)
return "";
content = content.substring(ix+sectionBegin.length);
ix = content.indexOf(sectionEnd);
if (ix < 0)
return "";
content = content.substring(0,ix);
if (debug)
alert('page nonce='+content);
return content;
}
-function notifBoxShow() {
+function notifBoxShow(cgiName, keyName) {
/* move the notification bar div under '#TrackHeaderForm' */
- var notifEl = document.getElementById("notifBox");
+ let lsKey = cgiName + "." + keyName;
+ var notifEl = document.getElementById(lsKey + "notifBox");
+ // TODO: make a generic element for positioning this
var parentEl = document.getElementById('TrackHeaderForm');
parentEl.appendChild(notifEl);
notifEl.style.display = 'block';
- //document.getElementById('notifOK').onclick = notifBoxHide;
+}
+
+function notifBoxSetup(cgiName, keyName, msg) {
+/* Create a notification box if one hasn't been created, and
+ * add msg to the list of shown notifications.
+ * cgiName.keyName will be saved to localStorage in order to show
+ * or hide this notification.
+ * Must call notifBoxShow() in order to display the notification */
+// the key to save into localStorage
+lsKey = cgiName + "." + keyName;
+let notifBox = document.getElementById(lsKey+"notifBox");
+if (notifBox) {
+ notifBox.innerHTML += "
" + msg;
+} else {
+ let newDiv = document.createElement("div");
+ newDiv.style.display = "none";
+ newDiv.style.width = "90%";
+ newDiv.style.marginLeft = "100px";
+ newDiv.id = lsKey+"notifBox";
+ if (msg) {
+ newDiv.innerHTML = msg;
+ }
+ newDiv.innerHTML += "