From d4943511fe47d1efbff20d201fcab6534f7a6553 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 22 Apr 2016 09:47:26 +0200 Subject: [PATCH] move text/ and hack/ to Netflux --- www/hack/main.js | 36 +++++++++++++++++++++++------------- www/text/main.js | 31 ++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/www/hack/main.js b/www/hack/main.js index 8805a3169..8830b9007 100644 --- a/www/hack/main.js +++ b/www/hack/main.js @@ -1,21 +1,28 @@ define([ '/api/config?cb=' + Math.random().toString(16).substring(2), - '/common/RealtimeTextarea.js', + '/common/realtime-input.js', '/common/crypto.js', '/common/TextPatcher.js', '/bower_components/jquery/dist/jquery.min.js' ], function (Config, Realtime, Crypto, TextPatcher) { var $ = window.jQuery; + /* $(window).on('hashchange', function() { window.location.reload(); - }); + });*/ + + var key; + var channel = ''; if (window.location.href.indexOf('#') === -1) { - window.location.href = window.location.href + '#' + Crypto.genKey(); - return; + key = Crypto.genKey(); + //window.location.href = window.location.href + '#' + Crypto.genKey(); + //return; + } else { + var hash = window.location.hash.substr(1); + channel = hash.substr(0,32); + key = hash.substr(32); } - var key = Crypto.parseKey(window.location.hash.substring(1)); - var $textarea = $('textarea'), $run = $('#run'); @@ -29,13 +36,14 @@ define([ transformFunction */ + var userName = Crypto.rand64(8); + var config = { - textarea: $textarea[0], - websocketURL: Config.websocketURL + '_old', - webrtcURL: Config.webrtcURL, - userName: Crypto.rand64(8), - channel: key.channel, - cryptKey: key.cryptKey, + initialState: '', + websocketURL: Config.websocketURL, + userName: userName, + channel: channel, + cryptKey: key, }; var initializing = true; @@ -44,7 +52,9 @@ define([ setEditable(false); - var onInit = config.onInit = function (info) { }; + var onInit = config.onInit = function (info) { + window.location.hash = info.channel + key; + }; var onRemote = config.onRemote = function (info) { if (initializing) { return; } diff --git a/www/text/main.js b/www/text/main.js index 0db823560..644fa86f6 100644 --- a/www/text/main.js +++ b/www/text/main.js @@ -1,6 +1,6 @@ define([ '/api/config?cb=' + Math.random().toString(16).substring(2), - '/common/RealtimeTextSocket.js', + '/common/realtime-input.js', '/common/messages.js', '/common/crypto.js', '/common/TextPatcher.js', @@ -11,22 +11,37 @@ define([ $(window).on('hashchange', function() { window.location.reload(); }); + /* if (window.location.href.indexOf('#') === -1) { window.location.href = window.location.href + '#' + Crypto.genKey(); return; + }*/ + + + var key; + var channel = ''; + if (window.location.href.indexOf('#') === -1) { + key = Crypto.genKey(); + } else { + var hash = window.location.hash.substr(1); + channel = hash.substr(0, 32); + key = hash.substr(32); } var module = window.APP = {}; - var key = Crypto.parseKey(window.location.hash.substring(1)); + + var userName = module.userName = Crypto.rand64(8); + var initializing = true; var $textarea = $('textarea'); var config = module.config = { + initialState: '', textarea: $textarea[0], - websocketURL: Config.websocketURL + '_old', - userName: Crypto.rand64(8), - channel: key.channel, - cryptKey: key.cryptKey + websocketURL: Config.websocketURL, + userName: userName, + channel: channel, + cryptKey: key, }; var setEditable = function (bool) { $textarea.attr('disabled', !bool); }; @@ -34,7 +49,9 @@ define([ setEditable(false); - var onInit = config.onInit = function (info) { }; + var onInit = config.onInit = function (info) { + window.location.hash = info.channel + key; + }; var onRemote = config.onRemote = function (info) { if (initializing) { return; }