Commit 131cb77c authored by Jérome Perrin's avatar Jérome Perrin

codemirror: cancel next AJAX request when before checking source code

I am not 100% sure this really change anything, codemirror have something with async: true that I have not checked
parent 85de1693
......@@ -451,30 +451,36 @@
is_maximized = true;\n
}\n
\n
var timer = 0;\n
function checkPythonSourceCode(text, updateLinting, options, cm) {\n
checker_parameters = {code: text};\n
<dtml-if bound_names>\n
checker_parameters[\'bound_names\'] = <dtml-var name="bound_names">;\n
checker_parameters[\'params\'] = $(\'input[name="params"]\').val();\n
</dtml-if>\n
$.post(\n
\'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n
{\'data\': JSON.stringify(checker_parameters)},\n
function(data){\n
var messages = data.annotations;\n
var found = [];\n
for(var i = 0; i < messages.length; i++) {\n
message = messages[i];\n
found.push({\n
from: CodeMirror.Pos(message.row, message.column - 1),\n
to: CodeMirror.Pos(message.row, message.column),\n
message: message.text,\n
severity: message.type\n
});\n
}\n
\n
updateLinting(cm, found);\n
});\n
if (timer) {\n
window.clearTimeout(timer);\n
timer = 0;\n
}\n
timer = window.setTimeout(function() {\n
$.post(\n
\'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n
{\'data\': JSON.stringify(checker_parameters)},\n
function(data){\n
var messages = data.annotations;\n
var found = [];\n
for(var i = 0; i < messages.length; i++) {\n
message = messages[i];\n
found.push({\n
from: CodeMirror.Pos(message.row, message.column - 1),\n
to: CodeMirror.Pos(message.row, message.column),\n
message: message.text,\n
severity: message.type\n
});\n
}\n
updateLinting(cm, found);\n
});\n
}, 500); // this timeout can depend on the source code len length\n
}\n
\n
var mode = "&dtml-mode;";\n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment