This commit is contained in:
parent
e5b9e87735
commit
5797639f99
|
@ -1,3 +1,4 @@
|
|||
*.swp
|
||||
bin/
|
||||
node_modules/
|
||||
node_modules/
|
||||
.DS_Store
|
||||
|
|
|
@ -40,14 +40,14 @@ module.exports = (grunt) ->
|
|||
files: [
|
||||
expand: true
|
||||
flatten: true
|
||||
src: ['src/example/*.html', 'src/example/*.png', 'src/example/*.md']
|
||||
src: ['src/example/*.html', 'src/example/*.png', 'src/example/*.md', 'bin/ficdown.min.js']
|
||||
dest: 'bin/example/'
|
||||
]
|
||||
|
||||
watch:
|
||||
js:
|
||||
files: ['src/**/*.coffee']
|
||||
tasks: ['build:js']
|
||||
tasks: ['build:js', 'copy:example']
|
||||
css:
|
||||
files: ['src/**/*.styl']
|
||||
tasks: ['stylus:compile']
|
||||
|
|
|
@ -14,9 +14,13 @@
|
|||
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/pagedown/1.0/Markdown.Converter.min.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/pagedown/1.0/Markdown.Sanitizer.min.js"></script>
|
||||
<script src="../ficdown.min.js"></script>
|
||||
<script src="ficdown.min.js"></script>
|
||||
<script>
|
||||
$.get('story.md', function(data){
|
||||
var story = location.search.replace('?', '');
|
||||
if(!story){
|
||||
story = 'story.md';
|
||||
}
|
||||
$.get(story, function(data){
|
||||
story = parseText(data);
|
||||
player = new Player(story, 'main');
|
||||
player.play();
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# [Testing](/scene)
|
||||
|
||||
Testing
|
||||
|
||||
## Scene
|
||||
|
||||
> This is first-seen text for the main scene.
|
||||
|
||||
This is a test.
|
||||
|
||||
- [|Set condition](?condition#condition)
|
||||
- [Go to another scene](/another-scene)
|
||||
|
||||
## Another Scene
|
||||
|
||||
> This is the first seen text of the unconditional scene.
|
||||
|
||||
This is the regular text of the unconditional scene.
|
||||
|
||||
- [Go back](/scene)
|
||||
|
||||
## [Another Scene](?condition)
|
||||
|
||||
> This is the first seen text of the conditional scene.
|
||||
|
||||
This is the regular text of the conditional scene.
|
||||
|
||||
- [Go back](/scene)
|
|
@ -7,6 +7,8 @@ class Player
|
|||
@visitedScenes = {}
|
||||
@currentScene = null
|
||||
@moveCounter = 0
|
||||
i = 0
|
||||
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})"
|
||||
|
@ -50,9 +52,9 @@ class Player
|
|||
$this.unbind 'click'
|
||||
$this.click -> return false
|
||||
|
||||
processHtml: (scene, html) ->
|
||||
processHtml: (sceneid, html) ->
|
||||
temp = $('<div/>').append $.parseHTML html
|
||||
if @visitedScenes[scene]
|
||||
if @visitedScenes[sceneid]
|
||||
temp.find('blockquote').remove()
|
||||
else
|
||||
temp.find('blockquote').each (i) ->
|
||||
|
@ -73,7 +75,6 @@ class Player
|
|||
matchedScene = null
|
||||
actions = []
|
||||
if match?.toggles?
|
||||
console.log "toggles: " + JSON.stringify match.toggles
|
||||
toggles = match.toggles.split '+'
|
||||
for toggle in toggles
|
||||
if @story.actions[toggle]?
|
||||
|
@ -95,14 +96,13 @@ class Player
|
|||
newContent = "###{newScene.name}\n\n"
|
||||
newContent += "#{action.description}\n\n" for action in actions
|
||||
newContent += newScene.description
|
||||
newHtml = @processHtml newScene.key, @converter.makeHtml newContent
|
||||
@visitedScenes[newScene.key] = true
|
||||
newHtml = @processHtml newScene.id, @converter.makeHtml newContent
|
||||
@visitedScenes[newScene.id] = true
|
||||
scrollId = "move-#{@moveCounter++}"
|
||||
@container.append $('<span/>').attr 'id', scrollId
|
||||
@container.append newHtml
|
||||
@wireLinks()
|
||||
@checkGameOver()
|
||||
console.log "scrolling to #{scrollId}"
|
||||
@container.parent('.container').animate
|
||||
scrollTop: $("##{scrollId}").offset().top - @container.offset().top
|
||||
, 1000
|
||||
|
|
|
@ -10,7 +10,7 @@ regexLib =
|
|||
|
||||
escapeChar: /\\(?=[^\\])/g
|
||||
|
||||
emptyListItem: /^\s*-\s*([\r\n]+|$)/gm
|
||||
emptyListItem: /^[ ]*-\s*([\r\n]+|$)/gm
|
||||
|
||||
matchAnchor = (text) ->
|
||||
re = new RegExp regexLib.anchors
|
||||
|
|
Loading…
Reference in New Issue