summaryrefslogtreecommitdiff
path: root/support/jsdoc/jsdoc-custom.js
diff options
context:
space:
mode:
authorGraeme Yeates <yeatesgraeme@gmail.com>2016-06-28 12:41:04 -0400
committerHubert Argasinski <argasinski.hubert@gmail.com>2016-06-29 02:01:35 -0400
commit0e11bf597567f3f0927cee293351fd017c33c680 (patch)
treead228d07214d452c53322a4bf4e58e03dc211cc6 /support/jsdoc/jsdoc-custom.js
parentb2f314f74c11364268e280735a457dd8183b310b (diff)
downloadasync-0e11bf597567f3f0927cee293351fd017c33c680.tar.gz
Attempt to fix search on subroutes
Diffstat (limited to 'support/jsdoc/jsdoc-custom.js')
-rw-r--r--support/jsdoc/jsdoc-custom.js45
1 files changed, 25 insertions, 20 deletions
diff --git a/support/jsdoc/jsdoc-custom.js b/support/jsdoc/jsdoc-custom.js
index 3dc26b0..e86160c 100644
--- a/support/jsdoc/jsdoc-custom.js
+++ b/support/jsdoc/jsdoc-custom.js
@@ -1,18 +1,15 @@
-function matchSubstrs(methodName) {
- var tokens = [];
-
- var len = methodName.length;
-
- for (var size = 1; size <= len; size++){
- for (var i = 0; i+size<= len; i++){
- tokens.push(methodName.substr(i, size));
+$(function initSearchBar() {
+ function matchSubstrs(methodName) {
+ var tokens = [];
+ var len = methodName.length;
+ for (var size = 1; size <= len; size++){
+ for (var i = 0; i+size<= len; i++){
+ tokens.push(methodName.substr(i, size));
+ }
}
+ return tokens;
}
- return tokens;
-}
-
-$(function initSearchBar() {
var methodNames = new Bloodhound({
datumTokenizer: matchSubstrs,
queryTokenizer: Bloodhound.tokenizers.whitespace,
@@ -55,7 +52,6 @@ $(function initSearchBar() {
}
});
-
$('.typeahead').typeahead({
hint: true,
highlight: true,
@@ -83,18 +79,27 @@ $(function initSearchBar() {
header: '<h3 class="search-bar-header">Issues</h3>'
}
}).on('typeahead:select', function(ev, suggestion) {
- var protocol = window.location.protocol
- var host = window.location.host;
- var currentPath = window.location.pathname;
+ var host;
+ if (location.origin != "null") {
+ host = location.origin;
+ } else {
+ host = location.protocol + '//' + location.host;
+ }
+
+ var _path = location.pathname.split("/");
+
+ var currentPage = _path[_path.length - 1];
+ host += _path.slice(1, -1).join("/") + "/";
+
// handle issues
if (typeof suggestion !== 'string') {
- window.location.href = suggestion.url;
+ location.href = suggestion.url;
// handle source files
} else if (suggestion.indexOf('.html') !== -1) {
- window.location.href = protocol + '//' + host + '/' + suggestion;
+ location.href = host + suggestion;
// handle searching from one of the source files or the home page
- } else if (currentPath !== '/docs.html') {
- window.location.href = protocol + '//' + host + '/docs.html#.' + suggestion;
+ } else if (currentPage !== 'docs.html') {
+ location.href = host + 'docs.html#.' + suggestion;
} else {
var $el = document.getElementById('.' + suggestion);
$('#main').animate({ scrollTop: $el.offsetTop }, 500);