Advertisement
Guest User

Untitled

a guest
May 29th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. (function() {
  2.  
  3. /**
  4. * Ad Debugger
  5. * Useful tools for debugging ad issues
  6. *
  7. * To use:
  8. * add '?ad_debug=true' to the end of the URL
  9. * or call 'ad_debug()' from the console
  10. *
  11. * For developers, you can log things by doing
  12. * >> FTBAds.log.push('something I am logging'); // String syntax
  13. * >> FTBAds.log.push(['%cstring to log', 'color: red']); // Array syntax
  14. */
  15.  
  16. // A flag to log data
  17. var ad_debug_on = GET().ad_debug,
  18. debug_log = [];
  19.  
  20. window.ad_debug = function() {
  21. if (FTBAds.ads && FTBAds.ads.info) {
  22. console.log('%c** Special Configuration **', 'Color:red; font-weight: bold;');
  23. _.forEach(FTBAds.ads.info, function(d, type){
  24. console.log('%cSetup on: ', 'font-weight: bold;', type === 'network' ? FTB.net_name : FTB.app_name);
  25. _.forEach(d.config, function(c, prop){
  26. console.log('%cProperty: ', 'font-weight: bold;', prop);
  27. var page_type = _.keys(c)[0];
  28. if (c[page_type]) {
  29. console.log('%cAd Units: ', 'font-weight: bold;', c[page_type].join(', '));
  30. }
  31. });
  32. console.log('');
  33. });
  34. console.log('');
  35. } else {
  36. console.log('%c** NO Special Configuration **', 'Color:green; font-weight: bold;');
  37. }
  38. _.forEach(debug_log, function(d){
  39. if (_.isArray(d)) {
  40. console.log.apply(console, d);
  41. } else {
  42. console.log(d);
  43. }
  44. });
  45. };
  46.  
  47. // If we set the ?ad_debug=true flag, log all calls to ad_debug2 as they are called
  48. if (ad_debug_on) {
  49. // Call this immediately
  50. window.ad_debug();
  51.  
  52. // Overwrite the debug_log.push method to log things too!
  53. debug_log.push = function(d){
  54. this[this.length] = d;
  55. if (_.isArray(d)) {
  56. console.log.apply(console, d);
  57. } else {
  58. console.log(d);
  59. }
  60. };
  61. }
  62.  
  63. // Export the logger to FTBAds.log
  64. FTBAds.log = debug_log;
  65.  
  66. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement