mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-08-09 14:47:47 +02:00
Added plugin context view
- Added plugin context view - Moved plugin type definition to separate file - Added wip request forwarder
This commit is contained in:
52
src/web/components/plugincontext.html
Normal file
52
src/web/components/plugincontext.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<div class="">
|
||||
<iframe id="pluginContextLoader" src="" style="width: 100%; border: none;">
|
||||
|
||||
</iframe>
|
||||
</div>
|
||||
<script>
|
||||
function initPluginUIView(){
|
||||
let pluginID = getPluginIDFromWindowHash();
|
||||
console.log("Launching plugin UI for plugin with ID:", pluginID);
|
||||
loadPluginContext(pluginID);
|
||||
}
|
||||
|
||||
function loadPluginContext(pluginID){
|
||||
let pluginContextURL = `/plugin.ui/${pluginID}/`;
|
||||
$("#pluginContextLoader").attr("src", pluginContextURL);
|
||||
}
|
||||
|
||||
function getPluginIDFromWindowHash(){
|
||||
let tabID = window.location.hash.substr(1);
|
||||
let pluginID = "";
|
||||
if (tabID.startsWith("{")) {
|
||||
tabID = decodeURIComponent(tabID);
|
||||
try {
|
||||
let parsedData = JSON.parse(tabID);
|
||||
if (typeof(parsedData.pluginID) != "undefined"){
|
||||
pluginID = parsedData.pluginID;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Invalid JSON data:", e);
|
||||
}
|
||||
}
|
||||
return pluginID;
|
||||
}
|
||||
|
||||
function resizeIframe() {
|
||||
let iframe = document.getElementById('pluginContextLoader');
|
||||
let mainMenuHeight = document.getElementById('mainmenu').offsetHeight;
|
||||
iframe.style.height = mainMenuHeight + 'px';
|
||||
}
|
||||
|
||||
$(window).on("resize", function(){
|
||||
resizeIframe();
|
||||
});
|
||||
|
||||
//Bind event to tab switch
|
||||
tabSwitchEventBind["pluginContextWindow"] = function(){
|
||||
//On switch over to this page, load info
|
||||
resizeIframe();
|
||||
}
|
||||
|
||||
initPluginUIView();
|
||||
</script>
|
Reference in New Issue
Block a user