From 0b531a70f88a138bd6d4295ea81bec96cccc2ac1 Mon Sep 17 00:00:00 2001 From: giomba Date: Sat, 24 Nov 2018 16:10:41 +0100 Subject: [PATCH] Dynamic frontend usable --- frontend.js | 15 +++++++++++++-- index.html | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend.js b/frontend.js index ce2a958..449d687 100644 --- a/frontend.js +++ b/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...'; } diff --git a/index.html b/index.html index edc7bc0..3bc0c83 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@

TPDF - Tellico Parser anD Finder

-
+