From 5d7eabb690941b4de27d48e487c344260fdcf8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 2 Oct 2015 16:48:09 +0200 Subject: Bugfix: don't remove [\n\r\t] from templates. --- js/codeq/core.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/codeq/core.js b/js/codeq/core.js index f1bd697..b54095f 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -144,18 +144,19 @@ regexpBackslash = new RegExp('\\\\', 'g'), regexpWhiteSpaceStart = new RegExp('^[ \r\n\t]+'), regexpWhiteSpaceEnd = new RegExp('[ \r\n\t]+$'), - regexpWhiteSpaceNonPrintable = new RegExp('[\r\n\t]', 'g'), regexpWhiteSpaceBeforeTag = new RegExp('[ \r\n\t]+(?=<)', 'g'), regexpWhiteSpaceAfterTag = new RegExp('>[ \r\n\t]+', 'g'), - regexpWhiteSpace = new RegExp('[ \\r\\n\\t]+'), regexpWhiteSpaceTrim = new RegExp('^[ \\t\\r\\n]*(.*[^ \\t\\r\\n])[ \\t\\r\\n]*$', 'm'), regexpAmp = new RegExp('&', 'g'), regexpLt = new RegExp('<', 'g'), - regexpGt = new RegExp('>', 'g'); + regexpGt = new RegExp('>', 'g'), + regexpCR = new RegExp('\\r', 'g'), + regexpLF = new RegExp('\\n', 'g'), + regexpTab = new RegExp('\\t', 'g'); // convert a string into its definition (javascript literal) var stringToDef = function (str) { - return str.replace(regexpBackslash, '\\\\').replace(regexpQuote, '\\"').replace(regexpWhiteSpaceNonPrintable, ' '); + return str.replace(regexpBackslash, '\\\\').replace(regexpQuote, '\\"').replace(regexpCR, '\\r').replace(regexpLF, '\\n').replace(regexpTab, '\\t'); }; // given a HTML source, remove whitespace among tags -- cgit v1.2.1 From 30f3e117840b2d7929822c7436ac47ab66a755e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 2 Oct 2015 17:02:26 +0200 Subject: Remove the deprecated codeq.chooseTranslation(). --- js/codeq/core.js | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'js') diff --git a/js/codeq/core.js b/js/codeq/core.js index b54095f..03c5539 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -357,23 +357,6 @@ codeq.fire('langchange', {'lang': newLang}); }, - 'chooseTranslation': function (translations, language) { - var tr, lang; - if ((typeof translations !== 'object') || (translations === null)) return {}; - tr = translations[language || codeq.lang]; - if ((typeof tr === 'object') && (tr !== null)) return tr; - // default fallback - tr = translations['en']; - if ((typeof tr === 'object') && (tr !== null)) return tr; - // fallback to whatever is available - for (lang in translations) { - tr = translations[lang]; - if ((typeof tr === 'object') && (tr !== null)) return tr; - } - // all options were exhausted, we have nothing - return {}; - }, - 'escapeHtml': function (s) { return ('' + s).replace(regexpAmp, '&').replace(regexpLt, '<').replace(regexpGt, '>'); }, @@ -541,10 +524,6 @@ } }; - // ================================================================================ - // The boot sequence - // ================================================================================ - var loadGuiTranslations = function () { var langs = codeq.availableLangs, loaders = [], @@ -588,6 +567,10 @@ }); }; + // ================================================================================ + // The boot sequence + // ================================================================================ + $(document).ready(function () { // set the language var navigatorLang = navigator.language || navigator.browserLanguage, // language reported by browser @@ -603,7 +586,7 @@ codeq.availableLangs.push(key); } - // the boot chain: must be a sequence of .then() terminated with a .fail().done() + // the boot chain of async handlers: must be a sequence of .then() terminated with a .fail().done() loadGuiTranslations() .then(codeq.comms.getResourceTree) .then(function (resourceTree) { -- cgit v1.2.1