Skip to content

Commit 31941c9

Browse files
authored
Update cm-validator-remote.js
1 parent a46151c commit 31941c9

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

static/js/cm-validator-remote.js

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,55 @@
1-
CodeMirror.remoteValidator=function(cm,updateLinting,options){var text=cm.getValue();if(text.trim()=="") {updateLinting(cm,[]);return;} function result_cb(error_list) {var found=[];for(var i in error_list) {var error=error_list[i];var start_line=error.line_no;var start_char;if(typeof(error.column_no_start)!="undefined") start_char=error.column_no_start;else start_char=error.column_no;var end_char;if(typeof(error.column_no_stop)!="undefined") end_char=error.column_no_stop;else end_char=error.column_no;var end_line=error.line_no;var message=error.message;var severity;if(typeof(error.severity)!="undefined") severity=error.severity;else severity='error';found.push({from:CodeMirror.Pos(start_line-1,start_char),to:CodeMirror.Pos(end_line-1,end_char),message:message,severity:severity});} updateLinting(cm,found);} options.check_cb(text,result_cb);};
1+
CodeMirror.remoteValidator = function(cm, updateLinting, options) {
2+
//Current value of text
3+
var text = cm.getValue();
4+
5+
6+
if(text.trim() == "")
7+
{
8+
updateLinting(cm, []);
9+
return;
10+
}
11+
12+
function result_cb(error_list)
13+
{
14+
var found = [];
15+
16+
for(var i in error_list)
17+
{
18+
var error = error_list[i];
19+
20+
var start_line = error.line_no;
21+
22+
var start_char;
23+
if(typeof(error.column_no_start) != "undefined")
24+
start_char = error.column_no_start;
25+
else
26+
start_char = error.column_no;
27+
28+
var end_char;
29+
if(typeof(error.column_no_stop) != "undefined")
30+
end_char = error.column_no_stop;
31+
else
32+
end_char = error.column_no;
33+
34+
var end_line = error.line_no;
35+
var message = error.message;
36+
37+
var severity;
38+
if(typeof(error.severity) != "undefined")
39+
severity = error.severity;
40+
else
41+
severity = 'error';
42+
43+
found.push({
44+
from: CodeMirror.Pos(start_line - 1, start_char),
45+
to: CodeMirror.Pos(end_line - 1, end_char),
46+
message: message,
47+
severity: severity // "error", "warning"
48+
});
49+
}
50+
51+
updateLinting(cm, found);
52+
}
53+
54+
options.check_cb(text, result_cb);
55+
};

0 commit comments

Comments
 (0)