added XMPP example, fixed bug in TextType binding to textfield

This commit is contained in:
DadaMonad 2015-01-03 01:08:28 +00:00
parent 877365d00c
commit e73829f73b
37 changed files with 435 additions and 214 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -210,14 +210,7 @@
}
Insert.__super__.applyDelete.call(this, garbagecollect);
if (callLater) {
this.parent.callEvent([
{
type: "insert",
position: this.getPosition(),
object: this.parent,
changed_by: o.uid.creator
}
]);
this.callOperationSpecificDeleteEvents(o);
}
if ((_ref = this.next_cl) != null ? _ref.isDeleted() : void 0) {
return this.next_cl.applyDelete();
@ -299,24 +292,36 @@
}
this.setParent(this.prev_cl.getParent());
Insert.__super__.execute.apply(this, arguments);
this.callOperationSpecificEvents();
this.callOperationSpecificInsertEvents();
return this;
}
};
Insert.prototype.callOperationSpecificEvents = function() {
Insert.prototype.callOperationSpecificInsertEvents = function() {
var _ref;
return (_ref = this.parent) != null ? _ref.callEvent([
{
type: "insert",
position: this.getPosition(),
object: this.parent,
changed_by: this.uid.creator,
changedBy: this.uid.creator,
value: this.content
}
]) : void 0;
};
Insert.prototype.callOperationSpecificDeleteEvents = function(o) {
return this.parent.callEvent([
{
type: "delete",
position: this.getPosition(),
object: this.parent,
length: 1,
changedBy: o.uid.creator
}
]);
};
Insert.prototype.getPosition = function() {
var position, prev;
position = 0;

File diff suppressed because one or more lines are too long

View File

@ -103,7 +103,7 @@
_results = [];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
if ((event.changed_by == null) && (event.type === "add" || (event.type = "update"))) {
if ((event.changedBy == null) && (event.type === "add" || (event.type = "update"))) {
_results.push(that.val(event.name, event.object[event.name]));
} else {
_results.push(void 0);
@ -128,7 +128,7 @@
type: 'update',
name: event.name,
oldValue: oldVal,
changed_by: event.changed_by
changedBy: event.changedBy
}));
} else {
notifier.performChange('add', function() {
@ -139,7 +139,7 @@
type: 'add',
name: event.name,
oldValue: oldVal,
changed_by: event.changed_by
changedBy: event.changedBy
}));
}
} else {

File diff suppressed because one or more lines are too long

View File

@ -35,40 +35,50 @@
};
MapManager.prototype.val = function(name, content) {
var o, obj, qqq, result, x, _ref, _ref1;
var o, obj, prop, result, _ref;
if (content != null) {
if (this.map[name] == null) {
(new AddName(void 0, this, name)).execute();
}
if (this.map[name] === null) {
qqq = this;
x = new AddName(void 0, this, name);
x.execute();
}
this.map[name].replace(content);
return this;
} else if (name != null) {
obj = (_ref = this.map[name]) != null ? _ref.val() : void 0;
if (obj instanceof types.ImmutableObject) {
return obj.val();
prop = this.map[name];
if ((prop != null) && !prop.isContentDeleted()) {
obj = prop.val();
if (obj instanceof types.ImmutableObject) {
return obj.val();
} else {
return obj;
}
} else {
return obj;
return void 0;
}
} else {
result = {};
_ref1 = this.map;
for (name in _ref1) {
o = _ref1[name];
obj = o.val();
if (obj instanceof types.ImmutableObject || obj instanceof MapManager) {
obj = obj.val();
_ref = this.map;
for (name in _ref) {
o = _ref[name];
if (!o.isContentDeleted()) {
obj = o.val();
if (obj instanceof types.ImmutableObject) {
obj = obj.val();
}
result[name] = obj;
}
result[name] = obj;
}
return result;
}
};
MapManager.prototype["delete"] = function(name) {
var _ref;
if ((_ref = this.map[name]) != null) {
_ref.deleteContent();
}
return this;
};
return MapManager;
})(types.Operation);
@ -221,9 +231,12 @@
ReplaceManager = (function(_super) {
__extends(ReplaceManager, _super);
function ReplaceManager(event_porperties, event_this, uid, beginning, end, prev, next, origin) {
this.event_porperties = event_porperties;
function ReplaceManager(event_properties, event_this, uid, beginning, end, prev, next, origin) {
this.event_properties = event_properties;
this.event_this = event_this;
if (this.event_properties['object'] == null) {
this.event_properties['object'] = this.event_this;
}
ReplaceManager.__super__.constructor.call(this, uid, beginning, end, prev, next, origin);
}
@ -253,11 +266,11 @@
ReplaceManager.prototype.callEventDecorator = function(events) {
var event, name, prop, _i, _len, _ref;
if (!this.isDeleted()) {
_ref = this.event_porperties;
for (name in _ref) {
prop = _ref[name];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
_ref = this.event_properties;
for (name in _ref) {
prop = _ref[name];
event[name] = prop;
}
}
@ -267,9 +280,18 @@
};
ReplaceManager.prototype.replace = function(content, replaceable_uid) {
var o;
var o, relp;
o = this.getLastOperation();
(new Replaceable(content, this, replaceable_uid, o, o.next_cl)).execute();
relp = (new Replaceable(content, this, replaceable_uid, o, o.next_cl)).execute();
return void 0;
};
ReplaceManager.prototype.isContentDeleted = function() {
return this.getLastOperation().isDeleted();
};
ReplaceManager.prototype.deleteContent = function() {
(new types.Delete(void 0, this.getLastOperation().uid)).execute();
return void 0;
};
@ -324,6 +346,8 @@
};
Replaceable.prototype.applyDelete = function() {
var res;
res = Replaceable.__super__.applyDelete.apply(this, arguments);
if (this.content != null) {
if (this.next_cl.type !== "Delimiter") {
this.content.deleteAllObservers();
@ -332,38 +356,50 @@
this.content.dontSync();
}
this.content = null;
return Replaceable.__super__.applyDelete.apply(this, arguments);
return res;
};
Replaceable.prototype.cleanup = function() {
return Replaceable.__super__.cleanup.apply(this, arguments);
};
Replaceable.prototype.callOperationSpecificEvents = function() {
Replaceable.prototype.callOperationSpecificInsertEvents = function() {
var old_value;
if (this.next_cl.type === "Delimiter" && this.prev_cl.type !== "Delimiter") {
old_value = this.prev_cl.content;
this.prev_cl.applyDelete();
this.parent.callEventDecorator([
{
type: "update",
changed_by: this.uid.creator,
changedBy: this.uid.creator,
oldValue: old_value
}
]);
this.prev_cl.applyDelete();
} else if (this.next_cl.type !== "Delimiter") {
this.applyDelete();
} else {
this.parent.callEventDecorator([
{
type: "add",
changed_by: this.uid.creator
changedBy: this.uid.creator
}
]);
}
return void 0;
};
Replaceable.prototype.callOperationSpecificDeleteEvents = function(o) {
if (this.next_cl.type === "Delimiter") {
return this.parent.callEventDecorator([
{
type: "delete",
changedBy: o.uid.creator,
oldValue: this.content
}
]);
}
};
Replaceable.prototype._encode = function() {
var json, _ref;
json = {

File diff suppressed because one or more lines are too long

View File

@ -197,37 +197,44 @@
var word;
word = this;
textfield.value = this.val();
this.on("insert", function(event, op) {
var fix, left, o_pos, right;
o_pos = op.getPosition();
fix = function(cursor) {
if (cursor <= o_pos) {
return cursor;
this.observe(function(events) {
var event, fix, left, o_pos, right, _i, _len, _results;
_results = [];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
if (event.type === "insert") {
o_pos = event.position;
fix = function(cursor) {
if (cursor <= o_pos) {
return cursor;
} else {
cursor += 1;
return cursor;
}
};
left = fix(textfield.selectionStart);
right = fix(textfield.selectionEnd);
textfield.value = word.val();
_results.push(textfield.setSelectionRange(left, right));
} else if (event.type === "delete") {
o_pos = event.position;
fix = function(cursor) {
if (cursor < o_pos) {
return cursor;
} else {
cursor -= 1;
return cursor;
}
};
left = fix(textfield.selectionStart);
right = fix(textfield.selectionEnd);
textfield.value = word.val();
_results.push(textfield.setSelectionRange(left, right));
} else {
cursor += 1;
return cursor;
_results.push(void 0);
}
};
left = fix(textfield.selectionStart);
right = fix(textfield.selectionEnd);
textfield.value = word.val();
return textfield.setSelectionRange(left, right);
});
this.on("delete", function(event, op) {
var fix, left, o_pos, right;
o_pos = op.getPosition();
fix = function(cursor) {
if (cursor < o_pos) {
return cursor;
} else {
cursor -= 1;
return cursor;
}
};
left = fix(textfield.selectionStart);
right = fix(textfield.selectionEnd);
textfield.value = word.val();
return textfield.setSelectionRange(left, right);
}
return _results;
});
textfield.onkeypress = function(event) {
var char, diff, new_pos, pos;

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

@ -57,16 +57,6 @@
</li>
</ul>
</ul>
<ul>
<li class='letter'>y</li>
<ul>
<li>
<a href='class/Yatta.html'>
Yatta
</a>
</li>
</ul>
</ul>
</div>
<h2>File Listing A-Z</h2>
<div class='index'>
@ -161,24 +151,11 @@
</li>
</ul>
</ul>
<ul>
<li class='letter'>y</li>
<ul>
<li>
<a href='file/lib/Yatta.coffee.html'>
Yatta.coffee
</a>
<small>
(lib)
</small>
</li>
</ul>
</ul>
</div>
</div>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -359,7 +359,7 @@ E.g.: let x = {a:[]}. Then x.a.push 1 wouldn&#39;t change anything</p>
</div>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -139,7 +139,7 @@ console.log(w.newProperty == &quot;Awesome&quot;) # true!</code></pre>
</div>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -389,7 +389,7 @@ yatta.bind(textbox);</code></pre>
</div>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -59,18 +59,6 @@
</small>
<small class='namespace'>
</small>
</li>
<li>
<a href='class/Yatta.html' target='main'>
Yatta
</a>
<small class='parent'>
<
types.JsonType
</small>
<small class='namespace'>
</small>
</li>
</ul>

View File

@ -38,7 +38,7 @@
</div>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -34,9 +34,9 @@
</p>
</nav>
<div id='filecontents'>
<h1 id="-yatta-https-dadamonad-github-io-files-layout-yatta_logo-png-"><img src="https://dadamonad.github.io/files/layout/Yatta_logo.png" alt="Yatta!"></h1><p>A Real-Time web framework that manages concurrency control for arbitrary data structures.
<h1 id="-yatta-https-dadamonad-github-io-files-layout-yatta_logo-png-"><img src="https://dadamonad.github.io/files/layout/Yatta_logo.png" alt="Yatta!"></h1><p>A Real-Time web framework that manages concurrency control for arbitrary data types.
Yatta! provides similar functionality as <a href="https://github.com/share/ShareJS">ShareJs</a> and <a href="https://github.com/opencoweb/coweb">OpenCoweb</a>,
but does not require you to understand how the internals work. The predefined data structures provide a simple API to access your shared data structures.</p><p>Predefined data structures:</p><ul>
but does not require you to understand how the internals work. The predefined data types provide a simple API to access your shared data types.</p><p>Predefined data types:</p><ul>
<li>Text - <a href="http://dadamonad.github.io/Yatta/examples/TextEditing/">Collaborative Text Editing Example</a></li>
<li>Json - <a href="http://dadamonad.github.io/Yatta/examples/PeerJs-Json/">Tutorial</a></li>
<li>XML - <a href="http://dadamonad.github.io/Yatta/examples/XmlExample/">XML Example</a> Collaboratively manipulate the dom with native dom-features and jQuery.</li>
@ -47,11 +47,10 @@ but does not require you to understand how the internals work. The predefined da
</ul>
<h2 id="use-it-">Use it!</h2><p>The <a href="./examples/">examples</a> provide an excellent starting point for beginners. Also the <a href="http://dadamonad.github.io/Yatta/doc/">API Documentation</a> could prove to be very helpful.</p><p>Either clone this git repository, install it with <a href="http://bower.io/">bower</a>, or install it with <a href="https://www.npmjs.org/package/yatta">npm</a>.</p><h3 id="bower">Bower</h3>
<pre><code>bower install Yatta
</code></pre><p>Then you include the libraries directly from the installation folder.</p><h3 id="npm">Npm</h3>
</code></pre><p>Then you include the libraries directly from the installation folder.</p><pre><code>&lt;script src=&quot;./bower_components/yatta.js&quot;&gt;&lt;/script&gt;
</code></pre><h3 id="npm">Npm</h3>
<pre><code>npm install yatta --save
</code></pre><p>And use it like this with <em>npm</em>:</p><pre><code>Y = require(&quot;yatta&quot;);
Y.createPeerJsConnector({key: &#39;xxx&#39;}, function(Connector, user_id){
yatta = new Y.JsonFramework(user_id, Connector);
</code></pre><p>And use it like this with <em>npm</em>:</p><pre><code>Yatta = require(&quot;yatta&quot;);
</code></pre><h2 id="about">About</h2><p>Find out more about the concurrent editing problem here
<a href="http://opencoweb.org/ocwdocs/intro/openg.html">Cooperation, Concurrency, Conflicts, and Convergence</a> and here
<a href="http://en.wikipedia.org/wiki/Operational_transformation">Operational Transformation (OT)</a></p><p>My Bachelor Thesis project aim was to develop a P2P OT Framework that enables collaboration on XML documents and supports
@ -76,7 +75,7 @@ But I would become really motivated if you gave me some feedback :) (<a href="ht
</ul>
<h2 id="support">Support</h2><p>Please report <em>any</em> issues to the <a href="https://github.com/DadaMonad/Yatta/issues">Github issue page</a>!
I would appreciate if developers gave me feedback on how <em>convenient</em> the framework is, and if it is easy to use. Particularly the XML-support may not support every DOM-methods - if you encounter a method that does not cause any change on other peers,
please state function name, and sample parameters. However, there are browser-specific features, that Yatta won&#39;t support.</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="&#109;&#97;&#x69;&#108;&#116;&#111;&#x3a;&#107;&#101;&#118;&#105;&#x6e;&#46;&#x6a;&#x61;&#104;&#110;&#115;&#64;&#114;&#119;&#x74;&#104;&#45;&#97;&#97;&#99;&#104;&#x65;&#x6e;&#x2e;&#x64;&#x65;">&#107;&#101;&#118;&#105;&#x6e;&#46;&#x6a;&#x61;&#104;&#110;&#115;&#64;&#114;&#119;&#x74;&#104;&#45;&#97;&#97;&#99;&#104;&#x65;&#x6e;&#x2e;&#x64;&#x65;</a>
please state function name, and sample parameters. However, there are browser-specific features, that Yatta won&#39;t support.</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="&#109;&#97;&#x69;&#108;&#x74;&#111;&#x3a;&#x6b;&#x65;&#118;&#105;&#x6e;&#x2e;&#x6a;&#97;&#x68;&#x6e;&#x73;&#x40;&#114;&#x77;&#116;&#x68;&#45;&#97;&#x61;&#99;&#x68;&#x65;&#x6e;&#46;&#100;&#101;">&#x6b;&#x65;&#118;&#105;&#x6e;&#x2e;&#x6a;&#97;&#x68;&#x6e;&#x73;&#x40;&#114;&#x77;&#116;&#x68;&#45;&#97;&#x61;&#99;&#x68;&#x65;&#x6e;&#46;&#100;&#101;</a>
@ -85,7 +84,7 @@ please state function name, and sample parameters. However, there are browser-sp
</div>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -106,7 +106,7 @@
</div>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -72,7 +72,7 @@
</dl>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -48,7 +48,7 @@
</dl>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
December 23, 14 11:09:09 by
January 02, 15 22:41:24 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -99,14 +99,6 @@
</li>
</ul>
<li>
<a href='file/lib/Yatta.coffee.html' target='main'>
Yatta.coffee
</a>
<small class='namespace'>
lib
</small>
</li>
</ul>
</ul>

View File

@ -1 +1 @@
window.searchData = [{"t":"JsonTypeWrapper","p":"class/JsonTypeWrapper.html"},{"t":"JsonType","p":"class/JsonType.html"},{"t":"WordType","p":"class/WordType.html"},{"t":"Yatta","p":"class/Yatta.html"},{"t":"lib/ConnectorAdapter.coffee","p":"file/lib/ConnectorAdapter.coffee.html"},{"t":"lib/Engine.coffee","p":"file/lib/Engine.coffee.html"},{"t":"lib/HistoryBuffer.coffee","p":"file/lib/HistoryBuffer.coffee.html"},{"t":"lib/Types/BasicTypes.coffee","p":"file/lib/Types/BasicTypes.coffee.html"},{"t":"lib/Types/JsonTypes.coffee","p":"file/lib/Types/JsonTypes.coffee.html"},{"t":"lib/Types/StructuredTypes.coffee","p":"file/lib/Types/StructuredTypes.coffee.html"},{"t":"lib/Types/TextTypes.coffee","p":"file/lib/Types/TextTypes.coffee.html"},{"t":"lib/Yatta.coffee","p":"file/lib/Yatta.coffee.html"},{"t":"README.md","p":"extra/README.md.html"},{"t":"LICENSE.txt","p":"extra/LICENSE.txt.html"},{"t":"WordType#_encode","p":"class/WordType.html#_encode-dynamic"},{"t":"JsonType#_encode","p":"class/JsonType.html#_encode-dynamic"},{"t":"lib/ConnectorAdapter.coffee~adaptConnector","p":"file/lib/ConnectorAdapter.coffee.html#adaptConnector-"},{"t":"JsonType#applyDelete","p":"class/JsonType.html#applyDelete-dynamic"},{"t":"WordType#applyDelete","p":"class/WordType.html#applyDelete-dynamic"},{"t":"WordType#bind","p":"class/WordType.html#bind-dynamic"},{"t":"JsonType#cleanup","p":"class/JsonType.html#cleanup-dynamic"},{"t":"WordType#cleanup","p":"class/WordType.html#cleanup-dynamic"},{"t":"Yatta#constructor","p":"class/Yatta.html#constructor-dynamic"},{"t":"JsonTypeWrapper#constructor","p":"class/JsonTypeWrapper.html#constructor-dynamic"},{"t":"WordType#constructor","p":"class/WordType.html#constructor-dynamic"},{"t":"lib/Yatta.coffee~createYatta","p":"file/lib/Yatta.coffee.html#createYatta-"},{"t":"WordType#deleteText","p":"class/WordType.html#deleteText-dynamic"},{"t":"Yatta#getConnector","p":"class/Yatta.html#getConnector-dynamic"},{"t":"WordType#insertAfter","p":"class/WordType.html#insertAfter-dynamic"},{"t":"WordType#insertText","p":"class/WordType.html#insertText-dynamic"},{"t":"WordType#push","p":"class/WordType.html#push-dynamic"},{"t":"JsonType#setMutableDefault","p":"class/JsonType.html#setMutableDefault-dynamic"},{"t":"JsonType#toJson","p":"class/JsonType.html#toJson-dynamic"},{"t":"WordType#toString","p":"class/WordType.html#toString-dynamic"},{"t":"WordType#val","p":"class/WordType.html#val-dynamic"},{"t":"JsonType#val","p":"class/JsonType.html#val-dynamic"}]
window.searchData = [{"t":"JsonTypeWrapper","p":"class/JsonTypeWrapper.html"},{"t":"JsonType","p":"class/JsonType.html"},{"t":"WordType","p":"class/WordType.html"},{"t":"lib/ConnectorAdapter.coffee","p":"file/lib/ConnectorAdapter.coffee.html"},{"t":"lib/Engine.coffee","p":"file/lib/Engine.coffee.html"},{"t":"lib/HistoryBuffer.coffee","p":"file/lib/HistoryBuffer.coffee.html"},{"t":"lib/Types/BasicTypes.coffee","p":"file/lib/Types/BasicTypes.coffee.html"},{"t":"lib/Types/JsonTypes.coffee","p":"file/lib/Types/JsonTypes.coffee.html"},{"t":"lib/Types/StructuredTypes.coffee","p":"file/lib/Types/StructuredTypes.coffee.html"},{"t":"lib/Types/TextTypes.coffee","p":"file/lib/Types/TextTypes.coffee.html"},{"t":"README.md","p":"extra/README.md.html"},{"t":"LICENSE.txt","p":"extra/LICENSE.txt.html"},{"t":"WordType#_encode","p":"class/WordType.html#_encode-dynamic"},{"t":"JsonType#_encode","p":"class/JsonType.html#_encode-dynamic"},{"t":"lib/ConnectorAdapter.coffee~adaptConnector","p":"file/lib/ConnectorAdapter.coffee.html#adaptConnector-"},{"t":"WordType#applyDelete","p":"class/WordType.html#applyDelete-dynamic"},{"t":"JsonType#applyDelete","p":"class/JsonType.html#applyDelete-dynamic"},{"t":"WordType#bind","p":"class/WordType.html#bind-dynamic"},{"t":"WordType#cleanup","p":"class/WordType.html#cleanup-dynamic"},{"t":"JsonType#cleanup","p":"class/JsonType.html#cleanup-dynamic"},{"t":"WordType#constructor","p":"class/WordType.html#constructor-dynamic"},{"t":"JsonTypeWrapper#constructor","p":"class/JsonTypeWrapper.html#constructor-dynamic"},{"t":"WordType#deleteText","p":"class/WordType.html#deleteText-dynamic"},{"t":"WordType#insertAfter","p":"class/WordType.html#insertAfter-dynamic"},{"t":"WordType#insertText","p":"class/WordType.html#insertText-dynamic"},{"t":"WordType#push","p":"class/WordType.html#push-dynamic"},{"t":"JsonType#setMutableDefault","p":"class/JsonType.html#setMutableDefault-dynamic"},{"t":"JsonType#toJson","p":"class/JsonType.html#toJson-dynamic"},{"t":"WordType#toString","p":"class/WordType.html#toString-dynamic"},{"t":"JsonType#val","p":"class/JsonType.html#val-dynamic"},{"t":"WordType#val","p":"class/WordType.html#val-dynamic"}]

View File

@ -53,14 +53,6 @@
(lib&#47;ConnectorAdapter.coffee)
</small>
</li>
<li>
<a href='class/JsonType.html#applyDelete-dynamic' target='main' title='applyDelete'>
#applyDelete
</a>
<small>
(JsonType)
</small>
</li>
<li>
<a href='class/WordType.html#applyDelete-dynamic' target='main' title='applyDelete'>
#applyDelete
@ -69,6 +61,14 @@
(WordType)
</small>
</li>
<li>
<a href='class/JsonType.html#applyDelete-dynamic' target='main' title='applyDelete'>
#applyDelete
</a>
<small>
(JsonType)
</small>
</li>
<li>
<a href='class/WordType.html#bind-dynamic' target='main' title='bind'>
#bind
@ -77,6 +77,14 @@
(WordType)
</small>
</li>
<li>
<a href='class/WordType.html#cleanup-dynamic' target='main' title='cleanup'>
#cleanup
</a>
<small>
(WordType)
</small>
</li>
<li>
<a href='class/JsonType.html#cleanup-dynamic' target='main' title='cleanup'>
#cleanup
@ -86,19 +94,11 @@
</small>
</li>
<li>
<a href='class/WordType.html#cleanup-dynamic' target='main' title='cleanup'>
#cleanup
</a>
<small>
(WordType)
</small>
</li>
<li>
<a href='class/Yatta.html#constructor-dynamic' target='main' title='constructor'>
<a href='class/WordType.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(Yatta)
(WordType)
</small>
</li>
<li>
@ -109,22 +109,6 @@
(JsonTypeWrapper)
</small>
</li>
<li>
<a href='class/WordType.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(WordType)
</small>
</li>
<li>
<a href='file/lib/Yatta.coffee.html#createYatta-' target='main' title='createYatta'>
~createYatta
</a>
<small>
(lib&#47;Yatta.coffee)
</small>
</li>
<li>
<a href='class/WordType.html#deleteText-dynamic' target='main' title='deleteText'>
#deleteText
@ -133,14 +117,6 @@
(WordType)
</small>
</li>
<li>
<a href='class/Yatta.html#getConnector-dynamic' target='main' title='getConnector'>
#getConnector
</a>
<small>
(Yatta)
</small>
</li>
<li>
<a href='class/WordType.html#insertAfter-dynamic' target='main' title='insertAfter'>
#insertAfter
@ -189,14 +165,6 @@
(WordType)
</small>
</li>
<li>
<a href='class/WordType.html#val-dynamic' target='main' title='val'>
#val
</a>
<small>
(WordType)
</small>
</li>
<li>
<a href='class/JsonType.html#val-dynamic' target='main' title='val'>
#val
@ -205,6 +173,14 @@
(JsonType)
</small>
</li>
<li>
<a href='class/WordType.html#val-dynamic' target='main' title='val'>
#val
</a>
<small>
(WordType)
</small>
</li>
</ul>
</div>
</body>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>PeerJs Json Example</title>
<script src="../../../Connector/xmpp-connector/strophe.js"></script>
<script src="../../../Connector/bower_components/strophejs-plugins/muc/strophe.muc.js"></script>
<script src="../../../Connector/xmpp-connector/xmpp-connector.js"></script>
<script src="../../build/browser/yatta.js"></script>
<script src="./index.js"></script>
</head>
<body>
<h1> PeerJs + Json Tutorial</h1>
<p> Collaborative Json editing with <a href="https://github.com/DadaMonad/Yatta/">Yatta</a>
and <a href="http://peerjs.com/">PeerJs</a> (WebRTC). </p>
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
<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/PeerJs-Json">here</a>.
</p>
</body>
</html>

View File

@ -0,0 +1,53 @@
/**
## 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 Json Framework. Open
[index.html](http://dadamonad.github.io/Yatta/examples/PeerJs-Json/index.html) in your Browser and
use the console to explore Yatta!
[PeerJs](http://peerjs.com) is a Framework that enables you to connect to other peers. You just need the
user-id of the peer (browser/client). And then you can connect to it.
First you have to include the following libraries in your html file:
```
<script src="http://cdn.peerjs.com/0.3/peer.js"></script>
<script src="../../build/browser/Frameworks/JsonFramework.js"></script>
<script src="../../build/browser/Connectors/PeerJsConnector.js"></script>
<script src="./index.js"></script>
```
### Create Connector
The PeerJs Framework requires an API key, or you need to set up your own PeerJs server.
Get an API key from the [Website](http://peerjs.com/peerserver).
The first parameter of `createPeerJsConnector` is forwarded as the options object in PeerJs.
Therefore, you may also specify the server/port here, if you have set up your own server.
*/
var yatta, yattaHandler;
/**
This will connect to the server owned by the peerjs team.
For now, you can use my API key.
*/
connector = new XMPPConnector();
/**
### Yatta
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 Yatta(connector);
window.onload = function(){
var textbox = document.getElementById("textfield");
yatta.observe(function(events){
for(var i=0; i<events.length; i++){
var event = events[i];
if(event.name === "textfield" && event.type !== "delete"){
yatta.val("textfield").bind(textbox);
}
}
});
yatta.val("textfield","");
};

View File

@ -20,7 +20,7 @@ cache = require 'gulp-cached'
gulp.task 'default', ['deploy']
gulp.task 'default', ['build_browser']
files =
lib : ['./lib/**/*.coffee']

View File

@ -22,6 +22,15 @@ class HistoryBuffer
@reserved_identifier_counter = 0
setTimeout @emptyGarbage, @garbageCollectTimeout
resetUserId: (id)->
own = @buffer[@user_id]
if own?
for o in own
o.uid.creator = id
@operation_counter[id] = @operation_counter[@user_id]
delete @operation_counter[@user_id]
@user_id = id
emptyGarbage: ()=>
for o in @garbage
#if @getOperationCounter(o.uid.creator) > o.uid.op_number

View File

@ -108,6 +108,7 @@ module.exports = (HB)->
# @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.
#
constructor: (uid, beginning, end, prev, next, origin)->
@textfields = []
super uid, beginning, end, prev, next, origin
#
@ -123,6 +124,10 @@ module.exports = (HB)->
type: "WordType"
applyDelete: ()->
for textfield in @textfields
textfield.onkeypress = null
textfield.onpaste = null
textfield.oncut = null
o = @beginning
while o?
o.applyDelete()
@ -205,6 +210,7 @@ module.exports = (HB)->
bind: (textfield)->
word = @
textfield.value = @val()
@textfields.push textfield
@observe (events)->
for event in events

View File

@ -5,7 +5,14 @@ Engine = require "./Engine"
adaptConnector = require "./ConnectorAdapter"
createYatta = (connector)->
user_id = connector.id # TODO: change to getUniqueId()
user_id = null
if connector.id?
user_id = connector.id # TODO: change to getUniqueId()
else
user_id = "_temp"
connector.whenUserIdSet (id)->
user_id = id
HB.resetUserId id
HB = new HistoryBuffer user_id
type_manager = json_types_uninitialized HB
types = type_manager.types

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long