From 13f85f956afdc4265383dcad04657fc6ce58cb79 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Thu, 17 Mar 2011 10:13:25 +0100 Subject: [PATCH] build error flash with different classes. in case the server reported a client error, show the supplied error message --- assets/javascripts/reporting.js | 7 ++++++- assets/javascripts/reporting/controls.js | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/reporting.js b/assets/javascripts/reporting.js index 515a912655..3484637d55 100644 --- a/assets/javascripts/reporting.js +++ b/assets/javascripts/reporting.js @@ -26,7 +26,12 @@ window.Reporting = { if (type === undefined) { type = "error"; } - $("content").insert({before: "
" + string + "
"}); + var flash = document.createElement('div'); + flash.setAttribute('id', 'flash_' + type); + flash.setAttribute('onclick', '$(this).remove();'); + flash.className = 'flash ' + type; + flash.innerHTML = string; + $("content").insert({before: flash}); }, fireEvent: function (element, event) { diff --git a/assets/javascripts/reporting/controls.js b/assets/javascripts/reporting/controls.js index 0eaf818e76..c3db22f27a 100644 --- a/assets/javascripts/reporting/controls.js +++ b/assets/javascripts/reporting/controls.js @@ -64,8 +64,12 @@ Reporting.Controls = { send_settings_data: function (targetUrl, callback, failureCallback) { if (failureCallback === undefined) { - failureCallback = function () { - Reporting.flash("There was an error getting the results. The administrator has been informed."); + failureCallback = function (response) { + if ((response.status + "")[0] === "4") { + Reporting.flash(response.responseText); + } else { + Reporting.flash("There was an error getting the results. The administrator has been informed."); + } }; } $$('div[id^=flash]').each(function (oldMsg) {