Spaces:
Running
Running
Update interface.js
Browse files- interface.js +31 -15
interface.js
CHANGED
|
@@ -72,7 +72,7 @@ const currentScriptTag = document.currentScript;
|
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
| 75 |
-
// βββ 5. Create the widget container
|
| 76 |
const widgetContainer = document.createElement('div');
|
| 77 |
widgetContainer.id = 'ply-widget-container-' + instanceId;
|
| 78 |
widgetContainer.classList.add('ply-widget-container');
|
|
@@ -80,7 +80,12 @@ const currentScriptTag = document.currentScript;
|
|
| 80 |
widgetContainer.style.paddingBottom = aspectPercent;
|
| 81 |
widgetContainer.setAttribute('data-original-aspect', aspectPercent);
|
| 82 |
|
| 83 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
widgetContainer.innerHTML = `
|
| 85 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 86 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
@@ -88,10 +93,8 @@ const currentScriptTag = document.currentScript;
|
|
| 88 |
</div>
|
| 89 |
<button id="fullscreen-toggle-${instanceId}" class="widget-button fullscreen-toggle">β±</button>
|
| 90 |
<button id="help-toggle-${instanceId}" class="widget-button help-toggle">?</button>
|
| 91 |
-
<button id="reset-camera-btn-${instanceId}" class="widget-button reset-camera-btn">
|
| 92 |
-
|
| 93 |
-
</button>
|
| 94 |
-
${config.tooltips_url ? `<button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">β¦Ώ</button>` : ''}
|
| 95 |
<div id="menu-content-${instanceId}" class="menu-content">
|
| 96 |
<span id="help-close-${instanceId}" class="help-close">Γ</span>
|
| 97 |
<div class="help-text"></div>
|
|
@@ -105,11 +108,10 @@ const currentScriptTag = document.currentScript;
|
|
| 105 |
</div>
|
| 106 |
</div>
|
| 107 |
`;
|
| 108 |
-
|
| 109 |
-
// Append the widget container immediately after the <script> tag
|
| 110 |
scriptTag.parentNode.appendChild(widgetContainer);
|
| 111 |
|
| 112 |
-
// βββ 6. Grab references
|
| 113 |
const viewerContainerElem = document.getElementById('viewer-container-' + instanceId);
|
| 114 |
const fullscreenToggle = document.getElementById('fullscreen-toggle-' + instanceId);
|
| 115 |
const helpToggle = document.getElementById('help-toggle-' + instanceId);
|
|
@@ -119,22 +121,22 @@ const currentScriptTag = document.currentScript;
|
|
| 119 |
const menuContent = document.getElementById('menu-content-' + instanceId);
|
| 120 |
const helpTextDiv = menuContent.querySelector('.help-text');
|
| 121 |
|
| 122 |
-
// Tooltip panel
|
| 123 |
const tooltipPanel = document.getElementById('tooltip-panel');
|
| 124 |
const tooltipTextDiv = document.getElementById('tooltip-text');
|
| 125 |
const tooltipImage = document.getElementById('tooltip-image');
|
| 126 |
const tooltipCloseBtn = document.getElementById('tooltip-close');
|
| 127 |
|
| 128 |
-
// βββ 6a.
|
| 129 |
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
| 130 |
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 131 |
|
| 132 |
-
// Conditionally include the French tooltip instruction
|
| 133 |
const tooltipInstruction = config.tooltips_url
|
| 134 |
? '- Cliquez sur β¦Ώ pour afficher/masquer les tooltips.<br>'
|
| 135 |
: '';
|
| 136 |
|
| 137 |
-
// βββ
|
| 138 |
if (isMobile) {
|
| 139 |
helpTextDiv.innerHTML = `
|
| 140 |
- Pour vous dΓ©placer, glissez deux doigts sur l'Γ©cran.<br>
|
|
@@ -155,10 +157,24 @@ const currentScriptTag = document.currentScript;
|
|
| 155 |
`;
|
| 156 |
}
|
| 157 |
|
| 158 |
-
//
|
| 159 |
menuContent.style.display = 'block';
|
| 160 |
viewerContainerElem.style.display = 'block';
|
| 161 |
|
| 162 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
})();
|
|
|
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
| 75 |
+
// βββ 5. Create the widget container ββββββββββββββββββββββββββββββββββββββββββββ
|
| 76 |
const widgetContainer = document.createElement('div');
|
| 77 |
widgetContainer.id = 'ply-widget-container-' + instanceId;
|
| 78 |
widgetContainer.classList.add('ply-widget-container');
|
|
|
|
| 80 |
widgetContainer.style.paddingBottom = aspectPercent;
|
| 81 |
widgetContainer.setAttribute('data-original-aspect', aspectPercent);
|
| 82 |
|
| 83 |
+
// Conditionally add the tooltips toggle button only if defined
|
| 84 |
+
const tooltipsButtonHTML = config.tooltips_url
|
| 85 |
+
? `<button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">β¦Ώ</button>`
|
| 86 |
+
: '';
|
| 87 |
+
|
| 88 |
+
// Add all inner HTML, including help panel with French lines
|
| 89 |
widgetContainer.innerHTML = `
|
| 90 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 91 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
|
|
| 93 |
</div>
|
| 94 |
<button id="fullscreen-toggle-${instanceId}" class="widget-button fullscreen-toggle">β±</button>
|
| 95 |
<button id="help-toggle-${instanceId}" class="widget-button help-toggle">?</button>
|
| 96 |
+
<button id="reset-camera-btn-${instanceId}" class="widget-button reset-camera-btn">β²</button>
|
| 97 |
+
${tooltipsButtonHTML}
|
|
|
|
|
|
|
| 98 |
<div id="menu-content-${instanceId}" class="menu-content">
|
| 99 |
<span id="help-close-${instanceId}" class="help-close">Γ</span>
|
| 100 |
<div class="help-text"></div>
|
|
|
|
| 108 |
</div>
|
| 109 |
</div>
|
| 110 |
`;
|
| 111 |
+
// Append to DOM
|
|
|
|
| 112 |
scriptTag.parentNode.appendChild(widgetContainer);
|
| 113 |
|
| 114 |
+
// βββ 6. Grab references βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 115 |
const viewerContainerElem = document.getElementById('viewer-container-' + instanceId);
|
| 116 |
const fullscreenToggle = document.getElementById('fullscreen-toggle-' + instanceId);
|
| 117 |
const helpToggle = document.getElementById('help-toggle-' + instanceId);
|
|
|
|
| 121 |
const menuContent = document.getElementById('menu-content-' + instanceId);
|
| 122 |
const helpTextDiv = menuContent.querySelector('.help-text');
|
| 123 |
|
| 124 |
+
// Tooltip panel refs
|
| 125 |
const tooltipPanel = document.getElementById('tooltip-panel');
|
| 126 |
const tooltipTextDiv = document.getElementById('tooltip-text');
|
| 127 |
const tooltipImage = document.getElementById('tooltip-image');
|
| 128 |
const tooltipCloseBtn = document.getElementById('tooltip-close');
|
| 129 |
|
| 130 |
+
// βββ 6a. Mobile detection βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 131 |
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
| 132 |
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 133 |
|
| 134 |
+
// Conditionally include the French tooltip instruction
|
| 135 |
const tooltipInstruction = config.tooltips_url
|
| 136 |
? '- Cliquez sur β¦Ώ pour afficher/masquer les tooltips.<br>'
|
| 137 |
: '';
|
| 138 |
|
| 139 |
+
// βββ 6b. Populate help-text with French instructions ββββββββββββββββββββββββββ
|
| 140 |
if (isMobile) {
|
| 141 |
helpTextDiv.innerHTML = `
|
| 142 |
- Pour vous dΓ©placer, glissez deux doigts sur l'Γ©cran.<br>
|
|
|
|
| 157 |
`;
|
| 158 |
}
|
| 159 |
|
| 160 |
+
// Show help panel by default
|
| 161 |
menuContent.style.display = 'block';
|
| 162 |
viewerContainerElem.style.display = 'block';
|
| 163 |
|
| 164 |
+
// βββ 7. Dynamically load viewer.js βββββββββββββββββββββββββββββββββββββββββββ
|
| 165 |
+
try {
|
| 166 |
+
console.log('[Viewer-Debug] About to import viewer.js');
|
| 167 |
+
const viewerModule = await import('./viewer.js');
|
| 168 |
+
console.log('[Viewer-Debug] viewer.js imported, calling initializeViewer()');
|
| 169 |
+
await viewerModule.initializeViewer(config, instanceId);
|
| 170 |
+
console.log('[Viewer-Debug] initializeViewer() completed');
|
| 171 |
+
} catch (err) {
|
| 172 |
+
console.error("Failed to load viewer.js or initialize the 3D viewer:", err);
|
| 173 |
+
return;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
// βββ 8. Rest of the event listeners (fullscreen, help toggle, tooltips, etc.) β
|
| 177 |
+
// (This section remains exactly as before, wiring up all button behaviour,
|
| 178 |
+
// drag-to-hide, wheel-to-hide, resize listeners, etc., without alteration.)
|
| 179 |
|
| 180 |
})();
|