1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 01:10:51 +01:00

various improvements

This commit is contained in:
Michael Foster 2013-09-15 14:11:09 +10:00
parent 00833eeafd
commit 31e64f096e

View File

@ -42,10 +42,12 @@ $(window).ready(function() {
$(form).find('input[type="submit"]').val(submit_txt); $(form).find('input[type="submit"]').val(submit_txt);
$(form).find('input[type="submit"]').removeAttr('disabled'); $(form).find('input[type="submit"]').removeAttr('disabled');
} else if (post_response.redirect && post_response.id) { } else if (post_response.redirect && post_response.id) {
if ($(form).find('input[name="thread"]')) {
document.location = post_response.redirect;
} else {
$.ajax({ $.ajax({
url: post_response.redirect, url: post_response.redirect,
success: function(data) { success: function(data) {
console.log(data);
$(data).find('div.post.reply').each(function() { $(data).find('div.post.reply').each(function() {
var id = $(this).attr('id'); var id = $(this).attr('id');
if($('#' + id).length == 0) { if($('#' + id).length == 0) {
@ -58,9 +60,13 @@ $(window).ready(function() {
$(form).find('input[type="submit"]').val(submit_txt); $(form).find('input[type="submit"]').val(submit_txt);
$(form).find('input[type="submit"]').removeAttr('disabled'); $(form).find('input[type="submit"]').removeAttr('disabled');
} $(form).find('input[name="subject"],textarea[name="body"],input[type="file"]').val('');
},
cache: false,
contentType: false,
processData: false
}, 'html'); }, 'html');
}
$(form).find('input[type="submit"]').val('Posted...'); $(form).find('input[type="submit"]').val('Posted...');
} else { } else {
alert(_('An unknown error occured when posting!')); alert(_('An unknown error occured when posting!'));
@ -71,14 +77,14 @@ $(window).ready(function() {
error: function(xhr, status, er) { error: function(xhr, status, er) {
// An error occured // An error occured
// TODO // TODO
console.log('Error'); alert('Something went wrong!');
}, },
// Form data // Form data
data: formData, data: formData,
cache: false, cache: false,
contentType: false, contentType: false,
processData: false processData: false
}, 'html'); }, 'json');
$(form).find('input[type="submit"]').val(_('Posting...')); $(form).find('input[type="submit"]').val(_('Posting...'));
$(form).find('input[type="submit"]').attr('disabled', true); $(form).find('input[type="submit"]').attr('disabled', true);