From fe53bcf127cfe3775a4f2c9c9c53286054324b40 Mon Sep 17 00:00:00 2001 From: tza Date: Wed, 6 Apr 2022 13:57:21 +0300 Subject: Change title when inside plugin view --- plugin_loader/static/plugin_page.js | 41 ++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'plugin_loader/static/plugin_page.js') diff --git a/plugin_loader/static/plugin_page.js b/plugin_loader/static/plugin_page.js index b42cd711..0d595ac9 100644 --- a/plugin_loader/static/plugin_page.js +++ b/plugin_loader/static/plugin_page.js @@ -1,3 +1,21 @@ +function setPluginName(name) { + document.getElementById("plugin_title").innerHTML = ` + + + + ${name} + `; +} + +function reloadIframe() { + document.getElementById("plugin_iframe").contentWindow.location.href = "http://127.0.0.1:1337/plugins/iframe"; +} + +function resolveMethodCall(call_id, result) { + let iframe = document.getElementById("plugin_iframe").contentWindow; + iframe.postMessage({'call_id': call_id, 'result': result}, "http://127.0.0.1:1337"); +} + (function () { const PLUGIN_ICON = ` @@ -31,19 +49,18 @@ if (document.hasFocus()) { inject(); document.getElementById("plugin_title").onclick = function() { - document.getElementById("plugin_iframe").contentWindow.location.href = "http://127.0.0.1:1337/plugins/iframe"; + reloadIframe(); + document.getElementById("plugin_title").innerText = "Plugins"; + } + window.onmessage = function(ev) { + document.getElementById("plugin_title").innerHTML = ` + + + + ${ev.data} + `; } clearInterval(injector); } }, 100); -})(); - -function reloadIframe() { - console.log("reloading iframe"); - document.getElementById("plugin_iframe").contentWindow.location.href = "http://127.0.0.1:1337/plugins/iframe"; -} - -function resolveMethodCall(call_id, result) { - let iframe = document.getElementById("plugin_iframe").contentWindow; - iframe.postMessage({'call_id': call_id, 'result': result}, "http://127.0.0.1:1337"); -} \ No newline at end of file +})(); \ No newline at end of file -- cgit v1.2.3