From 24a3a58382bc8d9a48c01e54f9ed1240cc1549de Mon Sep 17 00:00:00 2001 From: Maxim Lihachev Date: Wed, 11 Jan 2017 11:10:37 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89?= =?UTF-8?q?=D1=91=D0=BD=20=D1=80=D0=B0=D0=B7=D0=B1=D0=BE=D1=80=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2=20url=20?= =?UTF-8?q?=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20hash-=D1=81=D1=81=D1=8B?= =?UTF-8?q?=D0=BB=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/feminitives.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/js/feminitives.js b/js/feminitives.js index c264215..bb5691a 100644 --- a/js/feminitives.js +++ b/js/feminitives.js @@ -339,8 +339,6 @@ function tr(word) { var wd = word || HTML.input().value.trim().toLowerCase().split(" ")[0]; var feminitives = ""; - //Изменение адреса - window.location.hash = wd; URL.opt.href = encodeURIComponent(window.location.href); HTML.dict().innerHTML = ""; @@ -365,19 +363,29 @@ function tr(word) { HTML.content().innerHTML = feminitives[0].replace(/(.)/, s => s.toUpperCase()); HTML.dict().innerHTML = feminitives[1].join(" | ") || "Это слово и так прекрасно. Оставим его как есть."; + + //Изменение адреса + window.history.pushState({}, null, window.location.href.split('?')[0]+'?word='+wd); } //------------------------------------------------------------------------------ +//Разбор параметров var URL = {opt: {}}; +URL.parse = function() { + var gy = window.location.search.substring(1).split("&"); + gy.forEach(arg => { + let ft = arg.split("="); + this.opt[ft[0]] = this.opt[ft[0]] || decodeURIComponent(ft[1]); + }); +}; + //Инициализация с разбором адресной строки function init(container) { HTML.init(container); + URL.parse(); - URL.opt.href = decodeURIComponent(window.location.href); - URL.opt.word = URL.opt.href.split('#')[1] || null; - if (URL.opt.word) { HTML.input().value = URL.opt.word.replace(/\+/g," "); tr();