more examples

This commit is contained in:
Kevin Jahns
2014-08-19 21:51:23 +02:00
parent 71c01fbb9e
commit 9d871adb00
9 changed files with 49 additions and 41 deletions

View File

@@ -18,44 +18,12 @@ function init(){
```
yatta is the shared json object. If you change something on this object,
it will be instantly shared with all the other collaborators.
You don't have to use the proposed user_id.
```js
yatta = new Y.JsonYatta(user_id, Connector);
```
Add a integer-property like this
```js
yatta.val('x', 7);
```
Get the value of property x like this
```js
console.log(yatta.val('x') === 7); // true
```
A string property can be either mutable or immutable.
```js
yatta.val('mutable_string', "text", "mutable");
yatta.val('immutable_string', "text", "immutable");
console.log(yatta.val('immutable_string') === "text"); // true
yatta.val('mutable_string').insertText(2,"XXX"); // position, string
yatta.val('mutable_string').deleteText(0,1); // position, deletion length
console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
console.log("me is number 2")
yatta = new Y.JsonYatta(2, Connector);
})
}

View File

@@ -16,33 +16,16 @@ A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file
function init(){
Y.createIwcConnector(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.
You don't have to use the proposed user_id.
*/
// console.log("me is number 1");
// yatta = new JsonYatta(1, Connector);
/**
Though, it is recommended to use the user_id
*/
yatta = new Y.JsonYatta(user_id, Connector);
/**
Add a integer-property like this
*/
yatta.val('x', 7);
/**
Get the value of property x like this
*/
console.log(yatta.val('x') === 7); // true
/**
A string property can be either mutable or immutable.
*/
yatta.val('mutable_string', "text", "mutable");
yatta.val('immutable_string', "text", "immutable");
console.log(yatta.val('immutable_string') === "text"); // true
yatta.val('mutable_string').insertText(2,"XXX"); // position, string
yatta.val('mutable_string').deleteText(0,1); // position, deletion length
console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true
})
}

View File

@@ -0,0 +1,26 @@
/**
## IWC + JSON Example
Here, I will give a short overview on how to use the IwcJson Framework in Role-SDK widgets.
First you have to include the following libraries in your widget file:
```
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
<script src="./index.js"></script>
```
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
*/
function init(){
Y.createIwcConnector(function(Connector, user_id){
/**
You don't have to use the proposed user_id.
*/
console.log("me is number 2")
yatta = new Y.JsonYatta(2, Connector);
})
}
window.onload = init

View File

@@ -9,9 +9,9 @@
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
<script src="./index.js"></script>
<h1> Collaborative Json Widget </h1>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="./index1.js"></script>
<h1> Collaborative Json Widget 1</h1>
]]></Content>
</Module>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Video upload" description="Upload videos in Sevianno" author="Kevin Jahns, Chair of Computer Science 5, RWTH Aachen University, Germany" author_email="jahns@dbis.rwth-aachen.de" scrolling="true">
<Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html"><![CDATA[
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/~jahns/role-widgets/widgetbundles/libraries/DUIClient.js"></script>
<script src="../../build/browser/Connectors/IwcConnector.min.js"></script>
<script src="../../build/browser/Frameworks/JsonYatta.min.js"></script>
<script src="./index2.js"></script>
<h1> Collaborative Json Widget 2</h1>
]]></Content>
</Module>