-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nav changes not being displayed on small screens #3
base: main
Are you sure you want to change the base?
Conversation
Fix nav changes not being displayed on small screens
Fix nav changes not being displayed on small screens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for submitting your PR. I appreciate your efforts in addressing issue #2.
You have effectively resolved the problem by adding a second
By using the cloneNode() function, you can avoid duplicating the code and achieve the same desired result. It creates a copy of the element, including all its children and attributes. You can find more information about the cloneNode() function here.
Additionally, I would like to understand the benefits of the executeAsync() function for the code base. Could you please provide an explanation?
|
||
let a = document.createElement("li"); | ||
a.setAttribute("class", "px-6 py-3"); | ||
span = document.createElement("span"); | ||
span.setAttribute("class", "focus:outline-none"); | ||
span.setAttribute("tabindex", "0"); | ||
a.appendChild(span); | ||
link = document.createElement("a"); | ||
link.setAttribute("href", buttons[title].link); | ||
link.setAttribute("target", buttons[title].target); | ||
if (buttons[title].target == "_blank") | ||
link.setAttribute("rel", "noopener noreferrer"); | ||
link.setAttribute( | ||
"class" | ||
, "cursor-pointer router-link flex justify-between" | ||
); | ||
span.appendChild(link); | ||
p = document.createElement("p"); | ||
p.innerHTML = title; | ||
link.appendChild(p); | ||
p = document.createElement("p"); | ||
p.setAttribute("class", "text-white"); | ||
p.innerHTML = " • "; | ||
link.appendChild(p); | ||
|
||
n[1].insertAdjacentElement("beforeend", a); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to duplicate this part.
Better use .cloneNode(true);
var s = setInterval(function () { | ||
try { | ||
let n = document.querySelectorAll('.absolute.top-0.left-0.w-full'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is querySelectorAll needed here?
// console.log(n2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unneeded console.log() or replace it with console.debug()
function executeAsync(func) { | ||
try { | ||
let bar = e.target.parentElement; | ||
if(bar.classList == "flex justify-between cursor-pointer px-6 py-3") bar = bar.parentElement; | ||
if ( | ||
!( | ||
bar.classList == | ||
"bg-primary-900 border-t first:border-t-0 border-primary-500" | ||
) | ||
) | ||
throw "Clicked element isn't a navbar element"; | ||
if (bar.children[0].children[0].innerHTML == buttons[title].navbar) { | ||
let listing = | ||
bar.children[1].children[0].children[0].cloneNode(true); | ||
listing.children[0].children[0].children[0].innerHTML = title; | ||
try { | ||
let link = ""; | ||
extractString(buttons[title].link, "<", ">").forEach( | ||
(commands) => { | ||
if (commands.charAt(0) == "<") | ||
link = link + eval(commands.substring(1)); | ||
else link = link + commands; | ||
setTimeout(func, 0); | ||
} catch (error) { | ||
// (Note: the exact output may be browser-dependent) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this function needed?
[Fix nav changes not being displayed on small screens.