const autoEmbedLinksDivs = document.querySelectorAll(".h5p-autoembed"); let loadAutoResizerJs = false; for (const div of autoEmbedLinksDivs) { const autoEmbedLink = div.querySelector("a.autolink"); const autoEmbedUrl = new URL(autoEmbedLink.href); const autoEmbedId = autoEmbedUrl.searchParams.get("id"); const iframe = document.createElement('iframe'); // Concatenate the URL to prevent Moodle's auto link feature to mess with the url iframe.src = "https://" + "lernplattform.bycs.de/mod/hvp/embed.php?id=" + autoEmbedId; iframe.frameborder = div.frameborder ? div.frameborder : 0; iframe.allowfullscreen = div.allowfullscreen ? div.allowfullscreen : "allowfullscreen"; iframe.title = autoEmbedLink.title; if (div.width) { iframe.width = div.width; } else { loadAutoResizerJs = true; } if (div.height) { iframe.height = div.height; } else { loadAutoResizerJs = true; } // Replace the div with the new iframe div.parentNode.replaceChild(iframe, div); } if(loadAutoResizerJs) { let head = document.getElementsByTagName('head')[0]; let js = document.createElement("script"); js.type = "text/javascript"; js.src="https://lernplattform.bycs.de/mod/hvp/library/js/h5p-resizer.js"; head.appendChild(js); }