btn pagedjs

master
grgr 3 years ago
parent 82b654c85b
commit 72f3eed19f

@ -3,6 +3,9 @@ const contributionsList = document.getElementById("contributions");
const pagedjs = document.createElement("script"); const pagedjs = document.createElement("script");
pagedjs.src = "https://unpkg.com/pagedjs/dist/paged.polyfill.js"; pagedjs.src = "https://unpkg.com/pagedjs/dist/paged.polyfill.js";
pagedjs.id ="printview"
const printLib = document.getElementById("print");
window.addEventListener("load", () => { window.addEventListener("load", () => {
fetchContents(); fetchContents();
@ -10,6 +13,8 @@ window.addEventListener("load", () => {
//document.getElementsByTagName("head")[0].appendChild(pagedjs); //document.getElementsByTagName("head")[0].appendChild(pagedjs);
}); });
printLib.addEventListener("click", () => printViewToggle())
function fetchContents() { function fetchContents() {
fetch("https://hub.xpub.nl/soupboat/atlas-api/contributions") fetch("https://hub.xpub.nl/soupboat/atlas-api/contributions")
.then((response) => response.json()) .then((response) => response.json())
@ -44,3 +49,19 @@ function atlasLink() {
group.appendChild(link); 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");
}
}

@ -14,6 +14,7 @@
<body> <body>
<div class="container"> <div class="container">
<div class="atlas"> <div class="atlas">
<button id="print">libretto</button>
<svg <svg
width="1000" width="1000"
height="1000" height="1000"

@ -69,7 +69,7 @@
.contribution { .contribution {
border-bottom: none; border-bottom: none;
overflow: auto; overflow: hidden;
} }

Loading…
Cancel
Save