update minor editors to use new realtime-input api

pull/1/head
ansuz 9 years ago
parent 9b228eea6b
commit 1c54af69a1

@ -28,7 +28,13 @@ define([
transformFunction transformFunction
*/ */
var config = {}; var config = {
textarea: $textarea[0],
websocketURL: Config.websocketURL,
userName: Crypto.rand64(8),
channel: key.channel,
cryptKey: key.cryptKey,
};
var initializing = true; var initializing = true;
$textarea.attr('disabled', true); $textarea.attr('disabled', true);
@ -51,12 +57,7 @@ define([
window.alert("Server Connection Lost"); window.alert("Server Connection Lost");
}; };
var rt = Realtime.start($textarea[0], // window var rt = Realtime.start(config);
Config.websocketURL, // websocketUrl
Crypto.rand64(8), // userName
key.channel, // channel
key.cryptKey,
config); // cryptKey
$run.click(function (e) { $run.click(function (e) {
e.preventDefault(); e.preventDefault();

@ -28,10 +28,13 @@ define([
var key = Crypto.parseKey(window.location.hash.substring(1)); var key = Crypto.parseKey(window.location.hash.substring(1));
var rttext = var config = {
RTText.start( $textarea[0], // window textarea: $textarea[0],
Config.websocketURL, // websocketUrl websocketURL: Config.websocketURL,
Crypto.rand64(8), // userName userName: Crypto.rand64(8),
key.channel, // channel channel: key.channel,
key.cryptKey); // cryptKey key.cryptKey
};
var rttext = RTText.start(config);
}); });

@ -18,11 +18,15 @@ define([
var key = Crypto.parseKey(window.location.hash.substring(1)); var key = Crypto.parseKey(window.location.hash.substring(1));
var rts = $('textarea').toArray().map(function (e, i) { var rts = $('textarea').toArray().map(function (e, i) {
var rt = Realtime.start(e, // window var config = {
Config.websocketURL, // websocketUrl textarea: e,
Crypto.rand64(8), // userName websocketURL: Config.websocketURL,
key.channel, // channel userName: Crypto.rand64(8),
key.cryptKey); // cryptKey channel: key.channel,
cryptKey: key.cryptKey
};
var rt = Realtime.start(config);
return rt; return rt;
}); });
}); });

@ -83,23 +83,26 @@ define([
}, 450); }, 450);
}; };
var rts = Realtime.start($textarea[0], // window var config = {
Config.websocketURL, // websocketUrl textarea: $textarea[0],
Crypto.rand64(8), // userName websocketURL: Config.websocketURL,
key.channel, // channel userName: Crypto.rand64(8),
key.cryptKey, // cryptkey channel: key.channel,
{ cryptKey: key.cryptKey,
// when remote editors do things...
onRemote: function () { // when remote editors do things...
lazyDraw($textarea.val()); onRemote: function () {
}, lazyDraw($textarea.val());
// when your editor is ready },
onReady: function (info) { // when your editor is ready
if (info.userList) { console.log("Userlist: [%s]", info.userList.join(',')); } onReady: function (info) {
console.log("Realtime is ready!"); if (info.userList) { console.log("Userlist: [%s]", info.userList.join(',')); }
$textarea.trigger('keyup'); console.log("Realtime is ready!");
} $textarea.trigger('keyup');
}); }
};
var rts = Realtime.start(config);
$textarea.on('change keyup keydown', function () { $textarea.on('change keyup keydown', function () {
if (redrawTimeout) { clearTimeout(redrawTimeout); } if (redrawTimeout) { clearTimeout(redrawTimeout); }

@ -47,16 +47,20 @@ define([
.on('change', draw); .on('change', draw);
var rts = $('textarea').toArray().map(function (e, i) { var rts = $('textarea').toArray().map(function (e, i) {
var rt = Realtime.start(e, // window
Config.websocketURL, // websocketUrl var config = {
userName, // userName onRemote: draw,
key.channel, // channel onInit: draw,
key.cryptKey, // cryptKey onReady: draw,
{
onRemote: draw, textarea: e,
onInit: draw, websocketURL: Config.websocketURL,
onReady: draw userName: userName,
}); channel: key.channel,
cryptKey: key.cryptKey
};
var rt = Realtime.start(config);
return rt; return rt;
}); });
}); });

@ -19,7 +19,12 @@ define([
var initializing = true; var initializing = true;
var $textarea = $('textarea'); var $textarea = $('textarea');
var config = {}; var config = {
websocketURL: Config.websocketURL,
userName: Crypto.rand64(8),
channel: key.channel,
cryptKey: key.cryptKey
};
var onInit = config.onInit = function (info) { }; var onInit = config.onInit = function (info) { };
@ -38,10 +43,5 @@ define([
window.alert("Server Connection Lost"); window.alert("Server Connection Lost");
}; };
var rt = Realtime.start($textarea[0], // window var rt = Realtime.start(config);
Config.websocketURL, // websocketUrl
Crypto.rand64(8), // userName
key.channel, // channel
key.cryptKey,
config); // cryptKey
}); });

Loading…
Cancel
Save