replies are up

v1.18.x
psychobunny 12 years ago
parent a7f4c16140
commit e658531a67

@ -79,17 +79,57 @@ var socket,
}
var post_window = null,
mode = 'topic',
topic_id = null;
submit_post_btn = null,
post_title = null,
post_content = null;
app.open_post_window = function(post_mode, id) {
submit_post_btn = submit_post_btn || document.getElementById('submit_post_btn');
post_title = post_title || document.getElementById('post_title');
post_content = post_content || document.getElementById('post_content');
post_window = post_window || document.getElementById('post_window');
jQuery(post_window).slideToggle(250);
document.getElementById('post_title').focus();
mode = (post_mode == null) ? 'topic' : mode;
topic_id = (mode == 'reply') ? topic_id : null;
if (post_mode == null || post_mode == 'topic') {
post_title.style.display = 'block';
post_title.focus();
submit_post_btn.onclick = function() {
app.post_topic();
}
} else {
post_title.style.display = 'none';
post_content.focus();
submit_post_btn.onclick = function() {
app.post_reply(id)
}
}
};
app.post_reply = function(topic_id) {
var content = document.getElementById('post_content').value;
if (content.length < 5) {
app.alert({
title: 'Reply Failure',
message: 'You need to write more dude.',
type: 'error',
timeout: 2000
});
return;
}
socket.emit('api:posts.reply', {
'topic_id' : topic_id,
'content' : content
});
jQuery(post_window).slideToggle(250);
};
app.post_topic = function() {
var title = document.getElementById('post_title').value,
content = document.getElementById('post_content').value;
@ -99,10 +139,7 @@ var socket,
title: 'Topic Post Failure',
message: 'You need to write more dude.',
type: 'error',
timeout: 2000,
clickfn: function() {
ajaxify.go('register');
}
timeout: 2000
});
return;

@ -90,10 +90,10 @@
border: 1px solid #eee;
margin-top: 50px;
}
.topic-container li.topic-row:nth-child(odd) {
.topic-container a:nth-child(odd) li.topic-row {
background-color:#fdfdfd;
}
.topic-container li.topic-row:nth-child(even) {
.topic-container a:nth-child(even) li.topic-row {
background-color:#fff;
}
.topic-container li.topic-row {
@ -161,7 +161,7 @@
<a class="btn btn-link" href="#" tabindex="-1"><i class="icon-list"></i></a>
</div>
<div class="btn-group" style="float: right; margin-right: -12px">
<a class="btn" onclick="app.post_topic()"><i class="icon-ok"></i> Submit</a>
<a id="submit_post_btn" class="btn" onclick="app.post_topic()"><i class="icon-ok"></i> Submit</a>
<a class="btn" onclick="jQuery(post_window).slideToggle(250);"><i class="icon-remove"></i> Discard</a>
</div>
</div>

@ -13,4 +13,4 @@ var post_reply = document.getElementById('post_reply');
post_reply.onclick = function() {
app.open_post_window('reply', {TOPIC_ID});
}
</script>
</script>

@ -48,7 +48,7 @@ var RDB = require('./redis.js'),
});
}
callback({'posts': posts, 'TOPIC_ID': tid});
callback({'TOPIC_ID': tid, 'posts': posts});
});
} else {
callback({});
@ -60,8 +60,17 @@ var RDB = require('./redis.js'),
}
Posts.reply = function() {
Posts.reply = function(tid, uid, content) {
Posts.create(uid, content, function(pid) {
RDB.rpush('tid:' + tid + ':posts', pid);
global.socket.emit('event:alert', {
title: 'Reply Successful',
message: 'You have successfully replied. Click here to view your reply.',
type: 'notify',
timeout: 2000
});
});
};
Posts.create = function(uid, content, callback) {

@ -76,6 +76,10 @@
db.lpush(key, item);
}
RedisDB.rpush = function(key, item) {
db.rpush(key, item);
}
RedisDB.lrange = function(key, start, end, callback, error_handler) {
db.lrange(key, start, end, function(error, data) {
return_handler(error, data, callback, error_handler);

@ -93,7 +93,7 @@ var fs = require('fs');
block = parse(data[d], namespace, block);
template = setBlock(regex, block, template);
} else {
} else {
template = replace(namespace + d, data[d], template);
}
}

@ -93,6 +93,10 @@ var SocketIO = require('socket.io').listen(global.server),
modules.topics.post(uid, data.title, data.content);
});
socket.on('api:posts.reply', function(data) {
modules.posts.reply(data.topic_id, uid, data.content);
});
socket.on('api:user.active.get', function() {
modules.user.active.get();
});

Loading…
Cancel
Save