remove usernames, refactor a wee bit

This commit is contained in:
ansuz 2016-06-16 16:20:51 +02:00
parent 2b8c21d292
commit f818d873bb

View File

@ -12,11 +12,12 @@ define([
'/common/TypingTests.js', '/common/TypingTests.js',
'json.sortify', 'json.sortify',
'/bower_components/textpatcher/TextPatcher.amd.js', '/bower_components/textpatcher/TextPatcher.amd.js',
'/common/cryptpad-common.js',
'/bower_components/diff-dom/diffDOM.js', '/bower_components/diff-dom/diffDOM.js',
'/bower_components/jquery/dist/jquery.min.js', '/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.js' '/customize/pad.js'
], function (Config, Messages, Crypto, realtimeInput, Hyperjson, Hyperscript, ], function (Config, Messages, Crypto, realtimeInput, Hyperjson, Hyperscript,
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher) { Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad) {
var $ = window.jQuery; var $ = window.jQuery;
var ifrw = $('#pad-iframe')[0].contentWindow; var ifrw = $('#pad-iframe')[0].contentWindow;
@ -42,8 +43,7 @@ define([
fights: [] fights: []
}; };
var userName = Crypto.rand64(8), var toolbar;
toolbar;
var isNotMagicLine = function (el) { var isNotMagicLine = function (el) {
return !(el && typeof(el.getAttribute) === 'function' && return !(el && typeof(el.getAttribute) === 'function' &&
@ -58,26 +58,7 @@ define([
}; };
var andThen = function (Ckeditor) { var andThen = function (Ckeditor) {
/* This is turned off because we prefer that the channel name var secret = Cryptpad.getSecrets();
be chosen by the server, not generated by the client.
We still need a key, so we use genKey()
*/
// $(window).on('hashchange', function() {
// window.location.reload();
// });
var key;
var channel = '';
if (window.location.href.indexOf('#') === -1) {
key = Crypto.genKey();
// window.location.href = window.location.href + '#' + Crypto.genKey();
// return;
}
else {
var hash = window.location.hash.substring(1);
channel = hash.substr(0,32);
key = hash.substr(32);
}
var fixThings = false; var fixThings = false;
@ -91,7 +72,6 @@ define([
removePlugins: 'resize' removePlugins: 'resize'
}); });
editor.on('instanceReady', function (Ckeditor) { editor.on('instanceReady', function (Ckeditor) {
/* add a class to the magicline plugin so we can pick it out more easily */ /* add a class to the magicline plugin so we can pick it out more easily */
@ -188,7 +168,6 @@ define([
} }
}; };
var initializing = true; var initializing = true;
var userList = {}; // List of pretty name of all users (mapped with their server ID) var userList = {}; // List of pretty name of all users (mapped with their server ID)
var toolbarList; // List of users still connected to the channel (server IDs) var toolbarList; // List of users still connected to the channel (server IDs)
@ -252,14 +231,11 @@ define([
// the websocket URL // the websocket URL
websocketURL: Config.websocketURL, websocketURL: Config.websocketURL,
// our username
userName: userName,
// the channel we will communicate over // the channel we will communicate over
channel: channel, channel: secret.channel,
// our encryption key // our encryption key
cryptKey: key, cryptKey: secret.key,
// method which allows us to get the id of the user // method which allows us to get the id of the user
setMyID: setMyID, setMyID: setMyID,
@ -341,7 +317,7 @@ define([
createChangeName('cryptpad-changeName', $bar); createChangeName('cryptpad-changeName', $bar);
// set the hash // set the hash
window.location.hash = info.channel + key; window.location.hash = info.channel + secret.key;
}; };
// this should only ever get called once, when the chain syncs // this should only ever get called once, when the chain syncs