landing-page: Replace detect_path with path_parts.

path_parts returns an array of all location.pathname's `chunks`,
the strings within the path, split by slash.
This commit is contained in:
Jack Zhang 2017-07-17 19:40:31 -07:00 committed by Tim Abbott
parent a704dad06b
commit 5a87f90b24
1 changed files with 8 additions and 9 deletions

View File

@ -24,12 +24,11 @@ var ScrollTo = function () {
});
};
var detectPath = function (pathname) {
var match = (pathname || window.location.pathname).match(/(\/\w+)?\/(.+)\//);
if (match !== null) {
return match[2];
}
};
function path_parts() {
return window.location.pathname.split('/').filter(function (chunk) {
return chunk !== '';
});
}
// these are events that are only to run on the integrations page.
// check if the page location is integrations.
@ -411,16 +410,16 @@ var events = function () {
$("nav ul").addClass("show");
});
if (detectPath() === "apps") {
if (path_parts().includes("apps")) {
apps_events();
}
if (detectPath() === "integrations") {
if (path_parts().includes('integrations')) {
integration_events();
integration_search();
}
if (detectPath() === "hello") {
if (path_parts().includes('hello')) {
hello_events();
}
};