-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (34 loc) · 1.39 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function book() {
var done;
var id = document.getElementById("book").value;
fetch("csv/books.csv")
.then(x => x.text())
.then(y => {
console.log(y);
var data = CSVToArray(y, ',');
data.forEach(element => {
element.forEach(name => {
if (id.includes(name)) {
console.log("Book found, viewing book via pdf.js...");
var pdf = document.createElement("div");
pdf.innerHTML = `
<div>
<iframe id="pdf-js-viewer" src="web/viewer.html?file=/code-books/pdfs/` + element[1] + `.pdf" title="webviewer" frameborder="0" width="800" height="600"></iframe>
</div>
`;
document.body.appendChild(pdf);
done = true;
}
})
});
if (done !== true) {
console.warn("Book was not found.");
var error = document.createElement("p");
error.innerHTML = "The code is invalid... Try entering the code again.";
error.className = "myBlinkingDiv";
error.style.color = "red";
document.body.appendChild(error);
start_blink();
}
});
}