Testing History API (going back)
This commit is contained in:
parent
0d0f2e1f8e
commit
ef1ce16aeb
|
@ -10,6 +10,10 @@ salet = Salet({
|
|||
game_version: "1.2"
|
||||
})
|
||||
$(document).ready(() ->
|
||||
window.addEventListener('popstate', (event) ->
|
||||
salet.goBack()
|
||||
)
|
||||
|
||||
salet.beginGame()
|
||||
)
|
||||
|
||||
|
|
|
@ -82,6 +82,8 @@ class SaletRoom
|
|||
if system.rooms[f].exit?
|
||||
system.rooms[f].exit system, @name
|
||||
|
||||
history.pushState(@name, @title)
|
||||
|
||||
if @enter
|
||||
@enter system, f
|
||||
|
||||
|
|
|
@ -304,6 +304,7 @@ class Salet
|
|||
# Go back N rooms. It's not an UNDO.
|
||||
# Also, steps = 1 is the current room
|
||||
@goBack = (steps = 2) =>
|
||||
window.history.back()
|
||||
if @progress.path.length == 1
|
||||
location = @start
|
||||
else if @progress.path.length > steps
|
||||
|
|
Loading…
Reference in a new issue