diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 9646720521..ac96a7d6be 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -22,7 +22,7 @@ var ajaxify = {}; ajaxify.go = function(url, callback) { var url = url.replace(/\/$/, ""); - var tpl_url = (url === '') ? 'home' : url.split('/')[0]; + var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0]; if (templates[tpl_url]) { window.history.pushState({}, url, "/" + url); diff --git a/public/src/templates.js b/public/src/templates.js index e7ead3b743..f18b1e50b6 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -1,9 +1,17 @@ var templates = {}; (function() { + var ready_callback; + + templates.ready = function(callback) { + //quick implementation because introducing a lib to handle several async callbacks + if (callback == null) ready_callback(); + else ready_callback = callback; + } function loadTemplates(templatesToLoad) { var timestamp = new Date().getTime(); + var loaded = templatesToLoad.length; for (var t in templatesToLoad) { (function(file) { @@ -18,6 +26,12 @@ var templates = {}; template.prototype.html = String(html); templates[file] = new template; + + loaded--; + if (loaded == 0) templates.ready(); + }).fail(function() { + loaded--; + if (loaded == 0) templates.ready(); }); }(templatesToLoad[t])); } @@ -116,7 +130,7 @@ function load_template(callback) { rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''); var url = location.href.replace(rootUrl +'/', ''); - url = (url === '') ? 'home' : url; + url = (url === '' || url === '/') ? 'home' : url; jQuery.get(API_URL + url, function(data) { document.getElementById('content').innerHTML = templates[url.split('/')[0]].parse(JSON.parse(data)); diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 45604a7adf..a22c9e7e0a 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -108,6 +108,35 @@ background-color: #eee; } + + + .post-container { + list-style-type: none; + padding: 0; + margin: 0; + border: 1px solid #eee; + + } + .post-container li.post-row:nth-child(odd) { + background-color:#fdfdfd; + } + .post-container li.post-row:nth-child(even) { + background-color:#fff; + } + .post-container li.post-row { + cursor: pointer; + border-bottom: 1px solid #eee; + padding: 10px; + } + .post-container li:last-child { + border-bottom: 0; + } + .post-container li.post-row:hover { + background-color: #eee; + } + + + #user_label img { border: 1px solid #999; margin-right: 8px; diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 6abc380cf8..4c8ebfa9cb 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -5,9 +5,9 @@ -
{posts.content}
Posted {posts.relativeTime} by user {posts.uid}.