mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
closes #44
This commit is contained in:
@@ -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()));
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
<h1>Users</h1>
|
||||
<div>
|
||||
|
||||
<ul class="nav nav-pills">
|
||||
<li class='active'><a href='/users/latest'>Latest Users</a></li>
|
||||
<li class=''><a href='/users/sort-posts'>Top Posters</a></li>
|
||||
<li class=''><a href='/users/sort-reputation'>Most Reputation</a></li>
|
||||
<li class=''><a href='/users/search'>Search</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<div class="search {search_display} well">
|
||||
<input id="search-user" type="text" placeholder="Enter a username to search"/><br />
|
||||
<i class="icon-spinner icon-spin none"></i>
|
||||
<span id="user-notfound-notify" class="label label-important hide">User not found!</span><br/>
|
||||
</div>
|
||||
|
||||
<ul class="users">
|
||||
<!-- BEGIN users -->
|
||||
<div class="users-box well">
|
||||
<a href="/users/{users.userslug}">
|
||||
@@ -18,6 +33,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- END users -->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/src/forum/users.js"></script>
|
||||
@@ -24,10 +24,8 @@ var user = require('./../user.js'),
|
||||
});
|
||||
|
||||
app.get('/users', function(req, res) {
|
||||
user.getUserList(function(data) {
|
||||
res.send(app.build_header(res) + app.create_route("users", "users") + templates['footer']);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/users/:userslug', function(req, res) {
|
||||
|
||||
@@ -35,6 +33,13 @@ var user = require('./../user.js'),
|
||||
res.send("User doesn't exist!");
|
||||
return;
|
||||
}
|
||||
console.log('derp');
|
||||
console.log(req.params.userslug);
|
||||
|
||||
if(req.params.userslug === "sort-posts" || req.params.userslug === "sort-reputation" || req.params.userslug === "latest" || req.params.userslug === "search") {
|
||||
res.send(app.build_header(res) + app.create_route("users/"+req.params.userslug, "users") + templates['footer']);
|
||||
return;
|
||||
}
|
||||
|
||||
user.get_uid_by_userslug(req.params.userslug, function(uid) {
|
||||
if(!uid) {
|
||||
@@ -240,9 +245,38 @@ var user = require('./../user.js'),
|
||||
var callerUID = req.user?req.user.uid : 0;
|
||||
|
||||
if (!req.params.section && !req.params.userslug) {
|
||||
|
||||
user.getUserList(function(data) {
|
||||
res.json({users:data});
|
||||
data = data.sort(function(a, b) {
|
||||
return b.joindate - a.joindate;
|
||||
});
|
||||
res.json({search_display: 'none', users:data});
|
||||
});
|
||||
}
|
||||
else if (req.params.userslug == 'search') {
|
||||
res.json({search_display: 'block', users: []});
|
||||
}
|
||||
else if(req.params.userslug === "sort-posts") {
|
||||
user.getUserList(function(data) {
|
||||
data = data.sort(function(a, b) {
|
||||
return b.postcount - a.postcount;
|
||||
});
|
||||
res.json({search_display: 'none', users:data});
|
||||
});
|
||||
}
|
||||
else if(req.params.userslug === "sort-reputation") {
|
||||
user.getUserList(function(data) {
|
||||
data = data.sort(function(a, b) {
|
||||
return b.reputation - a.reputation;
|
||||
});
|
||||
res.json({search_display: 'none', users:data});
|
||||
});
|
||||
}
|
||||
else if(req.params.userslug === "latest") {
|
||||
user.getUserList(function(data) {
|
||||
data = data.sort(function(a, b) {
|
||||
return b.joindate - a.joindate;
|
||||
});
|
||||
res.json({search_display: 'none', users:data});
|
||||
});
|
||||
}
|
||||
else if(String(req.params.section).toLowerCase() === 'following') {
|
||||
|
||||
Reference in New Issue
Block a user