[Bps-public-commit] rt-extension-rightsdebugger branch, master, updated. c8177b6892339b6ac769e37589ccc257d79d4c06
Shawn Moore
shawn at bestpractical.com
Thu Mar 16 13:59:32 EDT 2017
The branch, master has been updated
via c8177b6892339b6ac769e37589ccc257d79d4c06 (commit)
from 78481f4ec560f026b195fcc21ad0114513fd766b (commit)
Summary of changes:
static/js/rights-debugger.js | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit c8177b6892339b6ac769e37589ccc257d79d4c06
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Mar 16 17:58:34 2017 +0000
Add a 200ms delay before searching
There's no way to tell the server to stop processing the previous request,
so typing quickly ends up overloading the server a little bit.
With this timer, just like autocompleters use, we can limit the number of
concurrent requests to the server.
diff --git a/static/js/rights-debugger.js b/static/js/rights-debugger.js
index e3f03f0..f711753 100644
--- a/static/js/rights-debugger.js
+++ b/static/js/rights-debugger.js
@@ -22,6 +22,7 @@ jQuery(function () {
var revoking = {};
var existingRequest;
+ var requestTimer;
var buttonForAction = function (action) {
return display.find('.revoke button[data-action="' + action + '"]');
@@ -46,6 +47,11 @@ jQuery(function () {
requestPage = function (search, continueAfter) {
search.continueAfter = continueAfter;
+ if (requestTimer) {
+ clearTimeout(requestTimer);
+ requestTimer = null;
+ }
+
existingRequest = jQuery.ajax({
url: form.attr('action'),
data: search,
@@ -98,7 +104,7 @@ jQuery(function () {
});
};
- var beginSearch = function () {
+ var beginSearch = function (delay) {
form.removeClass('continuing-load').addClass('awaiting-first-result');
form.find('button').addClass('ui-state-disabled').prop('disabled', true);
@@ -109,11 +115,23 @@ jQuery(function () {
search[field.name] = field.value;
});
+ if (requestTimer) {
+ clearTimeout(requestTimer);
+ requestTimer = null;
+ }
+
if (existingRequest) {
existingRequest.abort();
}
- requestPage(search, 0);
+ if (delay) {
+ requestTimer = setTimeout(function () {
+ requestPage(search, 0);
+ }, delay);
+ }
+ else {
+ requestPage(search, 0);
+ }
};
display.on('click', '.revoke button', function (e) {
@@ -148,7 +166,7 @@ jQuery(function () {
});
form.find('.search input').on('input', function () {
- beginSearch();
+ beginSearch(200);
});
beginSearch();
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list