updated examples

This commit is contained in:
Kevin Jahns 2015-11-09 03:04:03 +01:00
parent 0292181830
commit 6c13be376f
5 changed files with 2442 additions and 17 deletions

View File

@ -3,7 +3,7 @@
// create a shared object. This function call will return a promise! // create a shared object. This function call will return a promise!
Y({ Y({
db: { db: {
name: 'IndexedDB', name: 'indexeddb',
namespace: 'offlineEditingDemo' namespace: 'offlineEditingDemo'
}, },
connector: { connector: {
@ -11,8 +11,8 @@ Y({
room: 'offlineEditingDemo', room: 'offlineEditingDemo',
debug: true debug: true
}, },
types: [], types: ['Array', 'Text'],
sourceDir: '/bower_components/' sourceDir: '/bower_components'
}).then(function (yconfig) { }).then(function (yconfig) {
// yconfig holds all the information about the shared object // yconfig holds all the information about the shared object
window.yconfig = yconfig window.yconfig = yconfig
@ -33,10 +33,10 @@ Y({
text.bind(contenteditable) text.bind(contenteditable)
} }
}) })
// create a shared TextBind // create a shared Text
var textpromise = yconfig.root.get('text') var textpromise = yconfig.root.get('text')
if (textpromise == null) { if (textpromise == null) {
yconfig.root.set('text', Y.TextBind) yconfig.root.set('text', Y.Text)
} }
// We also provide a button for disconnecting/reconnecting the shared element // We also provide a button for disconnecting/reconnecting the shared element
var button = document.querySelector('#button') var button = document.querySelector('#button')

View File

@ -5,8 +5,7 @@
<h1 id="contenteditable" contentEditable></h1> <h1 id="contenteditable" contentEditable></h1>
<textarea style="width:80%;" rows=40 id="textfield"></textarea> <textarea style="width:80%;" rows=40 id="textfield"></textarea>
<script src="../../node_modules/simplewebrtc/simplewebrtc.bundle.js"></script> <script src="../bower_components/yjs/y.js"></script>
<script src="../../y.js"></script>
<script src="./index.js"></script> <script src="./index.js"></script>
</body> </body>
</html> </html>

View File

@ -3,13 +3,15 @@
// create a shared object. This function call will return a promise! // create a shared object. This function call will return a promise!
Y({ Y({
db: { db: {
name: 'Memory' name: 'memory'
}, },
connector: { connector: {
name: 'WebRTC', name: 'webrtc',
room: 'TextBindDemo', room: 'offlineEditingDemo',
debug: true debug: true
} },
types: ['Array', 'Text'],
sourceDir: '/bower_components/'
}).then(function (yconfig) { }).then(function (yconfig) {
// yconfig holds all the information about the shared object // yconfig holds all the information about the shared object
window.yconfig = yconfig window.yconfig = yconfig
@ -30,8 +32,8 @@ Y({
text.bind(contenteditable) text.bind(contenteditable)
} }
}) })
// create a shared TextBind // create a shared Text
yconfig.root.set('text', Y.TextBind) yconfig.root.set('text', Y.Text)
// We also provide a button for disconnecting/reconnecting the shared element // We also provide a button for disconnecting/reconnecting the shared element
var button = document.querySelector('#button') var button = document.querySelector('#button')

2430
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long