diff --git a/public/src/app.js b/public/src/app.js index a82c730ee2..b8d2afd710 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -36,6 +36,7 @@ var socket, $('#disconnect-modal').show(); $('#reload-button').on('click',function(){ $('#disconnect-modal').hide(); + console.log(window.location.href); window.location.reload(); }); }); diff --git a/public/src/templates.js b/public/src/templates.js index 3c0f40531d..c2b75a4779 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -40,6 +40,7 @@ var templates = {}; for (var t in templatesToLoad) { (function(file) { $.get('/templates/' + file + '.tpl?v=' + timestamp, function(html) { + var template = function() { this.toString = function() { return this.html; @@ -168,6 +169,12 @@ function load_template(callback, url, template) { jQuery.get(API_URL + url, function(data) { + console.log(data); + if(!data) { + window.location.href = '/403'; + return; + } + var tpl = templates.get_custom_map(url); if (tpl == false && !templates[url]) { diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index a12a6f2de2..9b8e203e36 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -284,7 +284,8 @@ 'event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room', 'event:topic_deleted', 'event:topic_restored', 'event:topic:locked', 'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned', - 'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored' + 'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored', + 'api:posts.favourite' ]); socket.on('api:get_users_in_room', function(users) { var anonymous = users.anonymous, @@ -374,6 +375,13 @@ }); }); + socket.on('api:posts.favourite', function(data) { + if (data.status !== 'ok' && data.pid) { + var favEl = document.querySelector('.post_rep_' + data.pid).nextSibling; + if (favEl) favEl.className = 'icon-star-empty'; + } + }); + socket.on('event:post_deleted', function(data) { if (data.pid) toggle_post_delete_state(data.pid, true); }); @@ -424,7 +432,6 @@ pid = ids[0], uid = ids[1]; - if (thread_state.locked !== '1') { if (this.children[1].className == 'icon-star-empty') { this.children[1].className = 'icon-star'; diff --git a/src/posts.js b/src/posts.js index e14f67e889..2c74859dcb 100644 --- a/src/posts.js +++ b/src/posts.js @@ -12,6 +12,7 @@ marked.setOptions({ (function(Posts) { Posts.get = function(callback, tid, current_user, start, end) { + if (start == null) start = 0; if (end == null) end = start + 10; @@ -74,7 +75,7 @@ marked.setOptions({ // get all data for thread in asynchronous fashion RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) { RDB.handle(err); - + var content = [], uid = [], timestamp = [], pid = [], post_rep = [], editor = [], editTime = [], deleted = []; for (var i=0, ii=pids.length; i