-
Notifications
You must be signed in to change notification settings - Fork 351
Fix search history #748
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 search history #748
Conversation
assets/js/search.js
Outdated
export function popstateHandler (event) { | ||
if(event.originalEvent.state == null) { | ||
// NOTE: for reasons only known to the browser makers we need to reload here, | ||
// on back after navigating away the page (clicking a result in the search) |
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.
Trailing spaces not allowed.
assets/js/search.js
Outdated
search(sidebarNodes, searchVal) | ||
export function popstateHandler (event) { | ||
if(event.originalEvent.state == null) { | ||
// NOTE: for reasons only known to the browser makers we need to reload here, |
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.
Trailing spaces not allowed.
assets/js/search.js
Outdated
|
||
search(sidebarNodes, searchVal) | ||
export function popstateHandler (event) { | ||
if(event.originalEvent.state == null) { |
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.
Expected space(s) after "if".
assets/js/search.js
Outdated
}) | ||
} | ||
|
||
function closeResults(e, removeResults) { |
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.
Missing space before function parentheses.
assets/js/search.js
Outdated
|
||
$.merge($results.find('a'), $sidebarItems).on('click', closeResults) | ||
// every other link closes the search | ||
$.merge($results.find('a').not('.close-search'), $sidebarItems).on('click', function(e) { |
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.
Missing space before function parentheses.
assets/js/search.js
Outdated
}) | ||
|
||
$.merge($results.find('a'), $sidebarItems).on('click', closeResults) | ||
// every other link closes the search |
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.
Trailing spaces not allowed.
assets/js/search.js
Outdated
}) | ||
// sometimes we need to stop adding to the history if it already exists. | ||
if (addHistory !== false) { | ||
history.pushState({searchValue: value}, "Searching for " + value, "/Search.html?q=" + value); |
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.
Extra semicolon.
assets/js/search.js
Outdated
}) | ||
// sometimes we need to stop adding to the history if it already exists. | ||
if (addHistory !== false) { | ||
history.pushState({searchValue: value}, "Searching for " + value, "/Search.html?q=" + value); |
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.
Strings must use singlequote.
assets/js/search.js
Outdated
}) | ||
// sometimes we need to stop adding to the history if it already exists. | ||
if (addHistory !== false) { | ||
history.pushState({searchValue: value}, "Searching for " + value, "/Search.html?q=" + value); |
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.
Strings must use singlequote.
assets/js/search.js
Outdated
return decodeURIComponent(results[2].replace(/\+/g, " ")); | ||
} | ||
|
||
function pushLevel (levels, search_entity, name) { |
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.
Identifier 'search_entity' is not in camel case.
Enforce the usage of camel case to have a consistent codebase.
assets/js/search.js
Outdated
results = regex.exec(url); | ||
if (!results) return null; | ||
if (!results[2]) return ''; | ||
return decodeURIComponent(results[2].replace(/\+/g, " ")); |
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.
Extra semicolon.
assets/js/search.js
Outdated
results = regex.exec(url); | ||
if (!results) return null; | ||
if (!results[2]) return ''; | ||
return decodeURIComponent(results[2].replace(/\+/g, " ")); |
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.
Strings must use singlequote.
assets/js/search.js
Outdated
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | ||
results = regex.exec(url); | ||
if (!results) return null; | ||
if (!results[2]) return ''; |
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.
Extra semicolon.
assets/js/search.js
Outdated
name = name.replace(/[\[\]]/g, "\\$&"); | ||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | ||
results = regex.exec(url); | ||
if (!results) return null; |
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.
Extra semicolon.
assets/js/search.js
Outdated
if (!url) url = window.location.href; | ||
name = name.replace(/[\[\]]/g, "\\$&"); | ||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | ||
results = regex.exec(url); |
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.
Extra semicolon.
assets/js/search.js
Outdated
if (!url) url = window.location.href; | ||
name = name.replace(/[\[\]]/g, "\\$&"); | ||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | ||
results = regex.exec(url); |
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.
Expected indentation of 4 spaces but found 6.
assets/js/search.js
Outdated
export function getParameterByName(name, url) { | ||
if (!url) url = window.location.href; | ||
name = name.replace(/[\[\]]/g, "\\$&"); | ||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), |
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.
Strings must use singlequote.
assets/js/search.js
Outdated
export function getParameterByName(name, url) { | ||
if (!url) url = window.location.href; | ||
name = name.replace(/[\[\]]/g, "\\$&"); | ||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), |
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.
Strings must use singlequote.
assets/js/search.js
Outdated
export function getParameterByName(name, url) { | ||
if (!url) url = window.location.href; | ||
name = name.replace(/[\[\]]/g, "\\$&"); | ||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), |
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.
Split initialized 'var' declarations into multiple statements.
assets/js/search.js
Outdated
function search (nodes, value) { | ||
export function getParameterByName(name, url) { | ||
if (!url) url = window.location.href; | ||
name = name.replace(/[\[\]]/g, "\\$&"); |
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.
Extra semicolon.
Okay lot's of little things to fix here... |
assets/js/search.js
Outdated
} | ||
|
||
function search (nodes, value) { | ||
export function getParameterByName(name, url) { |
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.
Missing space before function parentheses.
assets/js/events.js
Outdated
$(window).on('popstate', popstateHandler) | ||
|
||
// if the search stub is refreshed or loaded perform the search. | ||
if (window.location.pathname == '/Search.html') { |
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.
Bad equality comparison: Expected '===' and instead saw '=='.
Okay Ebert should be happy now! |
I am not the person to review this one. :) So let's ping @nscyclone, @dignifiedquire, @milmazz and @eksperimental. |
Well this was a battle! Do we support browsers that don't have the History API?
https://caniuse.com/#feat=history
Please try to break this obviously, back buttons can be rather awkward to get right!
Fixes #341