comparison app/assets/javascripts/zp.hash_magic.coffee @ 370:5a4d31e97937

Remove extra file extensions.
author edogawaconan <me@myconan.net>
date Tue, 14 Apr 2015 00:22:07 +0900
parents app/assets/javascripts/zp.hash_magic.js.coffee@f802099acd37
children
comparison
equal deleted inserted replaced
369:c0d4e6115642 370:5a4d31e97937
1 #= require zp.formatter
2 window.zp.hash_magic =
3 load_hash: ->
4 format = window.location.hash.slice(1)
5 tab_link = (fmt) -> zp.formatter.links().filter("[href='##{fmt}']")
6
7 format = "pl" unless tab_link(format).length
8 tab_link(format).click()
9
10 set_hash: (e) ->
11 format = zp.formatter.current()
12 newpath = window.location.pathname
13 newpath += "##{format}" if (format != "pl")
14 history.replaceState null, "", newpath
15
16 init: ->
17 return unless $("#paste").length
18 @load_hash()
19 if (history.replaceState)
20 @set_hash()
21 zp.formatter.links().on("shown.bs.tab", this.set_hash)