test out extended realtime-input api

This commit is contained in:
ansuz 2016-03-04 16:41:34 +01:00
parent 3539c71c07
commit e8469ae1bb
2 changed files with 31 additions and 8 deletions

View File

@ -26,6 +26,10 @@
/* disallow textarea resizes */ /* disallow textarea resizes */
resize: none; resize: none;
} }
textarea[disabled] {
background-color: #275662;
color: #637476;
}
</style> </style>
</head> </head>
<body> <body>

View File

@ -16,13 +16,32 @@ define([
} }
var key = Crypto.parseKey(window.location.hash.substring(1)); var key = Crypto.parseKey(window.location.hash.substring(1));
var initializing = true;
var $textarea = $('textarea');
var rts = $('textarea').toArray().map(function (e, i) { var config = {};
var rt = Realtime.start(e, // window
Config.websocketURL, // websocketUrl var onInit = config.onInit = function (info) { };
Crypto.rand64(8), // userName
key.channel, // channel var onRemote = config.onRemote = function (contents) {
key.cryptKey); // cryptKey if (initializing) { return; }
return rt; // TODO...
}); };
var onReady = config.onReady = function (info) {
initializing = false;
$textarea.attr('disabled', false);
};
var onAbort = config.onAbort = function (info) {
$textarea.attr('disabled', true);
window.alert("Server Connection Lost");
};
var rt = Realtime.start($textarea[0], // window
Config.websocketURL, // websocketUrl
Crypto.rand64(8), // userName
key.channel, // channel
key.cryptKey,
config); // cryptKey
}); });