Skip to content
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

Back button functionality #248

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<!-- TODO Add active to mode when clicked-->
<div class="navbar navbar-item">
<div class="navbar-item-menu active" id="home">
<a href="/">Home</a>
<a href="/" id="homeLink">Home</a>
</div>
<div class="navbar-item-menu" id="about">
<a href="#about">About Us</a>
<a href="./#about">About Us</a>
</div>
<div class="navbar-item-menu" id="mode">
Mode
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/static/vulnerableApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,24 @@ function _addingEventListenerToShowHideHelpButton(vulnerableAppEndPointData) {
document.getElementById("aboutContainer").scrollIntoView(true);
});
})();


document.getElementById("learnAndPracticeBtn").addEventListener("click", pushToVulnerabilities);
let previousUrl;

function pushToVulnerabilities() {
let b = document.getElementById("learnAndPracticeBtn");
previousUrl = './learnVulnerabilities';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have URL's with the element id's. WDYT ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also
Hi @ShareACoke1 ,

I had looked at the code, actually if we can do the same with opening the URL directly in browser then it would be great. I was thinking that we can parse the url, find the id's and click on the elements with those id's. this way we can achieve the full flow.

WDYT ?
Also i was planning to look at the router logics in frameworks so that we can do the same.

thanks,
Karan

let id = b.id;
history.pushState({id}, 'Learning Vulnerabilities', './learnVulnerabilities')
}

window.addEventListener('popstate', e => {
if (previousUrl === './learnVulnerabilities') {
returnToHome();
}
});

function returnToHome() {
document.getElementById("homeLink").click(); // Click on the checkbox
}