added template mapping, did users->account

This commit is contained in:
psychobunny
2013-05-07 16:12:26 +00:00
parent c80d178a57
commit 5153aa7652
3 changed files with 18 additions and 6 deletions

View File

@@ -1,7 +1,12 @@
var templates = {};
(function() {
var ready_callback;
var ready_callback,
config;
templates.get_custom_map = function(tpl) {
return (config['custom_mapping'] && config['custom_mapping'][tpl]) ? config['custom_mapping'][tpl] : tpl;
}
templates.ready = function(callback) {
//quick implementation because introducing a lib to handle several async callbacks
@@ -21,6 +26,11 @@ var templates = {};
var timestamp = new Date().getTime();
var loaded = templatesToLoad.length;
$.getJSON('/templates/config.json', function(data) {
config = data;
console.log('loaded');
});
for (var t in templatesToLoad) {
(function(file) {
$.get('/templates/' + file + '.tpl?v=' + timestamp, function(html) {
@@ -146,8 +156,10 @@ function load_template(callback) {
url = (url === '' || url === '/') ? 'home' : url;
jQuery.get(API_URL + url, function(data) {
console.log(data)
document.getElementById('content').innerHTML = templates[url.split('/')[0]].parse(JSON.parse(data));
var tpl = url.split('/')[0];
tpl = templates.get_custom_map(tpl);
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
if (callback) callback();
});
}