/
sql-lint.js
38 lines (33 loc) · 974 Bytes
/
sql-lint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
CodeMirror.sqlLint = function(text, updateLinting, options, cm) {
// Skipping check if text box is empty.
if(text.trim() == "") {
updateLinting(cm, []);
return;
}
function handleResponse(json) {
response = JSON.parse(json);
var found = [];
for (var idx in response) {
found.push({
from: CodeMirror.Pos(
response[idx].fromLine, response[idx].fromColumn
),
to: CodeMirror.Pos(
response[idx].toLine, response[idx].toColumn
),
message: response[idx].message,
severity : response[idx].severity
});
}
updateLinting(cm, found);
}
$.ajax({
method: "POST",
url: "lint.php",
data: {
sql_query: text,
token: PMA_commonParams.get('token'),
},
success: handleResponse
});
}