(function(compodoc) { var MAX_RESULTS = 15, MAX_DESCRIPTION_SIZE = 500, usePushState = (typeof history.pushState !== 'undefined'), // DOM Elements $body = $('body'), $searchResults, $searchInput, $searchList, $searchTitle, $searchResultsCount, $searchQuery, $mainContainer, $xsMenu; // Throttle search function throttle(fn, wait) { var timeout; return function() { var ctx = this, args = arguments; if (!timeout) { timeout = setTimeout(function() { timeout = undefined; fn.apply(ctx, args); }, wait); } }; } function displayResults(res) { var noResults = res.count == 0; var groups = {}; $searchResults.toggleClass('no-results', noResults); // Clear old results $searchList.empty(); // Display title for research $searchResultsCount.text(res.count); $searchQuery.text(res.query); // Group result by context res.results.forEach(function(res) { var context = res.title.split(' - ')[0]; if (typeof groups[context] === 'undefined') { groups[context] = { results: [res] } } else { groups[context].results.push(res) } }); var sortedGroups = Object.keys(groups).sort(); for (var i = 0; i < sortedGroups.length; i++) { var property = sortedGroups[i]; var $li = $('
  • ', { 'class': 'search-results-group' }); var finalPropertyLabel = ''; var propertyLabels = property.split('-'); if (propertyLabels.length === 2 && propertyLabels[0] !== 'miscellaneous' && propertyLabels[0] !== 'additional') { finalPropertyLabel = propertyLabels[0].charAt(0).toUpperCase() + propertyLabels[0].substring(1) + ' - ' + propertyLabels[1].charAt(0).toUpperCase() + propertyLabels[1].substring(1) + ' (' + groups[property].results.length + ')'; } else if (propertyLabels[0] === 'additional') { finalPropertyLabel = 'Additional pages' + ' (' + groups[property].results.length + ')' } else { finalPropertyLabel = propertyLabels[0].charAt(0).toUpperCase() + propertyLabels[0].substring(1) + ' (' + groups[property].results.length + ')' } var $groupTitle = $('

    ', { 'text': finalPropertyLabel }); $groupTitle.appendTo($li); var $ulResults = $('