From 3889edd8242f2949d3bf4c29ff37f130b8255b64 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 13 Mar 2014 10:32:44 -0400 Subject: [PATCH] Move xhr_error_message() into channel.js (imported from commit c68c2d475b5673a3dd5f68c75624dfcfe56728ca) --- static/js/channel.js | 9 +++++++++ static/js/compose.js | 2 +- static/js/message_edit.js | 2 +- static/js/util.js | 9 --------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/static/js/channel.js b/static/js/channel.js index 21e64f314d..233e4f33e2 100644 --- a/static/js/channel.js +++ b/static/js/channel.js @@ -110,6 +110,15 @@ exports.patch = function (options) { return exports.post(options, options.idempotent); }; +exports.xhr_error_message = function (message, xhr) { + if (xhr.status.toString().charAt(0) === "4") { + // Only display the error response for 4XX, where we've crafted + // a nice response. + message += ": " + $.parseJSON(xhr.responseText).msg; + } + return message; +}; + return exports; }()); diff --git a/static/js/compose.js b/static/js/compose.js index 79fbd1a31e..c437233b2f 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -373,7 +373,7 @@ function send_message_ajax(request, success, error) { return; } - var response = util.xhr_error_message("Error sending message", xhr); + var response = channel.xhr_error_message("Error sending message", xhr); error(response); } }); diff --git a/static/js/message_edit.js b/static/js/message_edit.js index 316fd14017..4c38ce921f 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -62,7 +62,7 @@ exports.save = function (row) { } }, error: function (xhr, error_type, xhn) { - var message = util.xhr_error_message("Error saving edit", xhr); + var message = channel.xhr_error_message("Error saving edit", xhr); row.find(".edit_error").text(message).show(); } }); diff --git a/static/js/util.js b/static/js/util.js index 79c8cc8629..a80b6d3e10 100644 --- a/static/js/util.js +++ b/static/js/util.js @@ -204,15 +204,6 @@ exports.array_compare = function util_array_compare(a, b) { return true; }; -exports.xhr_error_message = function (message, xhr) { - if (xhr.status.toString().charAt(0) === "4") { - // Only display the error response for 4XX, where we've crafted - // a nice response. - message += ": " + $.parseJSON(xhr.responseText).msg; - } - return message; -}; - /* Represents a value that is expensive to compute and should be * computed on demand and then cached. The value can be forcefully * recalculated on the next call to get() by calling reset().