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

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

@ -1,31 +1,7 @@
(function() { (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) { function isUserAdmin(element) {
var parent = $(element).parents('.users-box'); var parent = $(element).parents('.users-box');
@ -98,6 +74,70 @@
return false; 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; ptotal += value;
utotal += value; utotal += value;
post_rep.html(ptotal); post_rep.html(ptotal+ ' ');
user_rep.html(utotal); user_rep.html(utotal+ ' ');
} }

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

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

@ -11,33 +11,36 @@
<div class="search {search_display} well"> <div class="search {search_display} well">
<input id="search-user" type="text" placeholder="Enter a username to search"/><br /> <input id="search-user" type="text" placeholder="Enter a username to search"/><br />
<i class="icon-spinner icon-spin none"></i> <i class="icon-spinner icon-spin none"></i>
<span id="user-notfound-notify" class="label label-important hide">User not found!</span><br/>
</div> </div>
<!-- BEGIN users --> <ul class="users">
<div class="users-box well" data-uid="{users.uid}" data-admin="{users.administrator}" data-username="{users.username}"> <!-- BEGIN users -->
<a href="/users/{users.userslug}"> <div class="users-box well" data-uid="{users.uid}" data-admin="{users.administrator}" data-username="{users.username}">
<img src="{users.picture}" class="user-8080-picture"/> <a href="/users/{users.userslug}">
</a> <img src="{users.picture}" class="user-8080-picture"/>
<br/> </a>
<a href="/users/{users.userslug}">{users.username}</a> <br/>
<br/> <a href="/users/{users.userslug}">{users.username}</a>
<div title="reputation"> <br/>
<span id='reputation'>{users.reputation}</span> <div title="reputation">
<i class='icon-star'></i> <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>
<div title="post count"> <!-- END users -->
<span id='postcount'>{users.postcount}</span> </ul>
<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 -->
<input type="hidden" template-variable="yourid" value="{yourid}" /> <input type="hidden" template-variable="yourid" value="{yourid}" />

@ -7,12 +7,12 @@
<strong>Failed Login Attempt</strong> <p></p> <strong>Failed Login Attempt</strong> <p></p>
</div> </div>
<div> <form>
<label>Username</label><input type="text" placeholder="Enter Username" name="username" id="username" /><br /> <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 /> <label>Password</label><input type="password" placeholder="Enter Password" name="password" id="password" /><br />
<input type="hidden" name="_csrf" value="{token}" id="csrf-token" /> <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> <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/> <span id="login-error-notify" class="label label-important hide">Invalid username/password</span><br/>
</div> </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="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="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="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> <div class="post_reply" title="Reply"><i class="icon-reply"></i></div>
</span> </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 <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) { User.search = function(username, callback) {
console.log('searching '+username); if(!username) {
RDB.keys('username:'+ username + '*:uid', function(err, keys) { callback([]);
if(err === null) { return;
//console.log(data); }
/*var keys = [];
for(var i=0, ii=data.length; i<ii; ++i) {
keys.push('')
}*/
RDB.mget(keys, function(err, uids) { RDB.keys('username:*'+ username + '*:uid', function(err, keys) {
console.log(uids); if(err === null) {
User.getDataForUsers(uids, function(userdata) { if(keys && keys.length) {
callback(userdata); RDB.mget(keys, function(err, uids) {
User.getDataForUsers(uids, function(userdata) {
callback(userdata);
});
}); });
}); }
else
callback([]);
} }
else else
console.log(err); console.log(err);
@ -378,7 +377,7 @@ var utils = require('./../public/src/utils.js'),
User.getDataForUsers = function(userIds, callback) { User.getDataForUsers = function(userIds, callback) {
var returnData = []; var returnData = [];
if(userIds.length === 0) { if(!userIds || userIds.length === 0) {
callback(returnData); callback(returnData);
return; return;
} }

Loading…
Cancel
Save