From d8c68fe9cc59f667478bb763cf690d8f771afa59 Mon Sep 17 00:00:00 2001 From: Louie S Date: Mon, 3 Apr 2023 20:04:52 -0700 Subject: Fix refresh issue --- backend/__pycache__/config.cpython-39.pyc | Bin 413 -> 413 bytes .../endpoints/__pycache__/get_plist.cpython-39.pyc | Bin 1814 -> 1816 bytes backend/endpoints/get_plist.py | 4 ++-- backend/server.py | 2 +- frontend/index.html | 7 ------- frontend/script.js | 20 ++++++-------------- 6 files changed, 9 insertions(+), 24 deletions(-) diff --git a/backend/__pycache__/config.cpython-39.pyc b/backend/__pycache__/config.cpython-39.pyc index 03ffd8d..4c9478f 100644 Binary files a/backend/__pycache__/config.cpython-39.pyc and b/backend/__pycache__/config.cpython-39.pyc differ diff --git a/backend/endpoints/__pycache__/get_plist.cpython-39.pyc b/backend/endpoints/__pycache__/get_plist.cpython-39.pyc index 5410abf..892892d 100644 Binary files a/backend/endpoints/__pycache__/get_plist.cpython-39.pyc and b/backend/endpoints/__pycache__/get_plist.cpython-39.pyc differ diff --git a/backend/endpoints/get_plist.py b/backend/endpoints/get_plist.py index 1fda2d5..07d7b3a 100644 --- a/backend/endpoints/get_plist.py +++ b/backend/endpoints/get_plist.py @@ -9,8 +9,6 @@ from config import Config class Get_Plist: output = dict() - output["docsets"] = [] - def find_plist(path): with os.scandir(path) as it: @@ -46,6 +44,8 @@ class Get_Plist: def main(): + Get_Plist.output["docsets"] = [] + if not os.path.isdir(Config.docset_base): e = "Invalid DOCSET_BASE \"" + Config.docset_base + "\"" logging.error(e); diff --git a/backend/server.py b/backend/server.py index 477ad15..231a16a 100644 --- a/backend/server.py +++ b/backend/server.py @@ -9,11 +9,11 @@ class MyServer(http.server.BaseHTTPRequestHandler): self.send_header("Content-type", "application/json") self.send_header("Access-Control-Allow-Origin", "*") self.send_header("Access-Control-Allow-Headers", "content-type") + self.end_headers() output = Get_Plist.main() self.wfile.write(output.encode()) - if __name__ == "__main__": webServer = http.server.HTTPServer((Config.hostName, Config.serverPort), MyServer) print("Server started http://%s:%s" % (Config.hostName, Config.serverPort)) diff --git a/frontend/index.html b/frontend/index.html index 4036645..4828dd9 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -16,13 +16,6 @@ - - - - - diff --git a/frontend/script.js b/frontend/script.js index f40d70b..90dcb9a 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -1,35 +1,26 @@ const endpoint = "http://127.0.0.1:8080/endpoints" +let i = 0; -console.log("hello"); function set_embed_page(url) { document.getElementById("docset-page").src = url; } function populateSearchBar(docset_json) { - console.log(docset_json); + //console.log(docset_json); + ++i; + console.log(i); // Add to search bar document.getElementById("searchbar").getElementsByTagName("tbody")[0].innerHTML += "" + "" + - "" + "" + ""; - - // 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"); @@ -44,5 +35,6 @@ xhttp.onload = function(){ //populateSearchBar(json_response["docsets"][0]); json_response["docsets"].forEach(populateSearchBar); + delete json_response } xhttp.send(); -- cgit