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 @@ ...@@ -451,30 +451,36 @@
is_maximized = true;\n is_maximized = true;\n
}\n }\n
\n \n
var timer = 0;\n
function checkPythonSourceCode(text, updateLinting, options, cm) {\n function checkPythonSourceCode(text, updateLinting, options, cm) {\n
checker_parameters = {code: text};\n checker_parameters = {code: text};\n
<dtml-if bound_names>\n <dtml-if bound_names>\n
checker_parameters[\'bound_names\'] = <dtml-var name="bound_names">;\n checker_parameters[\'bound_names\'] = <dtml-var name="bound_names">;\n
checker_parameters[\'params\'] = $(\'input[name="params"]\').val();\n checker_parameters[\'params\'] = $(\'input[name="params"]\').val();\n
</dtml-if>\n </dtml-if>\n
$.post(\n if (timer) {\n
\'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n window.clearTimeout(timer);\n
{\'data\': JSON.stringify(checker_parameters)},\n timer = 0;\n
function(data){\n }\n
var messages = data.annotations;\n timer = window.setTimeout(function() {\n
var found = [];\n $.post(\n
for(var i = 0; i < messages.length; i++) {\n \'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n
message = messages[i];\n {\'data\': JSON.stringify(checker_parameters)},\n
found.push({\n function(data){\n
from: CodeMirror.Pos(message.row, message.column - 1),\n var messages = data.annotations;\n
to: CodeMirror.Pos(message.row, message.column),\n var found = [];\n
message: message.text,\n for(var i = 0; i < messages.length; i++) {\n
severity: message.type\n message = messages[i];\n
});\n found.push({\n
}\n from: CodeMirror.Pos(message.row, message.column - 1),\n
\n to: CodeMirror.Pos(message.row, message.column),\n
updateLinting(cm, found);\n message: message.text,\n
});\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
\n \n
var mode = "&dtml-mode;";\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