SiegeEngineers / aoe2techtree

Age of Empires II Tech Tree
https://aoe2techtree.net/
MIT License
226 stars 59 forks source link

Add support for loading civs when the url hash changes from user browsing. #57

Closed jackmelcher closed 4 years ago

jackmelcher commented 4 years ago

I'm not too familiar with the pull request process, so I'd like to submit a suggestion.

Add the below javascript into the "index.html" script section to allow users to navigate between Civs they have looked at. This will allow users to more conveniently compare tech trees of multiple Civs via the Back and Forward buttons. Also, users will not have to solely rely on the Civ Selection Dropdown to navigate the site.

//Update the Civ based on the url hash to support browsing history navigation changes window.onhashchange = function(){ let hash = window.location.hash; let civselect = document.getElementById("civselect"); if(hash.split('#')[1] != civselect.value && hash != "") { civselect.value = hash.split('#')[1]; loadCiv(); } };

HSZemi commented 4 years ago

I added this feature you suggested in 9513883d77aca0ffbd9bb333e532e47de31ce46c. That is actually really nice, I didn't think I would like it so much until I added it and tried it out. Thank you very much for the suggestion :yellow_heart: