simple editing working
This commit is contained in:
@@ -10,5 +10,10 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1> Yatta PeerJs Demo </h1>
|
||||
<p> Open this link in other browsers: <a id="peer_link" target="_blank">Drop me </a> </p>
|
||||
|
||||
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -13,6 +13,8 @@ A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file
|
||||
|
||||
|
||||
```js
|
||||
var yatta;
|
||||
|
||||
function init(){
|
||||
Y.createPeerJsConnector(function(Connector, user_id){
|
||||
```
|
||||
@@ -23,9 +25,29 @@ it will be instantly shared with all the other collaborators.
|
||||
|
||||
|
||||
```js
|
||||
Y.yatta = new JsonYatta(user_id, Connector);
|
||||
yatta = new Y.JsonYatta(user_id, Connector);
|
||||
|
||||
var url = window.location.href;
|
||||
var peer_id = location.search
|
||||
var url = url.substring(0,-peer_id.length);
|
||||
peer_id = peer_id.substring(1);
|
||||
document.getElementById("peer_link").setAttribute("href",url+"?"+user_id);
|
||||
|
||||
var textbox = document.getElementById("textfield");
|
||||
if (peer_id.length > 0) {
|
||||
yatta.connector.connectToPeer(peer_id);
|
||||
function f() {
|
||||
if (yatta.val('x') == null) {
|
||||
setTimeout(f, 500);
|
||||
} else {
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
}
|
||||
f();
|
||||
} else {
|
||||
yatta.val('x', "");
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
window.onload = init
|
||||
|
||||
@@ -13,15 +13,37 @@
|
||||
```
|
||||
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
|
||||
*/
|
||||
var yatta;
|
||||
|
||||
function init(){
|
||||
Y.createPeerJsConnector(function(Connector, user_id){
|
||||
/**
|
||||
yatta is the shared json object. If you change something on this object,
|
||||
it will be instantly shared with all the other collaborators.
|
||||
*/
|
||||
Y.yatta = new JsonYatta(user_id, Connector);
|
||||
yatta = new Y.JsonYatta(user_id, Connector);
|
||||
|
||||
var url = window.location.href;
|
||||
var peer_id = location.search
|
||||
var url = url.substring(0,-peer_id.length);
|
||||
peer_id = peer_id.substring(1);
|
||||
document.getElementById("peer_link").setAttribute("href",url+"?"+user_id);
|
||||
|
||||
var textbox = document.getElementById("textfield");
|
||||
if (peer_id.length > 0) {
|
||||
yatta.connector.connectToPeer(peer_id);
|
||||
function f() {
|
||||
if (yatta.val('x') == null) {
|
||||
setTimeout(f, 500);
|
||||
} else {
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
}
|
||||
f();
|
||||
} else {
|
||||
yatta.val('x', "");
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
window.onload = init
|
||||
|
||||
Reference in New Issue
Block a user