Skip to content

Commit 1cf44c4

Browse files
committed
Update doxygen-custom-page-injector.js
1 parent 38fb0cf commit 1cf44c4

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

doxygen/js/doxygen-custom-page-injector.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Created by basicx-StrgV //
33
// https://github.com/basicx-StrgV/ //
44
//--------------------------------------------------//
5-
// Version: 1.0.0 //
5+
// Version: 1.0.1 //
66
//--------------------------------------------------//
77
document.addEventListener("DOMContentLoaded", () => {
88
// Get the injection wrapper element and nav to value
@@ -39,27 +39,32 @@ document.addEventListener("DOMContentLoaded", () => {
3939
}
4040

4141
// Get the div that contains the content
42-
let containerChildren = document.getElementById("doc-content").children;
43-
let contentDiv;
44-
for (let i = 0; i < containerChildren.length; i++) {
45-
if (
46-
containerChildren[i].classList.length <= 0 &&
47-
containerChildren[i].id.trim() == ""
48-
) {
49-
// The content div has no classes or id
50-
contentDiv = containerChildren[i];
51-
}
52-
}
42+
let contentContainer = document.getElementById("doc-content");
5343

5444
// Exit if no content div was found and display error message
55-
if (contentDiv == null) {
45+
if (contentContainer == null) {
5646
document.body.innerHTML = "";
5747
document.body.innerText = "Failed to load custom page";
5848
return;
5949
}
6050

61-
// Replace document content
62-
contentDiv.innerHTML = injectionWrapper.innerHTML;
51+
// Clear the content div
52+
for (let i = 0; i < contentContainer.children.length; i++) {
53+
if (
54+
contentContainer.children[i].id.trim() != "MSearchSelectWindow" &&
55+
contentContainer.children[i].id.trim() != "MSearchResultsWindow"
56+
) {
57+
// Remove element from content if it does not belong to the layout
58+
contentContainer.removeChild(contentContainer.children[i]);
59+
}
60+
}
61+
62+
// Create a content wrapper element and add the custom content
63+
let contentWrapper = document.createElement("div");
64+
contentWrapper.innerHTML = injectionWrapper.innerHTML;
65+
66+
// Appand the content wrapper to the content container
67+
contentContainer.appendChild(contentWrapper);
6368
});
6469

6570
// Replace and close document

0 commit comments

Comments
 (0)