From e8469ae1bb50cfae00e4753fcd82a5772001ca16 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 4 Mar 2016 16:41:34 +0100 Subject: [PATCH] test out extended realtime-input api --- www/text/index.html | 4 ++++ www/text/main.js | 35 +++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/www/text/index.html b/www/text/index.html index 0b5d584d8..514095e99 100644 --- a/www/text/index.html +++ b/www/text/index.html @@ -26,6 +26,10 @@ /* disallow textarea resizes */ resize: none; } + textarea[disabled] { + background-color: #275662; + color: #637476; + } diff --git a/www/text/main.js b/www/text/main.js index d6fa8075d..9b8886e86 100644 --- a/www/text/main.js +++ b/www/text/main.js @@ -16,13 +16,32 @@ define([ } var key = Crypto.parseKey(window.location.hash.substring(1)); + var initializing = true; + var $textarea = $('textarea'); - var rts = $('textarea').toArray().map(function (e, i) { - var rt = Realtime.start(e, // window - Config.websocketURL, // websocketUrl - Crypto.rand64(8), // userName - key.channel, // channel - key.cryptKey); // cryptKey - return rt; - }); + var config = {}; + + var onInit = config.onInit = function (info) { }; + + var onRemote = config.onRemote = function (contents) { + if (initializing) { return; } + // 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 });