comparison app/assets/javascripts/zp.hash_magic.js @ 308:e855e58d137e

Always include current path when replacing state.
author edogawaconan <me@myconan.net>
date Wed, 19 Feb 2014 20:21:20 +0900
parents 77c157a9e645
children 4b91c0c1938c
comparison
equal deleted inserted replaced
307:1a409564ffad 308:e855e58d137e
15 if (zp.formatter.links().filter(e.target).length === 0) return 15 if (zp.formatter.links().filter(e.target).length === 0) return
16 else e.preventDefault() 16 else e.preventDefault()
17 } 17 }
18 var 18 var
19 format = zp.formatter.current(), 19 format = zp.formatter.current(),
20 hash = "#" 20 newpath = window.location.pathname
21 hash += format 21 if (format !== "pl") { newpath += "#" + format }
22 if (hash === "#pl") { hash = " " } 22 history.replaceState(null, "", newpath)
23 history.replaceState(null, "", hash)
24 }, 23 },
25 init: function() { 24 init: function() {
26 if (!$("#paste").length) return 25 if (!$("#paste").length) return
27 this.load_hash() 26 this.load_hash()
28 if (history.replaceState) { 27 if (history.replaceState) {