Activate plugin registry

Change-Id: I1c9305b21081b8f754adedc49326a3cab578df29
diff --git a/dev/js/spec/pipeSpec.js b/dev/js/spec/pipeSpec.js
index 078d4b1..93bf172 100644
--- a/dev/js/spec/pipeSpec.js
+++ b/dev/js/spec/pipeSpec.js
@@ -93,6 +93,7 @@
       let p = pipeClass.create();
       let e = p.element();
       expect(e.tagName).toEqual("INPUT");
+      expect(e.getAttribute("type")).toEqual("text");
       p.append('service1');
       expect(e.getAttribute("value")).toEqual("service1");
       p.append('service2');
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 62d0800..f9eaa13 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -28,6 +28,8 @@
   'panel/result',
   'panel/query',
   'tour/tours',
+  'plugin/server',
+  'pipe',
   'api',
   'mailToChiffre',
   'util',
@@ -43,7 +45,9 @@
              selectMenuClass,
              resultPanelClass,
              queryPanelClass,
-             tourClass) {
+             tourClass,
+             pluginClass,
+             pipeClass) {
 
   const d = document;
 
@@ -420,7 +424,34 @@
       sform.insertBefore(queryPanel.element(), vcView);
       KorAP.Panel['query'] = queryPanel;
     }
-    
+
+    /**
+     * Initialize Plugin registry.
+     */
+    let p = KorAP.Plugins;
+    if (p && p.length > 0) {
+      // Load Plugin Server first
+      KorAP.Plugin = pluginClass.create();
+
+      // Add services container to head
+      d.head.appendChild(KorAP.Plugin.element());
+
+      // Add pipe form
+      KorAP.Pipe = pipeClass.create();
+      d.getElementById("searchform").appendChild(KorAP.Pipe.element());
+
+      try {
+      
+        // Register all plugins
+        for (var i = 0; i < p.length; i++) {
+          KorAP.Plugin.register(p[i]);
+        }
+      }
+      catch (e) {
+        KorAP.log(0, e);
+      }
+    };
+
     return obj;
   });
   
diff --git a/dev/js/src/plugin/service.js b/dev/js/src/plugin/service.js
index be567be..3152f38 100644
--- a/dev/js/src/plugin/service.js
+++ b/dev/js/src/plugin/service.js
@@ -30,7 +30,13 @@
     load : function () {
       if (this._load)
         return this._load;
-      
+
+      if (window.location.protocol == 'https:' &&
+          this.src.toLowerCase().indexOf('https:') != 0) {
+        KorAP.log(0, "Service endpoint is insecure");
+        return;
+      };
+
       // Spawn new iframe
       let e = document.createElement('iframe');
       e.setAttribute('allowTransparency',"true");
diff --git a/dev/js/src/view.js b/dev/js/src/view.js
index fa830d6..d0a517c 100644
--- a/dev/js/src/view.js
+++ b/dev/js/src/view.js
@@ -53,8 +53,14 @@
         cl.add.apply(cl, this._classes);
 
       // TODO: The show may need to be wrapped in another DIV!
-      if (this.show !== undefined)
-        e.appendChild(this.show());
+      if (this.show !== undefined) {
+        let s = this.show();
+        if (s) {
+          e.appendChild(s);
+        } else {
+          return e
+        }
+      }
 
       this._shown = true;