custom template half in

This commit is contained in:
psychobunny
2013-05-07 21:17:22 +00:00
parent cdceb39828
commit 09c6aace09
3 changed files with 17 additions and 7 deletions

View File

@@ -147,17 +147,20 @@ var templates = {};
}());
function load_template(callback) {
function load_template(callback, custom_tpl) {
var location = document.location || window.location,
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
var url = location.href.replace(rootUrl +'/', '');
url = (url === '' || url === '/') ? 'home' : url;
jQuery.get(API_URL + url, function(data) {
var tpl = url.split('/')[0];
tpl = templates.get_custom_map(tpl);
if (custom_tpl) tpl = custom_tpl;
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
if (callback) callback();
});