From a765535636744e1256659531d565fdb2b9679165 Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Thu, 28 Dec 2017 16:48:24 -0600 Subject: [PATCH] ability to customize start and end text re #3 --- src/player.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/player.coffee b/src/player.coffee index 51c8a11..3bc61c8 100644 --- a/src/player.coffee +++ b/src/player.coffee @@ -1,5 +1,10 @@ class Player - constructor: (@story, @id) -> + constructor: ( + @story, + @id, + @startText = "Click to start...", + @endText = '## The End\n\nYou have reached the end of this story. Click here to start over.' + ) -> @converter = new Markdown.Converter() @container = $("##{@id}") @container.addClass('ficdown').data 'player', this @@ -11,7 +16,7 @@ class Player scene.id = "s#{++i}" for scene in scenes for key, scenes of @story.scenes play: -> - @container.html @converter.makeHtml "##{@story.name}\n\n#{@story.description}\n\n[Click to start...](/#{@story.firstScene})" + @container.html @converter.makeHtml "##{@story.name}\n\n#{@story.description}\n\n[#{@startText}](/#{@story.firstScene})" @wireLinks() wireLinks: -> @@ -64,7 +69,7 @@ class Player checkGameOver: -> if @container.find('a:not(.disabled):not(.external)').length == 0 - @container.append @converter.makeHtml '## The End\n\nYou have reached the end of this story. Click here to start over.' + @container.append @converter.makeHtml @endText $('#restart').data('info', [@id, @story]).click -> info = $(this).data 'info' $("##{info[0]}").empty()