Create a gist now

Instantly share code, notes, and snippets.

ShareJS 0.7.3 web client-side code
<!-- 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