Merge branch 'master' of github.com:psychobunny/node-forum

v1.18.x
Julian Lam 12 years ago
commit faf70d85d8

@ -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();
});
});

@ -426,8 +426,8 @@
ptotal += value;
utotal += value;
post_rep.html(ptotal);
user_rep.html(utotal);
post_rep.html(ptotal+ ' ');
user_rep.html(utotal+ ' ');
}

@ -38,6 +38,9 @@
</button>
<div class="nav-collapse collapse">
<ul class="nav">
<li>
<a href="/" target="_blank"><i class="icon-book"></i> Forum</a>
</li>
<li>
<a href="/admin/index"><i class="icon-home"></i> Home</a>
</li>

@ -42,8 +42,6 @@
app.enter_room('admin');
socket.emit('api:get_all_rooms');
socket.on('api:admin.user.search', function(data) {
console.log(data);
});
</script>

@ -11,33 +11,36 @@
<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>
<!-- BEGIN users -->
<div class="users-box well" data-uid="{users.uid}" data-admin="{users.administrator}" data-username="{users.username}">
<a href="/users/{users.userslug}">
<img src="{users.picture}" class="user-8080-picture"/>
</a>
<br/>
<a href="/users/{users.userslug}">{users.username}</a>
<br/>
<div title="reputation">
<span id='reputation'>{users.reputation}</span>
<i class='icon-star'></i>
<ul class="users">
<!-- BEGIN users -->
<div class="users-box well" data-uid="{users.uid}" data-admin="{users.administrator}" data-username="{users.username}">
<a href="/users/{users.userslug}">
<img src="{users.picture}" class="user-8080-picture"/>
</a>
<br/>
<a href="/users/{users.userslug}">{users.username}</a>
<br/>
<div title="reputation">
<span id='reputation'>{users.reputation}</span>
<i class='icon-star'></i>
</div>
<div title="post count">
<span id='postcount'>{users.postcount}</span>
<i class='icon-pencil'></i>
</div>
<div>
<a href="#" class="btn admin-btn">Admin</a>
</div>
<br/>
<div>
<a href="#" class="btn delete-btn btn-danger">Delete</a>
</div>
</div>
<div title="post count">
<span id='postcount'>{users.postcount}</span>
<i class='icon-pencil'></i>
</div>
<div>
<a href="#" class="btn admin-btn">Admin</a>
</div>
<br/>
<div>
<a href="#" class="btn delete-btn btn-danger">Delete</a>
</div>
</div>
<!-- END users -->
<!-- END users -->
</ul>
<input type="hidden" template-variable="yourid" value="{yourid}" />

@ -7,12 +7,12 @@
<strong>Failed Login Attempt</strong> <p></p>
</div>
<div>
<form>
<label>Username</label><input type="text" placeholder="Enter Username" name="username" id="username" /><br />
<label>Password</label><input type="password" placeholder="Enter Password" name="password" id="password" /><br />
<input type="hidden" name="_csrf" value="{token}" id="csrf-token" />
<button class="btn btn-primary" id="login" type="submit">Login</button> &nbsp; <a href="/reset">Forgot Password?</a>
</div>
</form>
<span id="login-error-notify" class="label label-important hide">Invalid username/password</span><br/>
</div>

@ -79,7 +79,7 @@
<div id="ids_{posts.pid}_{posts.uid}" class="edit {posts.display_moderator_tools} hidden-phone" title="Edit"><i class="icon-pencil"></i></div>
<div id="ids_{posts.pid}_{posts.uid}" class="delete {posts.display_moderator_tools} hidden-phone" title="Delete"><i class="icon-trash"></i></div>
<div id="quote_{posts.pid}_{posts.uid}" class="quote hidden-phone" title="Quote"><i class="icon-quote-left"></i></div>
<div id="favs_{posts.pid}_{posts.uid}" class="favourite hidden-phone" title="Favourite"><span class="post_rep_{posts.pid}">{posts.post_rep}</span><i class="{posts.fav_star_class}"></i></div>
<div id="favs_{posts.pid}_{posts.uid}" class="favourite hidden-phone" title="Favourite"><span class="post_rep_{posts.pid}">{posts.post_rep} </span><i class="{posts.fav_star_class}"></i></div>
<div class="post_reply" title="Reply"><i class="icon-reply"></i></div>
</span>
<img class="hidden-desktop" src="{posts.gravatar}?s=10&default=identicon" align="left" /> posted by <strong><a class="username-field" href="/users/{posts.userslug}">{posts.username}</a></strong> {posts.relativeTime} ago

@ -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(err === null) {
//console.log(data);
/*var keys = [];
for(var i=0, ii=data.length; i<ii; ++i) {
keys.push('')
}*/
if(!username) {
callback([]);
return;
}
RDB.mget(keys, function(err, uids) {
console.log(uids);
User.getDataForUsers(uids, function(userdata) {
callback(userdata);
RDB.keys('username:*'+ username + '*:uid', function(err, keys) {
if(err === null) {
if(keys && keys.length) {
RDB.mget(keys, function(err, uids) {
User.getDataForUsers(uids, function(userdata) {
callback(userdata);
});
});
});
}
else
callback([]);
}
else
console.log(err);
@ -378,7 +377,7 @@ var utils = require('./../public/src/utils.js'),
User.getDataForUsers = function(userIds, callback) {
var returnData = [];
if(userIds.length === 0) {
if(!userIds || userIds.length === 0) {
callback(returnData);
return;
}

Loading…
Cancel
Save