psychobunny 12 years ago
commit 279a0053f1

@ -17,7 +17,8 @@
latest_user = document.getElementById('latest_user'),
active_users = document.getElementById('active_users'),
user_label = document.getElementById('user_label'),
active_record = document.getElementById('active_record');
active_record = document.getElementById('active_record'),
right_menu = document.getElementById('right-menu');
socket.emit('user.count', {});
socket.on('user.count', function(data) {
@ -44,14 +45,30 @@
});
socket.emit('api:user.get', { fields: ['username', 'picture'] });
socket.on('api:user.get', function(data) {
if (data.uid > 0) {
var gravatar = document.createElement('img'),
name = document.createElement('span');
name = document.createElement('span')
logoutEl = document.createElement('li');
logoutEl.innerHTML = '<a href="/logout">Log out</a>';
name.innerHTML = data['username'];
gravatar.src = data['picture'];
user_label.innerHTML = '';
user_label.appendChild(gravatar);
user_label.appendChild(name);
right_menu.appendChild(logoutEl);
} else {
var registerEl = document.createElement('li'),
loginEl = document.createElement('li');
registerEl.innerHTML = '<a href="/register">Register</a>';
loginEl.innerHTML = '<a href="/login">Login</a>';
right_menu.appendChild(registerEl);
right_menu.appendChild(loginEl);
}
});
}());
</script>

@ -167,12 +167,12 @@
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="/">Forum</a></li>
<li><a href="/register">Register</a></li>
<li><a href="/login">Login</a></li>
<!-- <li><a href="/register">Register</a></li>
<li><a href="/login">Login</a></li> -->
</ul>
<ul class="nav pull-right">
<ul class="nav pull-right" id="right-menu">
<li><p class="navbar-text" id="user_label"></p></li>
<li><a href="/logout">Log out</a></li>
<!-- <li><a href="/logout">Log out</a></li> -->
</ul>
</div>
</div>

@ -10,7 +10,9 @@ var config = require('../config.js'),
User.get = function(uid, fields) {
if (uid > 0) {
var keys = [],
returnData = {},
returnData = {
uid: uid
},
removeEmail = false;
if (!(fields instanceof Array)) fields = ['username', 'email'];

Loading…
Cancel
Save