Issue #6: Events carry creator information
This commit is contained in:
parent
68c17f1876
commit
b750d95b98
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
@ -11,6 +11,7 @@
|
|||||||
function Operation(uid) {
|
function Operation(uid) {
|
||||||
this.is_deleted = false;
|
this.is_deleted = false;
|
||||||
this.doSync = true;
|
this.doSync = true;
|
||||||
|
this.garbage_collected = false;
|
||||||
if (uid != null) {
|
if (uid != null) {
|
||||||
this.doSync = !isNaN(parseInt(uid.op_number));
|
this.doSync = !isNaN(parseInt(uid.op_number));
|
||||||
} else {
|
} else {
|
||||||
@ -85,9 +86,10 @@
|
|||||||
if (garbagecollect == null) {
|
if (garbagecollect == null) {
|
||||||
garbagecollect = true;
|
garbagecollect = true;
|
||||||
}
|
}
|
||||||
if (!this.isDeleted()) {
|
if (!this.garbage_collected) {
|
||||||
this.is_deleted = true;
|
this.is_deleted = true;
|
||||||
if (garbagecollect) {
|
if (garbagecollect) {
|
||||||
|
this.garbage_collected = true;
|
||||||
return HB.addToGarbageCollector(this);
|
return HB.addToGarbageCollector(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +222,7 @@
|
|||||||
this.deleted_by = [];
|
this.deleted_by = [];
|
||||||
}
|
}
|
||||||
if ((this.parent != null) && !this.isDeleted()) {
|
if ((this.parent != null) && !this.isDeleted()) {
|
||||||
this.parent.callEvent("delete", this);
|
this.parent.callEvent("delete", this, o);
|
||||||
}
|
}
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
this.deleted_by.push(o);
|
this.deleted_by.push(o);
|
||||||
@ -228,10 +230,11 @@
|
|||||||
garbagecollect = false;
|
garbagecollect = false;
|
||||||
if (this.prev_cl.isDeleted()) {
|
if (this.prev_cl.isDeleted()) {
|
||||||
garbagecollect = true;
|
garbagecollect = true;
|
||||||
} else if (this.next_cl.isDeleted()) {
|
|
||||||
this.next_cl.applyDelete();
|
|
||||||
}
|
}
|
||||||
return Insert.__super__.applyDelete.call(this, garbagecollect);
|
Insert.__super__.applyDelete.call(this, garbagecollect);
|
||||||
|
if (this.next_cl.isDeleted()) {
|
||||||
|
return this.next_cl.applyDelete();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Insert.prototype.cleanup = function() {
|
Insert.prototype.cleanup = function() {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -242,27 +242,24 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ReplaceManager.prototype.setParent = function(parent, property_name) {
|
ReplaceManager.prototype.setParent = function(parent, property_name) {
|
||||||
var addPropertyListener;
|
var addPropertyListener, repl_manager;
|
||||||
this.on('insert', (function(_this) {
|
repl_manager = this;
|
||||||
return function(event, op) {
|
this.on('insert', function(event, op) {
|
||||||
if (op.next_cl instanceof types.Delimiter) {
|
if (op.next_cl instanceof types.Delimiter) {
|
||||||
return _this.parent.callEvent('change', property_name);
|
return repl_manager.parent.callEvent('change', property_name, op);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
})(this));
|
this.on('change', function(event, op) {
|
||||||
this.on('change', (function(_this) {
|
if (repl_manager !== this) {
|
||||||
return function(event) {
|
return repl_manager.parent.callEvent('change', property_name, op);
|
||||||
return _this.parent.callEvent('change', property_name);
|
}
|
||||||
};
|
});
|
||||||
})(this));
|
addPropertyListener = function(event, op) {
|
||||||
addPropertyListener = (function(_this) {
|
if (op.next_cl instanceof types.Delimiter && op.prev_cl instanceof types.Delimiter) {
|
||||||
return function(event, op) {
|
repl_manager.parent.callEvent('addProperty', property_name, op);
|
||||||
if (op.next_cl instanceof types.Delimiter && op.prev_cl instanceof types.Delimiter) {
|
}
|
||||||
_this.parent.callEvent('addProperty', property_name);
|
return repl_manager.deleteListener('addProperty', addPropertyListener);
|
||||||
}
|
};
|
||||||
return _this.deleteListener('addProperty', addPropertyListener);
|
|
||||||
};
|
|
||||||
})(this);
|
|
||||||
this.on('insert', addPropertyListener);
|
this.on('insert', addPropertyListener);
|
||||||
return ReplaceManager.__super__.setParent.call(this, parent);
|
return ReplaceManager.__super__.setParent.call(this, parent);
|
||||||
};
|
};
|
||||||
|
File diff suppressed because one or more lines are too long
@ -174,10 +174,16 @@
|
|||||||
WordType.prototype.setReplaceManager = function(op) {
|
WordType.prototype.setReplaceManager = function(op) {
|
||||||
this.saveOperation('replace_manager', op);
|
this.saveOperation('replace_manager', op);
|
||||||
this.validateSavedOperations();
|
this.validateSavedOperations();
|
||||||
return this.on(['insert', 'delete'], (function(_this) {
|
this.on('insert', (function(_this) {
|
||||||
return function() {
|
return function(event, ins) {
|
||||||
var _ref;
|
var _ref;
|
||||||
return (_ref = _this.replace_manager) != null ? _ref.callEvent('change') : void 0;
|
return (_ref = _this.replace_manager) != null ? _ref.forwardEvent(_this, 'change', ins) : void 0;
|
||||||
|
};
|
||||||
|
})(this));
|
||||||
|
return this.on('delete', (function(_this) {
|
||||||
|
return function(event, ins, del) {
|
||||||
|
var _ref;
|
||||||
|
return (_ref = _this.replace_manager) != null ? _ref.forwardEvent(_this, 'change', del) : void 0;
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
};
|
};
|
||||||
|
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
@ -248,7 +248,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -302,7 +302,7 @@ data from the received intent.</p>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -335,7 +335,7 @@ JsonFramework was initialized (Depending on the HistoryBuffer implementation).</
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -466,7 +466,7 @@ if (x.type === "JsonType") {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -139,7 +139,7 @@ console.log(w.newProperty == "Awesome") # true!</code></pre>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -222,7 +222,7 @@ on how to do that with urls.</p>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -356,7 +356,7 @@ JsonFramework was initialized (Depending on the HistoryBuffer implementation).</
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -415,7 +415,7 @@ yatta.bind(textbox);</code></pre>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -66,11 +66,11 @@ on which the operation was created. This is not necessary in Yata.</p><p>The dow
|
|||||||
In contrast, an OT algorithm can have an empty History Buffer while the document size is very big.</p><p>Eventually (after my thesis), I will publish more information about Yata.</p><p>So, how did I come up with the name for the implementation (Yatta! is not Yata)?
|
In contrast, an OT algorithm can have an empty History Buffer while the document size is very big.</p><p>Eventually (after my thesis), I will publish more information about Yata.</p><p>So, how did I come up with the name for the implementation (Yatta! is not Yata)?
|
||||||
Yatta! means "I did it!" in Japanese. You scream it when you accomplish something (for proper application I refer to the Yatta-man in <a href="http://heroeswiki.com/Yatta!">Heroes</a>).
|
Yatta! means "I did it!" in Japanese. You scream it when you accomplish something (for proper application I refer to the Yatta-man in <a href="http://heroeswiki.com/Yatta!">Heroes</a>).
|
||||||
There is also this awesome video on the Internet that will change your life <a href="https://www.youtube.com/watch?v=kL5DDSglM_s">Yatta</a>.</p><h2 id="status">Status</h2><p>Yatta! is still in an early development phase. Don't expect that everything is working fine.
|
There is also this awesome video on the Internet that will change your life <a href="https://www.youtube.com/watch?v=kL5DDSglM_s">Yatta</a>.</p><h2 id="status">Status</h2><p>Yatta! is still in an early development phase. Don't expect that everything is working fine.
|
||||||
But I would become really motivated if you gave me some feedback :) (<a href="https://github.com/DadaMonad/Yatta/issues">github</a>).</p><h3 id="current-issues">Current Issues</h3><p>Currently, I don't perform Garbage Collection. Therefore, the space requirement will never decrease.</p><ul>
|
But I would become really motivated if you gave me some feedback :) (<a href="https://github.com/DadaMonad/Yatta/issues">github</a>).</p><h3 id="current-issues">Current Issues</h3>
|
||||||
<li>Garbage Collection</li>
|
<ul>
|
||||||
<li>XML support</li>
|
<li>XML support</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2 id="support">Support</h2><p>Please report any issues to the <a href="https://github.com/DadaMonad/Yatta/issues">Github issue page</a>!</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="mailto:kevin.jahns@rwth-aachen.de">kevin.jahns@rwth-aachen.de</a>
|
<h2 id="support">Support</h2><p>Please report any issues to the <a href="https://github.com/DadaMonad/Yatta/issues">Github issue page</a>!</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="mailto:kevin.jahns@rwth-aachen.de">kevin.jahns@rwth-aachen.de</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ But I would become really motivated if you gave me some feedback :) (<a href="ht
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -158,7 +158,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
September 17, 14 16:00:52 by
|
September 17, 14 18:11:46 by
|
||||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||||
Codo
|
Codo
|
||||||
</a>
|
</a>
|
||||||
|
@ -170,8 +170,9 @@ Apply a 'addProperty' - listener to a JsonType.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function addProperty(event_name, property_name){
|
function addProperty(event_name, property_name, op){
|
||||||
console.log("Property '" + property_name + "' was created!");
|
// op is the operation that changed the objects value. In addProperty it is most likely to be a 'Replaceable' (see doc).
|
||||||
|
console.log("Property '" + property_name + "' was created by '"+op.creator+"'!");
|
||||||
console.log("Value: " + show(this.val(property_name))); // 'this' is the object on which the property was created.
|
console.log("Value: " + show(this.val(property_name))); // 'this' is the object on which the property was created.
|
||||||
};
|
};
|
||||||
yatta.on('addProperty', addProperty);
|
yatta.on('addProperty', addProperty);
|
||||||
@ -183,8 +184,13 @@ Apply a 'change' - listener to a JsonType.
|
|||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function change(event_name, property_name){
|
function change(event_name, property_name, op){
|
||||||
console.log("Value of property '" + property_name + "' changed!");
|
// Check who made this property change!
|
||||||
|
if(op.creator == yatta.getUserId()){
|
||||||
|
console.log("You changed the value of property '" + property_name + "'!");
|
||||||
|
}else{
|
||||||
|
console.log("User '"+op.creator+"' changed the value of property '" + property_name + "'!");
|
||||||
|
}
|
||||||
console.log("New value: " + show(this.val(property_name)) + ""); // 'this' is the object on which the property changed.
|
console.log("New value: " + show(this.val(property_name)) + ""); // 'this' is the object on which the property changed.
|
||||||
};
|
};
|
||||||
yatta.on('change', change);
|
yatta.on('change', change);
|
||||||
|
@ -135,8 +135,9 @@ Y.createPeerJsConnector("unique_id", {key: 'h7nlefbgavh1tt9'}, function(Connecto
|
|||||||
### Add listeners
|
### Add listeners
|
||||||
Apply a 'addProperty' - listener to a JsonType.
|
Apply a 'addProperty' - listener to a JsonType.
|
||||||
*/
|
*/
|
||||||
function addProperty(event_name, property_name){
|
function addProperty(event_name, property_name, op){
|
||||||
console.log("Property '" + property_name + "' was created!");
|
// op is the operation that changed the objects value. In addProperty it is most likely to be a 'Replaceable' (see doc).
|
||||||
|
console.log("Property '" + property_name + "' was created by '"+op.creator+"'!");
|
||||||
console.log("Value: " + show(this.val(property_name))); // 'this' is the object on which the property was created.
|
console.log("Value: " + show(this.val(property_name))); // 'this' is the object on which the property was created.
|
||||||
};
|
};
|
||||||
yatta.on('addProperty', addProperty);
|
yatta.on('addProperty', addProperty);
|
||||||
@ -145,8 +146,13 @@ Y.createPeerJsConnector("unique_id", {key: 'h7nlefbgavh1tt9'}, function(Connecto
|
|||||||
/**
|
/**
|
||||||
Apply a 'change' - listener to a JsonType.
|
Apply a 'change' - listener to a JsonType.
|
||||||
*/
|
*/
|
||||||
function change(event_name, property_name){
|
function change(event_name, property_name, op){
|
||||||
console.log("Value of property '" + property_name + "' changed!");
|
// Check who made this property change!
|
||||||
|
if(op.creator == yatta.getUserId()){
|
||||||
|
console.log("You changed the value of property '" + property_name + "'!");
|
||||||
|
}else{
|
||||||
|
console.log("User '"+op.creator+"' changed the value of property '" + property_name + "'!");
|
||||||
|
}
|
||||||
console.log("New value: " + show(this.val(property_name)) + ""); // 'this' is the object on which the property changed.
|
console.log("New value: " + show(this.val(property_name)) + ""); // 'this' is the object on which the property changed.
|
||||||
};
|
};
|
||||||
yatta.on('change', change);
|
yatta.on('change', change);
|
||||||
|
@ -272,7 +272,7 @@ module.exports = (HB)->
|
|||||||
@deleted_by ?= []
|
@deleted_by ?= []
|
||||||
if @parent? and not @isDeleted()
|
if @parent? and not @isDeleted()
|
||||||
# call iff wasn't deleted earlyer
|
# call iff wasn't deleted earlyer
|
||||||
@parent.callEvent "delete", @
|
@parent.callEvent "delete", @, o
|
||||||
if o?
|
if o?
|
||||||
@deleted_by.push o
|
@deleted_by.push o
|
||||||
garbagecollect = false
|
garbagecollect = false
|
||||||
|
@ -248,16 +248,18 @@ module.exports = (HB)->
|
|||||||
# Add change listeners for parent.
|
# Add change listeners for parent.
|
||||||
#
|
#
|
||||||
setParent: (parent, property_name)->
|
setParent: (parent, property_name)->
|
||||||
@on 'insert', (event, op)=>
|
repl_manager = this
|
||||||
|
@on 'insert', (event, op)->
|
||||||
if op.next_cl instanceof types.Delimiter
|
if op.next_cl instanceof types.Delimiter
|
||||||
@parent.callEvent 'change', property_name
|
repl_manager.parent.callEvent 'change', property_name, op
|
||||||
@on 'change', (event)=>
|
@on 'change', (event, op)->
|
||||||
@parent.callEvent 'change', property_name
|
if repl_manager isnt this
|
||||||
|
repl_manager.parent.callEvent 'change', property_name, op
|
||||||
# Call this, when the first element is inserted. Then delete the listener.
|
# Call this, when the first element is inserted. Then delete the listener.
|
||||||
addPropertyListener = (event, op)=>
|
addPropertyListener = (event, op)->
|
||||||
if op.next_cl instanceof types.Delimiter and op.prev_cl instanceof types.Delimiter
|
if op.next_cl instanceof types.Delimiter and op.prev_cl instanceof types.Delimiter
|
||||||
@parent.callEvent 'addProperty', property_name
|
repl_manager.parent.callEvent 'addProperty', property_name, op
|
||||||
@deleteListener 'addProperty', addPropertyListener
|
repl_manager.deleteListener 'addProperty', addPropertyListener
|
||||||
@on 'insert', addPropertyListener
|
@on 'insert', addPropertyListener
|
||||||
super parent
|
super parent
|
||||||
|
|
||||||
|
@ -196,9 +196,10 @@ module.exports = (HB)->
|
|||||||
setReplaceManager: (op)->
|
setReplaceManager: (op)->
|
||||||
@saveOperation 'replace_manager', op
|
@saveOperation 'replace_manager', op
|
||||||
@validateSavedOperations()
|
@validateSavedOperations()
|
||||||
@on ['insert', 'delete'], ()=>
|
@on 'insert', (event, ins)=>
|
||||||
@replace_manager?.callEvent 'change'
|
@replace_manager?.forwardEvent @, 'change', ins
|
||||||
|
@on 'delete', (event, ins, del)=>
|
||||||
|
@replace_manager?.forwardEvent @, 'change', del
|
||||||
#
|
#
|
||||||
# Bind this WordType to a textfield or input field.
|
# Bind this WordType to a textfield or input field.
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yatta",
|
"name": "yatta",
|
||||||
"version": "0.0.5",
|
"version": "0.1.0",
|
||||||
"description": "A Framework that enables Real-Time Collaboration on arbitrary data structures.",
|
"description": "A Framework that enables Real-Time Collaboration on arbitrary data structures.",
|
||||||
"main": "./build/node/index",
|
"main": "./build/node/index",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user