updated examples
This commit is contained in:
+1
-1
@@ -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>"
|
||||||
|
|||||||
+28
-22
File diff suppressed because one or more lines are too long
+28
-22
File diff suppressed because one or more lines are too long
@@ -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,16 +74,18 @@ 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();
|
||||||
ref = this.connections_listeners;
|
if (this.connections_listeners != null) {
|
||||||
results = [];
|
ref = this.connections_listeners;
|
||||||
for (i = 0, len = ref.length; i < len; i++) {
|
results = [];
|
||||||
f = ref[i];
|
for (i = 0, len = ref.length; i < len; i++) {
|
||||||
results.push(f({
|
f = ref[i];
|
||||||
action: "userLeft",
|
results.push(f({
|
||||||
user: user
|
action: "userLeft",
|
||||||
}));
|
user: user
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
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,17 +103,19 @@ module.exports = {
|
|||||||
this.performSyncWithMaster(user);
|
this.performSyncWithMaster(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref = this.connections_listeners;
|
if (this.connections_listeners != null) {
|
||||||
results = [];
|
ref = this.connections_listeners;
|
||||||
for (i = 0, len = ref.length; i < len; i++) {
|
results = [];
|
||||||
f = ref[i];
|
for (i = 0, len = ref.length; i < len; i++) {
|
||||||
results.push(f({
|
f = ref[i];
|
||||||
action: "userJoined",
|
results.push(f({
|
||||||
user: user,
|
action: "userJoined",
|
||||||
role: role
|
user: user,
|
||||||
}));
|
role: role
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
return results;
|
|
||||||
},
|
},
|
||||||
whenSynced: function(args) {
|
whenSynced: function(args) {
|
||||||
if (args.constructore === Function) {
|
if (args.constructore === Function) {
|
||||||
|
|||||||
+28
-22
File diff suppressed because one or more lines are too long
+28
-22
File diff suppressed because one or more lines are too long
+28
-25
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+28
-22
File diff suppressed because one or more lines are too long
@@ -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>
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ 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"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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)
|
||||||
})
|
})
|
||||||
@@ -52,4 +54,4 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</polymer-element>
|
</polymer-element>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ 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"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+13
-11
@@ -70,11 +70,12 @@ module.exports =
|
|||||||
userLeft: (user)->
|
userLeft: (user)->
|
||||||
delete @connections[user]
|
delete @connections[user]
|
||||||
@findNewSyncTarget()
|
@findNewSyncTarget()
|
||||||
for f in @connections_listeners
|
if @connections_listeners?
|
||||||
f {
|
for f in @connections_listeners
|
||||||
action: "userLeft"
|
f {
|
||||||
user: user
|
action: "userLeft"
|
||||||
}
|
user: user
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
userJoined: (user, role)->
|
userJoined: (user, role)->
|
||||||
@@ -91,12 +92,13 @@ 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
|
||||||
|
|
||||||
for f in @connections_listeners
|
if @connections_listeners?
|
||||||
f {
|
for f in @connections_listeners
|
||||||
action: "userJoined"
|
f {
|
||||||
user: user
|
action: "userJoined"
|
||||||
role: role
|
user: user
|
||||||
}
|
role: role
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Execute a function _when_ we are connected. If not connected, wait until connected.
|
# Execute a function _when_ we are connected. If not connected, wait until connected.
|
||||||
|
|||||||
+1
-1
@@ -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": {
|
||||||
|
|||||||
+2
-2
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user