diff --git a/public/src/forum/users.js b/public/src/forum/users.js index 36c34e58d7..87621b5d9d 100644 --- a/public/src/forum/users.js +++ b/public/src/forum/users.js @@ -1,6 +1,61 @@ (function() { $(document).ready(function() { + 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); + console.log('sent'); + }, 250); + }); + + socket.removeAllListeners('api:admin.user.search'); + + socket.on('api:admin.user.search', function(data) { + console.log('derp'); + var html = templates.prepare(templates['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'); + } + + }); $('.reputation').each(function(index, element) { $(element).html(app.addCommas($(element).html())); diff --git a/public/templates/config.json b/public/templates/config.json index b3038f4324..9f998567ca 100644 --- a/public/templates/config.json +++ b/public/templates/config.json @@ -16,10 +16,15 @@ "install/mail/?": "install/mail", "install/social/?": "install/social", "install/privileges/?": "install/privileges", + "users/sort-posts": "users", + "users/latest": "users", + "users/sort-reputation": "users", + "users/search": "users", "users[^]*edit": "accountedit", "users[^]*following": "following", "users[^]*followers": "followers", "users/[^]*": "account", + "recent": "category", "popular": "category", "active": "category" diff --git a/public/templates/users.tpl b/public/templates/users.tpl index 3cb0de603d..4f88ac193e 100644 --- a/public/templates/users.tpl +++ b/public/templates/users.tpl @@ -1,23 +1,39 @@ -