do away with a bit of boilerplate

pull/1/head
ansuz 9 years ago
parent e189092ba8
commit a0c73c95d8

@ -0,0 +1,19 @@
define([
'/common/crypto.js',
], function (Crypto) {
var common = {};
var getSecrets = common.getSecrets = function () {
var secret = {};
if (!/#/.test(window.location.href)) {
secret.key = Crypto.genKey();
} else {
var hash = window.location.hash.slice(1);
secret.channel = hash.slice(0, 32);
secret.key = hash.slice(32);
}
return secret;
};
return common;
});

@ -1,24 +1,16 @@
define([
'/json/api.js',
'/common/crypto.js',
'/common/cryptpad-common.js',
//'/customize/pad.js'
], function (RtListMap, Crypto) {
], function (RtListMap, Crypto, Common) {
var $ = window.jQuery;
var key;
var channel = '';
var hash = false;
if (!/#/.test(window.location.href)) {
key = Crypto.genKey();
} else {
hash = window.location.hash.slice(1);
channel = hash.slice(0,32);
key = hash.slice(32);
}
var secret = Common.getSecrets();
var config = {
channel: channel,
cryptKey: key,
channel: secret.channel,
cryptKey: secret.key,
data: {},
};
@ -38,7 +30,7 @@ define([
// or just remove?
var onInit = config.onInit = function (info) {
console.log("initializing!");
window.location.hash = info.channel + key;
window.location.hash = info.channel + secret.key;
};
// TODO replace with `proxy.on('ready'` ?

Loading…
Cancel
Save