From 6b7aeb91218bbcb135660ea856824023be13ef7a Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 17 May 2017 15:48:09 +0200 Subject: [PATCH] Fix the text example --- www/common/common-hash.js | 5 +++-- www/examples/text/main.js | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/www/common/common-hash.js b/www/common/common-hash.js index c6bf29ce9..c8536b347 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -113,12 +113,13 @@ Version 1 return ret; } - var hash = href.replace(patt, function (a, domain, type) { + href.replace(patt, function (a, domain, type) { ret.domain = domain; ret.type = type; return ''; }); - ret.hash = hash.replace(/#/g, ''); + var idx = href.indexOf('/#'); + ret.hash = href.slice(idx + 2); ret.hashData = parseTypeHash(ret.type, ret.hash); return ret; }; diff --git a/www/examples/text/main.js b/www/examples/text/main.js index eed9ff300..e4637b681 100644 --- a/www/examples/text/main.js +++ b/www/examples/text/main.js @@ -8,6 +8,9 @@ define([ ], function ($, Config, Realtime, Crypto, TextPatcher, Cryptpad) { var secret = Cryptpad.getSecrets(); + if (!secret.keys) { + secret.keys = secret.key; + } var module = window.APP = { TextPatcher: TextPatcher @@ -19,8 +22,9 @@ define([ var config = module.config = { initialState: '', websocketURL: Config.websocketURL, + validateKey: secret.keys.validateKey || undefined, channel: secret.channel, - crypto: Crypto.createEncryptor(secret.key), + crypto: Crypto.createEncryptor(secret.keys), }; var setEditable = function (bool) { $textarea.attr('disabled', !bool); }; @@ -29,7 +33,8 @@ define([ setEditable(false); config.onInit = function (info) { - window.location.hash = info.channel + secret.key; + var editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys); + Cryptpad.replaceHash(editHash); $(window).on('hashchange', function() { window.location.reload(); });