From: Dimitri Jorge Date: Thu, 4 Sep 2014 14:11:59 +0000 (+0200) Subject: Ensure all inserted searchTerms are unique X-Git-Tag: v5.4.3~14^2~4^2^2^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5741%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Ensure all inserted searchTerms are unique --- diff --git a/doc/assets/js/docs.js b/doc/assets/js/docs.js index 31d9edf2e..15dce1b58 100644 --- a/doc/assets/js/docs.js +++ b/doc/assets/js/docs.js @@ -1,20 +1,29 @@ var components = []; +var unique_search_terms = {}; + +function pushSearchTerm(searchTerm, data) { + if (!unique_search_terms[searchTerm]) { + components.push({ + value: searchTerm, + data: data + }); + + unique_search_terms[searchTerm] = true + } +} + $("[data-search]") .each(function() { var self = $(this), searchTerm = self.text().trim(), otherSearchTerms = self.data("search").trim(), url = self.attr("href"); - components.push({ - value: searchTerm, - data: self.attr("href") - }); + + pushSearchTerm(searchTerm, self.attr("href")) + if (otherSearchTerms !== "") { $.each(otherSearchTerms.split(","), function(idx, el) { - components.push({ - value: el, - data: self.attr("href") - }); + pushSearchTerm(el, self.attr("href")) }); } }); @@ -84,4 +93,4 @@ if ($('[data-forum-posts]').length > 0) { dataType:'jsonp', success: cb }); -} \ No newline at end of file +}