From a89511985f7fa430b2755565b855734a5fae51f6 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 22 Jun 2016 22:54:42 +0200 Subject: [PATCH] add _really_ basic multilanguage support. I'll come back for css later --- www/code/main.js | 17 ++++++++++++++++- www/code/modes.js | 13 +++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 www/code/modes.js diff --git a/www/code/main.js b/www/code/main.js index 064a1ab63..b84417b4b 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -9,10 +9,11 @@ define([ 'json.sortify', '/bower_components/chainpad-json-validator/json-ot.js', '/common/cryptpad-common.js', + '/code/modes.js', '/bower_components/file-saver/FileSaver.min.js', '/bower_components/jquery/dist/jquery.min.js', '/customize/pad.js' -], function (Config, /*RTCode,*/ Messages, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad) { +], function (Config, /*RTCode,*/ Messages, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Modes) { var $ = window.jQuery; var saveAs = window.saveAs; var module = window.APP = {}; @@ -160,6 +161,20 @@ define([ config.onLocal(); })); + var dropdown = ''; + + + $bar.find('.rtwysiwyg-toolbar-rightside').append(dropdown); + + $bar.find('#language-mode').on('change', function () { + console.log($(this).val()); + setMode($(this).val()); + }); + window.location.hash = info.channel + secret.key; Cryptpad.rememberPad(); }; diff --git a/www/code/modes.js b/www/code/modes.js new file mode 100644 index 000000000..5154c3331 --- /dev/null +++ b/www/code/modes.js @@ -0,0 +1,13 @@ +define(function () { + return [ + "Javascript javascript", + "Python python", + "Mixed_HTML htmlmixed", + ].map(function (line) { + var kv = line.split(/\s/); + return { + language: kv[0].replace(/_/g, ' '), + mode: kv[1] + }; + }); +});