From 41412acda7dbc4f13a892455e3f287427639dffb Mon Sep 17 00:00:00 2001 From: Robert Zorko Date: Tue, 29 Sep 2015 18:13:13 +0200 Subject: added the basic cahnge language handler and the support to send an 'settings' action --- js/codeq/comms.js | 4 ++++ js/codeq/settings.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 js/codeq/settings.js (limited to 'js') diff --git a/js/codeq/comms.js b/js/codeq/comms.js index 5ac3d66..ecca6ff 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -301,6 +301,10 @@ return this.connect().then(performLogin); }, + 'updateSettings': function (new_settings){ + return this.send({'action': 'settings', 'sid': sid, 'settings': new_settings}); + }, + sendActivity: function commsSendActivity (trace, solution, problem_id) { return this.send({'action': 'activity', 'trace': trace, 'solution': solution, 'problem_id': problem_id}); }, diff --git a/js/codeq/settings.js b/js/codeq/settings.js new file mode 100644 index 0000000..73bef14 --- /dev/null +++ b/js/codeq/settings.js @@ -0,0 +1,18 @@ +/** + * Created by robert on 9/29/15. + */ +(function(){ + $("#gui_lang_select").on("change",function() { + var lang = $("#gui_lang_select").val(); + if (lang in codeq.supportedLangs) { + codeq.log.debug("Changing lang to:" + lang); + codeq.comms.updateSettings({'lang': lang}) + .then(function (data) { + if (data.code !== 0) throw new Error('Change language failed, code: ' + data.code + ', message: ' + data.message); + codeq.log.debug("success with settings"); + codeq.setLang(lang); + }) + .done(); + } + }) +})(); \ No newline at end of file -- cgit v1.2.1