From 0f3f2bb859039116c18d4da71d745e3fd37bd1e1 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 1 May 2013 18:25:24 +0000 Subject: [PATCH] post replies, unfinished --- public/src/app.js | 8 ++++++-- public/templates/topic.tpl | 10 +++++++++- src/posts.js | 2 +- src/templates.js | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index 8b50d34af6..64dd8378ff 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -78,12 +78,16 @@ var socket, } } - var post_window = null; - app.open_post_window = function() { + var post_window = null, + mode = 'topic', + topic_id = null; + app.open_post_window = function(post_mode, id) { 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; }; app.post_topic = function() { diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 56c230a31f..ed5de86aa8 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -5,4 +5,12 @@

Posted on {posts.timestamp} by user {posts.uid}.

- \ No newline at end of file + +
+ + \ No newline at end of file diff --git a/src/posts.js b/src/posts.js index c34d088232..b2cac90985 100644 --- a/src/posts.js +++ b/src/posts.js @@ -46,7 +46,7 @@ var RDB = require('./redis.js'); }); } - callback({'posts': posts}); + callback({'posts': posts, 'TOPIC_ID': tid}); }); } else { callback({}); diff --git a/src/templates.js b/src/templates.js index f38a195475..c74aba7934 100644 --- a/src/templates.js +++ b/src/templates.js @@ -60,11 +60,11 @@ var fs = require('fs'); var template = this.html, regex, block; return (function parse(data, namespace, template) { - if (data.length == 0) { + if (Object.keys(data).length == 0) { regex = makeRegex('[^]*'); template = template.replace(regex, ''); } - + for (var d in data) { if (data.hasOwnProperty(d)) { if (data[d] instanceof String || data[d] === null) {