Patch #43208 » 0001-Reduce-requests-for-issue-ID-username-and-Wiki-page-name-autocomplete-with-debounce.patch
app/assets/javascripts/application-legacy.js | ||
---|---|---|
1257 | 1257 |
} |
1258 | 1258 |
} |
1259 | 1259 | |
1260 |
const remoteSearch = function(url, cb) { |
|
1260 |
const debounce = function(func, delay) { |
|
1261 |
let timeout; |
|
1262 | ||
1263 |
return function(...args) { |
|
1264 |
const context = this; |
|
1265 |
clearTimeout(timeout); |
|
1266 |
timeout = setTimeout(() => func.apply(context, args), delay); |
|
1267 |
}; |
|
1268 |
} |
|
1269 | ||
1270 |
const remoteSearch = debounce((url, cb) => { |
|
1261 | 1271 |
const xhr = new XMLHttpRequest(); |
1262 | 1272 |
xhr.onreadystatechange = function () |
1263 | 1273 |
{ |
... | ... | |
1272 | 1282 |
}; |
1273 | 1283 |
xhr.open("GET", url, true); |
1274 | 1284 |
xhr.send(); |
1275 |
}; |
|
1285 |
}, 300);
|
|
1276 | 1286 | |
1277 | 1287 |
const tribute = new Tribute({ |
1278 | 1288 |
collection: [ |