From b23e6e0d9cb34973dc9d2f059166ab19c24de7c8 Mon Sep 17 00:00:00 2001 From: Sunpy Date: Sat, 2 Mar 2019 23:38:59 +0100 Subject: [PATCH] Alert script --- static/js/alerts.js | 20 ++++++++++++++++++++ templates/layout/bootstrap.html | 1 + 2 files changed, 21 insertions(+) create mode 100644 static/js/alerts.js diff --git a/static/js/alerts.js b/static/js/alerts.js new file mode 100644 index 0000000..bb6f417 --- /dev/null +++ b/static/js/alerts.js @@ -0,0 +1,20 @@ +function _findAlertDom(caller) { + let selectedDOM = caller; + do { + if (selectedDOM.classList.contains("alert-section")){ + return selectedDOM; + } + selectedDOM = selectedDOM.parentElement; + } while (selectedDOM != null); + throw Error("Missing alert-section class for self/parent(s)"); +} + +function alertAbove(caller, t, s) { + let dom = _findAlertDom(caller); + dom.outerHTML = `` + dom.outerHTML; +} + +function alertUnder(caller, t, s) { + let dom = _findAlertDom(caller); + dom.outerHTML += ``; +} \ No newline at end of file diff --git a/templates/layout/bootstrap.html b/templates/layout/bootstrap.html index 93c1322..93d6d7a 100644 --- a/templates/layout/bootstrap.html +++ b/templates/layout/bootstrap.html @@ -17,5 +17,6 @@ + \ No newline at end of file