Skip to content

Instantly share code, notes, and snippets.

@jtuttas
Last active October 18, 2022 16:02
Show Gist options
  • Save jtuttas/69caf4b41ae38f66c255d7b4d262a37b to your computer and use it in GitHub Desktop.
Save jtuttas/69caf4b41ae38f66c255d7b4d262a37b to your computer and use it in GitHub Desktop.
MoodleContentLoader

Moodle Content Loader

Ein HTML zum Nachladen von HTML aus einem Repos. in eine Moodle Seite.

Anzupassen sind die Code genannten Variablen.

<!-- Content Loader Anzupassen ist in der folgenden Zeile die ID und die Variablen im Java Script Block -->
<p id="Aufgabe3"></p>
<script type="text/javascript">
// <![CDATA[
// Diese variablen müssen entsprechned angepasst wurden
// Tag ID des p Elementes (wie in Zeile 3)
var tagid = "Aufgabe3";
// Kommentar Tag im Markdown
var commentTag = "<!--Aufgabe3-->";
// Basis URL
var baseurl = "https://jtuttas.github.io/datenanalyse/docs/"
// Name der HTML Seite
var htmlpage = "azure_Texterkennung.html"
window.onload = function () {
console.log("All loaded");
fetch(baseurl + htmlpage + "?now=" + Date.now())
.then((response) => response.text())
.then((html) => {
html = html.replaceAll("src=\"", "src=\"" + baseurl)
html = html.split(commentTag);
document.getElementById(tagid).innerHTML = html[1];
var link = document.createElement('link');
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
//link.onload = CSSDone;
link.setAttribute("href", 'https://jtuttas.github.io/datenanalyse/css/syntax.css');
document.getElementsByTagName("head")[0].appendChild(link);
})
.catch((error) => {
console.warn(error);
});
}
// ]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment