added textbind example, improved & fixed syncing, RBTree handles ids correctly now, webrtc connector is quite reliable now

This commit is contained in:
Kevin Jahns
2015-07-16 06:15:23 +02:00
parent f9f8228db6
commit f78dc52d7b
14 changed files with 473 additions and 66 deletions

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Y Example</title>
<script src="../../node_modules/simplewebrtc/simplewebrtc.bundle.js"></script>
<script src="../../y.js"></script>
<script src="./index.js"></script>
</head>
<body>
<h1 contentEditable> yjs Tutorial</h1>
<p> Collaborative Json editing with <a href="https://github.com/rwth-acis/yjs/">yjs</a>
and XMPP Connector. </p>
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
<p> <a href="https://github.com/y-js/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
</p>
</body>
</html>

View File

@@ -0,0 +1,27 @@
Y({
db: {
name: "Memory"
},
connector: {
name: "WebRTC",
room: "mineeeeeee",
debug: true
}
}).then(function(yconfig){
window.y = yconfig.root;
window.yconfig = yconfig;
var textarea = document.getElementById("textfield");
yconfig.root.observe(function(events){
for (var e in events) {
var event = events[e];
if (event.name === "text" && (event.type === "add" || event.type === "update")) {
event.object.get(event.name).then(function(text){ //eslint-disable-line
text.bind(textarea);
window.ytext = text;
});
}
}
});
yconfig.root.set("text", Y.TextBind);
});