You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/17 12:37:23 UTC

[63/70] [abbrv] incubator-taverna-common-activities git commit: taverna-interaction-activity/

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/95509a51/taverna-interaction-activity/src/main/resources/json2.js
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/json2.js b/taverna-interaction-activity/src/main/resources/json2.js
new file mode 100644
index 0000000..2dbf60d
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/json2.js
@@ -0,0 +1,487 @@
+/*
+    http://www.JSON.org/json2.js
+    2011-10-19
+
+    Public Domain.
+
+    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+    See http://www.JSON.org/js.html
+
+
+    This code should be minified before deployment.
+    See http://javascript.crockford.com/jsmin.html
+
+    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+    NOT CONTROL.
+
+
+    This file creates a global JSON object containing two methods: stringify
+    and parse.
+
+        JSON.stringify(value, replacer, space)
+            value       any JavaScript value, usually an object or array.
+
+            replacer    an optional parameter that determines how object
+                        values are stringified for objects. It can be a
+                        function or an array of strings.
+
+            space       an optional parameter that specifies the indentation
+                        of nested structures. If it is omitted, the text will
+                        be packed without extra whitespace. If it is a number,
+                        it will specify the number of spaces to indent at each
+                        level. If it is a string (such as '\t' or ' '),
+                        it contains the characters used to indent at each level.
+
+            This method produces a JSON text from a JavaScript value.
+
+            When an object value is found, if the object contains a toJSON
+            method, its toJSON method will be called and the result will be
+            stringified. A toJSON method does not serialize: it returns the
+            value represented by the name/value pair that should be serialized,
+            or undefined if nothing should be serialized. The toJSON method
+            will be passed the key associated with the value, and this will be
+            bound to the value
+
+            For example, this would serialize Dates as ISO strings.
+
+                Date.prototype.toJSON = function (key) {
+                    function f(n) {
+                        // Format integers to have at least two digits.
+                        return n < 10 ? '0' + n : n;
+                    }
+
+                    return this.getUTCFullYear()   + '-' +
+                         f(this.getUTCMonth() + 1) + '-' +
+                         f(this.getUTCDate())      + 'T' +
+                         f(this.getUTCHours())     + ':' +
+                         f(this.getUTCMinutes())   + ':' +
+                         f(this.getUTCSeconds())   + 'Z';
+                };
+
+            You can provide an optional replacer method. It will be passed the
+            key and value of each member, with this bound to the containing
+            object. The value that is returned from your method will be
+            serialized. If your method returns undefined, then the member will
+            be excluded from the serialization.
+
+            If the replacer parameter is an array of strings, then it will be
+            used to select the members to be serialized. It filters the results
+            such that only members with keys listed in the replacer array are
+            stringified.
+
+            Values that do not have JSON representations, such as undefined or
+            functions, will not be serialized. Such values in objects will be
+            dropped; in arrays they will be replaced with null. You can use
+            a replacer function to replace those with JSON values.
+            JSON.stringify(undefined) returns undefined.
+
+            The optional space parameter produces a stringification of the
+            value that is filled with line breaks and indentation to make it
+            easier to read.
+
+            If the space parameter is a non-empty string, then that string will
+            be used for indentation. If the space parameter is a number, then
+            the indentation will be that many spaces.
+
+            Example:
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}]);
+            // text is '["e",{"pluribus":"unum"}]'
+
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+            text = JSON.stringify([new Date()], function (key, value) {
+                return this[key] instanceof Date ?
+                    'Date(' + this[key] + ')' : value;
+            });
+            // text is '["Date(---current time---)"]'
+
+
+        JSON.parse(text, reviver)
+            This method parses a JSON text to produce an object or array.
+            It can throw a SyntaxError exception.
+
+            The optional reviver parameter is a function that can filter and
+            transform the results. It receives each of the keys and values,
+            and its return value is used instead of the original value.
+            If it returns what it received, then the structure is not modified.
+            If it returns undefined then the member is deleted.
+
+            Example:
+
+            // Parse the text. Values that look like ISO date strings will
+            // be converted to Date objects.
+
+            myData = JSON.parse(text, function (key, value) {
+                var a;
+                if (typeof value === 'string') {
+                    a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+                    if (a) {
+                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+                            +a[5], +a[6]));
+                    }
+                }
+                return value;
+            });
+
+            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+                var d;
+                if (typeof value === 'string' &&
+                        value.slice(0, 5) === 'Date(' &&
+                        value.slice(-1) === ')') {
+                    d = new Date(value.slice(5, -1));
+                    if (d) {
+                        return d;
+                    }
+                }
+                return value;
+            });
+
+
+    This is a reference implementation. You are free to copy, modify, or
+    redistribute.
+*/
+
+/*jslint evil: true, regexp: true */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+    lastIndex, length, parse, prototype, push, replace, slice, stringify,
+    test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+var JSON;
+if (!JSON) {
+    JSON = {};
+}
+
+(function () {
+    'use strict';
+
+    function f(n) {
+        // Format integers to have at least two digits.
+        return n < 10 ? '0' + n : n;
+    }
+
+    if (typeof Date.prototype.toJSON !== 'function') {
+
+        Date.prototype.toJSON = function (key) {
+
+            return isFinite(this.valueOf())
+                ? this.getUTCFullYear()     + '-' +
+                    f(this.getUTCMonth() + 1) + '-' +
+                    f(this.getUTCDate())      + 'T' +
+                    f(this.getUTCHours())     + ':' +
+                    f(this.getUTCMinutes())   + ':' +
+                    f(this.getUTCSeconds())   + 'Z'
+                : null;
+        };
+
+        String.prototype.toJSON      =
+            Number.prototype.toJSON  =
+            Boolean.prototype.toJSON = function (key) {
+                return this.valueOf();
+            };
+    }
+
+    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+        gap,
+        indent,
+        meta = {    // table of character substitutions
+            '\b': '\\b',
+            '\t': '\\t',
+            '\n': '\\n',
+            '\f': '\\f',
+            '\r': '\\r',
+            '"' : '\\"',
+            '\\': '\\\\'
+        },
+        rep;
+
+
+    function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+        escapable.lastIndex = 0;
+        return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+            var c = meta[a];
+            return typeof c === 'string'
+                ? c
+                : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+        }) + '"' : '"' + string + '"';
+    }
+
+
+    function str(key, holder) {
+
+// Produce a string from holder[key].
+
+        var i,          // The loop counter.
+            k,          // The member key.
+            v,          // The member value.
+            length,
+            mind = gap,
+            partial,
+            value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+        if (value && typeof value === 'object' &&
+                typeof value.toJSON === 'function') {
+            value = value.toJSON(key);
+        }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+        if (typeof rep === 'function') {
+            value = rep.call(holder, key, value);
+        }
+
+// What happens next depends on the value's type.
+
+        switch (typeof value) {
+        case 'string':
+            return quote(value);
+
+        case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+            return isFinite(value) ? String(value) : 'null';
+
+        case 'boolean':
+        case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+            return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+        case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+            if (!value) {
+                return 'null';
+            }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+            gap += indent;
+            partial = [];
+
+// Is the value an array?
+
+            if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+                length = value.length;
+                for (i = 0; i < length; i += 1) {
+                    partial[i] = str(i, value) || 'null';
+                }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+                v = partial.length === 0
+                    ? '[]'
+                    : gap
+                    ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+                    : '[' + partial.join(',') + ']';
+                gap = mind;
+                return v;
+            }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+            if (rep && typeof rep === 'object') {
+                length = rep.length;
+                for (i = 0; i < length; i += 1) {
+                    if (typeof rep[i] === 'string') {
+                        k = rep[i];
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+                for (k in value) {
+                    if (Object.prototype.hasOwnProperty.call(value, k)) {
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+            v = partial.length === 0
+                ? '{}'
+                : gap
+                ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+                : '{' + partial.join(',') + '}';
+            gap = mind;
+            return v;
+        }
+    }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+    if (typeof JSON.stringify !== 'function') {
+        JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+            var i;
+            gap = '';
+            indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+            if (typeof space === 'number') {
+                for (i = 0; i < space; i += 1) {
+                    indent += ' ';
+                }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+            } else if (typeof space === 'string') {
+                indent = space;
+            }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+            rep = replacer;
+            if (replacer && typeof replacer !== 'function' &&
+                    (typeof replacer !== 'object' ||
+                    typeof replacer.length !== 'number')) {
+                throw new Error('JSON.stringify');
+            }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+            return str('', {'': value});
+        };
+    }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+    if (typeof JSON.parse !== 'function') {
+        JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+            var j;
+
+            function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+                var k, v, value = holder[key];
+                if (value && typeof value === 'object') {
+                    for (k in value) {
+                        if (Object.prototype.hasOwnProperty.call(value, k)) {
+                            v = walk(value, k);
+                            if (v !== undefined) {
+                                value[k] = v;
+                            } else {
+                                delete value[k];
+                            }
+                        }
+                    }
+                }
+                return reviver.call(holder, key, value);
+            }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+            text = String(text);
+            cx.lastIndex = 0;
+            if (cx.test(text)) {
+                text = text.replace(cx, function (a) {
+                    return '\\u' +
+                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+                });
+            }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+            if (/^[\],:{}\s]*$/
+                    .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+                        .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+                        .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+                j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+                return typeof reviver === 'function'
+                    ? walk({'': j}, '')
+                    : j;
+            }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+            throw new SyntaxError('JSON.parse');
+        };
+    }
+}());

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/95509a51/taverna-interaction-activity/src/main/resources/notify.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/notify.vm b/taverna-interaction-activity/src/main/resources/notify.vm
new file mode 100644
index 0000000..a144ccc
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/notify.vm
@@ -0,0 +1,39 @@
+#require("message")
+#require("title")
+#notify
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+      <style>
+      </style>
+  </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+         
+         pmrpc.call({
+           destination : "publish",
+           publicProcedureName : "setTitle",
+           params : ["$!title"]});
+
+       </script>
+  
+  <h2>Message: $!message</h2>
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/95509a51/taverna-interaction-activity/src/main/resources/pmrpc.js
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/pmrpc.js b/taverna-interaction-activity/src/main/resources/pmrpc.js
new file mode 100644
index 0000000..0edc8cf
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/pmrpc.js
@@ -0,0 +1,686 @@
+/*
+ * pmrpc 0.6 - Inter-widget remote procedure call library based on HTML5 
+ *             postMessage API and JSON-RPC. https://github.com/izuzak/pmrpc
+ *
+ * Copyright 2011 Ivan Zuzak, Marko Ivankovic
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+pmrpc = self.pmrpc =  function() {
+  // check if JSON library is available
+  if (typeof JSON === "undefined" || typeof JSON.stringify === "undefined" || 
+      typeof JSON.parse === "undefined") {
+    throw "pmrpc requires the JSON library";
+  }
+  
+  // TODO: make "contextType" private variable
+  // check if postMessage APIs are available
+  if (typeof this.postMessage === "undefined" &&  // window or worker
+        typeof this.onconnect === "undefined") {  // shared worker
+      throw "pmrpc requires the HTML5 cross-document messaging and worker APIs";
+  }
+    
+  // Generates a version 4 UUID
+  function generateUUID() {
+    var uuid = [], nineteen = "89AB", hex = "0123456789ABCDEF";
+    for (var i=0; i<36; i++) {
+      uuid[i] = hex[Math.floor(Math.random() * 16)];
+    }
+    uuid[14] = '4';
+    uuid[19] = nineteen[Math.floor(Math.random() * 4)];
+    uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
+    return uuid.join('');
+  }
+  
+  // TODO: remove this - make everything a regex?
+  // Converts a wildcard expression into a regular expression
+  function convertWildcardToRegex(wildcardExpression) {
+    var regex = wildcardExpression.replace(
+                  /([\^\$\.\+\?\=\!\:\|\\\/\(\)\[\]\{\}])/g, "\\$1");
+    regex = "^" + regex.replace(/\*/g, ".*") + "$";
+    return regex;
+  }
+  
+  // Checks whether a domain satisfies the access control list. The access 
+  // control list has a whitelist and a blacklist. In order to satisfy the acl, 
+  // the domain must be on the whitelist, and must not be on the blacklist.
+  function checkACL(accessControlList, origin) {
+    var aclWhitelist = accessControlList.whitelist;
+    var aclBlacklist = accessControlList.blacklist;
+      
+    var isWhitelisted = false;
+    var isBlacklisted = false;
+    
+    for (var i=0; i<aclWhitelist.length; ++i) {
+      var aclRegex = convertWildcardToRegex(aclWhitelist[i]);
+      if(origin.match(aclRegex)) {
+        isWhitelisted = true;
+        break;
+      }
+    }
+     
+    for (var j=0; i<aclBlacklist.length; ++j) {
+      var aclRegex = convertWildcardToRegex(aclBlacklist[j]);
+      if(origin.match(aclRegex)) {
+        isBlacklisted = true;
+        break;
+      }
+    }
+    
+    return isWhitelisted && !isBlacklisted;
+  }
+  
+  // Calls a function with either positional or named parameters
+  // In either case, additionalParams will be appended to the end
+  function invokeProcedure(fn, self, params, additionalParams) {
+    if (!(params instanceof Array)) {
+      // get string representation of function
+      var fnDef = fn.toString();
+      
+      // parse the string representation and retrieve order of parameters
+      var argNames = fnDef.substring(fnDef.indexOf("(")+1, fnDef.indexOf(")"));
+      argNames = (argNames === "") ? [] : argNames.split(", ");
+      
+      var argIndexes = {};
+      for (var i=0; i<argNames.length; i++) {
+        argIndexes[argNames[i]] = i;
+      }
+      
+      // construct an array of arguments from a dictionary
+      var callParameters = [];
+      for (var paramName in params) {
+        if (typeof argIndexes[paramName] !== "undefined") {
+          callParameters[argIndexes[paramName]] = params[paramName];
+        } else {
+          throw "No such param!";
+        }
+      }
+      
+      params = callParameters;
+    }
+    
+    // append additional parameters
+    if (typeof additionalParams !== "undefined") {
+      params = params.concat(additionalParams);
+    }
+    
+    // invoke function with specified context and arguments array
+    return fn.apply(self, params);
+  }
+  
+  // JSON encode an object into pmrpc message
+  function encode(obj) {
+    return "pmrpc." + JSON.stringify(obj);
+  }
+  
+  // JSON decode a pmrpc message
+  function decode(str) {
+    return JSON.parse(str.substring("pmrpc.".length));
+  }
+
+  // Creates a base JSON-RPC object, usable for both request and response.
+  // As of JSON-RPC 2.0 it only contains one field "jsonrpc" with value "2.0"
+  function createJSONRpcBaseObject() {
+    var call = {};
+    call.jsonrpc = "2.0";
+    return call;
+  }
+
+  // Creates a JSON-RPC request object for the given method and parameters
+  function createJSONRpcRequestObject(procedureName, parameters, id) {
+    var call = createJSONRpcBaseObject();
+    call.method = procedureName;
+    call.params = parameters;
+    if (typeof id !== "undefined") {
+      call.id = id;
+    }
+    return call;
+  }
+
+  // Creates a JSON-RPC error object complete with message and error code
+  function createJSONRpcErrorObject(errorcode, message, data) {
+    var error = {};
+    error.code = errorcode;
+    error.message = message;
+    error.data = data;
+    return error;
+  }
+
+  // Creates a JSON-RPC response object.
+  function createJSONRpcResponseObject(error, result, id) {
+    var response = createJSONRpcBaseObject();
+    response.id = id;
+    
+    if (typeof error === "undefined" || error === null) {
+      response.result = (result === "undefined") ? null : result;
+    } else {
+      response.error = error;
+    }
+    
+    return response;
+  }
+
+  // dictionary of services registered for remote calls
+  var registeredServices = {};
+  // dictionary of requests being processed on the client side
+  var callQueue = {};
+  
+  var reservedProcedureNames = {};
+  // register a service available for remote calls
+  // if no acl is given, assume that it is available to everyone
+  function register(config) {
+    if (config.publicProcedureName in reservedProcedureNames) {
+      return false;
+    } else {
+      registeredServices[config.publicProcedureName] = {
+        "publicProcedureName" : config.publicProcedureName,
+        "procedure" : config.procedure,
+        "context" : config.procedure.context,
+        "isAsync" : typeof config.isAsynchronous !== "undefined" ?
+                      config.isAsynchronous : false,
+        "acl" : typeof config.acl !== "undefined" ? 
+                  config.acl : {whitelist: ["*"], blacklist: []}};
+      return true;
+    }
+  }
+
+  // unregister a previously registered procedure
+  function unregister(publicProcedureName) {
+    if (publicProcedureName in reservedProcedureNames) {
+      return false;
+    } else {
+      delete registeredServices[publicProcedureName];
+      return true;
+    }
+  }
+
+  // retreive service for a specific procedure name
+  function fetchRegisteredService(publicProcedureName){
+    return registeredServices[publicProcedureName];
+  }
+  
+  // receive and execute a pmrpc call which may be a request or a response
+  function processPmrpcMessage(eventParams) {
+    var serviceCallEvent = eventParams.event;
+    var eventSource = eventParams.source;
+    var isWorkerComm = typeof eventSource !== "undefined" && eventSource !== null;
+    
+    // if the message is not for pmrpc, ignore it.
+    if (serviceCallEvent.data.indexOf("pmrpc.") !== 0) {
+      return;
+    } else {
+      var message = decode(serviceCallEvent.data);
+      //if (typeof console !== "undefined" && console.log !== "undefined" && (typeof this.frames !== "undefined")) { console.log("Received:" + encode(message)); }
+      if (typeof message.method !== "undefined") {
+        // this is a request
+        
+        // ako je 
+        var newServiceCallEvent = {
+          data : serviceCallEvent.data,
+          source : isWorkerComm ? eventSource : serviceCallEvent.source,
+          origin : isWorkerComm ? "*" : serviceCallEvent.origin,
+          shouldCheckACL : !isWorkerComm
+        };
+        
+        response = processJSONRpcRequest(message, newServiceCallEvent);
+        
+        // return the response
+        if (response !== null) {
+          sendPmrpcMessage(
+            newServiceCallEvent.source, response, newServiceCallEvent.origin);
+        }
+      } else {
+        // this is a response
+        processJSONRpcResponse(message);
+      }
+    }
+  }
+  
+  // Process a single JSON-RPC Request
+  function processJSONRpcRequest(request, serviceCallEvent, shouldCheckACL) {
+    if (request.jsonrpc !== "2.0") {
+      // Invalid JSON-RPC request    
+      return createJSONRpcResponseObject(
+        createJSONRpcErrorObject(-32600, "Invalid request.", 
+          "The recived JSON is not a valid JSON-RPC 2.0 request."),
+        null,
+        null);
+    }
+    
+    var id = request.id;
+    var service = fetchRegisteredService(request.method);
+    
+    if (typeof service !== "undefined") {
+      // check the acl rights
+      if (!serviceCallEvent.shouldCheckACL || 
+            checkACL(service.acl, serviceCallEvent.origin)) {
+        try {
+          if (service.isAsync) {
+            // if the service is async, create a callback which the service
+            // must call in order to send a response back
+            var cb = function (returnValue) {
+                       sendPmrpcMessage(
+                         serviceCallEvent.source,
+                         createJSONRpcResponseObject(null, returnValue, id),
+                         serviceCallEvent.origin);
+                     };
+            invokeProcedure(
+              service.procedure, service.context, request.params, [cb, serviceCallEvent]);
+            return null;
+          } else {
+            // if the service is not async, just call it and return the value
+            var returnValue = invokeProcedure(
+                                service.procedure,
+                                service.context, 
+                                request.params, [serviceCallEvent]);
+            return (typeof id === "undefined") ? null : 
+              createJSONRpcResponseObject(null, returnValue, id);
+          }
+        } catch (error) {
+          if (typeof id === "undefined") {
+            // it was a notification nobody cares if it fails
+            return null;
+          }
+          
+          if (error === "No such param!") {
+            return createJSONRpcResponseObject(
+              createJSONRpcErrorObject(
+                -32602, "Invalid params.", error.description),
+              null,
+              id);            
+          }            
+          
+          // the -1 value is "application defined"
+          return createJSONRpcResponseObject(
+            createJSONRpcErrorObject(
+              -1, "Application error.", error.description),
+            null,
+            id);
+        }
+      } else {
+        // access denied
+        return (typeof id === "undefined") ? null : createJSONRpcResponseObject(
+          createJSONRpcErrorObject(
+            -2, "Application error.", "Access denied on server."),
+          null,
+          id);
+      }
+    } else {
+      // No such method
+      return (typeof id === "undefined") ? null : createJSONRpcResponseObject(
+        createJSONRpcErrorObject(
+          -32601,
+          "Method not found.", 
+          "The requestd remote procedure does not exist or is not available."),
+        null,
+        id);
+    }
+  }
+  
+  // internal rpc service that receives responses for rpc calls 
+  function processJSONRpcResponse(response) {
+    var id = response.id;
+    var callObj = callQueue[id];
+    if (typeof callObj === "undefined" || callObj === null) {
+      return;
+    } else {
+      delete callQueue[id];
+    }
+    
+    // check if the call was sucessful or not
+    if (typeof response.error === "undefined") {
+      callObj.onSuccess( { 
+        "destination" : callObj.destination,
+        "publicProcedureName" : callObj.publicProcedureName,
+        "params" : callObj.params,
+        "status" : "success",
+        "returnValue" : response.result} );
+    } else {
+      callObj.onError( { 
+        "destination" : callObj.destination,
+        "publicProcedureName" : callObj.publicProcedureName,
+        "params" : callObj.params,
+        "status" : "error",
+        "description" : response.error.message + " " + response.error.data} );
+    }
+  }
+  
+  // call remote procedure
+  function call(config) {
+    // check that number of retries is not -1, that is a special internal value
+    if (config.retries && config.retries < 0) {
+      throw new Exception("number of retries must be 0 or higher");
+    }
+    
+    var destContexts = [];
+    
+    if (typeof config.destination === "undefined" || config.destination === null || config.destination === "workerParent") {
+      destContexts = [{context : null, type : "workerParent"}];
+    } else if (config.destination === "publish") {
+      destContexts = findAllReachableContexts();
+    } else if (config.destination instanceof Array) {
+      for (var i=0; i<config.destination.length; i++) {
+        if (config.destination[i] === "workerParent") {
+          destContexts.push({context : null, type : "workerParent"});
+        } else if (typeof config.destination[i].frames !== "undefined") {
+          destContexts.push({context : config.destination[i], type : "window"});
+        } else {
+          destContexts.push({context : config.destination[i], type : "worker"});
+        }
+      }
+    } else {
+      if (typeof config.destination.frames !== "undefined") {
+        destContexts.push({context : config.destination, type : "window"});
+      } else {
+        destContexts.push({context : config.destination, type : "worker"});
+      }
+    }
+        
+    for (var i=0; i<destContexts.length; i++) {
+      var callObj = {
+        destination : destContexts[i].context,
+        destinationDomain : typeof config.destinationDomain === "undefined" ? ["*"] : (typeof config.destinationDomain === "string" ? [config.destinationDomain] : config.destinationDomain),
+        publicProcedureName : config.publicProcedureName,
+        onSuccess : typeof config.onSuccess !== "undefined" ? 
+                      config.onSuccess : function (){},
+        onError : typeof config.onError !== "undefined" ? 
+                      config.onError : function (){},
+        retries : typeof config.retries !== "undefined" ? config.retries : 5,
+        timeout : typeof config.timeout !== "undefined" ? config.timeout : 500,
+        status : "requestNotSent"
+      };
+      
+      isNotification = typeof config.onError === "undefined" && typeof config.onSuccess === "undefined";
+      params = (typeof config.params !== "undefined") ? config.params : [];
+      callId = generateUUID();
+      callQueue[callId] = callObj; 
+      
+      if (isNotification) {
+        callObj.message = createJSONRpcRequestObject(
+                    config.publicProcedureName, params);
+      } else {
+        callObj.message = createJSONRpcRequestObject(
+                            config.publicProcedureName, params, callId);
+      }
+      
+      waitAndSendRequest(callId);
+    }
+  }
+  
+  // Use the postMessage API to send a pmrpc message to a destination
+  function sendPmrpcMessage(destination, message, acl) {
+    //if (typeof console !== "undefined" && console.log !== "undefined" && (typeof this.frames !== "undefined")) { console.log("Sending:" + encode(message)); }
+    if (typeof destination === "undefined" || destination === null) {
+      self.postMessage(encode(message));
+    } else if (typeof destination.frames !== "undefined") {
+      return destination.postMessage(encode(message), acl);
+    } else {
+      destination.postMessage(encode(message));
+    }
+  }
+    
+  // Execute a remote call by first pinging the destination and afterwards
+  // sending the request
+  function waitAndSendRequest(callId) {
+    var callObj = callQueue[callId];
+    if (typeof callObj === "undefined") {
+      return;
+    } else if (callObj.retries <= -1) {      
+      processJSONRpcResponse(
+        createJSONRpcResponseObject(
+          createJSONRpcErrorObject(
+          -4, "Application error.", "Destination unavailable."),
+          null,
+          callId));
+    } else if (callObj.status === "requestSent") {
+      return;
+    } else if (callObj.retries === 0 || callObj.status === "available") {
+      callObj.status = "requestSent";
+      callObj.retries = -1;
+      callQueue[callId] = callObj;
+      for (var i=0; i<callObj.destinationDomain.length; i++) {
+        sendPmrpcMessage(
+          callObj.destination, callObj.message, callObj.destinationDomain[i], callObj);
+        self.setTimeout(function() { waitAndSendRequest(callId); }, callObj.timeout);
+      }
+    } else {
+      // if we can ping some more - send a new ping request
+      callObj.status = "pinging";
+      callObj.retries = callObj.retries - 1;
+      
+      call({
+        "destination" : callObj.destination,
+        "publicProcedureName" : "receivePingRequest",
+        "onSuccess" : function (callResult) {
+                        if (callResult.returnValue === true &&
+                            typeof callQueue[callId] !== 'undefined') {
+                          callQueue[callId].status = "available";
+                          waitAndSendRequest(callId);
+                        }
+                      },
+        "params" : [callObj.publicProcedureName], 
+        "retries" : 0,
+        "destinationDomain" : callObj.destinationDomain});
+      callQueue[callId] = callObj;
+      self.setTimeout(function() { waitAndSendRequest(callId); }, callObj.timeout / callObj.retries);
+    }
+  }
+  
+  // attach the pmrpc event listener 
+  function addCrossBrowserEventListerner(obj, eventName, handler, bubble) {
+    if ("addEventListener" in obj) {
+      // FF
+      obj.addEventListener(eventName, handler, bubble);
+    } else {
+      // IE
+      obj.attachEvent("on" + eventName, handler);
+    }
+  }
+  
+  function createHandler(method, source, destinationType) {
+    return function(event) {
+      var params = {event : event, source : source, destinationType : destinationType};
+      method(params);
+    };
+  }
+  
+  if ('window' in this) {
+    // window object - window-to-window comm
+    var handler = createHandler(processPmrpcMessage, null, "window");
+    addCrossBrowserEventListerner(this, "message", handler, false);
+  } else if ('onmessage' in this) {
+    // dedicated worker - parent X to worker comm
+    var handler = createHandler(processPmrpcMessage, this, "worker");
+    addCrossBrowserEventListerner(this, "message", handler, false);
+  } else if ('onconnect' in this) {
+    // shared worker - parent X to shared-worker comm
+    var connectHandler = function(e) {
+      //this.sendPort = e.ports[0];
+      var handler = createHandler(processPmrpcMessage, e.ports[0], "sharedWorker");      
+      addCrossBrowserEventListerner(e.ports[0], "message", handler, false);
+      e.ports[0].start();
+    };
+    addCrossBrowserEventListerner(this, "connect", connectHandler, false);
+  } else {
+    throw "Pmrpc must be loaded within a browser window or web worker.";
+  }
+  
+  // Override Worker and SharedWorker constructors so that pmrpc may relay
+  // messages. For each message received from the worker, call pmrpc processing
+  // method. This is child worker to parent communication.
+    
+  var createDedicatedWorker = this.Worker;
+  this.nonPmrpcWorker = createDedicatedWorker;
+  var createSharedWorker = this.SharedWorker;
+  this.nonPmrpcSharedWorker = createSharedWorker;
+  
+  var allWorkers = [];
+  
+  this.Worker = function(scriptUri) {
+    var newWorker = new createDedicatedWorker(scriptUri);
+    allWorkers.push({context : newWorker, type : 'worker'});   
+    var handler = createHandler(processPmrpcMessage, newWorker, "worker");
+    addCrossBrowserEventListerner(newWorker, "message", handler, false);
+    return newWorker;
+  };
+  
+  this.SharedWorker = function(scriptUri, workerName) {
+    var newWorker = new createSharedWorker(scriptUri, workerName);
+    allWorkers.push({context : newWorker, type : 'sharedWorker'});    
+    var handler = createHandler(processPmrpcMessage, newWorker.port, "sharedWorker");
+    addCrossBrowserEventListerner(newWorker.port, "message", handler, false);
+    newWorker.postMessage = function (msg, portArray) {
+      return newWorker.port.postMessage(msg, portArray);
+    };
+    newWorker.port.start();
+    return newWorker;
+  };
+  
+  // function that receives pings for methods and returns responses 
+  function receivePingRequest(publicProcedureName) {
+    return typeof fetchRegisteredService(publicProcedureName) !== "undefined";
+  }
+  
+  function subscribe(params) {
+    return register(params);
+  }
+  
+  function unsubscribe(params) {
+    return unregister(params);
+  }
+  
+  function findAllWindows() {
+    var allWindowContexts = [];
+    
+    if (typeof window !== 'undefined') {
+      allWindowContexts.push( { context : window.top, type : 'window' } );
+      
+      // walk through all iframes, starting with window.top
+      for (var i=0; typeof allWindowContexts[i] !== 'undefined'; i++) {
+        var currentWindow = allWindowContexts[i];
+        for (var j=0; j<currentWindow.context.frames.length; j++) {
+          allWindowContexts.push({ 
+            context : currentWindow.context.frames[j],
+            type : 'window'
+          });
+        }
+      }
+    } else {
+      allWindowContexts.push( {context : this, type : 'workerParent'} );
+    }
+    
+    return allWindowContexts;
+  }
+  
+  function findAllWorkers() {
+    return allWorkers;
+  }
+  
+  function findAllReachableContexts() {
+    var allWindows = findAllWindows();
+    var allWorkers = findAllWorkers();
+    var allContexts = allWindows.concat(allWorkers);
+    
+    return allContexts;
+  }
+  
+  // register method for receiving and returning pings
+  register({
+    "publicProcedureName" : "receivePingRequest",
+    "procedure" : receivePingRequest});
+  
+  function getRegisteredProcedures() {
+    var regSvcs = [];
+    var origin = typeof this.frames !== "undefined" ? (window.location.protocol + "//" + window.location.host + (window.location.port !== "" ? ":" + window.location.port : "")) : "";
+    for (publicProcedureName in registeredServices) {
+      if (publicProcedureName in reservedProcedureNames) {
+        continue;
+      } else {
+        regSvcs.push( { 
+          "publicProcedureName" : registeredServices[publicProcedureName].publicProcedureName,
+          "acl" : registeredServices[publicProcedureName].acl,
+          "origin" : origin
+        } );
+      }
+    }
+    return regSvcs;
+  }
+  
+  // register method for returning registered procedures
+  register({
+    "publicProcedureName" : "getRegisteredProcedures",
+    "procedure" : getRegisteredProcedures});
+    
+  function discover(params) {
+    var windowsForDiscovery = null;
+    
+    if (typeof params.destination === "undefined") {
+      windowsForDiscovery = findAllReachableContexts();
+      for (var i=0; i<windowsForDiscovery.length; i++) {
+        windowsForDiscovery[i] = windowsForDiscovery[i].context;
+      }
+    } else {
+      windowsForDiscovery = params.destination;
+    }
+    var originRegex = typeof params.origin === "undefined" ?
+      ".*" : params.origin; 
+    var nameRegex = typeof params.publicProcedureName === "undefined" ?
+      ".*" : params.publicProcedureName;
+    
+    var counter = windowsForDiscovery.length;
+    
+    var discoveredMethods = [];
+    function addToDiscoveredMethods(methods, destination) {
+      for (var i=0; i<methods.length; i++) {
+        if (methods[i].origin.match(originRegex) && methods[i].publicProcedureName.match(nameRegex)) {
+          discoveredMethods.push({
+            publicProcedureName : methods[i].publicProcedureName,
+            destination : destination,
+            procedureACL : methods[i].acl,
+            destinationOrigin : methods[i].origin
+          });
+        }
+      }
+    }
+    
+    pmrpc.call({
+      destination : windowsForDiscovery,
+      destinationDomain : "*",
+      publicProcedureName : "getRegisteredProcedures",
+      onSuccess : function (callResult) {
+                    counter--;
+                    addToDiscoveredMethods(callResult.returnValue, callResult.destination);
+                    if (counter === 0) {
+                      params.callback(discoveredMethods);
+                    }
+                  },
+      onError : function (callResult) {
+                  counter--;
+                  if (counter === 0) {
+                    params.callback(discoveredMethods);
+                  }
+                }
+    });
+  }
+  
+  reservedProcedureNames = {"getRegisteredProcedures" : null, "receivePingRequest" : null};
+  
+  // return public methods
+  return {
+    register : register,
+    unregister : unregister,
+    call : call,
+    discover : discover
+  };
+}();

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/95509a51/taverna-interaction-activity/src/main/resources/schema.json
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/schema.json b/taverna-interaction-activity/src/main/resources/schema.json
new file mode 100644
index 0000000..dcde96e
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/schema.json
@@ -0,0 +1,31 @@
+{
+	"$schema": "http://json-schema.org/draft-03/schema#",
+    "id": "http://ns.taverna.org.uk/2010/activity/interaction.schema.json",
+    "title": Interaction activity configuration",
+    "type": "object",
+    "properties": {
+        "@context": {
+            "description": "JSON-LD context for interpreting the configuration as RDF",
+            "required": true,
+            "enum": ["http://ns.taverna.org.uk/2010/activity/interaction.context.json"]
+        },
+        "presentationOrigin": {
+        	"type": "string",
+        	"required": true,
+        	"minLength": 1,
+        	"description": "The URL of the presentation page, or the identifier of the standard template"
+        },
+        "interactionActivityType": {
+        	"type": "string",
+        	"required": true,
+        	"minLength": 1,
+		"enum" : [ "VelocityTemplate", "LocallyPresentedHtml"],
+        	"description": "Indication of the type of the definition for the interaction"
+        },
+        "progressNotification": {
+        	"type": "boolean",
+        	"required": true,
+        	"description": "True if the interaction should not block the workflow run"
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/95509a51/taverna-interaction-activity/src/main/resources/select.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/select.vm b/taverna-interaction-activity/src/main/resources/select.vm
new file mode 100644
index 0000000..6fe5764
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/select.vm
@@ -0,0 +1,61 @@
+#require("valueList",1)
+#require("message")
+#require("title")
+#produce("answer")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+      <style>
+      </style>
+  </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"answer" : document.myform.mySelect.options[document.myform.mySelect.selectedIndex].value}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+        
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+         
+         pmrpc.call({
+           destination : "publish",
+           publicProcedureName : "setTitle",
+           params : ["$!title"]});
+
+       </script>
+  
+  <h2>$!message</h2>
+    <form name="myform" onSubmit="reply(); return false;">
+      <select name="mySelect">
+#foreach( $value in $valueList )
+      <option value="$value">$value</option>
+#end
+      </select>
+      <br/>
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/95509a51/taverna-interaction-activity/src/main/resources/tell.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/tell.vm b/taverna-interaction-activity/src/main/resources/tell.vm
new file mode 100644
index 0000000..948c023
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/tell.vm
@@ -0,0 +1,54 @@
+#require("message")
+#require("title")
+#produce("answer")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+      <style>
+      </style>
+  </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"answer" : "answer"}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+         
+         pmrpc.call({
+           destination : "publish",
+           publicProcedureName : "setTitle",
+           params : ["$!title"]});
+
+       </script>
+  
+  <h2>Message: $!message</h2>
+    <form name="myform" onSubmit="reply(); return false;">
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="OK" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/95509a51/taverna-interaction-activity/src/main/resources/warn.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/warn.vm b/taverna-interaction-activity/src/main/resources/warn.vm
new file mode 100644
index 0000000..ae9f573
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/warn.vm
@@ -0,0 +1,54 @@
+#require("message")
+#require("title")
+#produce("answer")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="UTF-8" />
+      <title></title>
+      <style>
+      </style>
+  </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"answer" : "answer"}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+         
+         pmrpc.call({
+           destination : "publish",
+           publicProcedureName : "setTitle",
+           params : ["$!title"]});
+
+       </script>
+  
+  <h2>Warning: $!message</h2>
+    <form name="myform" onSubmit="reply(); return false;">
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="OK" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+