clean up realtime-input.js, break API
use an object for configuration, so as to be more extensible. modify applications which use the API to match.
This commit is contained in:
@@ -34,9 +34,18 @@
|
||||
code {
|
||||
font-family: monospace;
|
||||
}
|
||||
/* TODO
|
||||
bump up text size on mobile
|
||||
*/
|
||||
|
||||
/* bigger text size for difficult to read elements */
|
||||
blockquote, p, pre, code, li {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* tables */
|
||||
table, thead, tbody, th, tr, td{
|
||||
border: 1pt solid #586e75;
|
||||
background-color: #002b36;
|
||||
padding: 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -46,4 +55,3 @@
|
||||
<textarea></textarea>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ define([
|
||||
|
||||
var key = Crypto.parseKey(window.location.hash.substring(1));
|
||||
|
||||
var $textarea = $('textarea'),
|
||||
var $textarea = $('textarea').first(),
|
||||
$target = $('#target');
|
||||
|
||||
window.$textarea = $textarea;
|
||||
@@ -107,18 +107,23 @@ define([
|
||||
}, 450);
|
||||
};
|
||||
|
||||
var rts = $textarea.toArray().map(function (e, i) {
|
||||
var rt = Realtime.start(e, // window
|
||||
var rts = Realtime.start($textarea[0], // window
|
||||
Config.websocketURL, // websocketUrl
|
||||
Crypto.rand64(8), // userName
|
||||
key.channel, // channel
|
||||
key.cryptKey, // cryptkey
|
||||
null, // docBody
|
||||
function (){ // onChange received
|
||||
lazyDraw($textarea.val());
|
||||
{
|
||||
// when remote editors do things...
|
||||
onRemote: function () {
|
||||
lazyDraw($textarea.val());
|
||||
},
|
||||
// when your editor is ready
|
||||
onReady: function (info) {
|
||||
info.userList && console.log("Userlist: [%s]", info.userList.join(','));
|
||||
console.log("Realtime is ready!");
|
||||
$textarea.trigger('keyup');
|
||||
}
|
||||
});
|
||||
return rt;
|
||||
})[0];
|
||||
|
||||
$textarea.on('change keyup keydown', function () {
|
||||
redrawTimeout && clearTimeout(redrawTimeout);
|
||||
|
||||
Reference in New Issue
Block a user