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 ++++++++++++++++++++++---------- plugin_loader/templates/plugin_view.html | 11 ++++++--- 2 files changed, 37 insertions(+), 15 deletions(-) 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 diff --git a/plugin_loader/templates/plugin_view.html b/plugin_loader/templates/plugin_view.html index 3c0cbcc5..2187edae 100644 --- a/plugin_loader/templates/plugin_view.html +++ b/plugin_loader/templates/plugin_view.html @@ -8,6 +8,11 @@ iframe.contentWindow.postMessage(evt.data, "http://127.0.0.1:1337"); }); }, false); + + function loadPlugin(name) { + this.parent.postMessage(name, "https://steamloopback.host"); + location.href = `/plugins/load_main/${name}`; + } {% if not plugins|length %} @@ -23,7 +28,7 @@
{% for plugin in plugins %} {% if plugin.tile_view_html|length %} -