From 02ed3dff92cfa90b1f8142609e87704354d23a31 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 7 Jan 2021 19:30:10 -0800 Subject: [PATCH] Add function update_dynamic_elements. --- frontends/etiquette_flask/static/js/common.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontends/etiquette_flask/static/js/common.js b/frontends/etiquette_flask/static/js/common.js index 508b50e..1fab00a 100644 --- a/frontends/etiquette_flask/static/js/common.js +++ b/frontends/etiquette_flask/static/js/common.js @@ -171,6 +171,19 @@ function size_iframe_to_content(iframe) iframe.style.height = iframe.contentWindow.document.documentElement.scrollHeight + 'px'; } +common.update_dynamic_elements = +function update_dynamic_elements(class_name, text) +{ + /* + Find all elements with this class and set their innertext to this text. + */ + const elements = document.getElementsByClassName(class_name); + for (const element of elements) + { + element.innerText = text; + } +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // HOOKS & ADD-ONS ///////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////