From 4207792ffd8ab0a67aa8174c55a6349b67562716 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Mon, 30 Sep 2013 15:12:14 -0400 Subject: [PATCH] added app alert if template data cant be loaded --- public/src/templates.js | 61 ++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 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;