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([ define([
'/json/api.js', '/json/api.js',
'/common/crypto.js', '/common/crypto.js',
'/common/cryptpad-common.js',
//'/customize/pad.js' //'/customize/pad.js'
], function (RtListMap, Crypto) { ], function (RtListMap, Crypto, Common) {
var $ = window.jQuery; var $ = window.jQuery;
var key; var secret = Common.getSecrets();
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 config = { var config = {
channel: channel, channel: secret.channel,
cryptKey: key, cryptKey: secret.key,
data: {}, data: {},
}; };
@ -38,7 +30,7 @@ define([
// or just remove? // or just remove?
var onInit = config.onInit = function (info) { var onInit = config.onInit = function (info) {
console.log("initializing!"); console.log("initializing!");
window.location.hash = info.channel + key; window.location.hash = info.channel + secret.key;
}; };
// TODO replace with `proxy.on('ready'` ? // TODO replace with `proxy.on('ready'` ?

Loading…
Cancel
Save