From c2770a7a7461a903c1b267025a3d5bb89b882d81 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 7 Nov 2016 15:03:17 +0100 Subject: [PATCH] set correct hash even if browser does not implement replaceState --- www/code/main.js | 2 +- www/common/cryptpad-common.js | 4 ++-- www/pad/main.js | 2 +- www/poll/main.js | 2 +- www/slide/main.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/www/code/main.js b/www/code/main.js index a12d4bb8c..da0a2a385 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -495,7 +495,7 @@ define([ } // set the hash - if (!readOnly) { Cryptpad.setHash(editHash); } + if (!readOnly) { Cryptpad.replaceHash(editHash); } Cryptpad.getPadTitle(function (err, title) { if (err) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 85f07234c..1866fb34a 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -225,9 +225,9 @@ define([ return secret; }; - var setHash = common.setHash = function (hash) { - if (!/^#/.test(hash)) { hash = '#' + hash; } + var replaceHash = common.replaceHash = function (hash) { if (window.history && window.history.replaceState) { + if (!/^#/.test(hash)) { hash = '#' + hash; } return void window.history.replaceState({}, window.document.title, hash); } window.location.hash = hash; diff --git a/www/pad/main.js b/www/pad/main.js index c55370771..d1e6c9df0 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -601,7 +601,7 @@ define([ } // set the hash - if (!readOnly) { Cryptpad.setHash(editHash); } + if (!readOnly) { Cryptpad.replaceHash(editHash); } Cryptpad.getPadTitle(function (err, title) { if (err) { diff --git a/www/poll/main.js b/www/poll/main.js index 1caa10793..9fbf2cfde 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -914,7 +914,7 @@ define([ editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys); } // set the hash - if (!readOnly) { Cryptpad.setHash(editHash); } + if (!readOnly) { Cryptpad.replaceHash(editHash); } module.patchText = TextPatcher.create({ realtime: realtime, diff --git a/www/slide/main.js b/www/slide/main.js index 3efb9bd45..a291ae02c 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -585,7 +585,7 @@ define([ // set the hash if (!window.location.hash || window.location.hash === '#') { - Cryptpad.setHash(editHash); + Cryptpad.replaceHash(editHash); } Cryptpad.getPadTitle(function (err, title) {