X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=openx.js;h=eb85805f83aeaa98e9e9b4647893f86575cb86a1;hb=e01c7e49b34dc78efbe4a400ce1cfbfe4645c469;hp=68cc43171f7d6fcb4f5c04131a23b7940f6cf261;hpb=b8397395da614ad3cb031d54f285ad6441dcf748;p=openx
diff --git a/openx.js b/openx.js
index 68cc431..eb85805 100644
--- a/openx.js
+++ b/openx.js
@@ -4,68 +4,140 @@
(function( openx, $, undefined ) {
- var count = 0;
- var slots = {};
- var ads = new Array();
+ var
+ id,
+ node,
- openx.fetch_ads = function(server, zones) {
+ count = 0,
+ slots = {},
+ ads = [];
- 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("
");
+ if (typeof(OA_output[id]) != 'undefined' && OA_output[id] != '')
ads.push(id);
- // alert('Banner ' + id + ': ' + OA_output[id]);
- }
}
+ render_ad();
+
}
- openx.show_ads = function() {
+ function render_ad() {
- /** Show the rendered banners */
- for (var 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] = "";
+ render_ad();
+ return;
+ }
+ /** 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.push(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_ad); // << jQuery.getScript() generates onload-Handler for _all_ browsers ;)
+ return;
+ }
}
+ node.append(OA_output[id]);
+ OA_output[id] = "";
+
+ /** This statement will only reached, when no script-element was rendered! */
+ render_ad();
+
+ }
+
+ function render() {
+
+ if (id == undefined)
+ return;
+
+ var
+ str = "",
+ i;
+
+ for (i=0; i < arguments.length; i++)
+ str += arguments[i];
+
+ OA_output[id] = str + OA_output[id];
+
}
} ( window.openx = window.openx || {}, jQuery ));
+
+var OA_output = {}; // << Needed, because IE will complain loudly otherwise!