Changed how the comment was encoded/read.

Fixed CSRF + Post with comment preview.
Merged with latest master
This commit is contained in:
Emily O'Leary
2013-08-06 18:22:51 -04:00
committed by Rodney Ewing
parent 3cf4ae0c41
commit 3bd62dc4ca
3 changed files with 15 additions and 18 deletions

View File

@@ -18,21 +18,22 @@
var content="";
function previewComment(){
if ($('#comment_content').val() && (content != $('#comment_content').val())) {
content = $('#comment_content').val();
$.getJSON($('#previewURL').val(),JSON.stringify($('#comment_content').val()),
function(data){
$('#comment_preview').replaceWith("<div id=comment_preview><h3>{% trans -%}Comment Preview{%- endtrans %}</h3><br />" + decodeURIComponent(data) +
"<hr style='border: 1px solid #333;' /></div>");
});
}
if ($('#comment_content').val() && (content != $('#comment_content').val())) {
content = $('#comment_content').val();
$.post($('#previewURL').val(),$('#form_comment').serialize(),
function(data){
preview = JSON.parse(data)
$('#comment_preview').replaceWith("<div id=comment_preview><h3>" + $('#previewText').val() +"</h3><br />" + preview.content +
"<hr style='border: 1px solid #333;' /></div>");
});
}
}
$(document).ready(function(){
$('#form_comment').hide();
$('#button_addcomment').click(function(){
$(this).fadeOut('fast');
$('#form_comment').slideDown(function(){
setInterval("previewComment()",500);
setInterval("previewComment()",500);
$('#comment_content').focus();
});
});