Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Commit a765535

Browse files
author
Rudis Muiznieks
committed
ability to customize start and end text
re #3
1 parent 5794db2 commit a765535

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/player.coffee

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
class Player
2-
constructor: (@story, @id) ->
2+
constructor: (
3+
@story,
4+
@id,
5+
@startText = "Click to start...",
6+
@endText = '## The End\n\nYou have reached the end of this story. <a id="restart" href="">Click here</a> to start over.'
7+
) ->
38
@converter = new Markdown.Converter()
49
@container = $("##{@id}")
510
@container.addClass('ficdown').data 'player', this
@@ -11,7 +16,7 @@ class Player
1116
scene.id = "s#{++i}" for scene in scenes for key, scenes of @story.scenes
1217

1318
play: ->
14-
@container.html @converter.makeHtml "##{@story.name}\n\n#{@story.description}\n\n[Click to start...](/#{@story.firstScene})"
19+
@container.html @converter.makeHtml "##{@story.name}\n\n#{@story.description}\n\n[#{@startText}](/#{@story.firstScene})"
1520
@wireLinks()
1621

1722
wireLinks: ->
@@ -64,7 +69,7 @@ class Player
6469

6570
checkGameOver: ->
6671
if @container.find('a:not(.disabled):not(.external)').length == 0
67-
@container.append @converter.makeHtml '## The End\n\nYou have reached the end of this story. <a id="restart" href="">Click here</a> to start over.'
72+
@container.append @converter.makeHtml @endText
6873
$('#restart').data('info', [@id, @story]).click ->
6974
info = $(this).data 'info'
7075
$("##{info[0]}").empty()

0 commit comments

Comments
 (0)