author | hannesw |
Fri, 21 Dec 2018 11:02:36 +0100 | |
changeset 53113 | a92cd6585f60 |
parent 52961 | d67b37917e82 |
child 54358 | 72b637d53318 |
permissions | -rw-r--r-- |
33920 | 1 |
/* |
49427
d2fd2581325b
8199278: Javadoc search results does not link to anchors on a page
bpatel
parents:
48991
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
33920 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
var noResult = {l: "No results found"}; |
|
40511 | 27 |
var catModules = "Modules"; |
33920 | 28 |
var catPackages = "Packages"; |
29 |
var catTypes = "Types"; |
|
30 |
var catMembers = "Members"; |
|
31 |
var catSearchTags = "SearchTags"; |
|
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
32 |
var highlight = "<span class=\"resultHighlight\">$&</span>"; |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
33 |
var camelCaseRegexp = ""; |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
34 |
var secondaryMatcher = ""; |
51607
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
35 |
function escapeHtml(str) { |
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
36 |
return str.replace(/</g, "<").replace(/>/g, ">"); |
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
37 |
} |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
38 |
function getHighlightedText(item) { |
51607
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
39 |
var ccMatcher = new RegExp(escapeHtml(camelCaseRegexp)); |
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
40 |
var escapedItem = escapeHtml(item); |
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
41 |
var label = escapedItem.replace(ccMatcher, highlight); |
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
42 |
if (label === escapedItem) { |
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
43 |
var secMatcher = new RegExp(escapeHtml(secondaryMatcher.source), "i"); |
5eb48e9d607a
8176453: Javadoc search: there are issues with generics in parameters
hannesw
parents:
50856
diff
changeset
|
44 |
label = escapedItem.replace(secMatcher, highlight); |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
45 |
} |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
46 |
return label; |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
47 |
} |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
48 |
function getURLPrefix(ui) { |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
49 |
var urlPrefix=""; |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
50 |
if (useModuleDirectories) { |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
51 |
var slash = "/"; |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
52 |
if (ui.item.category === catModules) { |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
53 |
return ui.item.l + slash; |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
54 |
} else if (ui.item.category === catPackages && ui.item.m) { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
55 |
return ui.item.m + slash; |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
56 |
} else if ((ui.item.category === catTypes && ui.item.p) || ui.item.category === catMembers) { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
57 |
$.each(packageSearchIndex, function(index, item) { |
53113
a92cd6585f60
8215291: Broken links when generating from project without modules
hannesw
parents:
52961
diff
changeset
|
58 |
if (item.m && ui.item.p == item.l) { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
59 |
urlPrefix = item.m + slash; |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
60 |
} |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
61 |
}); |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
62 |
return urlPrefix; |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
63 |
} else { |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
64 |
return urlPrefix; |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
65 |
} |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
66 |
} |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
67 |
return urlPrefix; |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
68 |
} |
33920 | 69 |
var watermark = 'Search'; |
70 |
$(function() { |
|
47047
91082c3c1d05
8182263: Search box and reset button needs to be a11y fixed.
bpatel
parents:
45496
diff
changeset
|
71 |
$("#search").val(''); |
33920 | 72 |
$("#search").prop("disabled", false); |
73 |
$("#reset").prop("disabled", false); |
|
74 |
$("#search").val(watermark).addClass('watermark'); |
|
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
75 |
$("#search").blur(function() { |
33920 | 76 |
if ($(this).val().length == 0) { |
77 |
$(this).val(watermark).addClass('watermark'); |
|
78 |
} |
|
79 |
}); |
|
45496 | 80 |
$("#search").on('click keydown', function() { |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
81 |
if ($(this).val() == watermark) { |
33920 | 82 |
$(this).val('').removeClass('watermark'); |
83 |
} |
|
84 |
}); |
|
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
85 |
$("#reset").click(function() { |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
86 |
$("#search").val(''); |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
87 |
$("#search").focus(); |
33920 | 88 |
}); |
89 |
$("#search").focus(); |
|
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
90 |
$("#search")[0].setSelectionRange(0, 0); |
33920 | 91 |
}); |
92 |
$.widget("custom.catcomplete", $.ui.autocomplete, { |
|
93 |
_create: function() { |
|
94 |
this._super(); |
|
95 |
this.widget().menu("option", "items", "> :not(.ui-autocomplete-category)"); |
|
96 |
}, |
|
97 |
_renderMenu: function(ul, items) { |
|
98 |
var rMenu = this, |
|
99 |
currentCategory = ""; |
|
52961
d67b37917e82
8214468: jQuery UI upgrade from 1.11.4 to 1.12.1
pmuthuswamy
parents:
52391
diff
changeset
|
100 |
rMenu.menu.bindings = $(); |
33920 | 101 |
$.each(items, function(index, item) { |
102 |
var li; |
|
103 |
if (item.l !== noResult.l && item.category !== currentCategory) { |
|
104 |
ul.append("<li class=\"ui-autocomplete-category\">" + item.category + "</li>"); |
|
105 |
currentCategory = item.category; |
|
106 |
} |
|
107 |
li = rMenu._renderItemData(ul, item); |
|
108 |
if (item.category) { |
|
109 |
li.attr("aria-label", item.category + " : " + item.l); |
|
110 |
li.attr("class", "resultItem"); |
|
111 |
} else { |
|
112 |
li.attr("aria-label", item.l); |
|
113 |
li.attr("class", "resultItem"); |
|
114 |
} |
|
115 |
}); |
|
116 |
}, |
|
117 |
_renderItem: function(ul, item) { |
|
118 |
var label = ""; |
|
40511 | 119 |
if (item.category === catModules) { |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
120 |
label = getHighlightedText(item.l); |
40511 | 121 |
} else if (item.category === catPackages) { |
122 |
label = (item.m) |
|
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
123 |
? getHighlightedText(item.m + "/" + item.l) |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
124 |
: getHighlightedText(item.l); |
33920 | 125 |
} else if (item.category === catTypes) { |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
126 |
label = (item.p) |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
127 |
? getHighlightedText(item.p + "." + item.l) |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
128 |
: getHighlightedText(item.l); |
33920 | 129 |
} else if (item.category === catMembers) { |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
130 |
label = getHighlightedText(item.p + "." + (item.c + "." + item.l)); |
33920 | 131 |
} else if (item.category === catSearchTags) { |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
132 |
label = getHighlightedText(item.l); |
33920 | 133 |
} else { |
134 |
label = item.l; |
|
135 |
} |
|
51740
f79cfb07f13f
8209914: javadoc search sometimes generates bad URIs
hannesw
parents:
51607
diff
changeset
|
136 |
var li = $("<li/>").appendTo(ul); |
52961
d67b37917e82
8214468: jQuery UI upgrade from 1.11.4 to 1.12.1
pmuthuswamy
parents:
52391
diff
changeset
|
137 |
var div = $("<div/>").appendTo(li); |
33920 | 138 |
if (item.category === catSearchTags) { |
139 |
if (item.d) { |
|
52961
d67b37917e82
8214468: jQuery UI upgrade from 1.11.4 to 1.12.1
pmuthuswamy
parents:
52391
diff
changeset
|
140 |
div.html(label + "<span class=\"searchTagHolderResult\"> (" + item.h + ")</span><br><span class=\"searchTagDescResult\">" |
51740
f79cfb07f13f
8209914: javadoc search sometimes generates bad URIs
hannesw
parents:
51607
diff
changeset
|
141 |
+ item.d + "</span><br>"); |
33920 | 142 |
} else { |
52961
d67b37917e82
8214468: jQuery UI upgrade from 1.11.4 to 1.12.1
pmuthuswamy
parents:
52391
diff
changeset
|
143 |
div.html(label + "<span class=\"searchTagHolderResult\"> (" + item.h + ")</span>"); |
33920 | 144 |
} |
145 |
} else { |
|
52961
d67b37917e82
8214468: jQuery UI upgrade from 1.11.4 to 1.12.1
pmuthuswamy
parents:
52391
diff
changeset
|
146 |
div.html(label); |
33920 | 147 |
} |
51740
f79cfb07f13f
8209914: javadoc search sometimes generates bad URIs
hannesw
parents:
51607
diff
changeset
|
148 |
return li; |
33920 | 149 |
} |
150 |
}); |
|
151 |
$(function() { |
|
152 |
$("#search").catcomplete({ |
|
153 |
minLength: 1, |
|
52391
ac5a55c19bad
8210405: Javadoc search doesn't always consider full input upon Enter
hannesw
parents:
51740
diff
changeset
|
154 |
delay: 300, |
33920 | 155 |
source: function(request, response) { |
156 |
var result = new Array(); |
|
40511 | 157 |
var presult = new Array(); |
33920 | 158 |
var tresult = new Array(); |
159 |
var mresult = new Array(); |
|
160 |
var tgresult = new Array(); |
|
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
161 |
var secondaryresult = new Array(); |
33920 | 162 |
var displayCount = 0; |
163 |
var exactMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term) + "$", "i"); |
|
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
164 |
camelCaseRegexp = ($.ui.autocomplete.escapeRegex(request.term)).split(/(?=[A-Z])/).join("([a-z0-9_$]*?)"); |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
165 |
var camelCaseMatcher = new RegExp("^" + camelCaseRegexp); |
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
166 |
secondaryMatcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
167 |
|
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
168 |
// Return the nested innermost name from the specified object |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
169 |
function nestedName(e) { |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
170 |
return e.l.substring(e.l.lastIndexOf(".") + 1); |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
171 |
} |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
172 |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
173 |
function concatResults(a1, a2) { |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
174 |
a1 = a1.concat(a2); |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
175 |
a2.length = 0; |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
176 |
return a1; |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
177 |
} |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
178 |
|
40511 | 179 |
if (moduleSearchIndex) { |
180 |
var mdleCount = 0; |
|
181 |
$.each(moduleSearchIndex, function(index, item) { |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
182 |
item.category = catModules; |
33920 | 183 |
if (exactMatcher.test(item.l)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
184 |
result.push(item); |
40511 | 185 |
mdleCount++; |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
186 |
} else if (camelCaseMatcher.test(item.l)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
187 |
result.push(item); |
33920 | 188 |
} else if (secondaryMatcher.test(item.l)) { |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
189 |
secondaryresult.push(item); |
33920 | 190 |
} |
191 |
}); |
|
40511 | 192 |
displayCount = mdleCount; |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
193 |
result = concatResults(result, secondaryresult); |
40511 | 194 |
} |
195 |
if (packageSearchIndex) { |
|
196 |
var pCount = 0; |
|
197 |
var pkg = ""; |
|
198 |
$.each(packageSearchIndex, function(index, item) { |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
199 |
item.category = catPackages; |
40511 | 200 |
pkg = (item.m) |
201 |
? (item.m + "/" + item.l) |
|
202 |
: item.l; |
|
44296
e9bbaeab6f49
8176794: javadoc search results sorted incorrectly on packages
bpatel
parents:
43762
diff
changeset
|
203 |
if (exactMatcher.test(item.l)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
204 |
presult.push(item); |
40511 | 205 |
pCount++; |
41523
da4f500b886d
8141636: Javadoc search should support camelCase search
bpatel
parents:
41032
diff
changeset
|
206 |
} else if (camelCaseMatcher.test(pkg)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
207 |
presult.push(item); |
40511 | 208 |
} else if (secondaryMatcher.test(pkg)) { |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
209 |
secondaryresult.push(item); |
40511 | 210 |
} |
211 |
}); |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
212 |
result = result.concat(concatResults(presult, secondaryresult)); |
40511 | 213 |
displayCount = (pCount > displayCount) ? pCount : displayCount; |
33920 | 214 |
} |
215 |
if (typeSearchIndex) { |
|
216 |
var tCount = 0; |
|
217 |
$.each(typeSearchIndex, function(index, item) { |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
218 |
item.category = catTypes; |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
219 |
var s = nestedName(item); |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
220 |
if (exactMatcher.test(s)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
221 |
tresult.push(item); |
33920 | 222 |
tCount++; |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
223 |
} else if (camelCaseMatcher.test(s)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
224 |
tresult.push(item); |
33920 | 225 |
} else if (secondaryMatcher.test(item.p + "." + item.l)) { |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
226 |
secondaryresult.push(item); |
33920 | 227 |
} |
228 |
}); |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
229 |
result = result.concat(concatResults(tresult, secondaryresult)); |
33920 | 230 |
displayCount = (tCount > displayCount) ? tCount : displayCount; |
231 |
} |
|
232 |
if (memberSearchIndex) { |
|
233 |
var mCount = 0; |
|
234 |
$.each(memberSearchIndex, function(index, item) { |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
235 |
item.category = catMembers; |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
236 |
var s = nestedName(item); |
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
237 |
if (exactMatcher.test(s)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
238 |
mresult.push(item); |
33920 | 239 |
mCount++; |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
240 |
} else if (camelCaseMatcher.test(s)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
241 |
mresult.push(item); |
33920 | 242 |
} else if (secondaryMatcher.test(item.c + "." + item.l)) { |
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
243 |
secondaryresult.push(item); |
33920 | 244 |
} |
245 |
}); |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
246 |
result = result.concat(concatResults(mresult, secondaryresult)); |
33920 | 247 |
displayCount = (mCount > displayCount) ? mCount : displayCount; |
248 |
} |
|
249 |
if (tagSearchIndex) { |
|
250 |
var tgCount = 0; |
|
251 |
$.each(tagSearchIndex, function(index, item) { |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
252 |
item.category = catSearchTags; |
33920 | 253 |
if (exactMatcher.test(item.l)) { |
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
254 |
tgresult.push(item); |
33920 | 255 |
tgCount++; |
256 |
} else if (secondaryMatcher.test(item.l)) { |
|
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
257 |
secondaryresult.push(item); |
33920 | 258 |
} |
259 |
}); |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
260 |
result = result.concat(concatResults(tgresult, secondaryresult)); |
33920 | 261 |
displayCount = (tgCount > displayCount) ? tgCount : displayCount; |
262 |
} |
|
263 |
displayCount = (displayCount > 500) ? displayCount : 500; |
|
264 |
var counter = function() { |
|
40511 | 265 |
var count = {Modules: 0, Packages: 0, Types: 0, Members: 0, SearchTags: 0}; |
33920 | 266 |
var f = function(item) { |
267 |
count[item.category] += 1; |
|
268 |
return (count[item.category] <= displayCount); |
|
269 |
}; |
|
270 |
return f; |
|
271 |
}(); |
|
272 |
response(result.filter(counter)); |
|
273 |
}, |
|
274 |
response: function(event, ui) { |
|
275 |
if (!ui.content.length) { |
|
276 |
ui.content.push(noResult); |
|
277 |
} else { |
|
278 |
$("#search").empty(); |
|
279 |
} |
|
280 |
}, |
|
281 |
autoFocus: true, |
|
282 |
position: { |
|
283 |
collision: "flip" |
|
284 |
}, |
|
285 |
select: function(event, ui) { |
|
286 |
if (ui.item.l !== noResult.l) { |
|
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
287 |
var url = getURLPrefix(ui); |
40511 | 288 |
if (ui.item.category === catModules) { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
289 |
if (useModuleDirectories) { |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
290 |
url += "module-summary.html"; |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
291 |
} else { |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
292 |
url = ui.item.l + "-summary.html"; |
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
293 |
} |
40511 | 294 |
} else if (ui.item.category === catPackages) { |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
295 |
if (ui.item.url) { |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
296 |
url = ui.item.url; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
297 |
} else { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
298 |
url += ui.item.l.replace(/\./g, '/') + "/package-summary.html"; |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
299 |
} |
33920 | 300 |
} else if (ui.item.category === catTypes) { |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
301 |
if (ui.item.url) { |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
302 |
url = ui.item.url; |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49427
diff
changeset
|
303 |
} else if (ui.item.p === "<Unnamed>") { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
304 |
url += ui.item.l + ".html"; |
33920 | 305 |
} else { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
306 |
url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.l + ".html"; |
33920 | 307 |
} |
308 |
} else if (ui.item.category === catMembers) { |
|
309 |
if (ui.item.p === "<Unnamed>") { |
|
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
310 |
url += ui.item.c + ".html" + "#"; |
33920 | 311 |
} else { |
48991
978c3036fbfc
8198522: Javadoc search broken after output files organization for modules
bpatel
parents:
47216
diff
changeset
|
312 |
url += ui.item.p.replace(/\./g, '/') + "/" + ui.item.c + ".html" + "#"; |
33920 | 313 |
} |
314 |
if (ui.item.url) { |
|
315 |
url += ui.item.url; |
|
316 |
} else { |
|
49427
d2fd2581325b
8199278: Javadoc search results does not link to anchors on a page
bpatel
parents:
48991
diff
changeset
|
317 |
url += ui.item.l; |
33920 | 318 |
} |
319 |
} else if (ui.item.category === catSearchTags) { |
|
320 |
url += ui.item.u; |
|
321 |
} |
|
322 |
if (top !== window) { |
|
323 |
parent.classFrame.location = pathtoroot + url; |
|
324 |
} else { |
|
325 |
window.location.href = pathtoroot + url; |
|
326 |
} |
|
51740
f79cfb07f13f
8209914: javadoc search sometimes generates bad URIs
hannesw
parents:
51607
diff
changeset
|
327 |
$("#search").focus(); |
33920 | 328 |
} |
329 |
} |
|
330 |
}); |
|
43762
515fe48569fe
8168965: search items are not listed in any sensible order
bpatel
parents:
41523
diff
changeset
|
331 |
}); |