ENHANCEMENT Improved ajax error display within the CMS: Using Firebug (or Firebug Lite) for plaintext output instead of cramming everything into the CMS-status field

FEATURE Including Firebug Lite when requested by ?debug_firebug=1 for easy debugging in IE/Opera/Safari- otherwise including fake-objects with FirebugX by default to enable usage of console.* commands without javascript errors

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@62477 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-09-16 21:46:08 +00:00
parent a4dc629837
commit 9e2de7ba7e
2 changed files with 19 additions and 6 deletions

View File

@ -109,13 +109,24 @@ class LeftAndMain extends Controller {
Requirements::css('cms/css/cms_left.css'); Requirements::css('cms/css/cms_left.css');
Requirements::css('cms/css/cms_right.css'); Requirements::css('cms/css/cms_right.css');
if(isset($_REQUEST['debug_firebug'])) {
// Firebug is a useful console for debugging javascript
// Its available as a Firefox extension or a javascript library
// for easy inclusion in other browsers (just append ?debug_firebug=1 to the URL)
Requirements::javascript('jsparty/firebug/firebug-lite-compressed.js');
} else {
// By default, we include fake-objects for all firebug calls
// to avoid javascript errors when referencing console.log() etc in javascript code
Requirements::javascript('jsparty/firebug/firebugx.js');
}
Requirements::javascript('jsparty/prototype.js'); Requirements::javascript('jsparty/prototype.js');
Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript('jsparty/behaviour.js');
Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript('jsparty/prototype_improvements.js');
Requirements::javascript('jsparty/loader.js'); Requirements::javascript('jsparty/loader.js');
Requirements::javascript('jsparty/hover.js'); Requirements::javascript('jsparty/hover.js');
Requirements::javascript('jsparty/layout_helpers.js'); Requirements::javascript('jsparty/layout_helpers.js');
Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js'); Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
Requirements::javascript('cms/javascript/ImageEditor/Activator.js'); Requirements::javascript('cms/javascript/ImageEditor/Activator.js');
Requirements::javascript('jsparty/tiny_mce_improvements.js'); Requirements::javascript('jsparty/tiny_mce_improvements.js');

View File

@ -483,22 +483,24 @@ function clearStatusMessage() {
* Called when something goes wrong * Called when something goes wrong
*/ */
function errorMessage(msg, fullMessage) { function errorMessage(msg, fullMessage) {
// More complex error for developers // Show complex error for developers in the console
if(fullMessage && window.location.href.indexOf('//dev') != -1) { if(fullMessage) {
// Get the message from an Ajax response object // Get the message from an Ajax response object
try { try {
if(typeof fullMessage == 'object') fullMessage = fullMessage.status + '//' + fullMessage.responseText; if(typeof fullMessage == 'object') fullMessage = fullMessage.status + '//' + fullMessage.responseText;
} catch(er) { } catch(er) {
fullMessage = ""; fullMessage = "";
} }
msg = msg + '<br>' + fullMessage.replace(/\n/g,'<br>'); console.log(fullMessage);
} }
msg = msg.replace(/\n/g,'<br>');
$('statusMessage').showMessage(msg,'bad',60); $('statusMessage').showMessage(msg,'bad');
} }
function ajaxErrorHandler(response) { function ajaxErrorHandler(response) {
errorMessage('Error talking to server', response); errorMessage('Server Error', response);
} }
/** /**