diff options
author | Aleš Smodiš <aless@guru.si> | 2015-09-30 17:37:31 +0200 |
---|---|---|
committer | Aleš Smodiš <aless@guru.si> | 2015-09-30 17:37:31 +0200 |
commit | 0da1117cfc28688633be7b8382aa60435bf740eb (patch) | |
tree | b464b92e673419db595c231ed1ba8e7c6cfd783b /js/codeq/comms.js | |
parent | 8995341d43efe16f307b55f200821944cfecf4c8 (diff) |
Implemented GUI translations via the data-tkey tag attribute and res/*.json files.
Diffstat (limited to 'js/codeq/comms.js')
-rw-r--r-- | js/codeq/comms.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/js/codeq/comms.js b/js/codeq/comms.js index ecca6ff..f416e88 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -165,7 +165,6 @@ // ================================================================================ var languageCache = {}, // language defs, keyed by language identifier - problemCache = {}, // problem cache, 3-level, keyed by: language, problem group, and problem identifier ajaxGet = function (url) { return Q.Promise(function (resolve, reject, notify) { $.ajax({ @@ -197,7 +196,7 @@ }); }); }, - ajaxPrefix; + ajaxPrefix, ajaxDataPrefix, ajaxResPrefix; ajaxPrefix = location.pathname; if (!ajaxPrefix) ajaxPrefix = '/'; @@ -206,7 +205,8 @@ ajaxPrefix[ajaxPrefix.length - 1] = ''; ajaxPrefix = ajaxPrefix.join('/'); } - ajaxPrefix = ajaxPrefix + 'data/'; + ajaxDataPrefix = ajaxPrefix + 'data/'; + ajaxResPrefix = ajaxPrefix + 'res/'; // ================================================================================ // This module's API methods @@ -399,7 +399,7 @@ return Q(x); } } - x = ajaxGet(ajaxPrefix + identifier + '/language.json').then( + x = ajaxGet(ajaxDataPrefix + identifier + '/language.json').then( function getLanguageDefSuccess(data) { languageCache[identifier] = data; return data; // proxy further @@ -414,7 +414,11 @@ }, 'getProblemDef': function (language, group, problem) { - return ajaxGet(ajaxPrefix + language + '/' + group + '/' + problem + '/problem.json'); + return ajaxGet(ajaxDataPrefix + language + '/' + group + '/' + problem + '/problem.json'); + }, + + 'getGuiTranslation': function (lang) { + return ajaxGet(ajaxResPrefix + lang + '.json'); } }; })(); |