From 26382832f2a1445786cd90009120285c7b4b0014 Mon Sep 17 00:00:00 2001 From: GitJournal Date: Wed, 10 Jan 2024 05:52:16 +0800 Subject: [PATCH] update1 --- docs/index.html | 26 ++++++++++++++++++++++++-- docs/metadata.json | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/index.html b/docs/index.html index 9597a35..a46d767 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,5 +1,6 @@ + @@ -395,6 +396,7 @@ // const RESULT_LIMIT = 50; const progressOverlay = document.getElementById('progress-overlay'); const progressBar = document.querySelector('.progress'); + var isDebugMode = false; function navigateToPage(base_filepath, language_id, project_id, detail_filepath = "") { // Use a relative path to navigate to a specific page let page_param = "codeview.html"; @@ -580,6 +582,7 @@ const field = result.field; // "content" const ids = result.result; ids.forEach(id => { + id = id - 0 // to integer. const data_type = data[id].type; const file_id = data[id].file_id; if (searchResultItems[file_id] === undefined) { @@ -594,7 +597,11 @@ if (detail_types.indexOf(data_type) != -1) { const pair_id = ((data_type === "code") ? id : (id - 1)); if (searchResultItems[file_id].pairs[pair_id] === undefined) { - searchResultItems[file_id].pairs[pair_id] = { "left": data[pair_id].content, "right": data[pair_id - 1].content, "location": data[pair_id].location }; + // console.log(pair_id, pair_id+1, data_type, data[pair_id].location) + let mit = { "left": data[pair_id].content, "right": data[pair_id + 1].content, "location": data[pair_id].location } + // let mit = { "left": data[pair_id].content, "right": data[pair_id - 1].content, "location": data[pair_id].location } + // console.log(mit) + searchResultItems[file_id].pairs[pair_id] = mit; } } // listItem.textContent = `[${field}][${data_type}] ${data[id][field]}`; @@ -717,7 +724,20 @@ hasInputEvent = false; if (!isSearchRunning) { isSearchRunning = true; - searchInputEventListener(); + try { + searchInputEventListener(); + } catch (error) { + // Print exception info + console.error(error); + if (isDebugMode) { + // Show alert window in debug mode + console.log(error.message); + alert("An error occurred when searching: " + error.message); + } else { + // Raise exception when not in debug mode + throw error; + } + } isSearchRunning = false; } } @@ -747,6 +767,8 @@ const queryParams = getQueryParams(window.location.search); const query_from_url = queryParams.q; const file_path_from_url = queryParams.file; + isDebugMode = queryParams.debug == 'true'; + if (isDebugMode){console.log("You are in debug mode.")} if (query_from_url != null || query_from_url != undefined) { setTextAndTriggerInputEvent(query_from_url) } else if (file_path_from_url != null || file_path_from_url != undefined) { diff --git a/docs/metadata.json b/docs/metadata.json index e466981..63dfb2e 100644 --- a/docs/metadata.json +++ b/docs/metadata.json @@ -7,7 +7,7 @@ "0": { "filepath": "/README.md", "entry_id": 0, - "language_id": "plain-text" + "language_id": "markdown" }, "1": { "filepath": "/hubconf.py",