changed examples, added listener methods

This commit is contained in:
Kevin Jahns 2014-08-19 21:09:23 +02:00
parent 9a1b0b7ced
commit 92e23b7007
50 changed files with 1229 additions and 526 deletions

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
!function t(n,e,r){function i(o,a){if(!e[o]){if(!n[o]){var s="function"==typeof require&&require;if(!a&&s)return s(o,!0);if(u)return u(o,!0);throw new Error("Cannot find module '"+o+"'")}var c=e[o]={exports:{}};n[o][0].call(c.exports,function(t){var e=n[o][1][t];return i(e?e:t)},c,c.exports,t,n,e,r)}return e[o].exports}for(var u="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(t,n){var e;e=function(t,n){var e,r,i,u,o,a;return null!=n&&(a=n.iwcHandler),u={},r=new DUIClient,r.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),r.initOK(),o=null,e=function(){function t(t,n,e,i){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=i,this.duiClient=r,this.iwcHandler=u,l=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(e){var r;return n=e.extras.HB,r=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[r]=!0}}(this),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),c=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t}(),i=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(i,5e3)},n.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=e)},{}]},{},[1]);
!function t(n,e,r){function i(o,a){if(!e[o]){if(!n[o]){var s="function"==typeof require&&require;if(!a&&s)return s(o,!0);if(u)return u(o,!0);throw new Error("Cannot find module '"+o+"'")}var c=e[o]={exports:{}};n[o][0].call(c.exports,function(t){var e=n[o][1][t];return i(e?e:t)},c,c.exports,t,n,e,r)}return e[o].exports}for(var u="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(t,n){var e;e=function(t,n){var e,r,i,u,o,a;return a=null,null!=n&&(a=n.iwcHandler),u={},r=new DUIClient,r.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),r.initOK(),o=null,e=function(){function t(t,n,e,i){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=i,this.duiClient=r,this.iwcHandler=u,l=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(e){var r;return n=e.extras.HB,r=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[r]=!0}}(this),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),c=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.setIwcHandler=function(t){return a=t},t}(),i=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(i,5e3)},n.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=e)},{}]},{},[1]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,4 +3,4 @@
},{}]},{},[1])
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL2Rtb25hZC9Ecm9wYm94L1lhdHRhIS9ub2RlX21vZHVsZXMvZ3VscC1icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvaG9tZS9kbW9uYWQvRHJvcGJveC9ZYXR0YSEvbGliL1R5cGVzL1htbFR5cGVzLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiKGZ1bmN0aW9uIGUodCxuLHIpe2Z1bmN0aW9uIHMobyx1KXtpZighbltvXSl7aWYoIXRbb10pe3ZhciBhPXR5cGVvZiByZXF1aXJlPT1cImZ1bmN0aW9uXCImJnJlcXVpcmU7aWYoIXUmJmEpcmV0dXJuIGEobywhMCk7aWYoaSlyZXR1cm4gaShvLCEwKTt0aHJvdyBuZXcgRXJyb3IoXCJDYW5ub3QgZmluZCBtb2R1bGUgJ1wiK28rXCInXCIpfXZhciBmPW5bb109e2V4cG9ydHM6e319O3Rbb11bMF0uY2FsbChmLmV4cG9ydHMsZnVuY3Rpb24oZSl7dmFyIG49dFtvXVsxXVtlXTtyZXR1cm4gcyhuP246ZSl9LGYsZi5leHBvcnRzLGUsdCxuLHIpfXJldHVybiBuW29dLmV4cG9ydHN9dmFyIGk9dHlwZW9mIHJlcXVpcmU9PVwiZnVuY3Rpb25cIiYmcmVxdWlyZTtmb3IodmFyIG89MDtvPHIubGVuZ3RoO28rKylzKHJbb10pO3JldHVybiBzfSkiLCJcblxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZGF0YTphcHBsaWNhdGlvbi9qc29uO2Jhc2U2NCxleUoyWlhKemFXOXVJam96TENKbWFXeGxJam9pTDJodmJXVXZaRzF2Ym1Ga0wwUnliM0JpYjNndldXRjBkR0VoTDJ4cFlpOVVlWEJsY3k5WWJXeFVlWEJsY3k1amIyWm1aV1VpTENKemIzVnlZMlZTYjI5MElqb2lJaXdpYzI5MWNtTmxjeUk2V3lJdmFHOXRaUzlrYlc5dVlXUXZSSEp2Y0dKdmVDOVpZWFIwWVNFdmJHbGlMMVI1Y0dWekwxaHRiRlI1Y0dWekxtTnZabVpsWlNKZExDSnVZVzFsY3lJNlcxMHNJbTFoY0hCcGJtZHpJam9pUVVFd1kwY2lMQ0p6YjNWeVkyVnpRMjl1ZEdWdWRDSTZXeUlpWFgwPSJdfQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL2Rtb25hZC9Ecm9wYm94L1lhdHRhIS9ub2RlX21vZHVsZXMvZ3VscC1icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvaG9tZS9kbW9uYWQvRHJvcGJveC9ZYXR0YSEvbGliL1R5cGVzL1htbFR5cGVzLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiKGZ1bmN0aW9uIGUodCxuLHIpe2Z1bmN0aW9uIHMobyx1KXtpZighbltvXSl7aWYoIXRbb10pe3ZhciBhPXR5cGVvZiByZXF1aXJlPT1cImZ1bmN0aW9uXCImJnJlcXVpcmU7aWYoIXUmJmEpcmV0dXJuIGEobywhMCk7aWYoaSlyZXR1cm4gaShvLCEwKTt0aHJvdyBuZXcgRXJyb3IoXCJDYW5ub3QgZmluZCBtb2R1bGUgJ1wiK28rXCInXCIpfXZhciBmPW5bb109e2V4cG9ydHM6e319O3Rbb11bMF0uY2FsbChmLmV4cG9ydHMsZnVuY3Rpb24oZSl7dmFyIG49dFtvXVsxXVtlXTtyZXR1cm4gcyhuP246ZSl9LGYsZi5leHBvcnRzLGUsdCxuLHIpfXJldHVybiBuW29dLmV4cG9ydHN9dmFyIGk9dHlwZW9mIHJlcXVpcmU9PVwiZnVuY3Rpb25cIiYmcmVxdWlyZTtmb3IodmFyIG89MDtvPHIubGVuZ3RoO28rKylzKHJbb10pO3JldHVybiBzfSkiLCJcblxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZGF0YTphcHBsaWNhdGlvbi9qc29uO2Jhc2U2NCxleUoyWlhKemFXOXVJam96TENKbWFXeGxJam9pTDJodmJXVXZaRzF2Ym1Ga0wwUnliM0JpYjNndldXRjBkR0VoTDJ4cFlpOVVlWEJsY3k5WWJXeFVlWEJsY3k1amIyWm1aV1VpTENKemIzVnlZMlZTYjI5MElqb2lJaXdpYzI5MWNtTmxjeUk2V3lJdmFHOXRaUzlrYlc5dVlXUXZSSEp2Y0dKdmVDOVpZWFIwWVNFdmJHbGlMMVI1Y0dWekwxaHRiRlI1Y0dWekxtTnZabVpsWlNKZExDSnVZVzFsY3lJNlcxMHNJbTFoY0hCcGJtZHpJam9pUVVGdlpFY2lMQ0p6YjNWeVkyVnpRMjl1ZEdWdWRDSTZXeUlpWFgwPSJdfQ==

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
(function(){var t;t=function(t,n){var e,i,r,u,o,a;return null!=n&&(a=n.iwcHandler),u={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),i.initOK(),o=null,e=function(){function t(t,n,e,r){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=u,l=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(e){var i;return n=e.extras.HB,i=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[i]=!0}}(this),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),c=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t}(),r=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this);
(function(){var t;t=function(t,n){var e,i,r,u,o,a;return a=null,null!=n&&(a=n.iwcHandler),u={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),i.initOK(),o=null,e=function(){function t(t,n,e,r){var a,s,l,c;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=u,c=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(c),this.initialized={},a=function(t){return function(e){var i;return n=e.extras.HB,i=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[i]=!0}}(this),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),l=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[l]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.setIwcHandler=function(t){return a=t},t}(),r=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this);
//# sourceMappingURL=../Connectors/IwcConnector.js.map

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,7 @@ class JsonYatta
#
# @result JsonType
#
getRootElement: ()->
getSharedObject: ()->
@root_element
#

View File

@ -1,2 +1,2 @@
(function(){var t,e,n,o;o=require("../Types/JsonTypes"),e=require("../HistoryBuffer"),t=require("../Engine"),n=function(){function n(n,r){var i,s;this.HB=new e(n),s=o(this.HB),this.types=s.types,this.engine=new t(this.HB,s.parser),this.connector=new r(this.engine,this.HB,s.execution_listener,this),i=new this.types.JsonType(this.HB.getReservedUniqueIdentifier()),this.HB.addOperation(i).execute(),this.root_element=i}return n.prototype.getRootElement=function(){return this.root_element},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.setMutableDefault=function(t){return this.root_element.setMutableDefault(t)},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.toJson=function(){return this.root_element.toJson()},n.prototype.val=function(t,e,n){return this.root_element.val(t,e,n)},Object.defineProperty(n.prototype,"value",{get:function(){return this.root_element.value},set:function(t){var e,n,o;if(t.constructor==={}.constructor){o=[];for(e in t)n=t[e],o.push(this.val(e,n,"immutable"));return o}throw new Error("You must only set Object values!")}}),n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.JsonYatta=n)}).call(this);
(function(){var t,e,n,o;o=require("../Types/JsonTypes"),e=require("../HistoryBuffer"),t=require("../Engine"),n=function(){function n(n,r){var i,s;this.HB=new e(n),s=o(this.HB),this.types=s.types,this.engine=new t(this.HB,s.parser),this.connector=new r(this.engine,this.HB,s.execution_listener,this),i=new this.types.JsonType(this.HB.getReservedUniqueIdentifier()),this.HB.addOperation(i).execute(),this.root_element=i}return n.prototype.getSharedObject=function(){return this.root_element},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.setMutableDefault=function(t){return this.root_element.setMutableDefault(t)},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.toJson=function(){return this.root_element.toJson()},n.prototype.val=function(t,e,n){return this.root_element.val(t,e,n)},n.prototype.on=function(){var t;return(t=this.root_element).on.apply(t,arguments)},Object.defineProperty(n.prototype,"value",{get:function(){return this.root_element.value},set:function(t){var e,n,o;if(t.constructor==={}.constructor){o=[];for(e in t)n=t[e],o.push(this.val(e,n,"immutable"));return o}throw new Error("You must only set Object values!")}}),n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.JsonYatta=n)}).call(this);
//# sourceMappingURL=../Frameworks/JsonYatta.js.map

View File

@ -1 +1 @@
{"version":3,"file":"Frameworks/JsonYatta.js","sources":["Frameworks/JsonYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aASX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAe,EAAyB,KAAC,IACzC,KAAC,MAAQ,EAAa,MACtB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAa,QACvC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAa,mBAAoB,MAE1E,EAAiB,GAAA,MAAC,MAAM,SAAS,KAAC,GAAG,+BACrC,KAAC,GAAG,aAAa,GAAY,UAC7B,KAAC,aAAe,QATlB,GAAA,UAcA,eAAgB,iBACd,MAAC,cAfH,EAAA,UAoBA,UAAW,iBACT,MAAC,QArBH,EAAA,UA0BA,aAAc,iBACZ,MAAC,WA3BH,EAAA,UAgCA,iBAAkB,iBAChB,MAAC,IAjCH,EAAA,UAsCA,kBAAmB,SAAC,SAClB,MAAC,aAAa,kBAAkB,IAvClC,EAAA,UA8CA,UAAW,iBACT,MAAC,GAAG,aA/CN,EAAA,UAoDA,OAAS,iBACP,MAAC,aAAa,UArDhB,EAAA,UA0DA,IAAM,SAAC,EAAM,EAAS,SACpB,MAAC,aAAa,IAAI,EAAM,EAAS,IAKnC,OAAO,eAAe,EAAU,UAAW,SACzC,IAAM,iBAAG,MAAC,aAAa,OACvB,IAAM,SAAC,GACL,GAAA,GAAA,EAAA,CAAA,IAAG,EAAE,iBAAkB,YAAvB,CACE,SAAA,IAAA,UACE,EAAA,KAAA,KAAC,IAAI,EAAQ,EAAO,uBAEtB,KAAU,IAAA,OAAM,4CAExB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","sourcesContent":["\njson_types_uninitialized = require \"../Types/JsonTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Json data-structures.\n# Known values that are supported:\n# * String\n# * Integer\n# * Array\n#\nclass JsonYatta\n\n #\n # @param {String} user_id Unique id of the peer.\n # @param {Connector} Connector the connector class.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n type_manager = json_types_uninitialized @HB\n @types = type_manager.types\n @engine = new Engine @HB, type_manager.parser\n @connector = new Connector @engine, @HB, type_manager.execution_listener, @\n\n first_word = new @types.JsonType @HB.getReservedUniqueIdentifier()\n @HB.addOperation(first_word).execute()\n @root_element = first_word\n\n #\n # @result JsonType\n #\n getRootElement: ()->\n @root_element\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # @see JsonType.setMutableDefault\n #\n setMutableDefault: (mutable)->\n @root_element.setMutableDefault(mutable)\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.toJson\n #\n toJson : ()->\n @root_element.toJson()\n\n #\n # @see JsonType.val\n #\n val : (name, content, mutable)->\n @root_element.val(name, content, mutable)\n\n #\n # @see JsonType.value\n #\n Object.defineProperty JsonYatta.prototype, 'value',\n get : -> @root_element.value\n set : (o)->\n if o.constructor is {}.constructor\n for o_name,o_obj of o\n @val(o_name, o_obj, 'immutable')\n else\n throw new Error \"You must only set Object values!\"\n\nmodule.exports = JsonYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.JsonYatta = JsonYatta\n"],"sourceRoot":"/source/"}
{"version":3,"file":"Frameworks/JsonYatta.js","sources":["Frameworks/JsonYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aASX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAe,EAAyB,KAAC,IACzC,KAAC,MAAQ,EAAa,MACtB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAa,QACvC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAa,mBAAoB,MAE1E,EAAiB,GAAA,MAAC,MAAM,SAAS,KAAC,GAAG,+BACrC,KAAC,GAAG,aAAa,GAAY,UAC7B,KAAC,aAAe,QATlB,GAAA,UAcA,gBAAiB,iBACf,MAAC,cAfH,EAAA,UAoBA,UAAW,iBACT,MAAC,QArBH,EAAA,UA0BA,aAAc,iBACZ,MAAC,WA3BH,EAAA,UAgCA,iBAAkB,iBAChB,MAAC,IAjCH,EAAA,UAsCA,kBAAmB,SAAC,SAClB,MAAC,aAAa,kBAAkB,IAvClC,EAAA,UA8CA,UAAW,iBACT,MAAC,GAAG,aA/CN,EAAA,UAoDA,OAAS,iBACP,MAAC,aAAa,UArDhB,EAAA,UA0DA,IAAM,SAAC,EAAM,EAAS,SACpB,MAAC,aAAa,IAAI,EAAM,EAAS,IA3DnC,EAAA,UA6DA,GAAI,WACF,GAAA,UAAA,EAAA,KAAC,cAAa,GAAd,MAAA,EAAiB,YAKnB,OAAO,eAAe,EAAU,UAAW,SACzC,IAAM,iBAAG,MAAC,aAAa,OACvB,IAAM,SAAC,GACL,GAAA,GAAA,EAAA,CAAA,IAAG,EAAE,iBAAkB,YAAvB,CACE,SAAA,IAAA,UACE,EAAA,KAAA,KAAC,IAAI,EAAQ,EAAO,uBAEtB,KAAU,IAAA,OAAM,4CAExB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","sourcesContent":["\njson_types_uninitialized = require \"../Types/JsonTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Json data-structures.\n# Known values that are supported:\n# * String\n# * Integer\n# * Array\n#\nclass JsonYatta\n\n #\n # @param {String} user_id Unique id of the peer.\n # @param {Connector} Connector the connector class.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n type_manager = json_types_uninitialized @HB\n @types = type_manager.types\n @engine = new Engine @HB, type_manager.parser\n @connector = new Connector @engine, @HB, type_manager.execution_listener, @\n\n first_word = new @types.JsonType @HB.getReservedUniqueIdentifier()\n @HB.addOperation(first_word).execute()\n @root_element = first_word\n\n #\n # @result JsonType\n #\n getSharedObject: ()->\n @root_element\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # @see JsonType.setMutableDefault\n #\n setMutableDefault: (mutable)->\n @root_element.setMutableDefault(mutable)\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.toJson\n #\n toJson : ()->\n @root_element.toJson()\n\n #\n # @see JsonType.val\n #\n val : (name, content, mutable)->\n @root_element.val(name, content, mutable)\n\n on: ()->\n @root_element.on arguments...\n\n #\n # @see JsonType.value\n #\n Object.defineProperty JsonYatta.prototype, 'value',\n get : -> @root_element.value\n set : (o)->\n if o.constructor is {}.constructor\n for o_name,o_obj of o\n @val(o_name, o_obj, 'immutable')\n else\n throw new Error \"You must only set Object values!\"\n\nmodule.exports = JsonYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.JsonYatta = JsonYatta\n"],"sourceRoot":"/source/"}

View File

@ -25,7 +25,7 @@ class TextYatta
#
# @result Word
#
getRootElement: ()->
getSharedObject: ()->
@root_element
#

View File

@ -1,2 +1,2 @@
(function(){var e,t,n,o;o=require("../Types/TextTypes"),t=require("../HistoryBuffer"),e=require("../Engine"),n=function(){function n(n,r){var i,s,p,u,c,a,d,h;this.HB=new t(n),c=o(this.HB),this.types=c.types,this.engine=new e(this.HB,c.parser),this.connector=new r(this.engine,this.HB,c.execution_listener,this),s=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_beginning"},void 0,void 0)),p=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_end"},s,void 0)),s.next_cl=p,s.execute(),p.execute(),u=new this.types.Word({creator:"_",op_number:"_"},s,p),this.HB.addOperation(u).execute(),h={creator:"_",op_number:"RM"},a={creator:"_",op_number:"_RM_beginning"},d={creator:"_",op_number:"_RM_end"},i=this.HB.addOperation(new this.types.Delimiter(a,void 0,d)).execute(),p=this.HB.addOperation(new this.types.Delimiter(d,i,void 0)).execute(),this.root_element=this.HB.addOperation(new this.types.ReplaceManager(void 0,h,i,p)).execute(),this.root_element.replace(u,{creator:"_",op_number:"Replaceable"})}return n.prototype.getRootElement=function(){return this.root_element.val()},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.val=function(){return this.getRootElement().val()},n.prototype.insertText=function(e,t){return this.getRootElement().insertText(e,t)},n.prototype.deleteText=function(e,t){return this.getRootElement().deleteText(e,t)},n.prototype.bind=function(e){return this.getRootElement().bind(e)},n.prototype.replaceText=function(e){return this.getRootElement().replaceText(e)},n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=n)}).call(this);
(function(){var e,t,n,r;r=require("../Types/TextTypes"),t=require("../HistoryBuffer"),e=require("../Engine"),n=function(){function n(n,i){var o,p,s,u,c,a,d,h;this.HB=new t(n),c=r(this.HB),this.types=c.types,this.engine=new e(this.HB,c.parser),this.connector=new i(this.engine,this.HB,c.execution_listener,this),p=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_beginning"},void 0,void 0)),s=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_end"},p,void 0)),p.next_cl=s,p.execute(),s.execute(),u=new this.types.Word({creator:"_",op_number:"_"},p,s),this.HB.addOperation(u).execute(),h={creator:"_",op_number:"RM"},a={creator:"_",op_number:"_RM_beginning"},d={creator:"_",op_number:"_RM_end"},o=this.HB.addOperation(new this.types.Delimiter(a,void 0,d)).execute(),s=this.HB.addOperation(new this.types.Delimiter(d,o,void 0)).execute(),this.root_element=this.HB.addOperation(new this.types.ReplaceManager(void 0,h,o,s)).execute(),this.root_element.replace(u,{creator:"_",op_number:"Replaceable"})}return n.prototype.getSharedObject=function(){return this.root_element.val()},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.val=function(){return this.getSharedObject().val()},n.prototype.insertText=function(e,t){return this.getSharedObject().insertText(e,t)},n.prototype.deleteText=function(e,t){return this.getSharedObject().deleteText(e,t)},n.prototype.bind=function(e){return this.getSharedObject().bind(e)},n.prototype.replaceText=function(e){return this.getSharedObject().replaceText(e)},n.prototype.on=function(){var e;return(e=this.root_element).on.apply(e,arguments)},n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=n)}).call(this);
//# sourceMappingURL=../Frameworks/TextYatta.js.map

View File

@ -1 +1 @@
{"version":3,"file":"Frameworks/TextYatta.js","sources":["Frameworks/TextYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aAKX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAa,EAAyB,KAAC,IACvC,KAAC,MAAQ,EAAW,MACpB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAW,QACrC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAW,mBAAoB,MAExE,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,cAAgB,OAAW,SACvG,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,QAAgB,EAAW,SACvG,EAAU,QAAU,EACpB,EAAU,UACV,EAAI,UACJ,EAAiB,GAAA,MAAC,MAAM,MAAM,QAAS,IAAK,UAAW,KAAM,EAAW,GACxE,KAAC,GAAG,aAAa,GAAY,UAE7B,GAAU,QAAS,IAAK,UAAW,MACnC,GAAY,QAAS,IAAK,UAAW,iBACrC,GAAY,QAAS,IAAK,UAAW,WACrC,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,OAAW,IAAS,UACzE,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,EAAK,SAAW,UACrE,KAAC,aAAe,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,eAAe,OAAW,EAAO,EAAK,IAAK,UACvF,KAAC,aAAa,QAAQ,GAAc,QAAS,IAAK,UAAW,sBArB/D,GAAA,UA2BA,eAAgB,iBACd,MAAC,aAAa,OA5BhB,EAAA,UAiCA,UAAW,iBACT,MAAC,QAlCH,EAAA,UAuCA,aAAc,iBACZ,MAAC,WAxCH,EAAA,UA6CA,iBAAkB,iBAChB,MAAC,IA9CH,EAAA,UAqDA,UAAW,iBACT,MAAC,GAAG,aAtDN,EAAA,UA2DA,IAAK,iBACH,MAAC,iBAAiB,OA5DpB,EAAA,UAiEA,WAAY,SAAC,EAAK,SAChB,MAAC,iBAAiB,WAAW,EAAK,IAlEpC,EAAA,UAuEA,WAAY,SAAC,EAAK,SAChB,MAAC,iBAAiB,WAAW,EAAK,IAxEpC,EAAA,UA6EA,KAAM,SAAC,SACL,MAAC,iBAAiB,KAAK,IA9EzB,EAAA,UAmFA,YAAa,SAAC,SACZ,MAAC,iBAAiB,YAAY,SAGlC,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","sourcesContent":["\ntext_types_uninitialized = require \"../Types/TextTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Text Datastructures.\n#\nclass TextYatta\n\n #\n # @param {String} user_id Uniqe user id that defines this peer.\n # @param {Connector} Connector The connector defines how you connect to the other peers.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n text_types = text_types_uninitialized @HB\n @types = text_types.types\n @engine = new Engine @HB, text_types.parser\n @connector = new Connector @engine, @HB, text_types.execution_listener, @\n\n beginning = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_beginning'} , undefined, undefined\n end = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_end'} , beginning, undefined\n beginning.next_cl = end\n beginning.execute()\n end.execute()\n first_word = new @types.Word {creator: '_', op_number: '_'}, beginning, end\n @HB.addOperation(first_word).execute()\n\n uid_r = { creator: '_', op_number: \"RM\" }\n uid_beg = { creator: '_', op_number: \"_RM_beginning\" }\n uid_end = { creator: '_', op_number: \"_RM_end\" }\n beg = @HB.addOperation(new @types.Delimiter uid_beg, undefined, uid_end).execute()\n end = @HB.addOperation(new @types.Delimiter uid_end, beg, undefined).execute()\n @root_element = @HB.addOperation(new @types.ReplaceManager undefined, uid_r, beg, end).execute()\n @root_element.replace first_word, { creator: '_', op_number: 'Replaceable'}\n\n\n #\n # @result Word\n #\n getRootElement: ()->\n @root_element.val()\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.val\n #\n val: ()->\n @getRootElement().val()\n\n #\n # @see Word.insertText\n #\n insertText: (pos, content)->\n @getRootElement().insertText pos, content\n\n #\n # @see Word.deleteText\n #\n deleteText: (pos, length)->\n @getRootElement().deleteText pos, length\n\n #\n # @see Word.bind\n #\n bind: (textarea)->\n @getRootElement().bind textarea\n\n #\n # @see Word.replaceText\n #\n replaceText: (text)->\n @getRootElement().replaceText text\n\n\nmodule.exports = TextYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.TextYatta = TextYatta\n"],"sourceRoot":"/source/"}
{"version":3,"file":"Frameworks/TextYatta.js","sources":["Frameworks/TextYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aAKX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAa,EAAyB,KAAC,IACvC,KAAC,MAAQ,EAAW,MACpB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAW,QACrC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAW,mBAAoB,MAExE,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,cAAgB,OAAW,SACvG,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,QAAgB,EAAW,SACvG,EAAU,QAAU,EACpB,EAAU,UACV,EAAI,UACJ,EAAiB,GAAA,MAAC,MAAM,MAAM,QAAS,IAAK,UAAW,KAAM,EAAW,GACxE,KAAC,GAAG,aAAa,GAAY,UAE7B,GAAU,QAAS,IAAK,UAAW,MACnC,GAAY,QAAS,IAAK,UAAW,iBACrC,GAAY,QAAS,IAAK,UAAW,WACrC,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,OAAW,IAAS,UACzE,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,EAAK,SAAW,UACrE,KAAC,aAAe,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,eAAe,OAAW,EAAO,EAAK,IAAK,UACvF,KAAC,aAAa,QAAQ,GAAc,QAAS,IAAK,UAAW,sBArB/D,GAAA,UA2BA,gBAAiB,iBACf,MAAC,aAAa,OA5BhB,EAAA,UAiCA,UAAW,iBACT,MAAC,QAlCH,EAAA,UAuCA,aAAc,iBACZ,MAAC,WAxCH,EAAA,UA6CA,iBAAkB,iBAChB,MAAC,IA9CH,EAAA,UAqDA,UAAW,iBACT,MAAC,GAAG,aAtDN,EAAA,UA2DA,IAAK,iBACH,MAAC,kBAAkB,OA5DrB,EAAA,UAiEA,WAAY,SAAC,EAAK,SAChB,MAAC,kBAAkB,WAAW,EAAK,IAlErC,EAAA,UAuEA,WAAY,SAAC,EAAK,SAChB,MAAC,kBAAkB,WAAW,EAAK,IAxErC,EAAA,UA6EA,KAAM,SAAC,SACL,MAAC,kBAAkB,KAAK,IA9E1B,EAAA,UAmFA,YAAa,SAAC,SACZ,MAAC,kBAAkB,YAAY,IApFjC,EAAA,UAsFA,GAAI,WACF,GAAA,UAAA,EAAA,KAAC,cAAa,GAAd,MAAA,EAAiB,iBAGrB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","sourcesContent":["\ntext_types_uninitialized = require \"../Types/TextTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Text Datastructures.\n#\nclass TextYatta\n\n #\n # @param {String} user_id Uniqe user id that defines this peer.\n # @param {Connector} Connector The connector defines how you connect to the other peers.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n text_types = text_types_uninitialized @HB\n @types = text_types.types\n @engine = new Engine @HB, text_types.parser\n @connector = new Connector @engine, @HB, text_types.execution_listener, @\n\n beginning = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_beginning'} , undefined, undefined\n end = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_end'} , beginning, undefined\n beginning.next_cl = end\n beginning.execute()\n end.execute()\n first_word = new @types.Word {creator: '_', op_number: '_'}, beginning, end\n @HB.addOperation(first_word).execute()\n\n uid_r = { creator: '_', op_number: \"RM\" }\n uid_beg = { creator: '_', op_number: \"_RM_beginning\" }\n uid_end = { creator: '_', op_number: \"_RM_end\" }\n beg = @HB.addOperation(new @types.Delimiter uid_beg, undefined, uid_end).execute()\n end = @HB.addOperation(new @types.Delimiter uid_end, beg, undefined).execute()\n @root_element = @HB.addOperation(new @types.ReplaceManager undefined, uid_r, beg, end).execute()\n @root_element.replace first_word, { creator: '_', op_number: 'Replaceable'}\n\n\n #\n # @result Word\n #\n getSharedObject: ()->\n @root_element.val()\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.val\n #\n val: ()->\n @getSharedObject().val()\n\n #\n # @see Word.insertText\n #\n insertText: (pos, content)->\n @getSharedObject().insertText pos, content\n\n #\n # @see Word.deleteText\n #\n deleteText: (pos, length)->\n @getSharedObject().deleteText pos, length\n\n #\n # @see Word.bind\n #\n bind: (textarea)->\n @getSharedObject().bind textarea\n\n #\n # @see Word.replaceText\n #\n replaceText: (text)->\n @getSharedObject().replaceText text\n\n on: ()->\n @root_element.on arguments...\n\n\nmodule.exports = TextYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.TextYatta = TextYatta\n"],"sourceRoot":"/source/"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e};e=require("./StructuredTypes"),module.exports=function(t){var r,i,o,l,s,u;return s=e(t),u=s.types,l=s.parser,r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return n(t,e),t}(u.Delete),l.TextDelete=l.Delete,i=function(e){function t(e,n,r,i,o){if(this.content=e,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");t.__super__.constructor.call(this,n,r,i,o)}return n(t,e),t.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},t.prototype.val=function(){return this.isDeleted()?"":this.content},t.prototype._encode=function(){var e;return e={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},t}(u.Insert),l.TextInsert=function(e){var t,n,r,o,l;return t=e.content,l=e.uid,o=e.prev,n=e.next,r=e.origin,new i(t,l,o,n,r)},o=function(e){function o(e,t,n,r,i,l){o.__super__.constructor.call(this,e,t,n,r,i,l)}return n(o,e),o.prototype.insertText=function(e,n){var r,o,l,s,u,a;for(o=this.getOperationByPosition(e),a=[],s=0,u=n.length;u>s;s++)r=n[s],l=new i(r,void 0,o.prev_cl,o),a.push(t.addOperation(l).execute());return a},o.prototype.deleteText=function(e,n){var i,o,l,s,a;for(s=this.getOperationByPosition(e),o=[],l=a=0;(n>=0?n>a:a>n)&&!(s instanceof u.Delimiter);l=n>=0?++a:--a){for(i=t.addOperation(new r(void 0,s)).execute(),s=s.next_cl;!(s instanceof u.Delimiter)&&s.isDeleted();)s=s.next_cl;o.push(i._encode())}return o},o.prototype.replaceText=function(e){var n;if(null!=this.replace_manager)return n=t.addOperation(new o(void 0)).execute(),n.insertText(0,e),this.replace_manager.replace(n);throw new Error("This type is currently not maintained by a ReplaceManager!")},o.prototype.val=function(){var e,t;return e=function(){var e,n,r,i;for(r=this.toArray(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(null!=t.val?t.val():"");return i}.call(this),e.join("")},o.prototype.setReplaceManager=function(e){return this.saveOperation("replace_manager",e),this.validateSavedOperations},o.prototype.bind=function(e){var t;return t=this,e.value=this.val(),this.on("insert",function(n,r){var i,o,l,s;return l=r.getPosition(),i=function(e){return l>=e?e:e+=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,s)}),this.on("delete",function(n,r){var i,o,l,s;return l=r.getPosition(),i=function(e){return l>e?e:e-=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,s)}),e.onkeypress=function(n){var r,i,o,l;return r=null,r=null!=n.key?32===n.charCode?" ":13===n.keyCode?"\n":n.key:String.fromCharCode(n.keyCode),r.length>0?(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),t.deleteText(l,i),t.insertText(l,r),o=l+r.length,e.setSelectionRange(o,o),n.preventDefault()):n.preventDefault()},e.onpaste=function(e){return e.preventDefault()},e.oncut=function(e){return e.preventDefault()},e.onkeydown=function(n){var r,i,o,l,s;if(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),null!=n.keyCode&&8===n.keyCode){if(i>0)t.deleteText(l,i),e.setSelectionRange(l,l);else if(null!=n.ctrlKey&&n.ctrlKey){for(s=e.value,o=l,r=0,l>0&&(o--,r++);o>0&&" "!==s[o]&&"\n"!==s[o];)o--,r++;t.deleteText(o,l-o),e.setSelectionRange(o,o)}else t.deleteText(l-1,1);return n.preventDefault()}return null!=n.keyCode&&46===n.keyCode?(i>0?(t.deleteText(l,i),e.setSelectionRange(l,l)):(t.deleteText(l,1),e.setSelectionRange(l,l)),n.preventDefault()):void 0}},o.prototype._encode=function(){var e;return e={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(e.prev=this.prev_cl.getUid()),null!=this.next_cl&&(e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},o}(u.ListManager),l.Word=function(e){var t,n,r,i,l,s;return s=e.uid,t=e.beginning,n=e.end,l=e.prev,r=e.next,i=e.origin,new o(s,t,n,l,r,i)},u.TextInsert=i,u.TextDelete=r,u.Word=o,s}}).call(this);
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e};e=require("./StructuredTypes"),module.exports=function(t){var r,i,o,l,u,s;return u=e(t),s=u.types,l=u.parser,r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return n(t,e),t}(s.Delete),l.TextDelete=l.Delete,i=function(e){function t(e,n,r,i,o){if(this.content=e,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");t.__super__.constructor.call(this,n,r,i,o)}return n(t,e),t.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},t.prototype.val=function(){return this.isDeleted()?"":this.content},t.prototype._encode=function(){var e;return e={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},t}(s.Insert),l.TextInsert=function(e){var t,n,r,o,l;return t=e.content,l=e.uid,o=e.prev,n=e.next,r=e.origin,new i(t,l,o,n,r)},o=function(e){function o(e,t,n,r,i,l){o.__super__.constructor.call(this,e,t,n,r,i,l)}return n(o,e),o.prototype.insertText=function(e,n){var r,o,l,u,s,a;for(o=this.getOperationByPosition(e),a=[],u=0,s=n.length;s>u;u++)r=n[u],l=new i(r,void 0,o.prev_cl,o),a.push(t.addOperation(l).execute());return a},o.prototype.deleteText=function(e,n){var i,o,l,u,a;for(u=this.getOperationByPosition(e),o=[],l=a=0;(n>=0?n>a:a>n)&&!(u instanceof s.Delimiter);l=n>=0?++a:--a){for(i=t.addOperation(new r(void 0,u)).execute(),u=u.next_cl;!(u instanceof s.Delimiter)&&u.isDeleted();)u=u.next_cl;o.push(i._encode())}return o},o.prototype.replaceText=function(e){var n;if(null!=this.replace_manager)return n=t.addOperation(new o(void 0)).execute(),n.insertText(0,e),this.replace_manager.replace(n);throw new Error("This type is currently not maintained by a ReplaceManager!")},o.prototype.val=function(){var e,t;return e=function(){var e,n,r,i;for(r=this.toArray(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(null!=t.val?t.val():"");return i}.call(this),e.join("")},o.prototype.setReplaceManager=function(e){return this.saveOperation("replace_manager",e),this.validateSavedOperations(),this.on(["insert","delete"],function(e){return function(){var t;return null!=(t=e.replace_manager)?t.callEvent("change"):void 0}}(this))},o.prototype.bind=function(e){var t;return t=this,e.value=this.val(),this.on("insert",function(n,r){var i,o,l,u;return l=r.getPosition(),i=function(e){return l>=e?e:e+=1},o=i(e.selectionStart),u=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,u)}),this.on("delete",function(n,r){var i,o,l,u;return l=r.getPosition(),i=function(e){return l>e?e:e-=1},o=i(e.selectionStart),u=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,u)}),e.onkeypress=function(n){var r,i,o,l;return r=null,r=null!=n.key?32===n.charCode?" ":13===n.keyCode?"\n":n.key:String.fromCharCode(n.keyCode),r.length>0?(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),t.deleteText(l,i),t.insertText(l,r),o=l+r.length,e.setSelectionRange(o,o),n.preventDefault()):n.preventDefault()},e.onpaste=function(e){return e.preventDefault()},e.oncut=function(e){return e.preventDefault()},e.onkeydown=function(n){var r,i,o,l,u;if(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),null!=n.keyCode&&8===n.keyCode){if(i>0)t.deleteText(l,i),e.setSelectionRange(l,l);else if(null!=n.ctrlKey&&n.ctrlKey){for(u=e.value,o=l,r=0,l>0&&(o--,r++);o>0&&" "!==u[o]&&"\n"!==u[o];)o--,r++;t.deleteText(o,l-o),e.setSelectionRange(o,o)}else t.deleteText(l-1,1);return n.preventDefault()}return null!=n.keyCode&&46===n.keyCode?(i>0?(t.deleteText(l,i),e.setSelectionRange(l,l)):(t.deleteText(l,1),e.setSelectionRange(l,l)),n.preventDefault()):void 0}},o.prototype._encode=function(){var e;return e={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(e.prev=this.prev_cl.getUid()),null!=this.next_cl&&(e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},o}(s.ListManager),l.Word=function(e){var t,n,r,i,l,u;return u=e.uid,t=e.beginning,n=e.end,l=e.prev,r=e.next,i=e.origin,new o(u,t,n,l,r,i)},s.TextInsert=i,s.TextDelete=r,s.Word=o,u}}).call(this);
//# sourceMappingURL=../Types/TextTypes.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Video upload" description="Upload videos in Sevianno" author="Kevin Jahns, Chair of Computer Science 5, RWTH Aachen University, Germany" author_email="jahns@dbis.rwth-aachen.de" scrolling="true">
<Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html"><![CDATA[
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
<script src="./index.js"></script>
<h1> Collaborative Json Widget </h1>
]]></Content>
</Module>

View File

@ -1,177 +0,0 @@
## IWC + JSON Example
Here, I will give a short overview on how to use the IwcJson Framework in Role-SDK widgets.
First you have to include the following libraries in your widget file:
```
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
<script src="./index.js"></script>
```
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
```js
function init(){
createIwcConnector(function(Connector, user_id){
```
yatta is the shared json object. If you change something on this object,
it will be instantly shared with all the other collaborators.
```js
yatta = new JsonYatta(user_id, Connector);
```
Add a integer-property like this
```js
yatta.val('x', 7);
```
Get the value of property x like this
```js
console.log(yatta.val('x') === 7); // true
```
A string property can be either mutable or immutable.
```js
yatta.val('mutable_string', "text", "mutable");
yatta.val('immutable_string', "text", "immutable");
console.log(yatta.val('immutable_string') === "text"); // true
yatta.val('mutable_string').insertText(2,"XXX"); // position, string
yatta.val('mutable_string').deleteText(0,1); // position, deletion length
console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
```
You can omit the mutable - parameter. In that case the default will be used.
Initially the default is 'mutable'. You can set it like this:
```js
yatta.setMutableDefault('mutable');
// or
yatta.setMutableDefault('immutable');
yatta.val('new_string', "string");
console.log(yatta.val('new_string') === "string"); // true
```
yatta is chainable:
```js
yatta.val('a', 4).val('b',5);
console.log(yatta.val('a') === 4); // true
console.log(yatta.val('b') === 5); // true
```
You can alse set objects.
```js
yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
console.log(yatta.val('object').val('c').val('d') === 5); // true
```
Lists are always immutable.
```js
yatta.val('list', [1,2,3]);
console.log(yatta.val('list')[2] === 3); // true
```
But there is a much more convenient way!
```js
console.log(yatta.value.list[2] === 3) // true
yatta.value.list = [3,4,5]
console.log(yatta.val('list')[2] === 5) // true
yatta.value.object = {c : 4}
console.log(yatta.value.object.c === 4) // true
```
The downside is that you are only allowed to overwrite existing properties.
```js
yatta.value.newProperty = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
```
So, how do we create new properties?
```js
yatta.value = {newProperty : "Awesome"}
console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
```
This is stupid! I don't want to overwrite all my existing properties!
Very well.. The solution is that we merge yatta.value with the new assignment.
For example: assuming we want to overwrite yatta.value with some object o.
Then these two rules apply:
* The result has all properties of o
* The result has all properties of yatta.value if they don't occur under the same property-name in o
```js
yatta.value = {newProperty : {Awesome : true }}
console.log(yatta.value.list[2] === 5) // true, old value list still exists.
console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
```
Consider this case.
```js
yatta.value = {newProperty : { x : 4} }
console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
```
Did you notice that you always set immutable objects if you set properties like this?
Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
One last thing. You are only allowed to set properties like this `yatta.value = o`.
Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
```js
w = yatta.value.newProperty
w = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
```
Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
```js
})
}
window.onload = init
```

View File

@ -1,130 +0,0 @@
/**
## IWC + JSON Example
Here, I will give a short overview on how to use the IwcJson Framework in Role-SDK widgets.
First you have to include the following libraries in your widget file:
```
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
<script src="./index.js"></script>
```
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
*/
function init(){
createIwcConnector(function(Connector, user_id){
/**
yatta is the shared json object. If you change something on this object,
it will be instantly shared with all the other collaborators.
*/
yatta = new JsonYatta(user_id, Connector);
/**
Add a integer-property like this
*/
yatta.val('x', 7);
/**
Get the value of property x like this
*/
console.log(yatta.val('x') === 7); // true
/**
A string property can be either mutable or immutable.
*/
yatta.val('mutable_string', "text", "mutable");
yatta.val('immutable_string', "text", "immutable");
console.log(yatta.val('immutable_string') === "text"); // true
yatta.val('mutable_string').insertText(2,"XXX"); // position, string
yatta.val('mutable_string').deleteText(0,1); // position, deletion length
console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
/**
You can omit the mutable - parameter. In that case the default will be used.
Initially the default is 'mutable'. You can set it like this:
*/
yatta.setMutableDefault('mutable');
// or
yatta.setMutableDefault('immutable');
yatta.val('new_string', "string");
console.log(yatta.val('new_string') === "string"); // true
/**
yatta is chainable:
*/
yatta.val('a', 4).val('b',5);
console.log(yatta.val('a') === 4); // true
console.log(yatta.val('b') === 5); // true
/**
You can alse set objects.
*/
yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
console.log(yatta.val('object').val('c').val('d') === 5); // true
/**
Lists are always immutable.
*/
yatta.val('list', [1,2,3]);
console.log(yatta.val('list')[2] === 3); // true
/**
But there is a much more convenient way!
*/
console.log(yatta.value.list[2] === 3) // true
yatta.value.list = [3,4,5]
console.log(yatta.val('list')[2] === 5) // true
yatta.value.object = {c : 4}
console.log(yatta.value.object.c === 4) // true
/**
The downside is that you are only allowed to overwrite existing properties.
*/
yatta.value.newProperty = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
/**
So, how do we create new properties?
*/
yatta.value = {newProperty : "Awesome"}
console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
/**
This is stupid! I don't want to overwrite all my existing properties!
Very well.. The solution is that we merge yatta.value with the new assignment.
For example: assuming we want to overwrite yatta.value with some object o.
Then these two rules apply:
* The result has all properties of o
* The result has all properties of yatta.value if they don't occur under the same property-name in o
*/
yatta.value = {newProperty : {Awesome : true }}
console.log(yatta.value.list[2] === 5) // true, old value list still exists.
console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
/**
Consider this case.
*/
yatta.value = {newProperty : { x : 4} }
console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
/**
Did you notice that you always set immutable objects if you set properties like this?
Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
One last thing. You are only allowed to set properties like this `yatta.value = o`.
Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
*/
w = yatta.value.newProperty
w = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
/**
Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
*/
})
}
window.onload = init

View File

@ -0,0 +1,232 @@
## PeerJs + JSON Example
Here, I will give a short overview on how to enable collaborative json with the
[PeerJs](http://peerjs.com/) Connector and the JsonYatta Framework.
First you have to include the following libraries in your html file:
```
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="../../build/browser/Connectors/PeerJsConnector.min.js"></script>
<script src="./index.js"></script>
```
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
```js
var yatta, yattaHandler;
Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){
```
yatta is the shared json object. If you change something on this object,
it will be instantly shared with all the other collaborators.
```js
yattaHandler = new Y.JsonYatta(user_id, Connector);
yatta = yattaHandler.getSharedObject();
```
Add a integer-property like this
```js
yatta.val('x', 7);
```
Get the value of property x like this
```js
console.log(yatta.val('x') === 7); // true
```
A string property can be either mutable or immutable.
```js
yatta.val('mutable_string', "text", "mutable");
yatta.val('immutable_string', "text", "immutable");
console.log(yatta.val('immutable_string') === "text"); // true
yatta.val('mutable_string').insertText(2,"XXX"); // position, string
yatta.val('mutable_string').deleteText(0,1); // position, deletion length
console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
```
You can omit the mutable - parameter. In that case the default will be used.
Initially the default is 'mutable'. You can set it like this:
```js
yatta.setMutableDefault('mutable');
// or
yatta.setMutableDefault('immutable');
yatta.val('new_string', "string");
console.log(yatta.val('new_string') === "string"); // true
```
yatta is chainable:
```js
yatta.val('a', 4).val('b',5);
console.log(yatta.val('a') === 4); // true
console.log(yatta.val('b') === 5); // true
```
You can alse set objects.
```js
yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
console.log(yatta.val('object').val('c').val('d') === 5); // true
```
Lists are always immutable.
```js
yatta.val('list', [1,2,3]);
console.log(yatta.val('list')[2] === 3); // true
```
### Add listeners
Apply a 'addProperty' - listener to a JsonType.
```js
function addProperty(event_name, property_name){
console.log("Property '" + property_name + "' was created!");
};
yatta.on('addProperty', addProperty);
yatta.val('q', {z: 7}); // Property 'newString' was created!
```
Apply a 'change' - listener to a JsonType.
```js
function change(event_name, property_name){
console.log("Property '" + property_name + "' was replaced or changed!");
console.log("New value: \"" + this.val(property_name).val() + "\""); // 'this' is the new/created value
};
yatta.on('change', change);
yatta.val('mutable_string', "text", 'mutable'); // Property 'mutable_string' was replaced or changed!
```
Does not fire for nested properties.
```js
yatta.val('q').val('z', 8); // No output!
```
Apply 'insert' and 'delete' - listeners to Words.
```js
function insert_delete(event_name, op){
if (event_name === "insert"){
console.log("Inserted '" + op.content + "' at position " + op.getPosition());
} else if (event_name === "delete"){
console.log("Deleted character at position " + op.getPosition());
}
};
yatta.val('mutable_string').on(['insert', 'delete'], insert_delete);
yatta.val('mutable_string').insertText(0, 'a'); // Inserted 'a' at position 0
yatta.val('mutable_string').deleteText(0, 1); // Deleted character at position 0
yatta.deleteListener('addProperty', addProperty);
yatta.deleteListener('change', change);
yatta.deleteListener('insert_delete', insert_delete);
```
But there is a much more convenient way!
```js
console.log(yatta.value.list[2] === 3) // true
yatta.value.list = [3,4,5]
console.log(yatta.val('list')[2] === 5) // true
yatta.value.object = {c : 4}
console.log(yatta.value.object.c === 4) // true
```
The downside is that you are only allowed to overwrite existing properties.
```js
yatta.value.newProperty = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
```
So, how do we create new properties?
```js
yatta.value = {newProperty : "Awesome"}
console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
```
This is stupid! I don't want to overwrite all my existing properties!
Very well.. The solution is that we merge yatta.value with the new assignment.
For example: assuming we want to overwrite yatta.value with some object o.
Then these two rules apply:
* The result has all properties of o
* The result has all properties of yatta.value if they don't occur under the same property-name in o
```js
yatta.value = {newProperty : {Awesome : true }}
console.log(yatta.value.list[2] === 5) // true, old value list still exists.
console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
```
Consider this case.
```js
yatta.value = {newProperty : { x : 4} }
console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
```
Did you notice that you always set immutable objects if you set properties like this?
Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
One last thing. You are only allowed to set properties like this `yatta.value = o`.
Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
```js
w = yatta.value.newProperty
w = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
```
Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
```js
});
```

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>PeerJs Json Example</title>
<script src="http://cdn.peerjs.com/0.3/peer.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.js"></script>
<script src="../../build/browser/Connectors/PeerJsConnector.js"></script>
<script src="./index.js"></script>
</head>
<body>
<h1> Text Editing Demo</h1>
<p> Collaborative text editing with <a href="https://github.com/DadaMonad/Yatta/">Yatta</a>
and <a href="http://peerjs.com/">PeerJs</a> (WebRTC). Open this link in other browsers: <a id="peer_link" target="_blank">Drop me </a> </p>
<p> <a href="https://github.com/DadaMonad/Yatta/">Yatta</a> is a Framework for Real-Time collaboration on arbitrary data structures.
You can find the code for this example <a href="https://github.com/DadaMonad/Yatta/tree/master/examples/TextEditing">here</a>.
</p>
</body>
</html>

View File

@ -0,0 +1,174 @@
/**
## PeerJs + JSON Example
Here, I will give a short overview on how to enable collaborative json with the
[PeerJs](http://peerjs.com/) Connector and the JsonYatta Framework.
First you have to include the following libraries in your html file:
```
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="../../build/browser/Connectors/PeerJsConnector.min.js"></script>
<script src="./index.js"></script>
```
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
*/
var yatta, yattaHandler;
Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){
/**
yatta is the shared json object. If you change something on this object,
it will be instantly shared with all the other collaborators.
*/
yattaHandler = new Y.JsonYatta(user_id, Connector);
yatta = yattaHandler.getSharedObject();
/**
Add a integer-property like this
*/
yatta.val('x', 7);
/**
Get the value of property x like this
*/
console.log(yatta.val('x') === 7); // true
/**
A string property can be either mutable or immutable.
*/
yatta.val('mutable_string', "text", "mutable");
yatta.val('immutable_string', "text", "immutable");
console.log(yatta.val('immutable_string') === "text"); // true
yatta.val('mutable_string').insertText(2,"XXX"); // position, string
yatta.val('mutable_string').deleteText(0,1); // position, deletion length
console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
/**
You can omit the mutable - parameter. In that case the default will be used.
Initially the default is 'mutable'. You can set it like this:
*/
yatta.setMutableDefault('mutable');
// or
yatta.setMutableDefault('immutable');
yatta.val('new_string', "string");
console.log(yatta.val('new_string') === "string"); // true
/**
yatta is chainable:
*/
yatta.val('a', 4).val('b',5);
console.log(yatta.val('a') === 4); // true
console.log(yatta.val('b') === 5); // true
/**
You can alse set objects.
*/
yatta.val('object', {a : {b : "b"}, c : { d : 5 }});
console.log(yatta.val('object').val('c').val('d') === 5); // true
/**
Lists are always immutable.
*/
yatta.val('list', [1,2,3]);
console.log(yatta.val('list')[2] === 3); // true
/**
### Add listeners
Apply a 'addProperty' - listener to a JsonType.
*/
function addProperty(event_name, property_name){
console.log("Property '" + property_name + "' was created!");
};
yatta.on('addProperty', addProperty);
yatta.val('q', {z: 7}); // Property 'newString' was created!
/**
Apply a 'change' - listener to a JsonType.
*/
function change(event_name, property_name){
console.log("Property '" + property_name + "' was replaced or changed!");
console.log("New value: \"" + this.val(property_name).val() + "\""); // 'this' is the new/created value
};
yatta.on('change', change);
yatta.val('mutable_string', "text", 'mutable'); // Property 'mutable_string' was replaced or changed!
/**
Does not fire for nested properties.
*/
yatta.val('q').val('z', 8); // No output!
/**
Apply 'insert' and 'delete' - listeners to Words.
*/
function insert_delete(event_name, op){
if (event_name === "insert"){
console.log("Inserted '" + op.content + "' at position " + op.getPosition());
} else if (event_name === "delete"){
console.log("Deleted character at position " + op.getPosition());
}
};
yatta.val('mutable_string').on(['insert', 'delete'], insert_delete);
yatta.val('mutable_string').insertText(0, 'a'); // Inserted 'a' at position 0
yatta.val('mutable_string').deleteText(0, 1); // Deleted character at position 0
yatta.deleteListener('addProperty', addProperty);
yatta.deleteListener('change', change);
yatta.deleteListener('insert_delete', insert_delete);
/**
But there is a much more convenient way!
*/
console.log(yatta.value.list[2] === 3) // true
yatta.value.list = [3,4,5]
console.log(yatta.val('list')[2] === 5) // true
yatta.value.object = {c : 4}
console.log(yatta.value.object.c === 4) // true
/**
The downside is that you are only allowed to overwrite existing properties.
*/
yatta.value.newProperty = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined.
/**
So, how do we create new properties?
*/
yatta.value = {newProperty : "Awesome"}
console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;)
/**
This is stupid! I don't want to overwrite all my existing properties!
Very well.. The solution is that we merge yatta.value with the new assignment.
For example: assuming we want to overwrite yatta.value with some object o.
Then these two rules apply:
* The result has all properties of o
* The result has all properties of yatta.value if they don't occur under the same property-name in o
*/
yatta.value = {newProperty : {Awesome : true }}
console.log(yatta.value.list[2] === 5) // true, old value list still exists.
console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten.
/**
Consider this case.
*/
yatta.value = {newProperty : { x : 4} }
console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined
/**
Did you notice that you always set immutable objects if you set properties like this?
Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val().
One last thing. You are only allowed to set properties like this `yatta.value = o`.
Yatta can't observe if you overwrite object references `yatta = "Awesome"`.
*/
w = yatta.value.newProperty
w = "Awesome"
console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome..
/**
Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html)
*/
});

View File

@ -2,7 +2,11 @@
Here you find some (hopefully) usefull examples on how to use Yatta!
* [Text Editing](./TextEditing/) Simple collaborative text editing demo with PeerJs and Text Framework
* [IWC + Json](./IwcJson/) Tutorial on how to use Yatta! with Json and IWC
* [IWC](./IwcJson/) More IWC example widgets.
## Tutorials
* [PeerJs-Json Tutorial](./PeerJs-Json/) Tutorial on how to use Yatta! with Json and PeerJs Connector.
* [IWC Tutorial](./Iwc/) Tutorial on how to use IWC Connector.
## Demos
* [Text Editing](./TextEditing/) Simple collaborative text editing demo with PeerJs and Text Framework.
* [IWC Demo](./IwcDemo/) More IWC example widgets..

View File

@ -30,7 +30,7 @@ class JsonYatta
#
# @result JsonType
#
getRootElement: ()->
getSharedObject: ()->
@root_element
#
@ -77,6 +77,9 @@ class JsonYatta
val : (name, content, mutable)->
@root_element.val(name, content, mutable)
on: ()->
@root_element.on arguments...
#
# @see JsonType.value
#

View File

@ -39,7 +39,7 @@ class TextYatta
#
# @result Word
#
getRootElement: ()->
getSharedObject: ()->
@root_element.val()
#
@ -72,31 +72,34 @@ class TextYatta
# @see JsonType.val
#
val: ()->
@getRootElement().val()
@getSharedObject().val()
#
# @see Word.insertText
#
insertText: (pos, content)->
@getRootElement().insertText pos, content
@getSharedObject().insertText pos, content
#
# @see Word.deleteText
#
deleteText: (pos, length)->
@getRootElement().deleteText pos, length
@getSharedObject().deleteText pos, length
#
# @see Word.bind
#
bind: (textarea)->
@getRootElement().bind textarea
@getSharedObject().bind textarea
#
# @see Word.replaceText
#
replaceText: (text)->
@getRootElement().replaceText text
@getSharedObject().replaceText text
on: ()->
@root_element.on arguments...
module.exports = TextYatta

View File

@ -32,25 +32,35 @@ module.exports = (HB)->
# @param {String} event Name of the event.
# @param {Function} f f is executed in case the event fires.
#
on: (event, f)->
on: (events, f)->
@event_listeners ?= {}
@event_listeners[event] ?= []
@event_listeners[event].push f
if events.constructor isnt [].constructor
events = [events]
for e in events
@event_listeners[e] ?= []
@event_listeners[e].push f
deleteListener: (events, f)->
if events.constructor isnt [].constructor
events = [events]
for e in events
if @event_listeners?[e]?
@event_listeners[e] = @event_listeners[e].filter (g)->
f isnt g
#
# Fire an event.
# TODO: Do something with timeouts. You don't want this to fire for every operation (e.g. insert).
#
callEvent: (event, args)->
callEvent: (event, args...)->
if @event_listeners?[event]?
for f in @event_listeners[event]
f.call @, event, args
f.call @, event, args...
#
# Set the parent of this operation.
#
setParent: (o)->
@parent = o
setParent: (@parent)->
#
# Get the parent of this operation.

View File

@ -77,7 +77,10 @@ module.exports = (HB)->
uid_end.op_number = "_#{uid_end.op_number}_RM_#{@name}_end"
beg = HB.addOperation(new types.Delimiter uid_beg, undefined, uid_end).execute()
end = HB.addOperation(new types.Delimiter uid_end, beg, undefined).execute()
@map_manager.map[@name] = HB.addOperation(new ReplaceManager undefined, uid_r, beg, end).execute()
@map_manager.map[@name] = HB.addOperation(new ReplaceManager undefined, uid_r, beg, end)
@map_manager.map[@name].setParent @map_manager, @name
@map_manager.map[@name].execute()
@map_manager.callEvent 'addProperty', @name
super
#
@ -165,8 +168,6 @@ module.exports = (HB)->
o = o.next_cl
if not o.isDeleted()
position -= 1
o
#
@ -199,6 +200,16 @@ module.exports = (HB)->
HB.addOperation(op).execute()
#
# Add change listeners for parent.
#
setParent: (parent, property_name)->
@on 'insert', (event, op)=>
if op.next_cl instanceof types.Delimiter
@parent.callEvent 'change', property_name
@on 'change', (event)=>
@parent.callEvent 'change', property_name
super parent
#
# Get the value of this Word
# @return {String}
#

View File

@ -140,7 +140,9 @@ module.exports = (HB)->
#
setReplaceManager: (op)->
@saveOperation 'replace_manager', op
@validateSavedOperations
@validateSavedOperations()
@on ['insert', 'delete'], ()=>
@replace_manager?.callEvent 'change'
#
# Bind this Word to a textfield.

View File

@ -17,7 +17,7 @@ class JsonTest extends Test
new Y.JsonYatta user, conn
getRandomRoot: (user_num, root)->
root ?= @users[user_num].getRootElement()
root ?= @users[user_num].getSharedObject()
types = @users[user_num].types
if _.random(0,1) is 1 # take root
root
@ -71,6 +71,29 @@ describe "JsonYatta", ->
it "can handle many engines, many operations, concurrently (random)", ->
@yTest.run()
it "has a change listener", ()->
addName = false
change = false
change2 = 0
@test_user.on 'addProperty', (eventname, property_name)->
if property_name is 'x'
addName = true
@test_user.val('x',5)
@test_user.on 'change', (eventname, property_name)->
if property_name is 'x'
change = true
@test_user.val('x', 6)
@test_user.val('ins', "text", 'mutable')
@test_user.on 'change', (eventname, property_name)->
if property_name is 'ins'
change2++
@test_user.val('ins').insertText 4, " yay"
@test_user.val('ins').deleteText 0, 4
expect(addName).to.be.ok
expect(change).to.be.ok
expect(change2).to.equal 8
it "has a JsonWrapper", ->
y = this.yTest.getSomeUser().root_element
y.val('x',"dtrn", 'immutable')

View File

@ -17,7 +17,7 @@ class TextTest extends Test
new Y.TextYatta user, conn
getRandomRoot: (user_num)->
@users[user_num].getRootElement()
@users[user_num].getSharedObject()
getContent: (user_num)->
@users[user_num].val()