diff --git a/public/css/style.less b/public/css/style.less index 9de2532e5e..4f2c7f3125 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -205,8 +205,8 @@ footer.footer { .latest-post { float: right; padding-top: 2px; - margin-right: 30px; - width: 50%; + margin-right: 0px; + width: 40%; .pull-right { width: 100%; diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 2361b0c0bd..94074c825f 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -21,12 +21,11 @@ var ajaxify = {}; window.onpopstate = function(event) { + // "quiet": If set to true, will not call pushState if (event !== null && event.state && event.state.url !== undefined) ajaxify.go(event.state.url, null, null, true); }; ajaxify.go = function(url, callback, template, quiet) { - // "quiet": If set to true, will not call pushState - // leave room and join global app.enter_room('global'); @@ -61,9 +60,6 @@ var ajaxify = {}; jQuery('#content, #footer').fadeIn(200); }, url, template); - return true; - } else { - document.location.href = url; return true; } @@ -71,26 +67,20 @@ var ajaxify = {}; } ajaxify.enable = function() { - $('a').unbind('mouseup', ajaxify.onmouseup).bind('mouseup', ajaxify.onmouseup); $('a').unbind('click', ajaxify.onclick).bind('click', ajaxify.onclick); } - ajaxify.onmouseup = function(ev) { + ajaxify.onclick = function(ev) { if (this.href == window.location.href + "#") return; var url = this.href.replace(rootUrl +'/', ''); if (!ev.ctrlKey && ev.which === 1) { - if (ajaxify.go(url)) ev.preventDefault(); - } else if ((ev.ctrlKey && ev.which === 1) || ev.which === 2) { - window.open(this.href, '_blank'); - ev.preventDefault(); + if (ajaxify.go(url)) { + ev.preventDefault(); + } } } - ajaxify.onclick = function(ev) { - ev.preventDefault(); - } - $('document').ready(function() { if (!window.history || !window.history.pushState) return; // no ajaxification for old browsers 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/header.tpl b/public/templates/header.tpl index 252611a734..cf4984bdbf 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -7,7 +7,7 @@ - + diff --git a/public/vendor/bootstrap/js/bootstrap.js b/public/vendor/bootstrap/js/bootstrap.js index c298ee42e3..f6a61079df 100644 --- a/public/vendor/bootstrap/js/bootstrap.js +++ b/public/vendor/bootstrap/js/bootstrap.js @@ -788,7 +788,7 @@ /* APPLY TO STANDARD DROPDOWN ELEMENTS * =================================== */ - $(document) + $('.dropdown') .on('click.dropdown.data-api', clearMenus) .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.dropdown-menu', function (e) { e.stopPropagation() }) diff --git a/src/posts.js b/src/posts.js index 527b07ffe6..9ab6935004 100644 --- a/src/posts.js +++ b/src/posts.js @@ -13,12 +13,16 @@ marked.setOptions({ (function(Posts) { Posts.get = function(callback, tid, current_user, start, end) { + if (start == null) start = 0; if (end == null) end = start + 10; var post_data, user_data, thread_data, vote_data, viewer_data; - topics.markAsRead(tid, current_user); + getTopicPosts(); + + getUserReputation(); + //compile thread after all data is asynchronously called function generateThread() { @@ -71,84 +75,94 @@ marked.setOptions({ }); } + function getTopicPosts() { + // get all data for thread in asynchronous fashion + RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) { + RDB.handle(err); + + if(pids.length === 0 ){ + callback(false); + return; + } + + topics.markAsRead(tid, current_user); + + var content = [], uid = [], timestamp = [], pid = [], post_rep = [], editor = [], editTime = [], deleted = []; + + for (var i=0, ii=pids.length; i