Dynamic frontend usable
This commit is contained in:
parent
a4f6e305b1
commit
0b531a70f8
15
frontend.js
15
frontend.js
|
@ -4,7 +4,12 @@ class TPDF {
|
|||
console.log(TPDF.xhr.responseText);
|
||||
|
||||
if (TPDF.xhr.readyState == 4 && TPDF.xhr.status == 200) {
|
||||
TPDF.output.removeChild(TPDF.output.childNodes[0]);
|
||||
/* Clean up output div */
|
||||
while (TPDF.output.firstChild) {
|
||||
TPDF.output.removeChild(TPDF.output.firstChild);
|
||||
}
|
||||
|
||||
/* Take up json */
|
||||
var results = JSON.parse(TPDF.xhr.responseText);
|
||||
|
||||
for (var i in results['books']) {
|
||||
|
@ -84,10 +89,16 @@ class TPDF {
|
|||
static submit() {
|
||||
TPDF.xhr = new XMLHttpRequest();
|
||||
TPDF.xhr.onload = TPDF.display;
|
||||
TPDF.xhr.open('GET', 'https://golem.linux.it/cgi/tpdf/main.py?format=json')
|
||||
TPDF.xhr.open('GET',
|
||||
'https://golem.linux.it/cgi/tpdf/main.py?format=json' +
|
||||
'&author=' + encodeURIComponent(document.querySelector('#tpdfForm input[name="author"]').value) +
|
||||
'&title=' + encodeURIComponent(document.querySelector('#tpdfForm input[name="title"]').value));
|
||||
TPDF.xhr.send(null);
|
||||
|
||||
TPDF.output = document.getElementById('tpdfOutput');
|
||||
while (TPDF.output.firstChild) {
|
||||
TPDF.output.removeChild(TPDF.output.firstChild);
|
||||
}
|
||||
TPDF.output.childNodes[0].textContent = 'Searching...';
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div id="tpdfSearchDiv">
|
||||
<h1>TPDF - Tellico Parser anD Finder</h1>
|
||||
|
||||
<form action="main.py" method="get">
|
||||
<form id="tpdfForm" action="main.py" method="get">
|
||||
<label for="title">Title</label>
|
||||
<input type="text" name="title" />
|
||||
<br />
|
||||
|
|
Loading…
Reference in New Issue