From 17a2f5b7816379f69363ccb9e3c421eecedbea7a Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 28 Feb 2013 19:36:40 +0100 Subject: [PATCH] Added debugging-output (debugging can be turned on/off via options) --- jquery.openx.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/jquery.openx.js b/jquery.openx.js index 889a539..3ccdb39 100644 --- a/jquery.openx.js +++ b/jquery.openx.js @@ -108,6 +108,7 @@ * If the value is choosen to small, a recalculation * might be scheduled, while resizing is still in * progress. DEFAULT: 200. + * debug: boolean Turn on/off console-debugging. DEFAULT: false. */ $.openx = function( options ) { @@ -141,7 +142,8 @@ 'selector': '.oa', 'min_prefix': 'min_', 'max_prefix': 'max_', - 'resize_delay': 200 + 'resize_delay': 200, + 'debug': false }, options ); @@ -153,6 +155,9 @@ if (settings.protocol === 'https:' && settings.https_port) domain += ':' + settings.https_port; + if (settings.debug && console.debug) + console.debug('Ad-Server: ' + domain); + /** * Without this option, jQuery appends an timestamp to every URL, that * is fetched via $.getScript(). This can mess up badly written @@ -198,6 +203,12 @@ } rendered[id] = false; visible[id] = false; + if (settings.debug && console.debug) + console.debug( + 'Slot ' + count + ': ' + this.id + ' (' + min_width[id] + + (max_width[id] != Number.MAX_VALUE ? '-' + max_width[id] : '') + + ')' + ); } }); } @@ -216,6 +227,8 @@ function recalculate_visible() { width = $(document).width(); + if (settings.debug && console.debug) + console.debug('Scheduling recalculation of visible banners for width ' + width); if (!rendering) fetch_ads(); @@ -226,6 +239,9 @@ /** Guide rendering-process for early restarts */ rendering = true; + if (settings.debug && console.debug) + console.debug('Starting recalculation of visible banners for width ' + width); + var name, src = domain + settings.delivery + '/spc.php'; /** Order banners for all zones that were found on the page */ @@ -237,14 +253,20 @@ queue.push(id); src += escape(id + '=' + OA_zones[slots[id].id] + "|"); rendered[id] = true; + if (settings.debug && console.debug) + console.debug('Fetching banner ' + slots[id].id); } else { /** Unhide already fetched visible banners */ + if (settings.debug && console.debug) + console.debug('Unhiding already fetched banner ' + slots[id].id); $(slots[id]).slideDown(); } } else { /** Hide unvisible banners */ + if (settings.debug && console.debug) + console.debug('Hiding banner ' + slots[id].id); $(slots[id]).hide(); } } @@ -308,6 +330,9 @@ id = queue.shift(); node = $(slots[id]); + if (settings.debug && console.debug) + console.debug('Rendering banner ' + slots[id].id); + node.slideDown(); // node.append(id + ": " + node.attr('class')); @@ -367,6 +392,9 @@ node = undefined; rendering = false; + if (settings.debug && console.debug) + console.debug('Recalculation of visible banners done!'); + /** Restart rendering, if new task was queued */ if (width) fetch_ads(); -- 2.20.1