Files
zoraxy/src/web/components/plugincontext.html
Toby Chui 136989f2ea Added plugin dir parameter
- Added plugin dir parameter
- Fixed critical architectural bug that effects plugin UI in production mode
- Updated implementation of embed FS routing
- Minor dark theme update
- Fixed ztnc UI bug for msgbox and confirm box
2025-03-28 21:24:18 +08:00

63 lines
2.1 KiB
HTML

<div class="">
<iframe id="pluginContextLoader" src="" style="width: 100%; border: none;" allow="scripts" sandbox="allow-scripts allow-same-origin">
</iframe>
</div>
<script>
function initPluginUIView(forceOverwritePluginID = undefined){
if (typeof(forceOverwritePluginID) != "undefined"){
let pluginID = forceOverwritePluginID;
console.log("Launching plugin UI for plugin with ID:", pluginID);
loadPluginContext(pluginID);
return;
}
let pluginID = getPluginIDFromWindowHash();
if (pluginID == ""){
return;
}
console.log("Launching plugin UI for plugin with ID:", pluginID);
loadPluginContext(pluginID);
}
function loadPluginContext(pluginID){
//Check if the iframe is currently visable
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;
if (mainMenuHeight == 0){
mainMenuHeight = window.innerHeight - 198; //Fallback to window height
}
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();
}
</script>