Last active
August 29, 2015 14:08
-
-
Save NOtherDev/2ea2bb111c00282e7617 to your computer and use it in GitHub Desktop.
ShareJS 0.7.3 web client-side code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- see http://notherdev.blogspot.com/2014/10/sharejs-073-working-example.html --> | |
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<textarea id="pad"></textarea> | |
<script src="/srv/text.js"></script> | |
<script src="/srv/share.js"></script> | |
<script> | |
var getUrlParameter = function (name) { | |
return (new RegExp(name + '=' + '(.+?)(&|$)').exec(window.location.search)||[,null])[1]; | |
}; | |
var ws = new WebSocket('ws://127.0.0.1:7007'); | |
var share = new sharejs.Connection(ws); | |
var doc = share.get('docs', getUrlParameter('doc')); | |
doc.subscribe(); | |
doc.whenReady(function () { | |
if (!doc.type) { | |
doc.create('text'); | |
} | |
var elem = document.getElementById('pad'); | |
doc.attachTextarea(elem); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment