X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=openx.js;h=34993451a2c565b79b037c439fb8db975c658927;hb=bcf3be2e38ab96a41118a23e7e96db59655de733;hp=68cc43171f7d6fcb4f5c04131a23b7940f6cf261;hpb=b8397395da614ad3cb031d54f285ad6441dcf748;p=openx
diff --git a/openx.js b/openx.js
index 68cc431..3499345 100644
--- a/openx.js
+++ b/openx.js
@@ -4,68 +4,160 @@
(function( openx, $, undefined ) {
- var count = 0;
- var slots = {};
- var ads = new Array();
+ var
+ id,
+ node,
- openx.fetch_ads = function(server, zones) {
+ count = 0,
+ slots = {},
+ queue = [],
+ ads = [],
+ output = [];
- var spc;
- spc = "";
+ $.getScript(src, init_ads);
- document.write(spc);
- document.write("");
- }
+ src = domain + '/www/delivery/fl.js';
+ $.getScript(src);
+ }
- openx.render_ads = function() {
+ function init_ads() {
- /** Render the fetched ad-banners... */
- for (var id in slots) {
- // alert(id + ": " + OA_output[id]);
- if (typeof(OA_output[id]) != 'undefined' && OA_output[id] != '') {
- document.write("
");
- document.write(OA_output[id]);
- document.write("
");
+ var i, id;
+ for (i=0; i 0) {
+
+ var result, src, inline, i;
+
+ id = ads.shift();
+ node = slots[id];
+
+ node.slideDown();
+
+ // node.append(id + ": " + node.attr('class'));
- /** Show the rendered banners */
- for (var i=0; i 0) {
+ output.push(OA_output[id]);
+ OA_output[id] = "";
+ for (i=0; i]*)>([\s\S]*?)<\\?\/script>/i.exec(OA_output[id]);
+ if (result == null) {
+ /** Invalid syntax in delivered banner-code: ignoring the rest of this banner-code! */
+ // alert(OA_output[id]);
+ OA_output[id] = "";
+ }
+ else {
+ /** Remember iinline-code, if present */
+ src = result[1]
+ inline = result[2];
+ /** Strip all text up to and including "" from OA_output[id] */
+ OA_output[id] = OA_output[id].slice(result[0].length,OA_output[id].length);
+ result = /src\s*=\s*['"]([^'"]*)['"]/i.exec(src);
+ if (result == null) {
+ /** script-tag with inline-code: execute inline-code! */
+ result = /^\s*<.*$/m.exec(inline);
+ if (result != null) {
+ /** Remove leading HTML-comments, because IE will stumble otherwise */
+ inline = inline.slice(result[0].length,inline.length);
+ }
+ $.globalEval(inline);
+ }
+ else {
+ /** script-tag with src-URL! */
+ ads.unshift(id); // << The banner might not be rendered fully, or include more calls to document.write().
+ /** Load the script and halt all work until the script is loaded and executed... */
+ $.getScript(result[1], render_ads); // << jQuery.getScript() generates onload-Handler for _all_ browsers ;)
+ return;
+ }
+ }
+ }
+
+ node.append(OA_output[id]);
+ OA_output[id] = "";
}
+
+ /** All entries from OA_output were rendered */
+
+ id = undefined;
+ node = undefined;
+ }
+
+ function document_write() {
+
+ for (var i=0; i