mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-10 16:12:22 +03:00
Redirect to exact match on pressing enter
This commit is contained in:
parent
d61bb2e87f
commit
bdedd2dc26
|
@ -171,8 +171,22 @@ function updateSearch(event) {
|
||||||
var foundTypes = getSearchArray(types, typesu, query);
|
var foundTypes = getSearchArray(types, typesu, query);
|
||||||
var foundConstructors = getSearchArray(constructors, constructorsu, query);
|
var foundConstructors = getSearchArray(constructors, constructorsu, query);
|
||||||
|
|
||||||
|
var original = requests.concat(constructors);
|
||||||
|
var originalu = requestsu.concat(constructorsu);
|
||||||
|
var destination = [];
|
||||||
|
var destinationu = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < original.length; ++i) {
|
||||||
|
if (original[i].toLowerCase().replace("request", "") == query) {
|
||||||
|
destination.push(original[i]);
|
||||||
|
destinationu.push(originalu[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event && event.keyCode == 13) {
|
if (event && event.keyCode == 13) {
|
||||||
if (methodsDetails.open && foundRequests[1].length) {
|
if (destination.length != 0) {
|
||||||
|
window.location = destinationu[0];
|
||||||
|
} else if (methodsDetails.open && foundRequests[1].length) {
|
||||||
window.location = foundRequests[1][0];
|
window.location = foundRequests[1][0];
|
||||||
} else if (typesDetails.open && foundTypes[1].length) {
|
} else if (typesDetails.open && foundTypes[1].length) {
|
||||||
window.location = foundTypes[1][0];
|
window.location = foundTypes[1][0];
|
||||||
|
@ -187,18 +201,6 @@ function updateSearch(event) {
|
||||||
buildList(constructorsCount, constructorsList, foundConstructors);
|
buildList(constructorsCount, constructorsList, foundConstructors);
|
||||||
|
|
||||||
// Now look for exact matches
|
// Now look for exact matches
|
||||||
var original = requests.concat(constructors);
|
|
||||||
var originalu = requestsu.concat(constructorsu);
|
|
||||||
var destination = [];
|
|
||||||
var destinationu = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < original.length; ++i) {
|
|
||||||
if (original[i].toLowerCase().replace("request", "") == query) {
|
|
||||||
destination.push(original[i]);
|
|
||||||
destinationu.push(originalu[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (destination.length == 0) {
|
if (destination.length == 0) {
|
||||||
exactMatch.style.display = "none";
|
exactMatch.style.display = "none";
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user