| author | |
| committer | |
| log | c9ffb6f734567ecb2a368d0d8786e9d1365f42b8 |
| tree | 8aebe9ad34e1d911a021984cafe71309b375a97b |
| parent | 545830c0fff449f219557b45911195b4a4026692 |
Before this change every keypress in the search field causes a browser
history entry, which makes navigating back annoying.
On first keypress in the search field, a new history entry is created.
On subsequent keypresses, the most recent history entry is replaced.
Therefore a typical history after searching and navigating to an entry
might look like
1. documentation root
2. search page "print"
3. docs for `std.debug.print`
Co-authored-by: Žiga Željko <ziga.zeljko@gmail.com>1 files changed, 7 insertions(+), 1 deletions(-)
lib/std/special/docs/main.js+7-1| ... | ... | @@ -1844,7 +1844,13 @@ |
| 1844 | 1844 | var oldHash = location.hash; |
| 1845 | 1845 | var parts = oldHash.split("?"); |
| 1846 | 1846 | var newPart2 = (domSearch.value === "") ? "" : ("?" + domSearch.value); |
| 1847 | location.hash = (parts.length === 1) ? (oldHash + newPart2) : (parts[0] + newPart2); | |
| 1847 | var newHash = (oldHash === "" ? "#" : parts[0]) + newPart2; | |
| 1848 | // create a history entry only once per search | |
| 1849 | if (parts.length === 1) { | |
| 1850 | location.assign(newHash); | |
| 1851 | } else { | |
| 1852 | location.replace(newHash); | |
| 1853 | } | |
| 1848 | 1854 | } |
| 1849 | 1855 | function getSearchTerms() { |
| 1850 | 1856 | var list = curNavSearch.trim().split(/[ \r\n\t]+/); |