Snowman 1.3: window.story
The Snowman story format doesn't always have much in the way of documentation (as of this writing, anyway), but that doesn't mean there aren't useful functions behind the scenes.
[[Through a window to a story]]As Snowman doesn't have built-in macros, JavaScript -- and jQuery! -- must be used to reference the existing functionality around global properties like those in <em>window.story</em>.
<div id="log"></div>
<script>
var propertyList = "The name of the story is: " + window.story.name + "<br>";
propertyList += "ID of the startPassage: " + window.story.startPassage + "<br>";
propertyList += "Program used to create story: " + window.story.creator + "<br>";
$("#log").html(propertyList);
</script>
[[Arrays of information about the story]]Like with Harlowe and SugarCube, it is possible to access information about the passages in the story via an API around, in Snowman, the <em>window.story</em> interface.
<div id="log"></div>
<script>
var passageList = "";
$.each(window.story.passages, function(index, passage) {
if(index != 0) {
passageList += "Passage: " + passage.name + "<br>";
}
});
$("#log").html(passageList);
</script>
[[Functions?]]Like with the other story formats, there are not just properties and values, but functions too. To get information about a passage, use <em>window.story.passage()</em> with the name of a passage in the story or use <em>window.story.render()</em> to parse and return the content of a passage.
<div id="log"></div>
<div id="passageDetails"></div>
<script>
var passageContent = window.story.render("Include me!");
$("#log").html(passageContent);
var passageDetails = window.story.passage("Unconnected!");
$("#passageDetails").html("The name of the passage is: " + passageDetails.name + " and its content is: " + passageDetails.source );
</script>
And here is some content!Extra text!