Skip to content

Node.js based forum software built for the modern web

derp conflicts Merge branch 'master' of https://github.com/psychobunny/NodeBB

psychobunnycb6d98cecb24
diff --cc public/src/templates.js
index e9868be01b,f030d94f5c..a5818e1649
--- a/public/src/templates.js
+++ b/public/src/templates.js
@@@ -92,71 -119,6 +92,72 @@@
}
+
+ templates.load_template = function(callback, url, template) {
+ var location = document.location || window.location,
+ rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
+
+ var api_url = (url === '' || url === '/') ? 'home' : url;
+
+ var tpl_url = templates.get_custom_map(url);
+ if (tpl_url == false && !templates[api_url]) {
+ tpl_url = api_url.split('/')[0];
+ } else {
+ tpl_url = api_url;
+ }
+
+ var template_data = null;
+
+
+ (function() {
+ var timestamp = new Date().getTime(); //debug
+
+ if (!templates[tpl_url]) {
+ jQuery.get('/templates/' + tpl_url + '.tpl?v=' + timestamp, function(html) {
+ var template = function() {
+ this.toString = function() {
+ return this.html;
+ };
+ }
+
+ template.prototype.parse = parse;
+ template.prototype.html = String(html);
+ template.prototype.blocks = {};
+
+ templates[tpl_url] = new template;
+
+ parse_template();
+ });
+ } else {
+ parse_template();
+ }
+
+ }());
+
+ (function() {
+ jQuery.get(API_URL + api_url, function(data) {
+ if(!data) {
+ window.location.href = '/404';
+ return;
+ }
+
+ template_data = data;
+ parse_template();
+ });
+ }());
+
+
+ function parse_template() {
+ if (!templates[tpl_url] || !template_data) return;
+
+ document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data));
+ if (callback) callback(true);
+ }
++
+ }
+
+
+
//modified from https://github.com/psychobunny/dcp.templates
var parse = function(data) {
var self = this;