cap items to maximum in their array, in case the user manually entered

a number larger than the max allowed item in the "restore" modal
This commit is contained in:
Tyler Renelle
2013-07-24 16:45:48 -04:00
parent a5eb64f771
commit dab72e5865
3 changed files with 38 additions and 19 deletions
+7
View File
@@ -107,3 +107,10 @@ module.exports.updateStore = (user) ->
showNext = false
changes[type] = if showNext then items[type][i] else {hide:true}
return changes
###
Gets an itme, and caps max to the last item in its array
###
module.exports.getItem = (type, index=0) ->
i = if (~~index > items[type].length - 1) then items[type].length - 1 else ~~index
items[type][i]