updated examples

This commit is contained in:
Kevin Jahns 2015-04-30 14:15:48 +02:00
parent 8a5b69e86c
commit 4d926cf841
18 changed files with 256 additions and 205 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "0.4.1", "version": "0.5.0",
"homepage": "https://github.com/DadaMonad/yjs", "homepage": "https://github.com/DadaMonad/yjs",
"authors": [ "authors": [
"Kevin Jahns <kevin.jahns@rwth-aachen.de>" "Kevin Jahns <kevin.jahns@rwth-aachen.de>"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,10 +38,12 @@ module.exports = {
this.connections = {}; this.connections = {};
this.current_sync_target = null; this.current_sync_target = null;
this.sent_hb_to_all_users = false; this.sent_hb_to_all_users = false;
this.is_initialized = true; return this.is_initialized = true;
return this.connections_listeners = [];
}, },
onUserEvent: function(f) { onUserEvent: function(f) {
if (this.connections_listeners == null) {
this.connections_listeners = [];
}
return this.connections_listeners.push(f); return this.connections_listeners.push(f);
}, },
isRoleMaster: function() { isRoleMaster: function() {
@ -72,6 +74,7 @@ module.exports = {
var f, i, len, ref, results; var f, i, len, ref, results;
delete this.connections[user]; delete this.connections[user];
this.findNewSyncTarget(); this.findNewSyncTarget();
if (this.connections_listeners != null) {
ref = this.connections_listeners; ref = this.connections_listeners;
results = []; results = [];
for (i = 0, len = ref.length; i < len; i++) { for (i = 0, len = ref.length; i < len; i++) {
@ -82,6 +85,7 @@ module.exports = {
})); }));
} }
return results; return results;
}
}, },
userJoined: function(user, role) { userJoined: function(user, role) {
var base, f, i, len, ref, results; var base, f, i, len, ref, results;
@ -99,6 +103,7 @@ module.exports = {
this.performSyncWithMaster(user); this.performSyncWithMaster(user);
} }
} }
if (this.connections_listeners != null) {
ref = this.connections_listeners; ref = this.connections_listeners;
results = []; results = [];
for (i = 0, len = ref.length; i < len; i++) { for (i = 0, len = ref.length; i < len; i++) {
@ -110,6 +115,7 @@ module.exports = {
})); }));
} }
return results; return results;
}
}, },
whenSynced: function(args) { whenSynced: function(args) {
if (args.constructore === Function) { if (args.constructore === Function) {

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

@ -4,6 +4,7 @@
<meta charset=utf-8 /> <meta charset=utf-8 />
<title>Y Example</title> <title>Y Example</title>
<script src="../../build/browser/y.js"></script> <script src="../../build/browser/y.js"></script>
<script src="../../../y-text/build/browser/y-text.js"></script>
<script src="../../../y-webrtc/build/browser/y-webrtc.js"></script> <script src="../../../y-webrtc/build/browser/y-webrtc.js"></script>
<script src="./index.js"></script> <script src="./index.js"></script>
</head> </head>
@ -14,7 +15,7 @@ and WebRTC Connector. </p>
<textarea style="width:80%;" rows=40 id="textfield"></textarea> <textarea style="width:80%;" rows=40 id="textfield"></textarea>
<p> <a href="https://github.com/rwth-acis/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types. <p> <a href="https://github.com/y-js/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
</p> </p>
</body> </body>
</html> </html>

View File

@ -19,8 +19,8 @@ window.onload = function(){
}); });
connector.whenSynced(function(){ connector.whenSynced(function(){
if(y.val("textfield") == null){ if(y.val("textfield") == null){
y.val("headline","headline", "mutable"); y.val("headline", new Y.Text("headline"));
y.val("textfield","stuff", "mutable") y.val("textfield",new Y.Text("stuff"))
} }
}) })

View File

@ -1,3 +1,5 @@
<script src="../../build/browser/y.js"></script>
<script src="../../../y-text/build/browser/y-text.js"></script>
<link rel="import" href="../../build/browser/y-object.html"> <link rel="import" href="../../build/browser/y-object.html">
<link rel="import" href="../../../y-xmpp/build/browser/y-xmpp.html"> <link rel="import" href="../../../y-xmpp/build/browser/y-xmpp.html">
<link rel="import" href="../../../paper-slider/paper-slider.html"> <link rel="import" href="../../../paper-slider/paper-slider.html">
@ -28,7 +30,7 @@
var that = this; var that = this;
this.connector.whenSynced(function(){ this.connector.whenSynced(function(){
if(that.y.val("text") == null){ if(that.y.val("text") == null){
that.y.val("text","stuff","mutable"); that.y.val("text",Y.Text("stuff"));
} }
that.y.val("text").bind(that.$.text,that.shadowRoot) that.y.val("text").bind(that.$.text,that.shadowRoot)
}) })

View File

@ -4,6 +4,7 @@
<meta charset=utf-8 /> <meta charset=utf-8 />
<title>Y Example</title> <title>Y Example</title>
<script src="../../build/browser/y.js"></script> <script src="../../build/browser/y.js"></script>
<script src="../../../y-text/build/browser/y-text.js"></script>
<script src="../../../y-xmpp/y-xmpp.js"></script> <script src="../../../y-xmpp/y-xmpp.js"></script>
<script src="./index.js"></script> <script src="./index.js"></script>
</head> </head>
@ -14,7 +15,7 @@ and XMPP Connector. </p>
<textarea style="width:80%;" rows=40 id="textfield"></textarea> <textarea style="width:80%;" rows=40 id="textfield"></textarea>
<p> <a href="https://github.com/rwth-acis/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types. <p> <a href="https://github.com/y-js/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
</p> </p>
</body> </body>
</html> </html>

View File

@ -18,8 +18,8 @@ window.onload = function(){
}); });
connector.whenSynced(function(){ connector.whenSynced(function(){
if(y.val("textfield") == null){ if(y.val("textfield") == null){
y.val("headline","headline", "mutable"); y.val("headline", new Y.Text("headline"));
y.val("textfield","stuff", "mutable") y.val("textfield",new Y.Text("stuff"))
} }
}) })

View File

@ -70,6 +70,7 @@ module.exports =
userLeft: (user)-> userLeft: (user)->
delete @connections[user] delete @connections[user]
@findNewSyncTarget() @findNewSyncTarget()
if @connections_listeners?
for f in @connections_listeners for f in @connections_listeners
f { f {
action: "userLeft" action: "userLeft"
@ -91,6 +92,7 @@ module.exports =
# TODO: What if there are two masters? Prevent sending everything two times! # TODO: What if there are two masters? Prevent sending everything two times!
@performSyncWithMaster user @performSyncWithMaster user
if @connections_listeners?
for f in @connections_listeners for f in @connections_listeners
f { f {
action: "userJoined" action: "userJoined"

View File

@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "0.4.1", "version": "0.5.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/y.js", "main": "./build/node/y.js",
"scripts": { "scripts": {

File diff suppressed because one or more lines are too long

4
y.js

File diff suppressed because one or more lines are too long