mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Website issue tracker link and better search performance
* last minor improvements
This commit is contained in:
parent
12a35abba1
commit
97f5db97c4
@ -77,7 +77,7 @@
|
|||||||
<div class="col-md-12 form-horizontal">
|
<div class="col-md-12 form-horizontal">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label>
|
<label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label>
|
||||||
<input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" />
|
<input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" ng-model-options="{debounce: 50}"/>
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
<button class="btn btn-default" type="button" ng-click="search = ''">
|
<button class="btn btn-default" type="button" ng-click="search = ''">
|
||||||
Clear
|
Clear
|
||||||
@ -119,6 +119,7 @@
|
|||||||
{{title}}
|
{{title}}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="list-group-item-text" ng-bind-html="text | markdown"></div>
|
<div class="list-group-item-text" ng-bind-html="text | markdown"></div>
|
||||||
|
<a ng-if="title == 'Known problems'" href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+{{lint.id}}">Search on GitHub</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
@ -180,6 +181,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function searchLint(lint, therm) {
|
||||||
|
for (const field in lint.docs) {
|
||||||
|
// Continue if it's not a property
|
||||||
|
if (!lint.docs.hasOwnProperty(field)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return if not found
|
||||||
|
if (lint.docs[field].toLowerCase().indexOf(therm) !== -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
angular.module("clippy", [])
|
angular.module("clippy", [])
|
||||||
.filter('markdown', function ($sce) {
|
.filter('markdown', function ($sce) {
|
||||||
return function (text) {
|
return function (text) {
|
||||||
@ -216,40 +233,31 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.bySearch = function (lint, index, array) {
|
$scope.bySearch = function (lint, index, array) {
|
||||||
let search_str = $scope.search;
|
let searchStr = $scope.search;
|
||||||
// It can be `null` I haven't missed this value
|
// It can be `null` I haven't missed this value
|
||||||
if (search_str == null || search_str.length == 0) {
|
if (searchStr == null || searchStr.length < 3) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
search_str = search_str.toLowerCase();
|
searchStr = searchStr.toLowerCase();
|
||||||
|
|
||||||
// Search by id
|
// Search by id
|
||||||
let id_search = search_str.trim().replace(/(\-| )/g, "_");
|
if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
|
||||||
if (lint.id.includes(id_search)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search the description
|
// Search the description
|
||||||
// The use of `for`-loops instead of `foreach` enables us to return early
|
// The use of `for`-loops instead of `foreach` enables us to return early
|
||||||
let search_lint = (lint, therm) => {
|
let therms = searchStr.split(" ");
|
||||||
for (const field in lint.docs) {
|
|
||||||
// Continue if it's not a property
|
|
||||||
if (!lint.docs.hasOwnProperty(field)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return if not found
|
|
||||||
if (lint.docs[field].toLowerCase().includes(therm)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
let therms = search_str.split(" ");
|
|
||||||
for (index = 0; index < therms.length; index++) {
|
for (index = 0; index < therms.length; index++) {
|
||||||
if (!search_lint(lint, therms[index])) {
|
if (lint.id.indexOf(therms[index]) !== -1) {
|
||||||
return false;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (searchLint(lint, therms[index])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user