X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=openx.js;h=e074a9a7b4ce5f950bc59a66f5daf2e91df6342c;hb=85b8e0cc15c980368286f8a84444e5b7eca8e8b3;hp=18d96ee5d3c5bfe126180572366c65c9ee231652;hpb=fb22378b1631a2f50e685cb3bc2eff6bbd8fe34d;p=openx diff --git a/openx.js b/openx.js index 18d96ee..e074a9a 100644 --- a/openx.js +++ b/openx.js @@ -11,36 +11,46 @@ count = 0, slots = {}, - ads = []; + queue = [], + ads = [], + output = []; openx.show_ads = function(server, zones) { var domain = document.location.protocol == 'https:' ? 'https://' + server + ':8443':'http://' + server, + name, src = domain; - document.write = document_write; - document.writeln = document_write; + /** + * Without this option, jQuery appends an timestamp to every URL, that + * is fetched via $.getScript(). This can mess up badly written + * third-party-ad-scripts, that assume that the called URL's are not + * altered. + */ + $.ajaxSetup({ cache: true }); src += "/www/delivery/spc.php?zones="; /** Only fetch banners, that are really included in this page */ - $('.oa').each(function() { - var - node = $(this), - name, id; - for(name in zones) { + for(name in zones) { + $('.oa').each(function() { + var + node = $(this), + id; if (node.hasClass(name)) { id = 'oa_' + ++count; slots[id] = node; + queue.push(id); src += escape(id + '=' + zones[name] + "|"); } - } - }); + }); + } - src += "&nz=1&source=" + escape(OA_source); - src += "&r=" + Math.floor(Math.random()*99999999); + if (typeof OA_source !== 'undefined') + src += "&source=" + escape(OA_source); + src += "&nz=1&r=" + Math.floor(Math.random()*99999999); src += "&block=1&charset=UTF-8"; if (window.location) src += "&loc=" + escape(window.location); @@ -55,11 +65,16 @@ function init_ads() { - for (var id in slots) { + var i, id; + for (i=0; i 0) { - id = ads.pop(); + var result, src, inline, i; + + id = ads.shift(); node = slots[id]; node.slideDown(); // node.append(id + ": " + node.attr('class')); - var result, src, inline; + /** + * If output was added via document.write(), this output must be + * rendered before other banner-code from the OpenX-server is rendered! + */ + insert_output(); while ((result = /