Added special delivery-configuration-options
[openx] / jquery.openx.js
index d49a852..f5f2253 100644 (file)
@@ -25,7 +25,7 @@
 
   var
 
-  settings, _zones, _options, domain, id, node,
+  settings, _options, domain, id, node,
 
   count = 0,
   slots = {},
   /*
    * Configuration-Options for jQuery.openx
    *
+   * Since the domain-name of the ad-server is the only required parameter,
+   * jQuery.openx for convenience can be configured with only that one
+   * parameter. For example: "jQuery.openx('openx.example.org');". If more
+   * configuration-options are needed, they must be specified as an object.
+   * For example: "jQuery.openx({'server': 'openx.example.org', ... });".
+   *
    *
    * Server-Settings:
    *
    *                        (only needed, when it is not the default-value 443).
    *
    *
+   * Seldom needed special Server-Settings (these parameters are only needed,
+   * if the default delivery-configration of the OpenX-Server was changed):
+   *
+   * path:          string  Path to delivery-scripts. DEFAULT: "/www/delivery".
+   * fl:            string  Flash-Include-Script. DEFAULT: "fl.js".
+   *
+   *
    * Delivery-Options (for details and explanations see the see:
    * http://www.openx.com/docs/2.8/userguide/single%20page%20call):
    *
    *                        If empty, the charset is guessed by OpenX. Examples
    *                        for sensible values: "UTF-8", "ISO-8859-1".
    */
-  $.openx = function( zones, options ) {
+  $.openx = function( options ) {
 
     var name, src, errors = [], i;
 
     if (domain) {
       if (console.error) {
         console.error('jQuery.openx was already initialized!');
-        console.log('Configured zones: ', _zones);
         console.log('Configured options: ', _options);
       }
       return;
     }
 
-    _zones = zones;
+    /** Enable convenient-configuration */
+    if (typeof(options) == 'string')
+      options = { 'server': options };
+
     _options = options;
 
     if (!options.server)
     settings = $.extend(
       {
         'protocol': document.location.protocol,
+        'delivery': '/www/delivery',
+        'fl': 'fl.js',
         'cache': true
       },
       options
     $.ajaxSetup({ 'cache': true });
 
 
-    src = domain + '/www/delivery/spc.php';
+    src = domain + settings.delivery + '/spc.php';
 
     /**
      * jQuery.openx only works with "named zones", because it does not know,
      * to unnecessarily fetched banners.
      */
     src += '?zones=';
-    for(name in zones) {
+    for(name in OA_zones) {
       $('.oa').each(function() {
         var
         node = $(this),
           id = 'oa_' + ++count;
           slots[id] = node;
           queue.push(id);
-          src += escape(id + '=' + zones[name] + "|");
+          src += escape(id + '=' + OA_zones[name] + "|");
         }
       });
     }
     if (settings.blockcampaign === 1)
       src += '&blockcampaign=1';
     if (settings.target)
-      src += '&target' + settings.target;
+      src += '&target=' + settings.target;
     if (settings.withtext === 1)
       src += '&withtext=1';
     if (settings.charset)
 
   function load_flash() {
 
-    $.getScript(domain + '/www/delivery/fl.js', init_ads);
+    $.getScript(domain + settings.delivery + '/' + settings.fl, init_ads);
 
   }