add missing js file
This commit is contained in:
parent
825a0111b4
commit
6cfc417937
|
@ -0,0 +1,25 @@
|
||||||
|
var csrftoken = $.cookie('csrftoken');
|
||||||
|
|
||||||
|
function csrfSafeMethod(method) {
|
||||||
|
// these HTTP methods do not require CSRF protection
|
||||||
|
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
||||||
|
}
|
||||||
|
$.ajaxSetup({
|
||||||
|
beforeSend: function(xhr, settings) {
|
||||||
|
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
||||||
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a[href="#preview"]').on("show.bs.tab", function (e) {
|
||||||
|
$('#markdown-preview').html('Loading preview...');
|
||||||
|
var markdown = $('#markdown-content').val();
|
||||||
|
$.post(markdown_preview_url, {'data': markdown})
|
||||||
|
.done(function(data, textStatus) {
|
||||||
|
$('#markdown-preview').html(data);
|
||||||
|
})
|
||||||
|
.fail(function () {
|
||||||
|
$('#markdown-preview').html('Sorry, an error occured.');
|
||||||
|
});
|
||||||
|
})
|
Loading…
Reference in New Issue