(function() { var ActorPlayer, Gst, Nev, Story, Wst; /* Iffy - parserless interactive fiction for the web (c)2010 Jeremy Penner */ Wst = function(obj, _arg) { this.gst = _arg; this.prototype = obj; return this; }; Wst.prototype.WstNext = function(nev) { var wstNext; wstNext = new Object(); wstNext.prototype = this; wstNext.nev = nev; return wstNext; }; Wst.prototype.WstPrev = function() { var _ref; return (typeof (_ref = this.prototype.nev) !== "undefined" && _ref !== null) ? this.prototype : null; }; Gst = function(_arg, _arg2) { this.jDiv = _arg2; this.story = _arg; this.wstInit = this.story.WstInit(this); return this; }; Gst.prototype.Display = function() { var _i, _len, _ref, _result, nev; this.jDiv.append("
\

" + (this.story.jStory.attr('title')) + "

\

" + (this.story.jStory.attr('author')) + "

\
"); _result = []; _ref = this.RgnevRun(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { nev = _ref[_i]; _result.push((function() { this.jDiv.append($("
").append(nev.StHtmlDisplay(this))); return this.jDiv.append($("
").append(nev.StHtmlDisplay(this))); }).call(this)); } return _result; }; Gst.prototype.RgnevRun = function() { var _i, _len, _ref, inev, nevResponse, rgnev, wst; rgnev = [this.story.NevByName("start")]; wst = this.wstInit; inev = 0; while (inev < rgnev.length) { _ref = this.story.RgnevResponse(rgnev[inev], wst); for (_i = 0, _len = _ref.length; _i < _len; _i++) { nevResponse = _ref[_i]; if (nev.FCanRun(this, wst)) { wst = wst.WstNext(nevResponse); nevReponse.RunAction(gst, wst); rgnev.push(nevResponse); } } inev++; } return rgnev; }; Gst.prototype.FilterStHtml = function(stHtml) { var _i, _len, _ref, _result, actor; _result = []; _ref = this.story.rgactor; for (_i = 0, _len = _ref.length; _i < _len; _i++) { actor = _ref[_i]; _result.push(stHtml = actor.FilterStHtml(stHtml)); } return _result; }; Nev = function(_arg) { this.jnev = _arg; return this; }; Nev.prototype.ID = function() { return this.jnev; }; Nev.prototype.FCanRun = function() { return true; }; Nev.prototype.RunAction = function(gst, wst) {}; Nev.prototype.StHtmlDisplay = function(gst) { var _i, _len, _ref, dHTML, jdivTmp, stHtml; jdivTmp = $("
"); _ref = $(this.jnev).children(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { dHTML = _ref[_i]; jdivTmp.append(document.importNode(dHTML, true)); } stHtml = jdivTmp[0].innerHTML; gst.FilterStHtml(stHtml); return stHtml; }; ActorPlayer = function(_arg) { this.story = _arg; this.mpnevID_rgaction = {}; return this; }; ActorPlayer.prototype.RgnevResponse = function(nev, wst) { var rgaction; rgaction = this.mpnevID_rgaction[nev.ID()]; return []; }; ActorPlayer.prototype.FilterStHtml = function(stHtml) { return stHtml; }; Story = function(_arg) { this.jStory = _arg; this.rgactor = [new ActorPlayer(this)]; return this; }; Story.prototype.NevByName = function(stName) { var jNev; jNev = this.jStory.find("[name=" + (stName) + "]"); return jNev.length > 0 ? new Nev(jNev[0]) : null; }; Story.prototype.RgnevResponse = function(nev, wst) { var _i, _j, _len, _len2, _ref, _ref2, actor, rgnev; rgnev = []; _ref = this.rgactor; for (_i = 0, _len = _ref.length; _i < _len; _i++) { actor = _ref[_i]; _ref2 = actor.RgnevResponse(nev, wst); for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { nev = _ref2[_j]; rgnev.push(nev); } } return rgnev; }; Story.prototype.WstInit = function(gst) { return new Wst({}, gst); }; window.PlayStory = function(url, jDiv) { return $.get(url, function(domXml) { var gst, story; story = new Story($("story", domXml)); gst = new Gst(story, jDiv); return gst.Display(); }, "xml"); }; }).call(this);