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,12 +451,18 @@ ...@@ -451,12 +451,18 @@
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
if (timer) {\n
window.clearTimeout(timer);\n
timer = 0;\n
}\n
timer = window.setTimeout(function() {\n
$.post(\n $.post(\n
\'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n \'&dtml-portal_url;/ERP5Site_checkPythonSourceCodeAsJSON\',\n
{\'data\': JSON.stringify(checker_parameters)},\n {\'data\': JSON.stringify(checker_parameters)},\n
...@@ -472,9 +478,9 @@ ...@@ -472,9 +478,9 @@
severity: message.type\n severity: message.type\n
});\n });\n
}\n }\n
\n
updateLinting(cm, found);\n updateLinting(cm, found);\n
});\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