summaryrefslogtreecommitdiff
path: root/js/codeq/core.js
diff options
context:
space:
mode:
authorMarko Pušnik <marko.pusnik@guru.si>2015-10-05 15:57:43 +0200
committerMarko Pušnik <marko.pusnik@guru.si>2015-10-05 15:57:43 +0200
commit16e584cc8dc057290e14f829b507fbbef3cdf60f (patch)
tree2f6c0aa706f7d38425f69dd50f491b4492ba1a01 /js/codeq/core.js
parent28e59b13a7c348570ee15663dc5153c5c8012794 (diff)
handle phonegap native mobile app
Diffstat (limited to 'js/codeq/core.js')
-rw-r--r--js/codeq/core.js84
1 files changed, 1 insertions, 83 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js
index 2d88f18..02bc2f0 100644
--- a/js/codeq/core.js
+++ b/js/codeq/core.js
@@ -393,6 +393,7 @@
'en': 'English',
'sl': 'Slovenščina'
},
+ 'isWebApp': false, // this is a PhoneGap/Cordova build, will be overridden in cordova.js for webapp
'getLang': function () {
return lang;
},
@@ -570,87 +571,4 @@
}
}
};
-
- var loadGuiTranslations = function () {
- var langs = codeq.availableLangs,
- loaders = [],
- loaderLangs = [],
- i, lang;
- for (i = langs.length - 1; i >= 0; i--) {
- lang = langs[i];
- loaders.push(codeq.comms.getGuiTranslation(lang));
- loaderLangs.push(lang);
- }
- return Q.all(loaders)
- .then(function (results) {
- // convert translations into something that the translation module can use
- var dictionary = {},
- i, json, key, lang, translations;
- for (i = results.length - 1; i >= 0; i--) {
- json = results[i];
- lang = loaderLangs[i];
- for (key in json) {
- if (!json.hasOwnProperty(key)) continue;
- translations = dictionary[key];
- if (translations) translations[lang] = json[key];
- else {
- translations = {};
- dictionary[key] = translations;
- translations[lang] = json[key];
- }
- }
- }
- // ensure each key contains all translations
- for (key in dictionary) {
- if (!dictionary.hasOwnProperty(key)) continue;
- translations = dictionary[key];
- for (i = langs.length - 1; i >= 0; i--) {
- lang = langs[i];
- if (!(lang in translations)) translations[lang] = "(Untranslated: " + lang + ")";
- }
- }
- // register with the system
- codeq.tr.registerDictionary('gui', dictionary);
- });
- };
-
- // ================================================================================
- // The boot sequence
- // ================================================================================
-
- $(document).ready(function () {
- // set the language
- var navigatorLang = navigator.language || navigator.browserLanguage, // language reported by browser
- lang = null, // the translation language that will be chosen
- key;
- if (typeof navigatorLang === 'string') {
- navigatorLang = navigatorLang.split('-')[0]; // truncate the language variant, in eg. en-US
- }
- else navigatorLang = 'en';
- for (key in codeq.supportedLangs) {
- if (!codeq.supportedLangs.hasOwnProperty(key)) continue;
- if (key === navigatorLang) lang = key; // we support the browser's language
- codeq.availableLangs.push(key);
- }
-
- // 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) {
- resources = resourceTree; // save the loaded resource tree to the internal variable
-
- codeq.fire('init'); // tell any interested modules that we are now initialized, perhaps they want to initialize too
- codeq.setLang(lang || 'en'); // initial language setting, this also translates the GUI
- // go to login
- codeq.globalStateMachine.transition('login');
-
- //For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
- $('[data-toggle="popover"]').popover()
- })
- .fail(function (e) {
- codeq.log.error('CodeQ failed to start: ' + e, e);
- alert('CodeQ failed to start: ' + e);
- })
- .done();
- });
})();