Plugin shows configuration from first call, when its initialized twice
[openx] / jquery.openx.js
index 5825593..adcf78f 100644 (file)
@@ -25,7 +25,7 @@
 
   var
 
-  domain, id, node,
+  settings, _zones, _options, domain, id, node,
 
   count = 0,
   slots = {},
   output = [];
 
 
-  $.openx = function( server, zones, options ) {
+  $.openx = function( zones, options ) {
 
     if (domain) {
-      if (console.error)
-        console.error('jQuery.openx was already initialized!');
+      if (console.error) {
+        console.error('jQuery.openx was already initialized:');
+        console.error(_zones);
+        console.error(_options);
+      }
       return;
     }
 
-    domain = document.location.protocol == 'https:' ? 'https://' + server + ':8443':'http://' + server;
+    _zones = zones;
+    _options = options;
+
+    settings = $.extend(
+      {
+        'protocol': document.location.protocol,
+        'server': 'localhost'
+      },
+      options
+      );
+
+    domain = settings.protocol + '//';
+    domain += settings.server;
+    if (settings.protocol === 'http:' && settings.http_port)
+      domain += ':' + settings.http_port;
+    if (settings.protocol === 'https:' && settings.https_port)
+      domain += ':' + settings.https_port;
 
     var
     name,