diff --git a/public/src/forum/admin/users.js b/public/src/forum/admin/users.js index 7906579950..37204dfbec 100644 --- a/public/src/forum/admin/users.js +++ b/public/src/forum/admin/users.js @@ -1,31 +1,7 @@ (function() { - jQuery('document').ready(function() { - - var yourid = templates.get('yourid'); - - var url = window.location.href, - parts = url.split('/'), - active = parts[parts.length-1]; - jQuery('.nav-pills li').removeClass('active'); - jQuery('.nav-pills li a').each(function() { - if (this.getAttribute('href').match(active)) { - jQuery(this.parentNode).addClass('active'); - return false; - } - }); - - 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()); - }); - - - - + function initUsers() { function isUserAdmin(element) { var parent = $(element).parents('.users-box'); @@ -98,6 +74,70 @@ return false; }); + } + + + jQuery('document').ready(function() { + + var yourid = templates.get('yourid'); + var timeoutId = 0; + + var url = window.location.href, + parts = url.split('/'), + active = parts[parts.length-1]; + + jQuery('.nav-pills li').removeClass('active'); + jQuery('.nav-pills li a').each(function() { + if (this.getAttribute('href').match(active)) { + jQuery(this.parentNode).addClass('active'); + return false; + } + }); + + jQuery('#search-user').on('keyup', function () { + if(timeoutId !== 0) { + clearTimeout(timeoutId); + timeoutId = 0; + } + + timeoutId = setTimeout(function() { + var username = $('#search-user').val(); + + jQuery('.icon-spinner').removeClass('none'); + socket.emit('api:admin.user.search', username); + + }, 250); + }); + + initUsers(); + + socket.removeAllListeners('api:admin.user.search'); + + socket.on('api:admin.user.search', function(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'); + } + + initUsers(); + }); }); diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index fef2681fb4..c4f550423c 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -426,8 +426,8 @@ ptotal += value; utotal += value; - post_rep.html(ptotal); - user_rep.html(utotal); + post_rep.html(ptotal+ ' '); + user_rep.html(utotal+ ' '); } diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl index 21ef16da22..c05d2e7ff8 100644 --- a/public/templates/admin/header.tpl +++ b/public/templates/admin/header.tpl @@ -38,6 +38,9 @@ -
+


  Forgot Password? -
+ Invalid username/password
diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index d8f054928b..2a9b880353 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -79,7 +79,7 @@
-
{posts.post_rep}
+
{posts.post_rep}
posted by {posts.username} {posts.relativeTime} ago diff --git a/src/user.js b/src/user.js index 2d26c535cd..ae5862e2d3 100644 --- a/src/user.js +++ b/src/user.js @@ -254,23 +254,22 @@ var utils = require('./../public/src/utils.js'), } User.search = function(username, callback) { - console.log('searching '+username); - RDB.keys('username:'+ username + '*:uid', function(err, keys) { + if(!username) { + callback([]); + return; + } + + RDB.keys('username:*'+ username + '*:uid', function(err, keys) { if(err === null) { - //console.log(data); - - /*var keys = []; - for(var i=0, ii=data.length; i