User:Jono Bean/common.js: Difference between revisions
From DQWiki
Jump to navigationJump to search
No edit summary |
mNo edit summary |
||
| Line 2: | Line 2: | ||
(function() { | (function() { | ||
var username = mw.config.get('wgUserName'); | var username = mw.config.get('wgUserName'); | ||
var iframeUrl = 'https://npc-forge- | |||
// Uses the correct Firebase Hosted App URL | |||
var iframeUrl = 'https://npc-forge--npc-forge-qh4gc.asia-southeast1.hosted.app/widget'; | |||
if (username) { | if (username) { | ||
iframeUrl += '?user=' + encodeURIComponent(username); | iframeUrl += '?user=' + encodeURIComponent(username); | ||
| Line 24: | Line 26: | ||
document.body.appendChild(widgetContainer); | document.body.appendChild(widgetContainer); | ||
// ? | // ? Listen for the widget telling the Wiki to "Grow" and "Shrink" | ||
window.addEventListener('message', function(event) { | window.addEventListener('message', function(event) { | ||
if (event.origin !== 'https://npc-forge- | // Updated to the correct App Hosting domain | ||
if (event.origin !== 'https://npc-forge--npc-forge-qh4gc.asia-southeast1.hosted.app') return; | |||
if (event.data.type === 'lorekeeper-resize') { | if (event.data.type === 'lorekeeper-resize') { | ||
widgetContainer.style.width = event.data.width + 'px'; | widgetContainer.style.width = event.data.width + 'px'; | ||
Revision as of 10:19, 25 February 2026
/* Lorekeeper Widget Loader - Advanced Version */
(function() {
var username = mw.config.get('wgUserName');
// Uses the correct Firebase Hosted App URL
var iframeUrl = 'https://npc-forge--npc-forge-qh4gc.asia-southeast1.hosted.app/widget';
if (username) {
iframeUrl += '?user=' + encodeURIComponent(username);
} else {
iframeUrl += '?guest=Traveler';
}
// Create a container that doesn't block the Wiki
var widgetContainer = document.createElement('div');
widgetContainer.id = 'lorekeeper-widget-container';
widgetContainer.style.cssText = 'position:fixed; bottom:0; right:0; z-index:99999; pointer-events:none; transition: width 0.3s ease, height 0.3s ease;';
widgetContainer.style.width = '300px';
widgetContainer.style.height = '120px';
var iframe = document.createElement('iframe');
iframe.src = iframeUrl;
iframe.style.cssText = 'width:100%; height:100%; border:none; background:transparent; pointer-events:auto;';
iframe.setAttribute('allow', 'clipboard-write'); // For links/sharing later
widgetContainer.appendChild(iframe);
document.body.appendChild(widgetContainer);
// ? Listen for the widget telling the Wiki to "Grow" and "Shrink"
window.addEventListener('message', function(event) {
// Updated to the correct App Hosting domain
if (event.origin !== 'https://npc-forge--npc-forge-qh4gc.asia-southeast1.hosted.app') return;
if (event.data.type === 'lorekeeper-resize') {
widgetContainer.style.width = event.data.width + 'px';
widgetContainer.style.height = event.data.height + 'px';
}
});
})();