diff --git a/public/src/forum/admin/users.js b/public/src/forum/admin/users.js index 7906579950..c589ee4b34 100644 --- a/public/src/forum/admin/users.js +++ b/public/src/forum/admin/users.js @@ -3,6 +3,7 @@ jQuery('document').ready(function() { var yourid = templates.get('yourid'); + var timeoutId = 0; var url = window.location.href, parts = url.split('/'), @@ -17,14 +18,17 @@ }); jQuery('#search-user').on('keyup', function () { - console.log('derp'); - jQuery('.icon-spinner').removeClass('none'); - console.log($('#search-user').val()); - socket.emit('api:admin.user.search', $('#search-user').val()); - }); - + if(timeoutId !== 0) { + clearTimeout(timeoutId); + timeoutId = 0; + } + timeoutId = setTimeout(function() { + jQuery('.icon-spinner').removeClass('none'); + socket.emit('api:admin.user.search', $('#search-user').val()); + }, 250); + }); function isUserAdmin(element) { diff --git a/public/templates/admin/index.tpl b/public/templates/admin/index.tpl index 7d1d74fce0..843a155ede 100644 --- a/public/templates/admin/index.tpl +++ b/public/templates/admin/index.tpl @@ -43,7 +43,26 @@ socket.emit('api:get_all_rooms'); socket.on('api:admin.user.search', function(data) { - console.log(data); + var html = templates.prepare(templates['admin/users'].blocks['users']).parse({ + users: data + }), + userListEl = document.querySelector('.users'); + + userListEl.innerHTML = html; + jQuery('.icon-spinner').addClass('none'); + + if(data && data.length === 0) { + $('#user-notfound-notify').html('User not found!') + .show() + .addClass('label-important') + .removeClass('label-success'); + } + else + $('#user-notfound-notify').html(data.length + ' user'+(data.length>1?'s':'') + ' found!') + .show() + .addClass('label-success') + .removeClass('label-important'); + }); \ No newline at end of file diff --git a/public/templates/admin/users.tpl b/public/templates/admin/users.tpl index bac6328897..1f9bc8af8a 100644 --- a/public/templates/admin/users.tpl +++ b/public/templates/admin/users.tpl @@ -11,33 +11,36 @@