create index funct

master
grgr 2 years ago
commit 1775fa0f07

@ -4,7 +4,7 @@ const trackList = document.getElementById("trackList");
const pagedjs = document.createElement("script");
pagedjs.src = "https://unpkg.com/pagedjs/dist/paged.polyfill.js";
pagedjs.id ="printview"
pagedjs.id = "printview";
const printLib = document.getElementById("btn-print");
@ -14,7 +14,7 @@ window.addEventListener("load", () => {
//document.getElementsByTagName("head")[0].appendChild(pagedjs);
});
printLib.addEventListener("click", () =>{
printLib.addEventListener("click", () => {
printViewToggle();
console.log(btnPrint);
});
@ -26,6 +26,7 @@ function fetchContents() {
}
function populateContributions(contributions) {
contributions.sort((a, b) => a.order - b.order);
contributions.forEach((contribution) => {
contributionsList.appendChild(createSection(contribution));
createIndexSection(contribution);
@ -48,7 +49,7 @@ function atlasLink() {
let groups = atlas.querySelectorAll("g");
for (const group of groups) {
let link = document.createElementNS("http://www.w3.org/2000/svg", "a");
link.setAttributeNS("http://www.w3.org/2000/svg", "href", "#" + group.id);
link.setAttribute("href", "#" + group.id);
link.innerHTML = group.innerHTML;
group.innerHTML = "";
group.appendChild(link);
@ -56,7 +57,7 @@ function atlasLink() {
}
function createIndexSection(contribution) {
let table = document.createElement("table");
let table = document.createElement("table");
let title = document.createElement("h4");
title.innerHTML = contribution.title;
if (contribution.audio){
@ -77,20 +78,16 @@ function createIndexSection(contribution) {
trackList.appendChild(table);
}
function printViewToggle() {
var printview = document.getElementById("printview")
var printview = document.getElementById("printview");
if (!printview) {
document.getElementsByTagName("head")[0].appendChild(pagedjs);
// sto provando sta porcata qui, ma non funzia uguale. quando la pagina si trasforma in pagedjs la variabile del btn non è più definita (????)
var btnPrint = document.getElementById("btn-print");
console.log(btnPrint);
} else {
//document.getElementsByTagName("head")[0].removeChild(printview);
pagejs.remove();
console.log("aooooo che cazzo");
}
}
}

@ -14,7 +14,7 @@
<body>
<div class="container">
<div class="atlas">
<button id="btn-print">libretto</button>
<!-- <button id="btn-print">libretto</button> -->
<svg
width="1000"
height="1000"
@ -152,7 +152,7 @@
<dt>Caretakers</dt>
<dd>Erica, Gersande, Kamo</dd>
</dl>
<button id="print">Print Libretto</button>
<button id="btn-print">Print Libretto</button>
</header>
<!-- <section class="vocabulary"></section> -->

@ -165,7 +165,7 @@ dd {
height: auto;
}
#print {
#btn-print {
display: inline-block;
margin-top: 32px;
background: none;
@ -174,7 +174,7 @@ dd {
font-size: 1rem;
}
#print:hover{
#btn-print:hover{
cursor: pointer;
}

Loading…
Cancel
Save