comparison static/jquery.log.js @ 0:2d9ee2b3ae82

Initial commit of iWWS.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 15 Aug 2011 17:44:56 +0930
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2d9ee2b3ae82
1 /**
2 * Copyright (C) 2009 Jonathan Azoff <jon@azoffdesign.com>
3 *
4 * This script is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 *
15 * jQuery.log v1.0.0 - A jQuery plugin that unifies native console logging across browsers
16 *
17 * @usage call jQuery.log([args...]) to write to attempt to write to the console of any browser.
18 * **See http: *azoffdesign.com/plugins/js/log for an example.
19 * @param args... one or more javascript objects to be written to the console
20 * @returns true if a console was detected and successfully used, false if the plug-in had to resort to alert boxes
21 * @note if a plug-in cannot be located then an alert is called with the arguments you wish to log. Multiple
22 * arguments are separated with a space.
23 * @depends just make sure you have jQuery and some code you want to debug.
24 */
25 (function($){
26 $.extend({"log":function(){
27 if(arguments.length > 0) {
28
29 // join for graceful degregation
30 var args = (arguments.length > 1) ? Array.prototype.join.call(arguments, " ") : arguments[0];
31
32 // this is the standard; firebug and newer webkit browsers support this
33 try {
34 console.log(args);
35 return true;
36 } catch(e) {
37 // newer opera browsers support posting erros to their consoles
38 try {
39 opera.postError(args);
40 return true;
41 } catch(e) { }
42 }
43
44 // catch all; a good old alert box
45 //alert(args);
46 return false;
47 }
48 }});
49 })(jQuery);