Index: experimental/webtry/res/js/webtry.js |
diff --git a/experimental/webtry/js/webtry.js b/experimental/webtry/res/js/webtry.js |
similarity index 92% |
rename from experimental/webtry/js/webtry.js |
rename to experimental/webtry/res/js/webtry.js |
index aafadf3b67bb4165ebb948558db2acdb953e99d1..7dfd756a9bb5f77545d5b2963ec7f0e447f8b4c8 100644 |
--- a/experimental/webtry/js/webtry.js |
+++ b/experimental/webtry/res/js/webtry.js |
@@ -128,6 +128,23 @@ |
var parser = new DOMParser(); |
var tryTemplate = document.getElementById('tryTemplate'); |
+ var editor = CodeMirror.fromTextArea(code, { |
+ theme: "ambiance", |
+ lineNumbers: true, |
+ matchBrackets: true, |
+ mode: "text/x-c++src", |
+ indentUnit: 4, |
+ }); |
+ |
+ // Match the initial textarea size. |
+ editor.setSize(editor.defaultCharWidth() * code.cols, |
+ editor.defaultTextHeight() * code.rows); |
+ |
+ // Suppress changes to the first/last line (draw wrapper method) |
+ editor.on('beforeChange', function(cm, change) { |
+ if (change.from.line < 1 || change.from.line == cm.lineCount() - 1) |
+ change.cancel(); |
+ }); |
function beginWait() { |
document.body.classList.add('waiting'); |
@@ -258,7 +275,7 @@ |
req.overrideMimeType('application/json'); |
req.open('POST', '/', true); |
req.setRequestHeader('content-type', 'application/json'); |
- req.send(JSON.stringify({'code': code.value, 'name': workspaceName})); |
+ req.send(JSON.stringify({'code': editor.getValue(), 'name': workspaceName})); |
} |
run.addEventListener('click', onSubmitCode); |