diff --git a/code/modules/tgui/tgui_window.dm b/code/modules/tgui/tgui_window.dm index 40aef1b72ea..c437ce5817c 100644 --- a/code/modules/tgui/tgui_window.dm +++ b/code/modules/tgui/tgui_window.dm @@ -291,6 +291,18 @@ : "[id].browser:update") message_queue = null +/** + * public + * + * Replaces the inline HTML content. + * + * required inline_html string HTML to inject + */ +/datum/tgui_window/proc/replace_html(inline_html = "") + client << output(url_encode(inline_html), is_browser \ + ? "[id]:replaceHtml" \ + : "[id].browser:replaceHtml") + /** * private * diff --git a/tgui/public/tgui.html b/tgui/public/tgui.html index ecb3e11b9cc..d7c1b4b5d97 100644 --- a/tgui/public/tgui.html +++ b/tgui/public/tgui.html @@ -470,6 +470,26 @@ window.update.flushQueue = function (listener) { } }; +window.replaceHtml = function (inline_html) { + var children = document.body.childNodes; + + for (var i = 0; i < children.length; i++) { + if (children[i].nodeValue == " tgui:inline-html-start ") { + while (children[i].nodeValue != " tgui:inline-html-end ") { + children[i].remove(); + } + children[i].remove(); + } + } + + document.body.insertAdjacentHTML( + "afterbegin", + "" + + inline_html + + "" + ); +}; + // Signal tgui that we're ready to receive updates Byond.sendMessage('ready'); @@ -577,7 +597,9 @@ blink { + +