summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2023-04-03 17:16:25 -0700
committerLouie Shprung <lshprung@scu.edu>2023-04-03 17:16:25 -0700
commite45d210517ae56abfec61ce1a8db1fc6ed7c4b4b (patch)
treebc10dd29333025b8eaf77ed68164e32d4ce15c0f
parentd209ff852ff153b067e975deda28cbdfa7d0dd41 (diff)
Get buttons printing
-rw-r--r--backend/__pycache__/config.cpython-39.pycbin426 -> 413 bytes
-rw-r--r--backend/endpoints/__pycache__/get_plist.cpython-39.pycbin1814 -> 1814 bytes
-rw-r--r--backend/endpoints/get_plist.py2
-rw-r--r--frontend/script.js40
4 files changed, 38 insertions, 4 deletions
diff --git a/backend/__pycache__/config.cpython-39.pyc b/backend/__pycache__/config.cpython-39.pyc
index 662d54d..03ffd8d 100644
--- a/backend/__pycache__/config.cpython-39.pyc
+++ b/backend/__pycache__/config.cpython-39.pyc
Binary files differ
diff --git a/backend/endpoints/__pycache__/get_plist.cpython-39.pyc b/backend/endpoints/__pycache__/get_plist.cpython-39.pyc
index d70e425..5410abf 100644
--- a/backend/endpoints/__pycache__/get_plist.cpython-39.pyc
+++ b/backend/endpoints/__pycache__/get_plist.cpython-39.pyc
Binary files differ
diff --git a/backend/endpoints/get_plist.py b/backend/endpoints/get_plist.py
index 6d2ca4c..1fda2d5 100644
--- a/backend/endpoints/get_plist.py
+++ b/backend/endpoints/get_plist.py
@@ -19,7 +19,7 @@ class Get_Plist:
plist_path = os.path.join(docset_root, "Contents", "Info.plist")
if(os.path.isfile(plist_path)):
if(Get_Plist.parse_plist(plist_path)):
- Get_Plist.output["docsets"][-1]["plist_path"] = plist_path
+ Get_Plist.output["docsets"][-1]["docset_root"] = docset_root
for f in ["icon.png", "icon@2x.png"]:
if os.path.isfile(os.path.join(docset_root, f)):
Get_Plist.output["docsets"][-1][f] = os.path.join(docset_root, f)
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();