diff --git a/contents.js b/contents.js index 5f2b4bf..16042c9 100644 --- a/contents.js +++ b/contents.js @@ -3,6 +3,9 @@ const contributionsList = document.getElementById("contributions"); const pagedjs = document.createElement("script"); pagedjs.src = "https://unpkg.com/pagedjs/dist/paged.polyfill.js"; +pagedjs.id ="printview" + +const printLib = document.getElementById("print"); window.addEventListener("load", () => { fetchContents(); @@ -10,6 +13,8 @@ window.addEventListener("load", () => { //document.getElementsByTagName("head")[0].appendChild(pagedjs); }); +printLib.addEventListener("click", () => printViewToggle()) + function fetchContents() { fetch("https://hub.xpub.nl/soupboat/atlas-api/contributions") .then((response) => response.json()) @@ -44,3 +49,19 @@ function atlasLink() { group.appendChild(link); } } + + + +function printViewToggle() { + var printview = document.getElementById("printview") + if (!printview) { + + document.getElementsByTagName("head")[0].appendChild(pagedjs); + console.log("first") + + } else { + //document.getElementsByTagName("head")[0].removeChild(printview); + pagejs.remove(); + console.log("aooooo che cazzo"); + } +} \ No newline at end of file diff --git a/index.html b/index.html index f3d8a16..3c34123 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@
+