tests run fine. but it needs some more user testing
This commit is contained in:
@@ -194,7 +194,7 @@ Apply a 'change' - listener to a JsonType.
|
||||
console.log("New value: " + show(this.val(property_name)) + ""); // 'this' is the object on which the property changed.
|
||||
};
|
||||
yatta.on('change', change);
|
||||
yatta.val('mutable_string', "text", 'mutable'); // Property 'mutable_string' was replaced or changed!
|
||||
yatta.val('mutable_string', "text", 'mutable'); // You changed the value of property 'mutable_string'!
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ Y.createPeerJsConnector("unique_id", {key: 'h7nlefbgavh1tt9'}, function(Connecto
|
||||
console.log("New value: " + show(this.val(property_name)) + ""); // 'this' is the object on which the property changed.
|
||||
};
|
||||
yatta.on('change', change);
|
||||
yatta.val('mutable_string', "text", 'mutable'); // Property 'mutable_string' was replaced or changed!
|
||||
yatta.val('mutable_string', "text", 'mutable'); // You changed the value of property 'mutable_string'!
|
||||
|
||||
/**
|
||||
'change' and 'addProperty' do also fire for nested properties.
|
||||
|
||||
@@ -27,6 +27,41 @@ var yatta, yattaHandler;
|
||||
Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){
|
||||
|
||||
yatta = new Y.XmlFramework(user_id, Connector);
|
||||
console.log(yatta.getUserId());
|
||||
```
|
||||
|
||||
|
||||
Get the url of this frame. If it has a url-encoded parameter
|
||||
we will connect to the foreign peer.
|
||||
|
||||
|
||||
```js
|
||||
var url = window.location.href;
|
||||
var peer_id = location.search
|
||||
var url = url.substring(0,-peer_id.length);
|
||||
peer_id = peer_id.substring(1);
|
||||
```
|
||||
|
||||
|
||||
Set the shareable link.
|
||||
|
||||
|
||||
```js
|
||||
document.getElementById("peer_link").setAttribute("href",url+"?"+user_id);
|
||||
```
|
||||
|
||||
|
||||
Connect to other peer.
|
||||
|
||||
|
||||
```js
|
||||
if (peer_id.length > 0){
|
||||
yatta.connector.connectToPeer(peer_id);
|
||||
}
|
||||
yatta.connector.onNewConnection(function(){
|
||||
$("#collaborative").replaceWith(yatta.val())
|
||||
});
|
||||
|
||||
yatta.val($("#collaborative")[0])
|
||||
console.log(yatta.getUserId());
|
||||
});
|
||||
```
|
||||
|
||||
@@ -9,14 +9,17 @@
|
||||
<script src="./index.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1> PeerJs + Json Tutorial</h1>
|
||||
<p> Collaborative Json editing with <a href="https://github.com/DadaMonad/Yatta/">Yatta</a>
|
||||
<body id="collaborative">
|
||||
<h1> PeerJs + XML Example</h1>
|
||||
<p> Collaborative XML editing with <a href="https://github.com/DadaMonad/Yatta/">Yatta</a>
|
||||
and <a href="http://peerjs.com/">PeerJs</a> (WebRTC). </p>
|
||||
|
||||
|
||||
<p> <a href="https://github.com/DadaMonad/Yatta/">Yatta</a> is a Framework for Real-Time collaboration on arbitrary data structures.
|
||||
You can find the code for this example <a href="https://github.com/DadaMonad/Yatta/tree/master/examples/PeerJs-Json">here</a>.
|
||||
|
||||
<a id="peer_link" target="_blank">Drop me </a>
|
||||
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -27,5 +27,31 @@ var yatta, yattaHandler;
|
||||
Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){
|
||||
|
||||
yatta = new Y.XmlFramework(user_id, Connector);
|
||||
console.log(yatta.getUserId());
|
||||
|
||||
/**
|
||||
Get the url of this frame. If it has a url-encoded parameter
|
||||
we will connect to the foreign peer.
|
||||
*/
|
||||
var url = window.location.href;
|
||||
var peer_id = location.search
|
||||
var url = url.substring(0,-peer_id.length);
|
||||
peer_id = peer_id.substring(1);
|
||||
|
||||
/**
|
||||
Set the shareable link.
|
||||
*/
|
||||
document.getElementById("peer_link").setAttribute("href",url+"?"+user_id);
|
||||
|
||||
/**
|
||||
Connect to other peer.
|
||||
*/
|
||||
if (peer_id.length > 0){
|
||||
yatta.connector.connectToPeer(peer_id);
|
||||
}
|
||||
yatta.connector.onNewConnection(function(){
|
||||
$("#collaborative").replaceWith(yatta.val())
|
||||
});
|
||||
|
||||
yatta.val($("#collaborative")[0])
|
||||
console.log(yatta.getUserId());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user