added support for namespaces on types

This commit is contained in:
DadaMonad 2015-03-09 17:38:26 +00:00
parent 148e46f043
commit 446560d9e8
14 changed files with 546 additions and 356 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

@ -131,7 +131,7 @@ module.exports = {
for (_i = 0, _len = hb.length; _i < _len; _i++) {
o = hb[_i];
_hb.push(o);
if (_hb.length > 30) {
if (_hb.length > 10) {
this.broadcast({
sync_step: "applyHB_",
data: _hb
@ -159,7 +159,7 @@ module.exports = {
for (_i = 0, _len = hb.length; _i < _len; _i++) {
o = hb[_i];
_hb.push(o);
if (_hb.length > 30) {
if (_hb.length > 10) {
this.broadcast({
sync_step: "applyHB_",
data: _hb
@ -221,7 +221,7 @@ module.exports = {
for (_j = 0, _len1 = hb.length; _j < _len1; _j++) {
o = hb[_j];
_hb.push(o);
if (_hb.length > 30) {
if (_hb.length > 10) {
sendApplyHB({
sync_step: "applyHB_",
data: _hb

View File

@ -190,11 +190,18 @@ module.exports = function() {
};
Operation.prototype.getCustomType = function() {
var Type, t, _i, _len, _ref;
if (this.custom_type == null) {
throw new Error("This operation was not initialized with a custom type");
}
if (this.custom_type.constructor === String) {
this.custom_type = new this.custom_types[this.custom_type]();
Type = this.custom_types;
_ref = this.custom_type.split(".");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
t = _ref[_i];
Type = Type[t];
}
this.custom_type = new Type();
this.custom_type._setModel(this);
}
return this.custom_type;

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,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Y Example</title>
<script src="../../build/browser/y.js"></script>
<script src="../../../y-xmpp/y-xmpp.js"></script>
<script src="./index.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<h1> yjs HTML </h1>
<p> Collaborative editing on HTML with <a href="https://github.com/rwth-acis/yjs/">yjs</a>
and XMPP Connector. </p>
<p> <a href="https://github.com/rwth-acis/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
</p>
</body>
</html>

View File

@ -1,26 +0,0 @@
connector = new Y.XMPP().join("testy-xmpp-json3", {syncMode: "syncAll"});
connector.debug = true
y = new Y(connector);
window.onload = function(){
var textbox = document.getElementById("textfield");
y.observe(function(events){
for(var i=0; i<events.length; i++){
var event = events[i];
if(event.name === "textfield" && event.type !== "delete"){
y.val("textfield").bind(textbox);
y.val("headline").bind(document.querySelector("h1"))
}
}
});
connector.whenSynced(function(){
if(y.val("textfield") == null){
y.val("headline","headline", "mutable");
y.val("textfield","stuff", "mutable")
}
})
};

View File

@ -133,7 +133,7 @@ module.exports =
_hb = []
for o in hb
_hb.push o
if _hb.length > 30
if _hb.length > 10
@broadcast
sync_step: "applyHB_"
data: _hb
@ -158,7 +158,7 @@ module.exports =
_hb = []
for o in hb
_hb.push o
if _hb.length > 30
if _hb.length > 10
@broadcast
sync_step: "applyHB_"
data: _hb
@ -207,7 +207,7 @@ module.exports =
for o in hb
_hb.push o
if _hb.length > 30
if _hb.length > 10
sendApplyHB
sync_step: "applyHB_"
data: _hb

View File

@ -227,7 +227,10 @@ module.exports = ()->
throw new Error "This operation was not initialized with a custom type"
if @custom_type.constructor is String
# has not been initialized yet (only the name is specified)
@custom_type = new @custom_types[@custom_type]()
Type = @custom_types
for t in @custom_type.split(".")
Type = Type[t]
@custom_type = new Type()
@custom_type._setModel @
@custom_type

File diff suppressed because one or more lines are too long

2
y.js

File diff suppressed because one or more lines are too long