mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
More JS-like, callback as last argument
This commit is contained in:
parent
42f5773f51
commit
ced90c23db
@ -14,14 +14,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Custom markdown parser
|
// Custom markdown parser
|
||||||
function customMarkdownParser(plainText, preview) {
|
function customMarkdownParser(plainText, cb) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ markdown_api_url }}",
|
url: "{{ markdown_api_url }}",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: { text: plainText, csrfmiddlewaretoken: getCSRFToken() },
|
data: { text: plainText, csrfmiddlewaretoken: getCSRFToken() },
|
||||||
}).done(function (msg) {
|
}).done(cb);
|
||||||
preview.innerHTML = msg;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pretty markdown input
|
// Pretty markdown input
|
||||||
@ -31,9 +29,9 @@
|
|||||||
autoDownloadFontAwesome: false,
|
autoDownloadFontAwesome: false,
|
||||||
previewRender: function(plainText, preview){ // Async method
|
previewRender: function(plainText, preview){ // Async method
|
||||||
clearTimeout(lastAPICall);
|
clearTimeout(lastAPICall);
|
||||||
lastAPICall = setTimeout(function (plainText, preview){
|
lastAPICall = setTimeout(() => {
|
||||||
customMarkdownParser(plainText, preview);
|
customMarkdownParser(plainText, (msg) => preview.innerHTML = msg);
|
||||||
}, 300, plainText, preview);
|
}, 300);
|
||||||
return preview.innerHTML;
|
return preview.innerHTML;
|
||||||
},
|
},
|
||||||
forceSync: true, // Avoid validation error on generic create view
|
forceSync: true, // Avoid validation error on generic create view
|
||||||
|
Loading…
Reference in New Issue
Block a user