Node.js based forum software built for the modern web
added app alert if template data cant be loaded
Baris Usakli4207792ffd8a
diff --git a/public/src/templates.js b/public/src/templates.jsindex 2e4faffc21..82c0438b05 100644--- a/public/src/templates.js+++ b/public/src/templates.js@@ -124,47 +124,40 @@var template_data = null;- (function () {- var timestamp = new Date().getTime(); //debug-- if (!templates[tpl_url]) {- jQuery.get(RELATIVE_PATH + '/templates/' + tpl_url + '.tpl?v=' + timestamp, function (html) {- var template = function () {- this.toString = function () {- return this.html;- };- }+ var timestamp = new Date().getTime(); //debug++ if (!templates[tpl_url]) {+ jQuery.get(RELATIVE_PATH + '/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 = {};+ template.prototype.parse = parse;+ template.prototype.html = String(html);+ template.prototype.blocks = {};- templates[tpl_url] = new template;+ templates[tpl_url] = new template;- parse_template();- });- } else {parse_template();- }-- }());-- (function () {- jQuery.get(RELATIVE_PATH + '/api/' + api_url, function (data) {+ });+ } else {+ parse_template();+ }- if (!data) {- ajaxify.go('404');- return;- }+ jQuery.get(RELATIVE_PATH + '/api/' + api_url, function (data) {- template_data = data;- parse_template();- }).fail(function (data) {- template_data = {};- parse_template();- });- }());+ if (!data) {+ ajaxify.go('404');+ return;+ }+ template_data = data;+ parse_template();+ }).fail(function (data) {+ app.alertError("Can't load template data!");+ });function parse_template() {if (!templates[tpl_url] || !template_data) return;