Skip to content

Conversation

aphillipo
Copy link
Contributor

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

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)

Choose a reason for hiding this comment

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

Trailing spaces not allowed.

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,

Choose a reason for hiding this comment

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

Trailing spaces not allowed.


search(sidebarNodes, searchVal)
export function popstateHandler (event) {
if(event.originalEvent.state == null) {

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".

})
}

function closeResults(e, removeResults) {

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.


$.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) {

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.

})

$.merge($results.find('a'), $sidebarItems).on('click', closeResults)
// every other link closes the search

Choose a reason for hiding this comment

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

Trailing spaces not allowed.

})
// 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);

Choose a reason for hiding this comment

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

Extra semicolon.

Read more about it here.

})
// 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);

Choose a reason for hiding this comment

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

Strings must use singlequote.

Read more about it here.

})
// 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);

Choose a reason for hiding this comment

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

Strings must use singlequote.

Read more about it here.

return decodeURIComponent(results[2].replace(/\+/g, " "));
}

function pushLevel (levels, search_entity, name) {

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.

Read more about it here.

results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));

Choose a reason for hiding this comment

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

Extra semicolon.

Read more about it here.

results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));

Choose a reason for hiding this comment

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

Strings must use singlequote.

Read more about it here.

var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';

Choose a reason for hiding this comment

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

Extra semicolon.

Read more about it here.

name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;

Choose a reason for hiding this comment

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

Extra semicolon.

Read more about it here.

if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);

Choose a reason for hiding this comment

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

Extra semicolon.

Read more about it here.

if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);

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.

Read more about it here.

export function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),

Choose a reason for hiding this comment

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

Strings must use singlequote.

Read more about it here.

export function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),

Choose a reason for hiding this comment

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

Strings must use singlequote.

Read more about it here.

export function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),

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.

function search (nodes, value) {
export function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");

Choose a reason for hiding this comment

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

Extra semicolon.

Read more about it here.

@aphillipo
Copy link
Contributor Author

Okay lot's of little things to fix here...

}

function search (nodes, value) {
export function getParameterByName(name, url) {

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.

$(window).on('popstate', popstateHandler)

// if the search stub is refreshed or loaded perform the search.
if (window.location.pathname == '/Search.html') {

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 '=='.

@aphillipo
Copy link
Contributor Author

Okay Ebert should be happy now!

@josevalim
Copy link
Member

I am not the person to review this one. :) So let's ping @nscyclone, @dignifiedquire, @milmazz and @eksperimental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants