Guest User

Untitled

a guest
May 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. // Simple logger that will use firebug console log first if available, otherwise simply log to a div
  2. // Requires jquery
  3. // Usage L.log('log this text');
  4.  
  5. var L = {
  6.  
  7. logEnabled: true,
  8. log: function(obj)
  9. {
  10. if(L.logEnabled){
  11. try{
  12. console.log(obj);
  13. }catch(ex){
  14. var theConsole = $('#pp-log-console');
  15. var cnt = theConsole.data('cnt');
  16. if(theConsole.length == 0){
  17. theConsole = jQuery("<div/>").attr('id','pp-log-console').appendTo('body');
  18. theConsole.css({ position: 'absolute', left: '15px', top: '40px', border: '5px solid #999'});
  19.  
  20. topBar = jQuery("<div/>").appendTo(theConsole);
  21. topBar.css({ height: '25px', background: '#4466BB', width: '100%'});
  22. topBar.css({ position: 'absolute', left: '-5px', top: '-30px', zIndex: '20'});
  23. topBar.css({ border: '5px solid #999', borderBottom: '0px none'});
  24.  
  25. closeBut = jQuery("<a/>").text('close').prependTo(theConsole);
  26. closeBut.css({ position: 'absolute', right: '10px', top: '-20px', color: '#fff', cursor: 'pointer', zIndex: '200'});
  27. closeBut.click(function(e){
  28. $('#pp-log-console').remove();
  29. });
  30.  
  31. ul = jQuery("<ul/>").appendTo(theConsole);
  32. ul.css({ background: '#000', color: '#00ff00', fontFamily: 'lucida console,monospace' });
  33. ul.css({ height: '100%', width: '100%', overflow: 'auto' });
  34. cnt = 100;
  35. try{ theConsole.draggable({cancel: '#pp-log-console ul'}); }catch(ex){}
  36. try{ theConsole.resizable(); }catch(ex){}
  37. }
  38.  
  39. cnt++;
  40. theConsole.data('cnt', cnt);
  41. jQuery("<li/>").css({padding: '2px 10px'}).text(cnt + ' | ' + obj).prependTo(theConsole.find('ul'));
  42. }
  43. }
  44. }
  45. };
Add Comment
Please, Sign In to add comment