-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10d5b20
commit 70b810c
Showing
3 changed files
with
20 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 16 additions & 18 deletions
34
static/to_compile/entrypoints/assistant/script-to-iframe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
import { iframeResize } from "iframe-resizer"; | ||
|
||
window.addEventListener("DOMContentLoaded", () => { | ||
const script = document.getElementById("quefairedemesdechets"); | ||
const slug = script?.dataset?.objet; | ||
const origin = new URL(script?.getAttribute("src")).origin | ||
const src = `${origin}/dechet/${slug || ''}?iframe`; | ||
const iframe = document.createElement("iframe"); | ||
const script = document.currentScript as HTMLScriptElement | ||
const slug = script?.dataset?.objet; | ||
const origin = new URL(script?.getAttribute("src")).origin | ||
const src = `${origin}/dechet/${slug || ''}?iframe`; | ||
const iframe = document.createElement("iframe"); | ||
|
||
const iframeAttributes = { | ||
src, | ||
style: "border: none; width: 100%; display: block; margin: 0 auto;", | ||
allowfullscreen: true, | ||
allow: "geolocation; clipboard-write", | ||
}; | ||
const iframeAttributes = { | ||
src, | ||
style: "border: none; width: 100%; display: block; margin: 0 auto;", | ||
allowfullscreen: true, | ||
allow: "geolocation; clipboard-write", | ||
}; | ||
|
||
for (var key in iframeAttributes) { | ||
iframe.setAttribute(key, iframeAttributes[key]); | ||
} | ||
for (var key in iframeAttributes) { | ||
iframe.setAttribute(key, iframeAttributes[key]); | ||
} | ||
|
||
iframeResize({}, iframe); | ||
iframeResize({}, iframe); | ||
|
||
script.parentNode.insertBefore(iframe, script); | ||
}) | ||
script.parentNode.insertBefore(iframe, script); |