summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/core.js36
1 files changed, 10 insertions, 26 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js
index f1bd697..03c5539 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
@@ -356,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, '&amp;').replace(regexpLt, '&lt;').replace(regexpGt, '&gt;');
},
@@ -540,10 +524,6 @@
}
};
- // ================================================================================
- // The boot sequence
- // ================================================================================
-
var loadGuiTranslations = function () {
var langs = codeq.availableLangs,
loaders = [],
@@ -587,6 +567,10 @@
});
};
+ // ================================================================================
+ // The boot sequence
+ // ================================================================================
+
$(document).ready(function () {
// set the language
var navigatorLang = navigator.language || navigator.browserLanguage, // language reported by browser
@@ -602,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) {