Revision 1da8a2e3
Added by Stephen Beaver almost 10 years ago
src/usr/local/www/pkg_mgr.php | ||
---|---|---|
159 | 159 |
<select id="where" class="form-control"> |
160 | 160 |
<option value="0"><?=gettext("Name")?></option> |
161 | 161 |
<option value="1"><?=gettext("Description")?></option> |
162 |
<option value="2"><?=gettext("Both")?></option> |
|
162 |
<option value="2" selected><?=gettext("Both")?></option>
|
|
163 | 163 |
</select> |
164 | 164 |
</div> |
165 | 165 |
<div class="col-sm-3"><a id="btnsearch" type="button" title="<?=gettext("Search")?>" class="btn btn-primary btn-sm"><?=gettext("Search")?></a> |
... | ... | |
246 | 246 |
<script> |
247 | 247 |
//<![CDATA[ |
248 | 248 |
events.push(function(){ |
249 |
$("#btnsearch").prop('type' ,'button'); |
|
250 |
$("#btnclear").prop('type' ,'button'); |
|
251 | 249 |
|
252 | 250 |
// Initial state & toggle icons of collapsed panel |
253 | 251 |
$('.panel-heading a[data-toggle="collapse"]').each(function (idx, el){ |
... | ... | |
263 | 261 |
}); |
264 | 262 |
}); |
265 | 263 |
|
264 |
// Make these controls plain buttons |
|
265 |
$("#btnsearch").prop('type' ,'button'); |
|
266 |
$("#btnclear").prop('type' ,'button'); |
|
267 |
|
|
268 |
// Search for a term in the package name and/or description |
|
266 | 269 |
$("#btnsearch").click(function() { |
267 | 270 |
var searchstr = $('#searchstr').val().toLowerCase(); |
268 | 271 |
var table = $("table tbody"); |
... | ... | |
275 | 278 |
|
276 | 279 |
regexp = new RegExp(searchstr); |
277 | 280 |
if(searchstr.length > 0) { |
278 |
if( !(regexp.test(shortname) && ((where == 0) || (where == 2))) && !(regexp.test(descr) && (( where == 1) || (where == 2)))) {
|
|
281 |
if( !(regexp.test(shortname) && (where != 1)) && !(regexp.test(descr) && (where != 0))) {
|
|
279 | 282 |
$(this).hide(); |
280 | 283 |
} else { |
281 | 284 |
$(this).show(); |
... | ... | |
286 | 289 |
}); |
287 | 290 |
}); |
288 | 291 |
|
292 |
// Clear the search term and unhide all rows (that were hidden during a previous search) |
|
289 | 293 |
$("#btnclear").click(function() { |
290 | 294 |
var table = $("table tbody"); |
291 | 295 |
|
296 |
$('#searchstr').val(""); |
|
297 |
|
|
292 | 298 |
table.find('tr').each(function (i) { |
293 | 299 |
$(this).show(); |
294 |
$('#searchstr').val(""); |
|
295 | 300 |
}); |
296 | 301 |
}); |
302 |
|
|
303 |
// Hitting the enter key will do the same as clicking the search button |
|
304 |
$("#searchstr").on("keyup", function (event) { |
|
305 |
if (event.keyCode==13) { |
|
306 |
$("#btnsearch").get(0).click(); |
|
307 |
} |
|
308 |
}); |
|
297 | 309 |
}); |
298 | 310 |
//]]> |
299 | 311 |
</script> |
Also available in: Unified diff
Hitting "Enter" now same as clicking "Search" button
"Where" default to "Both"