Add support for response pipes
Change-Id: I86905bb22ffa70b86476f0de6fa8343f687dc740
diff --git a/dev/js/src/pipe.js b/dev/js/src/pipe.js
index 7f0f6be..f10853e 100644
--- a/dev/js/src/pipe.js
+++ b/dev/js/src/pipe.js
@@ -1,12 +1,13 @@
/**
* Create a pipe object, that holds a list of services
* meant to transform the KQ passed before it's finally
- * passed to the search engine.
+ * passed to the search engine or to transform the response
+ * afterwards.
*
* @author Nils Diewald
*/
"use strict";
-define(function () {
+define(['util'], function () {
const notNullRe = new RegExp("[a-zA-Z0-9]");
// Trim and check
@@ -23,8 +24,9 @@
/**
* Constructor
*/
- create : function () {
+ create : function (name) {
const obj = Object.create(this);
+ obj._name = (name == undefined) ? 'pipe' : name;
obj._pipe = [];
return obj;
},
@@ -81,6 +83,13 @@
return this._pipe.join(',');
},
+ /**
+ * Return the pipe as a an URI compliant string.
+ */
+ toUriString : function () {
+ return encodeURIComponent(this.toString());
+ },
+
/**
* Update the pipe value.
@@ -100,7 +109,7 @@
if (e == null) {
e = this.e = document.createElement('input');
e.setAttribute("type","text");
- e.setAttribute("name","pipe");
+ e.setAttribute("name",this._name);
e.classList.add("pipe");
};
return e;