X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/3d2834dab9979fc59b50d09d5bad69b547915be2..07eb5e1ab5d3c9174fe01ef66acecc92227f4768:/forum/skins/default/media/js/osqa.main.js?ds=sidebyside diff --git a/forum/skins/default/media/js/osqa.main.js b/forum/skins/default/media/js/osqa.main.js index 7d6294f..8fb4d63 100644 --- a/forum/skins/default/media/js/osqa.main.js +++ b/forum/skins/default/media/js/osqa.main.js @@ -19,10 +19,12 @@ $('html').ajaxSend(function(event, xhr, settings) { } return cookieValue; } - if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { - // Only send the token to relative URLs i.e. locally. - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); - } + try { + if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { + // Only send the token to relative URLs i.e. locally. + xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); + } + } catch (e) {} }); var response_commands = { @@ -329,7 +331,8 @@ function process_ajax_response(data, evt, callback) { if (!data.success && data['error_message'] != undefined) { show_message(evt, data.error_message, function() {if (callback) callback(true);}); end_command(false); - } else if (typeof data['commands'] != undefined){ + } + if (typeof data['commands'] != undefined){ for (var command in data.commands) { response_commands[command].apply(null, data.commands[command]) @@ -375,7 +378,7 @@ function canned_comment(post_id, comment) { // Get the text from the caret to the end textarea_end = textarea.val().substr(comment_box_cursor_position, textarea.val().length) - textarea.val(textarea_start + comment + textarea_endsvn ); + textarea.val(textarea_start + comment + textarea_end); } $(function() { @@ -594,7 +597,7 @@ $(function() { } start_command(); - $.post($form.attr('action'), $form.serialize(), function(data) { + $.post($form.attr('action'), post_data, function(data) { process_ajax_response(data, evt, function(error) { if (!error) { cleanup_form(); @@ -607,6 +610,14 @@ $(function() { return false; }); + // Submit comment with CTRL + Enter + $textarea.keydown(function(e) { + if (e.ctrlKey && e.keyCode == 13 && !$button.attr('disabled')) { + // console.log('submit'); + $(this).parent().find('input.comment-submit').click(); + } + }); + $cancel.click(function(event) { if (confirm("You will lose all of your changes in this comment. Do you still wish to proceed?")){ if (comment_in_form) {