|
|
@ -1,21 +1,28 @@
|
|
|
|
define([
|
|
|
|
define([
|
|
|
|
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
|
|
|
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
|
|
|
'/common/RealtimeTextarea.js',
|
|
|
|
'/common/realtime-input.js',
|
|
|
|
'/common/crypto.js',
|
|
|
|
'/common/crypto.js',
|
|
|
|
'/common/TextPatcher.js',
|
|
|
|
'/common/TextPatcher.js',
|
|
|
|
'/bower_components/jquery/dist/jquery.min.js'
|
|
|
|
'/bower_components/jquery/dist/jquery.min.js'
|
|
|
|
], function (Config, Realtime, Crypto, TextPatcher) {
|
|
|
|
], function (Config, Realtime, Crypto, TextPatcher) {
|
|
|
|
var $ = window.jQuery;
|
|
|
|
var $ = window.jQuery;
|
|
|
|
|
|
|
|
/*
|
|
|
|
$(window).on('hashchange', function() {
|
|
|
|
$(window).on('hashchange', function() {
|
|
|
|
window.location.reload();
|
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
});*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var key;
|
|
|
|
|
|
|
|
var channel = '';
|
|
|
|
if (window.location.href.indexOf('#') === -1) {
|
|
|
|
if (window.location.href.indexOf('#') === -1) {
|
|
|
|
window.location.href = window.location.href + '#' + Crypto.genKey();
|
|
|
|
key = Crypto.genKey();
|
|
|
|
return;
|
|
|
|
//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'),
|
|
|
|
var $textarea = $('textarea'),
|
|
|
|
$run = $('#run');
|
|
|
|
$run = $('#run');
|
|
|
|
|
|
|
|
|
|
|
@ -29,13 +36,14 @@ define([
|
|
|
|
transformFunction
|
|
|
|
transformFunction
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userName = Crypto.rand64(8);
|
|
|
|
|
|
|
|
|
|
|
|
var config = {
|
|
|
|
var config = {
|
|
|
|
textarea: $textarea[0],
|
|
|
|
initialState: '',
|
|
|
|
websocketURL: Config.websocketURL + '_old',
|
|
|
|
websocketURL: Config.websocketURL,
|
|
|
|
webrtcURL: Config.webrtcURL,
|
|
|
|
userName: userName,
|
|
|
|
userName: Crypto.rand64(8),
|
|
|
|
channel: channel,
|
|
|
|
channel: key.channel,
|
|
|
|
cryptKey: key,
|
|
|
|
cryptKey: key.cryptKey,
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var initializing = true;
|
|
|
|
var initializing = true;
|
|
|
|
|
|
|
|
|
|
|
@ -44,7 +52,9 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
setEditable(false);
|
|
|
|
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) {
|
|
|
|
var onRemote = config.onRemote = function (info) {
|
|
|
|
if (initializing) { return; }
|
|
|
|
if (initializing) { return; }
|
|
|
|