build error flash with different classes. in case the server reported a client error, show the supplied error message

pull/6827/head
Tim Felgentreff 14 years ago
parent 8e972b5d8b
commit 13f85f956a
  1. 7
      assets/javascripts/reporting.js
  2. 8
      assets/javascripts/reporting/controls.js

@ -26,7 +26,12 @@ window.Reporting = {
if (type === undefined) { if (type === undefined) {
type = "error"; type = "error";
} }
$("content").insert({before: "<div onclick='$(this).remove();' id='flash_" + type + "'>" + string + "</div>"}); 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) { fireEvent: function (element, event) {

@ -64,8 +64,12 @@ Reporting.Controls = {
send_settings_data: function (targetUrl, callback, failureCallback) { send_settings_data: function (targetUrl, callback, failureCallback) {
if (failureCallback === undefined) { if (failureCallback === undefined) {
failureCallback = function () { failureCallback = function (response) {
Reporting.flash("There was an error getting the results. The administrator has been informed."); 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) { $$('div[id^=flash]').each(function (oldMsg) {

Loading…
Cancel
Save