* A function to compute the Levenshtein distance between two strings
* Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported
* Full License can be found at http://creativecommons.org/licenses/by-sa/3.0/legalcode
- * This code is an unmodified version of the code written by Marco de Wit
+ * This code is an unmodified version of the code written by Marco de Wit
* and was found at http://stackoverflow.com/a/18514751/745719
*/
var levenshtein = (function() {
});
}
} else if (
- (lev_distance = levenshtein(searchWords[j], val)) <=
+ (lev_distance = levenshtein(searchWords[j], val)) <=
MAX_LEV_DISTANCE) {
if (typeFilter < 0 || typeFilter === searchIndex[j].ty) {
results.push({
function validateResult(name, path, keys, parent) {
for (var i=0; i < keys.length; ++i) {
// each check is for validation so we negate the conditions and invalidate
- if (!(
+ if (!(
// check for an exact name match
name.toLowerCase().indexOf(keys[i]) > -1 ||
// then an exact path match
path.toLowerCase().indexOf(keys[i]) > -1 ||
// next if there is a parent, check for exact parent match
- (parent !== undefined &&
+ (parent !== undefined &&
parent.name.toLowerCase().indexOf(keys[i]) > -1) ||
// lastly check to see if the name was a levenshtein match
- levenshtein(name.toLowerCase(), keys[i]) <=
+ levenshtein(name.toLowerCase(), keys[i]) <=
MAX_LEV_DISTANCE)) {
return false;
}
if (window.location.pathname == dst.pathname) {
$('#search').addClass('hidden');
$('#main').removeClass('hidden');
+ document.location.href = dst.href;
}
- document.location.href = dst.href;
}).on('mouseover', function() {
var $el = $(this);
clearTimeout(hoverTimeout);
shown = [];
results.forEach(function(item) {
- var name, type;
+ var name, type, href, displayPath;
if (shown.indexOf(item) !== -1) {
return;
name = item.name;
type = itemTypes[item.ty];
- output += '<tr class="' + type + ' result"><td>';
-
if (type === 'mod') {
- output += item.path +
- '::<a href="' + rootPath +
- item.path.replace(/::/g, '/') + '/' +
- name + '/index.html" class="' +
- type + '">' + name + '</a>';
+ displayPath = item.path + '::';
+ href = rootPath + item.path.replace(/::/g, '/') + '/' +
+ name + '/index.html';
} else if (type === 'static' || type === 'reexport') {
- output += item.path +
- '::<a href="' + rootPath +
- item.path.replace(/::/g, '/') +
- '/index.html" class="' + type +
- '">' + name + '</a>';
+ displayPath = item.path + '::';
+ href = rootPath + item.path.replace(/::/g, '/') +
+ '/index.html';
} else if (item.parent !== undefined) {
var myparent = item.parent;
var anchor = '#' + type + '.' + name;
- output += item.path + '::' + myparent.name +
- '::<a href="' + rootPath +
- item.path.replace(/::/g, '/') +
- '/' + itemTypes[myparent.ty] +
- '.' + myparent.name +
- '.html' + anchor +
- '" class="' + type +
- '">' + name + '</a>';
+ displayPath = item.path + '::' + myparent.name + '::';
+ href = rootPath + item.path.replace(/::/g, '/') +
+ '/' + itemTypes[myparent.ty] +
+ '.' + myparent.name +
+ '.html' + anchor;
} else {
- output += item.path +
- '::<a href="' + rootPath +
- item.path.replace(/::/g, '/') +
- '/' + type +
- '.' + name +
- '.html" class="' + type +
- '">' + name + '</a>';
+ displayPath = item.path + '::';
+ href = rootPath + item.path.replace(/::/g, '/') +
+ '/' + type + '.' + name + '.html';
}
- output += '</td><td><span class="desc">' + item.desc +
- '</span></td></tr>';
+ output += '<tr class="' + type + ' result"><td>' +
+ '<a href="' + href + '">' +
+ displayPath + '<span class="' + type + '">' +
+ name + '</span></a></td><td>' +
+ '<a href="' + href + '">' +
+ '<span class="desc">' + item.desc +
+ ' </span></a></td></tr>';
});
} else {
output += 'No results :( <a href="https://duckduckgo.com/?q=' +
});
$(function() {
- var toggle = "<a href='javascript:void(0)'"
- + "class='collapse-toggle'>[<span class='inner'>-</span>]</a>";
+ var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'})
+ .html("[<span class='inner'>-</span>]");
$(".method").each(function() {
if ($(this).next().is(".docblock")) {
- $(this).children().first().after(toggle);
+ $(this).children().first().after(toggle[0]);
}
});
- var mainToggle = $(toggle);
- mainToggle.append("<span class='toggle-label' style='display:none'>"
- + " Expand description</span></a>")
- var wrapper = $("<div class='toggle-wrapper'>");
- wrapper.append(mainToggle);
+ var mainToggle =
+ $(toggle).append(
+ $('<span/>', {'class': 'toggle-label'})
+ .css('display', 'none')
+ .html(' Expand description'));
+ var wrapper = $("<div class='toggle-wrapper'>").append(mainToggle);
$("#main > .docblock").before(wrapper);
});