Skip to content

Commit 28d36ac

Browse files
committed
Fix wrapper mode demo to use CDN on deployed site
- Use dynamic script loading with environment detection - Load from ../dist locally, unpkg CDN on deployed demo - Bump version to 1.3.1
1 parent d61f38b commit 28d36ac

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

demo/wrapper-mode.html

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,37 @@ <h3>Wrapper Mode Demo</h3>
215215
</div>
216216
</div>
217217

218-
<!-- Service Injector in Wrapper Mode -->
219-
<script
220-
id="service-injector"
221-
src="../dist/index.iife.js"
222-
data-wrapper-mode="true"
223-
data-wrapper-url="https://en.wikipedia.org/wiki/OpenStreetMap"
224-
data-url="https://www.openstreetmap.org/export/embed.html?bbox=-0.15%2C51.49%2C-0.08%2C51.52&layer=mapnik"
225-
data-position="right"
226-
data-offset="50%"
227-
data-window-width="400px"
228-
data-window-height="350px"
229-
data-dockable="true"
230-
></script>
231-
232218
<script>
219+
// Determine script URL based on environment (local vs deployed)
220+
function getScriptUrl() {
221+
var isLocal = window.location.hostname === 'localhost' ||
222+
window.location.hostname === '127.0.0.1' ||
223+
window.location.protocol === 'file:';
224+
225+
if (isLocal) {
226+
return '../dist/index.iife.js';
227+
} else {
228+
// Use CDN for deployed demo
229+
return 'https://unpkg.com/service-injector/dist/index.iife.js';
230+
}
231+
}
232+
233+
// Create and inject the service-injector script
234+
(function() {
235+
var script = document.createElement('script');
236+
script.id = 'service-injector';
237+
script.src = getScriptUrl();
238+
script.setAttribute('data-wrapper-mode', 'true');
239+
script.setAttribute('data-wrapper-url', 'https://en.wikipedia.org/wiki/OpenStreetMap');
240+
script.setAttribute('data-url', 'https://www.openstreetmap.org/export/embed.html?bbox=-0.15%2C51.49%2C-0.08%2C51.52&layer=mapnik');
241+
script.setAttribute('data-position', 'right');
242+
script.setAttribute('data-offset', '50%');
243+
script.setAttribute('data-window-width', '400px');
244+
script.setAttribute('data-window-height', '350px');
245+
script.setAttribute('data-dockable', 'true');
246+
document.body.appendChild(script);
247+
})();
248+
233249
// Panel minimize/expand toggle
234250
function togglePanel() {
235251
var panel = document.getElementById('controlPanel');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "service-injector",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Lightweight library for SaaS providers to embed services on client websites as a floating tab/window with iframe integration",
55
"author": "OrienteerBAP",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)