|
@@ -48,19 +48,49 @@
|
|
enableSnippets: false,
|
|
enableSnippets: false,
|
|
enableLiveAutocompletion: false,
|
|
enableLiveAutocompletion: false,
|
|
highlightActiveLine: false,
|
|
highlightActiveLine: false,
|
|
- fontSize: 12
|
|
|
|
|
|
+ fontSize: 12,
|
|
|
|
+ minLines: 10
|
|
});
|
|
});
|
|
- editor.renderer.setShowGutter(false);
|
|
|
|
|
|
+ editor.renderer.setShowGutter(true);
|
|
editor.renderer.setPrintMarginColumn(false);
|
|
editor.renderer.setPrintMarginColumn(false);
|
|
editor.renderer.setPadding(10);
|
|
editor.renderer.setPadding(10);
|
|
editor.getSession().setUseWrapMode(true);
|
|
editor.getSession().setUseWrapMode(true);
|
|
|
|
+ editor.commands.addCommand({
|
|
|
|
+ name: 'run',
|
|
|
|
+ bindKey: {win: 'Ctrl-Enter', mac: 'Command-Enter'},
|
|
|
|
+ exec: function(editor) {
|
|
|
|
+ $("#run").click();
|
|
|
|
+ },
|
|
|
|
+ readOnly: false // false if this command should not apply in readOnly mode
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ editor.resize();
|
|
$("#editor").show();
|
|
$("#editor").show();
|
|
|
|
+ editor.focus();
|
|
|
|
|
|
- $("#run").click( function (e) {
|
|
|
|
|
|
+ var error_line = null;
|
|
|
|
+
|
|
|
|
+ $("#run").click(function (e) {
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
|
+
|
|
|
|
+ if (error_line) {
|
|
|
|
+ editor.getSession().removeGutterDecoration(error_line - 1, "error");
|
|
|
|
+ error_line = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
$("#results").html('<p class="text-muted">Loading...</p>');
|
|
$("#results").html('<p class="text-muted">Loading...</p>');
|
|
$.post("<%= run_queries_path %>", {statement: editor.getValue()}, function (data) {
|
|
$.post("<%= run_queries_path %>", {statement: editor.getValue()}, function (data) {
|
|
$("#results").html(data);
|
|
$("#results").html(data);
|
|
|
|
+
|
|
|
|
+ error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());
|
|
|
|
+
|
|
|
|
+ if (error_line) {
|
|
|
|
+ error_line = parseInt(error_line[1], 10);
|
|
|
|
+ editor.getSession().addGutterDecoration(error_line - 1, "error");
|
|
|
|
+ editor.scrollToLine(error_line, true, true, function () {});
|
|
|
|
+ editor.gotoLine(error_line, 0, true);
|
|
|
|
+ editor.focus();
|
|
|
|
+ }
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|