0
0
Fork 0
mirror of https://gitlab.com/Oreolek/salet-module.git synced 2024-06-26 03:50:49 +03:00

Fixed goBack and normaliseTabs, updated git links

This commit is contained in:
Alexander Yakovlev 2017-04-02 11:37:36 +07:00
parent 7b1d1cd2b4
commit 6292baab99
3 changed files with 11 additions and 8 deletions

View file

@ -1,11 +1,11 @@
{ {
"name": "salet", "name": "salet",
"version": "1.6.16", "version": "1.6.17",
"description": "A general client-side framework for cybertext interactive fiction games.", "description": "A general client-side framework for cybertext interactive fiction games.",
"keywords": ["ifiction", "interactive fiction", "games", "coffee-script", "text", "menu"], "keywords": ["ifiction", "interactive fiction", "games", "coffee-script", "text", "menu"],
"homepage": "http://salet.oreolek.ru", "homepage": "http://salet.oreolek.ru",
"bugs": { "bugs": {
"url" : "https://git.oreolek.ru/oreolek/salet-module/issues" "url" : "https://gitlab.com/oreolek/salet-module/issues"
}, },
"license" : "MIT", "license" : "MIT",
"dependencies": {}, "dependencies": {},
@ -21,6 +21,6 @@
"main": "lib/index.min.js", "main": "lib/index.min.js",
"repository": { "repository": {
"type" : "git", "type" : "git",
"url" : "https://git.oreolek.ru/oreolek/salet-module" "url" : "https://gitlab.com/oreolek/salet-module"
} }
} }

View file

@ -6,7 +6,9 @@ Copyright 2015 Bruno Dias
normaliseTabs = (text) -> normaliseTabs = (text) ->
if not text? or typeof(text) != "string" or text == "" if not text? or typeof(text) != "string" or text == ""
return "" return ""
lines = text.split('\n'); lines = text.split('\n')
if not lines?
lines = text
indents = lines indents = lines
.filter((l) => l != '') .filter((l) => l != '')
.map((l) => l.match(/^\s+/)) .map((l) => l.match(/^\s+/))

View file

@ -61,14 +61,14 @@ class Salet
on to the room. Note that this is the only one of on to the room. Note that this is the only one of
these global handlers that can consume the event. these global handlers that can consume the event.
### ###
@beforeAction = (situationId, actionId) -> @beforeAction = (roomId, actionId) ->
### ###
This function is called after carrying out any action in This function is called after carrying out any action in
any room. It is called after the corresponding any room. It is called after the corresponding
room has its `act` method called. room has its `act` method called.
### ###
@afterAction = (situationId, actionId) -> @afterAction = (roomId, actionId) ->
### ###
This function is called after leaving any room. It is This function is called after leaving any room. It is
@ -306,13 +306,14 @@ class Salet
# Also, steps = 1 is the current room # Also, steps = 1 is the current room
@goBack = (steps = 2) -> @goBack = (steps = 2) ->
window.history.back() window.history.back()
if @progress.path.length == 1 if @progress.path.length <= 1
location = @start location = @start
else if @progress.path.length > steps else if @progress.path.length > steps
location = @progress.path[@progress.path.length - steps] location = @progress.path[@progress.path.length - steps]
else else
return @goBack(steps - 1) return @goBack(steps - 1)
@processClick(location) if location?
@processClick(location)
# Transition between rooms. # Transition between rooms.
@doTransitionTo = (newRoomId, force = false) -> @doTransitionTo = (newRoomId, force = false) ->