-/*jslint devel: true*/
-/*jslint forin: true*/ /* temporary - from Tizen SDK */
/*global tizen, $, app */
/**
* @class 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);
}
/**
* Load templates to cache
+ * @param {string} tplNames
+ * @param {function} onSuccess
*/
loadToCache: function TemplateManager_loadToCache(tplNames, onSuccess) {
var self = this,
// 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') {
}
},
error: function (jqXHR, textStatus, errorThrown) {
- alert('templateManagerError: ' + errorThrown);
+ console.error('templateManagerError: ' + errorThrown);
}
});
} else {
/**
* 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;