aboutsummaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-04-03 18:46:16 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-06-02 12:53:55 +0200
commitdbc854d8b8cb0a187859fae174a41de5b296595c (patch)
treefecc502078f024619c714565f0d23778a96c3edb /settings/js
parent8df50acce78e56518131a5905ae45b1a3fb0f821 (diff)
downloadnextcloud-server-dbc854d8b8cb0a187859fae174a41de5b296595c.tar.gz
nextcloud-server-dbc854d8b8cb0a187859fae174a41de5b296595c.zip
Fire up server request only on typing printed or modifying characters and when the string actually changed
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/users/filter.js36
1 files changed, 28 insertions, 8 deletions
diff --git a/settings/js/users/filter.js b/settings/js/users/filter.js
index 493ce991732..2c0eefe25d4 100644
--- a/settings/js/users/filter.js
+++ b/settings/js/users/filter.js
@@ -14,6 +14,7 @@ function UserManagementFilter(filterInput, userList) {
this.filterInput = filterInput;
this.userList = userList;
this.thread = undefined;
+ this.oldval = this.filterInput.val();
this.init();
}
@@ -23,14 +24,33 @@ function UserManagementFilter(filterInput, userList) {
*/
UserManagementFilter.prototype.init = function() {
umf = this;
- this.filterInput.keyup(function() {
- clearTimeout(umf.thread);
- umf.thread = setTimeout(
- function() {
- umf.run();
- },
- 300
- );
+ this.filterInput.keyup(function(e) {
+ console.log(e.keyCode);
+
+ //we want to react on any printable letter, plus on modyfing stuff like
+ //Backspace and Delete. extended https://stackoverflow.com/a/12467610
+ var valid =
+ e.keyCode === 0 || e.keyCode === 8 || // like ö or ж; backspace
+ e.keyCode === 9 || e.keyCode === 46 || // tab; delete
+ e.keyCode === 32 || // space
+ (e.keyCode > 47 && e.keyCode < 58) || // number keys
+ (e.keyCode > 64 && e.keyCode < 91) || // letter keys
+ (e.keyCode > 95 && e.keyCode < 112) || // numpad keys
+ (e.keyCode > 185 && e.keyCode < 193) || // ;=,-./` (in order)
+ (e.keyCode > 218 && e.keyCode < 223); // [\]' (in order)
+
+ //besides the keys, the value must have been changed compared to last
+ //time
+ if(valid && umf.oldVal !== umf.getPattern()) {
+ clearTimeout(umf.thread);
+ umf.thread = setTimeout(
+ function() {
+ umf.run();
+ },
+ 300
+ );
+ }
+ umf.oldVal = umf.getPattern();
});
}