[CallLog]update CallLog(tizen_2.1)
[samples/web/CallLog.git] / js / app.ui.templateManager.js
index 62892cb..68c6678 100644 (file)
@@ -1,5 +1,3 @@
-/*jslint devel: true*/
-/*jslint forin: true*/ /* temporary - from Tizen SDK */
 /*global tizen, $, app */
 /**
  * @class TemplateManager
@@ -22,14 +20,14 @@ function TemplateManager() {
                 * UI module initialisation
                 */
                init: function init() {
-
                },
 
                /**
                 * Returns template html (from cache)
+                * @param {string} tplName
+                * @param {string} tplParams
                 */
                get: function TemplateManager_get(tplName, tplParams) {
-                       console.log('TemplateManager_get:' + tplName);
                        if (this.cache[tplName] !== undefined) {
                                return this.getCompleted(this.cache[tplName], tplParams);
                        }
@@ -38,6 +36,8 @@ function TemplateManager() {
 
                /**
                 * Load templates to cache
+                * @param {string} tplNames
+                * @param {function} onSuccess
                 */
                loadToCache: function TemplateManager_loadToCache(tplNames, onSuccess) {
                        var self = this,
@@ -66,7 +66,6 @@ function TemplateManager() {
 
                                                                // save to cache
                                                                self.cache[fileName] = data;
-                                                               console.log('Cached template: ' + fileName);
 
                                                                // if all templates are cached launch callback
                                                                if (cachedTemplates >= tplNames.length && typeof onSuccess === 'function') {
@@ -74,7 +73,7 @@ function TemplateManager() {
                                                                }
                                                        },
                                                        error: function (jqXHR, textStatus, errorThrown) {
-                                                               alert('templateManagerError: ' + errorThrown);
+                                                               console.error('templateManagerError: ' + errorThrown);
                                                        }
                                                });
                                        } else {
@@ -92,13 +91,17 @@ function TemplateManager() {
 
                /**
                 * Returns template completed by specified params
+               * @param {string} tplHtml
+               * @param {string} tplParams
                 */
                getCompleted: function TemplateManager_getCompleted(tplHtml, tplParams) {
                        var tplParam, replaceRegExp;
 
                        for (tplParam in tplParams) {
-                               replaceRegExp = new RegExp(['%', tplParam, '%'].join(''), 'g');
-                               tplHtml = tplHtml.replace(replaceRegExp, tplParams[tplParam]);
+                               if (tplParams.hasOwnProperty(tplParam)) {
+                                       replaceRegExp = new RegExp(['%', tplParam, '%'].join(''), 'g');
+                                       tplHtml = tplHtml.replace(replaceRegExp, tplParams[tplParam]);
+                               }
                        }
 
                        return tplHtml;