From 9e2de7ba7ed924107ceb8be9e88f59893f7320e8 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 16 Sep 2008 21:46:08 +0000 Subject: [PATCH] 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 --- code/LeftAndMain.php | 13 ++++++++++++- javascript/LeftAndMain.js | 12 +++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 86c188a2..79d1d530 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -109,13 +109,24 @@ class LeftAndMain extends Controller { Requirements::css('cms/css/cms_left.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/behaviour.js'); Requirements::javascript('jsparty/prototype_improvements.js'); Requirements::javascript('jsparty/loader.js'); Requirements::javascript('jsparty/hover.js'); Requirements::javascript('jsparty/layout_helpers.js'); - + Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js'); Requirements::javascript('cms/javascript/ImageEditor/Activator.js'); Requirements::javascript('jsparty/tiny_mce_improvements.js'); diff --git a/javascript/LeftAndMain.js b/javascript/LeftAndMain.js index e7c0fd2f..e9275b45 100644 --- a/javascript/LeftAndMain.js +++ b/javascript/LeftAndMain.js @@ -483,22 +483,24 @@ function clearStatusMessage() { * Called when something goes wrong */ function errorMessage(msg, fullMessage) { - // More complex error for developers - if(fullMessage && window.location.href.indexOf('//dev') != -1) { + // Show complex error for developers in the console + if(fullMessage) { // Get the message from an Ajax response object try { if(typeof fullMessage == 'object') fullMessage = fullMessage.status + '//' + fullMessage.responseText; } catch(er) { fullMessage = ""; } - msg = msg + '
' + fullMessage.replace(/\n/g,'
'); + console.log(fullMessage); } + + msg = msg.replace(/\n/g,'
'); - $('statusMessage').showMessage(msg,'bad',60); + $('statusMessage').showMessage(msg,'bad'); } function ajaxErrorHandler(response) { - errorMessage('Error talking to server', response); + errorMessage('Server Error', response); } /**