Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: experimental/webtry/res/js/webtry.js

Issue 261693003: Use CodeMirror for WebTry snippets. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rebased. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: experimental/webtry/res/js/webtry.js
diff --git a/experimental/webtry/js/webtry.js b/experimental/webtry/res/js/webtry.js
similarity index 94%
rename from experimental/webtry/js/webtry.js
rename to experimental/webtry/res/js/webtry.js
index aafadf3b67bb4165ebb948558db2acdb953e99d1..6a1a68b905ada624f7496de7471a007f00466b6c 100644
--- a/experimental/webtry/js/webtry.js
+++ b/experimental/webtry/res/js/webtry.js
@@ -128,6 +128,19 @@
var parser = new DOMParser();
var tryTemplate = document.getElementById('tryTemplate');
+ var editor = CodeMirror.fromTextArea(code, {
jcgregorio 2014/05/01 13:27:30 Can we fix the editor so that it defaults to 100 c
f(malita) 2014/05/01 14:24:40 Done.
+ theme: "ambiance",
+ lineNumbers: true,
+ matchBrackets: true,
+ mode: "text/x-c++src",
+ indentUnit: 4,
+ });
+
+ // 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 +271,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);

Powered by Google App Engine
This is Rietveld 408576698