summaryrefslogtreecommitdiff
path: root/frontend/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/script.js')
-rw-r--r--frontend/script.js40
1 files changed, 37 insertions, 3 deletions
diff --git a/frontend/script.js b/frontend/script.js
index 05468dc..f40d70b 100644
--- a/frontend/script.js
+++ b/frontend/script.js
@@ -2,13 +2,47 @@ const endpoint = "http://127.0.0.1:8080/endpoints"
console.log("hello");
-document.getElementById("docset-example-parent").onclick = function(){
- document.getElementById("docset-page").src = "https://example.com";
+function set_embed_page(url) {
+ document.getElementById("docset-page").src = url;
}
+function populateSearchBar(docset_json) {
+ console.log(docset_json);
+
+ // Add to search bar
+ document.getElementById("searchbar").getElementsByTagName("tbody")[0].innerHTML += "<tr>" +
+ "<td scope=\"row\">" +
+ "<button id=\"docset-\"" + docset_json["CFBundleIdentifier"] + "-parent\" class=\"docset-parent\">" +
+ docset_json["CFBundleName"] +
+ "</button>" +
+ "</td>" +
+ "</tr>";
+
+ // Add onclick event
+ /*
+ document.getElementById("docset-" + docset_json["CFBundleIdentifier"] + "-parent").addEventListener("click", function(){
+ set_embed_page(docset_json["docset_root"]);
+ });
+ */
+}
+
+document.getElementById("docset-example-parent").addEventListener("click", function() {
+ set_embed_page("https://example.com");
+});
+
+
let xhttp = new XMLHttpRequest();
xhttp.open("GET", endpoint + "/get_plist.py");
xhttp.onload = function(){
- console.log(this.response);
+ const json_response = JSON.parse(this.response);
+ console.log(json_response);
+
+ if(!json_response["success"]) {
+ console.warn("Invalid json_response");
+ return 1;
+ }
+
+ //populateSearchBar(json_response["docsets"][0]);
+ json_response["docsets"].forEach(populateSearchBar);
}
xhttp.send();