From fb43282a9cf6144d31e466bc27cdcf6a0b1b0c17 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 13 Apr 2014 22:04:04 -0400 Subject: [PATCH] removed for in loop --- public/src/translator.js | 53 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/public/src/translator.js b/public/src/translator.js index 4fad01e31a..7f1886ac28 100644 --- a/public/src/translator.js +++ b/public/src/translator.js @@ -104,7 +104,7 @@ if (value) { for (var i = 1, ii = variables.length; i < ii; i++) { var variable = variables[i].replace(']]', ''); - value = ('' + value).replace('%' + i, variable); + value = value.replace('%' + i, variable); } text = text.replace(key, value); @@ -119,31 +119,35 @@ var keys = data.match(/\[\[.*?\]\]/g), loading = 0; - for (var key in keys) { - if (keys.hasOwnProperty(key)) { - keys[key] = '' + keys[key]; - var variables = keys[key].split(/[,][?\s+]/); + if (!keys) { + return callback(data); + } - var parsedKey = keys[key].replace('[[', '').replace(']]', '').split(':'); - if (!(parsedKey[0] && parsedKey[1])) { - continue; - } + for (var i=0; i