/
parchment.min.js
1 lines (1 loc) · 20.6 KB
/
parchment.min.js
1
(function(){window.gIsIphone=navigator.userAgent.match(/iPhone/i);var b;var a="0";$(document).ready(function(){b=document.getElementById("top-window");a="0";var d=navigator.appVersion.match(/MSIE (\d+)\./);if(d&&+d[1]<7){b.style.position="absolute";var c=function(){b.style.top=1*(document.documentElement.scrollTop+1*a)+"px"};window.onscroll=c;window.onresize=c}})})();function EngineRunner(d,c,e){this._engine=d;this._zui=c;this._isRunning=false;this._isInLoop=false;this._isWaitingForCallback=false;this._log=e;var b=this;var a={stop:function(){b._isRunning=false},run:function(){var f=b._zui.getSize();b._zui.setVersion(b._engine.m_version);b._isRunning=true;b._engine.m_memory[32]=f[1];b._engine.m_memory[33]=f[0];b._continueRunning()},_continueRunning:function(){while(b._isRunning&&!b._isWaitingForCallback){b._loop()}},_receiveLineInput:function(f){b._isWaitingForCallback=false;b._engine.answer(0,13);b._engine.answer(1,f);if(!b._isInLoop){b._continueRunning()}else{}},_receiveCharacterInput:function(f){b._isWaitingForCallback=false;b._engine.answer(0,f);if(!b._isInLoop){b._continueRunning()}else{}},_unWimpOut:function(){b._isWaitingForCallback=false;if(!b._isInLoop){b._continueRunning()}else{}},_loop:function(){if(b._isInLoop){throw new FatalError("Already in loop!")}b._isInLoop=true;var k=b._engine;k.run();var o=k.consoleText();if(o){b._zui.onPrint(o)}var q='"'+k.effect(0)+'"';var g="[ "+k.effect(0);for(var h=1;k.effect(h)!=undefined;h++){var n=k.effect(h);if(typeof n=="string"){n=n.quote()}g+=", "+n}b._log(g+" ]");switch(q){case GNUSTO_EFFECT_INPUT:b._isWaitingForCallback=true;b._zui.onLineInput(b._receiveLineInput);break;case GNUSTO_EFFECT_INPUT_CHAR:b._isWaitingForCallback=true;b._zui.onCharacterInput(b._receiveCharacterInput);break;case GNUSTO_EFFECT_SAVE:k.saveGame();if(b._zui.onSave(k.saveGameData())){k.answer(0,1)}else{k.answer(0,0)}break;case GNUSTO_EFFECT_RESTORE:var r=b._zui.onRestore();if(r){var l=new Beret(k);l.load(r)}else{k.answer(0,0)}break;case GNUSTO_EFFECT_QUIT:b.stop();b._zui.onQuit();break;case GNUSTO_EFFECT_RESTART:b.stop();b._zui.onRestart();break;case GNUSTO_EFFECT_WIMP_OUT:b._isWaitingForCallback=true;b._zui.onWimpOut(b._unWimpOut);break;case GNUSTO_EFFECT_BREAKPOINT:throw new FatalError("Unimplemented effect: "+q);case GNUSTO_EFFECT_FLAGS_CHANGED:var j=k.m_printing_header_bits&1;var m=k.m_printing_header_bits&2;b._zui.onFlagsChanged(j,m);break;case GNUSTO_EFFECT_PIRACY:throw new FatalError("Unimplemented effect: "+q);case GNUSTO_EFFECT_STYLE:b._zui.onSetStyle(k.effect(1),k.effect(2),k.effect(3));break;case GNUSTO_EFFECT_SOUND:break;case GNUSTO_EFFECT_SPLITWINDOW:b._zui.onSplitWindow(k.effect(1));break;case GNUSTO_EFFECT_SETWINDOW:b._zui.onSetWindow(k.effect(1));break;case GNUSTO_EFFECT_ERASEWINDOW:b._zui.onEraseWindow(k.effect(1));break;case GNUSTO_EFFECT_ERASELINE:throw new FatalError("Unimplemented effect: "+q);case GNUSTO_EFFECT_SETCURSOR:b._zui.onSetCursor(k.effect(2),k.effect(1));break;case GNUSTO_EFFECT_SETBUFFERMODE:b._zui.onSetBufferMode(k.effect(1));break;case GNUSTO_EFFECT_SETINPUTSTREAM:case GNUSTO_EFFECT_GETCURSOR:throw new FatalError("Unimplemented effect: "+q);break;case GNUSTO_EFFECT_PRINTTABLE:var f=k.effect(1);var p=[];for(h=0;h<f;h++){p.push(k.effect(2+h))}b._zui.onPrintTable(p);break}b._isInLoop=false}};for(name in a){b[name]=a[name]}}function Console(d,a,c,b){this.width=d;this.height=a;this._element=c;this._pos=[0,0];this._observer=b;this._isRenderScheduled=false;this.clear()}Console.prototype={resize:function(a){var b=a-this.height;if(b==0){return}var c;if(b>0){for(c=0;c<b;c++){this._addRow()}}else{for(c=0;c<-b;c++){this._delRow()}}this.height=a;this._scheduleRender()},_delRow:function(){this._characters.pop();this._styles.pop()},_addRow:function(){var b=[];var c=[];for(var a=0;a<this.width;a++){b.push(" ");c.push(null)}this._characters.push(b);this._styles.push(c)},clear:function(){this._characters=[];this._styles=[];for(var a=0;a<this.height;a++){this._addRow()}this._scheduleRender()},moveTo:function(a,b){this._pos=[a,b]},write:function(b,d){var a=this._pos[0];var f=this._pos[1];for(var c=0;c<b.length;c++){var e=null;if(b.charAt(c)==" "){e=" "}else{if(b.charAt(c)=="\n"){a=0;f+=1}else{e=b.charAt(c).entityify()}}if(f>this.height-1){this.resize(f+1)}if(e!=null){this._characters[f][a]=e;this._styles[f][a]=d;a+=1}}this._pos=[a,f];this._scheduleRender()},_scheduleRender:function(){if(!this._isRenderScheduled){this._isRenderScheduled=true;var a=this;window.setTimeout(function(){a._doRender()},0)}},renderHtml:function(){var c="";for(var d=0;d<this.height;d++){var b=null;for(var a=0;a<this.width;a++){if(this._styles[d][a]!==b){if(b!==null){c+="</span>"}b=this._styles[d][a];if(b!==null){c+='<span class="'+b+'">'}}c+=this._characters[d][a]}if(b!==null){c+="</span>"}c+="<br/>"}return c},_doRender:function(){this._element.innerHTML=this.renderHtml();this._isRenderScheduled=false;this._observer.onConsoleRender()},close:function(){this._element.innerHTML="";this._observer.onConsoleRender()}};var ESCAPE_KEYCODE=27;var BACKSPACE_KEYCODE=8;var RETURN_KEYCODE=13;var SHIFT_KEYCODE=16;var LEFT_KEYCODE=37;var UP_KEYCODE=38;var RIGHT_KEYCODE=39;var DOWN_KEYCODE=40;var ZSCII_UP=129;var ZSCII_DOWN=130;var ZSCII_LEFT=131;var ZSCII_RIGHT=132;var ZSCII_NEWLINE=13;var ZSCII_DELETE=8;var ZSCII_ESCAPE=27;var __origKeyCodeHandlerMap={BACKSPACE_KEYCODE:"backwardDeleteChar",LEFT_KEYCODE:"backwardChar",UP_KEYCODE:"previousHistory",RIGHT_KEYCODE:"forwardChar",DOWN_KEYCODE:"nextHistory"};var __originalKeyCodeToZSCIIMap={RETURN_KEYCODE:ZSCII_NEWLINE,BACKSPACE_KEYCODE:ZSCII_DELETE,ESCAPE_KEYCODE:ZSCII_ESCAPE,LEFT_KEYCODE:ZSCII_LEFT,UP_KEYCODE:ZSCII_UP,RIGHT_KEYCODE:ZSCII_RIGHT,DOWN_KEYCODE:ZSCII_DOWN};function constKeysToValues(c,b){var a={};for(name in c){a[b[name]]=c[name]}return a}var keyCodeHandlerMap=constKeysToValues(__origKeyCodeHandlerMap,this);var keyCodeToZSCIIMap=constKeysToValues(__originalKeyCodeToZSCIIMap,this);function LineEditor(){this.line="";this.pos=0;this._history=[""];this._savedHistory={};this._historyPos=0;var a=this;this.acceptLine=function(){var b=a.line;a.line="";a.pos=0;for(var c in a._savedHistory){a._history[c]=a._savedHistory[c]}a._savedHistory={};if(b.length>0){a._history[a._history.length-1]=b;a._history.push("")}a._historyPos=a._history.length-1;return b};this.forwardChar=function(){if(a.pos<a.line.length){a.pos++}};this.backwardChar=function(){if(a.pos>0){a.pos--}};this.backwardDeleteChar=function(){if(a.pos>0){var c=a.line.slice(0,a.pos-1);var b=a.line.slice(a.pos);if(b.charAt(0)==" "&&c.charAt(c.length-1)==" "){b=b.slice(1)}a.line=c+b;a.pos--}};this.selfInsert=function(d){var b=String.fromCharCode(d);if(b==" "){if(a.pos>0&&a.line.charAt(a.pos-1)==" "){return}else{if(a.pos<a.line.length&&a.line.charAt(a.pos)==" "){return}}}a.line=(a.line.slice(0,a.pos)+b+a.line.slice(a.pos));a.pos++};this._saveHistoryExcursion=function(){if(a._history[a._historyPos]!=a._line){if(!(a._historyPos in a._savedHistory)){a._savedHistory[a._historyPos]=a._history[a._historyPos]}a._history[a._historyPos]=a.line}};this.previousHistory=function(){if(a._historyPos<=0){return}a._saveHistoryExcursion();a._historyPos--;a.line=a._history[a._historyPos];a.pos=a.line.length};this.nextHistory=function(){if(a._historyPos+1>=a._history.length){return}a._saveHistoryExcursion();a._historyPos++;a.line=a._history[a._historyPos];a.pos=a.line.length}}function WebZui(e){var a=gIsIphone?38:80;this._size=[a,25];this._console=null;this._activeWindow=0;this._lineEditor=new LineEditor();this._currentCallback=null;this._foreground="default";this._background="default";this._reverseVideo=false;this._lastSeenY=0;this._currStyles=["z-roman"];this._expectedHash=window.location.hash;this._isFixedWidth=false;this._bufferMode=0;this.bottom=$("#bottom");this.current_input=$("#current-input");if(e){this._log=e}else{this._log=function(){}}var c=this;var b={onConsoleRender:function(){var g=$("#top-window").height();$("#content").css({padding:""+g+"px 0 0 0"});c._scrollBottomWindow()},_scrollBottomWindow:function(){if(!gIsIphone){window.scroll(0,c._lastSeenY)}},_finalize:function(){if(c._console){c._console.close();c._console=null}$("#content").empty();c._unbindEventHandlers()},_bindEventHandlers:function(){if(gIsIphone){$(document).keyup(c._iphoneKeyup)}else{$(document).bind("keydown","Ctrl+v",c._windowPasteHandler).keypress(c._windowKeypress).keyup(c._windowKeyup).keydown(c._windowKeydown).mousewheel(c._windowMousewheel)}$(window).resize(c._windowResize);c._intervalId=window.setInterval(c._windowHashCheck,1000)},_unbindEventHandlers:function(){if(gIsIphone){$(document).unbind("keyup",c._iphoneKeyup)}else{$(document).unbind("keydown","Ctrl+v",c._windowPasteHandler).unbind("keypress",c._windowKeypress).unbind("keyup",c._windowKeyup).unbind("keydown",c._windowKeydown).unbind("mousewheel",c._windowMousewheel)}$(window).unbind("resize",c._windowResize);window.clearInterval(c._intervalId)},_windowMousewheel:function(g,h){window.scrollBy(0,-h*5)},_isHotKey:function(g){return(g.altKey||g.ctrlKey||g.metaKey)},_iphoneKeyup:function(g){$("#iphone-text-field").val("");var h=new Object();switch(g.keyCode){case 127:h.keyCode=BACKSPACE_KEYCODE;break;case 10:h.keyCode=RETURN_KEYCODE;break;default:h.charCode=g.keyCode}return c._handleKeyEvent(h)},_windowKeyup:function(g){if(jQuery.browser.mozilla){return c._isHotKey(g)}else{return true}},_windowKeydown:function(g){if(jQuery.browser.mozilla){return c._isHotKey(g)}else{if(((jQuery.browser.safari||jQuery.browser.msie)&&(!jQuery.browser.opera)&&(g.keyCode==LEFT_KEYCODE||g.keyCode==UP_KEYCODE||g.keyCode==RIGHT_KEYCODE||g.keyCode==DOWN_KEYCODE||g.keyCode==BACKSPACE_KEYCODE))){return c._handleKeyEvent(g)}else{return true}}},_windowKeypress:function(g){if(c._isHotKey(g)){return true}if(jQuery.browser.mozilla){return c._handleKeyEvent(g)}else{var h=new Object();if(jQuery.browser.opera){h.charCode=g.which;if(g.which!=LEFT_KEYCODE&&g.which!=RIGHT_KEYCODE&&g.which!=UP_KEYCODE&&g.which!=DOWN_KEYCODE){h.keyCode=g.keyCode}}else{if(jQuery.browser.safari){if(g.charCode&&g.keyCode!=RETURN_KEYCODE){h.charCode=g.charCode}else{h.keyCode=g.keyCode}}else{if(jQuery.browser.msie){if(g.keyCode==RETURN_KEYCODE){h.keyCode=g.keyCode}else{h.charCode=g.keyCode}}}}return c._handleKeyEvent(h)}},_handleKeyEvent:function(g){if(g.keyCode==SHIFT_KEYCODE){return false}c._removeBufferedWindows();c._lastSeenY=c.bottom.offset().top;c._scrollBottomWindow();if(c.current_input.length==0){if(c._currentCallback){var p=0;if(g.charCode){p=g.charCode}else{if(keyCodeToZSCIIMap[g.keyCode]){p=keyCodeToZSCIIMap[g.keyCode]}}if(p!=0){var o=c._currentCallback;c._currentCallback=null;o(p)}}return false}var i=c._lineEditor.line;var h=c._lineEditor.pos;if(g.keyCode==RETURN_KEYCODE){var k=c._lineEditor.acceptLine();var o=c._currentCallback;c._currentCallback=null;c._lastSeenY=c.current_input.offset().top;var q=c.current_input.attr("class");c.current_input.replaceWith(('<span class="finished-input '+q+'">'+k.entityify()+"</span><br/>"));c.current_input=$("#current-input");o(k)}else{if(g.keyCode in keyCodeHandlerMap){c._lineEditor[keyCodeHandlerMap[g.keyCode]]()}else{if(g.charCode){c._lineEditor.selfInsert(g.charCode)}}}if(c.current_input&&(i!=c._lineEditor.line||h!=c._lineEditor.pos)){var j=c._lineEditor.line.slice(0,c._lineEditor.pos);var n;var m;var l;if(c._lineEditor.line.length<=c._lineEditor.pos){n="";m="_";l="cursor"}else{n=c._lineEditor.line.slice(c._lineEditor.pos+1);m=c._lineEditor.line.charAt(c._lineEditor.pos);l="editing-cursor";if(m==" "){m=" "}else{m=m.entityify()}}c.current_input.html(j.entityify()+'<span id="'+l+'">'+m+"</span>"+n.entityify())}return false},_windowPasteHandler:function(g){if(c.current_input.length!=0){$("#pasteinput").focus();window.setTimeout(c._inputPasteHandler,10)}},_inputPasteHandler:function(j){var h=$("#pasteinput").val();$("#pasteinput").val("");var k={charCode:0,keyCode:0};for(var g=0;g<h.length;g++){k.charCode=h.charCodeAt(g);c._handleKeyEvent(k)}},_windowResize:function(){var g=$("#content").offset().left+"px";$(".buffered-window").css({left:g})},_windowHashCheck:function(){if(window.location.hash!=c._expectedHash){c._restart()}},_removeBufferedWindows:function(){var g=$("#buffered-windows > .buffered-window");g.fadeOut("slow",function(){g.remove()})},_eraseBottomWindow:function(){$("#content").empty();this._lastSeenY=0},_restart:function(){c._finalize();window.setTimeout(_webZuiStartup,0)},setVersion:function(g){c._version=g},getSize:function(){return c._size},onLineInput:function(i){if(window.engine.m_version<=3){var g=c._activeWindow;var h=this._reverseVideo;if(!c._console){c.onSplitWindow(1)}c._console.moveTo(0,0);c._activeWindow=1;this._reverseVideo=true;c.onPrint(window.engine.getStatusLine(c._console.width));this._reverseVideo=h;c._activeWindow=g}c._currentCallback=i;$("#content").append('<span id="current-input"><span id="cursor">_</span></span>');c.current_input=$("#current-input");c.current_input.attr("class",c._calcFinalStyles())},onCharacterInput:function(g){c._currentCallback=g},onSave:function(i){var h=gStory+"_saveData";var g=file.base64_encode(i);if(window.globalStorage){window.globalStorage[location.hostname][h]=g}window.location.hash="#"+g;c._expectedHash=window.location.hash;c.onPrint("Your game has been saved to the URL. You may want to bookmark this page now; just reload it at any time to restore your game from this point.\n");return true},onRestore:function(){var h=null;if(window.location.hash){h=window.location.hash.slice(1)}if(!h&&window.globalStorage){var g=globalStorage[location.hostname][gStory+"_saveData"];if(g){h=g.value}}if(h){window.location.hash="#"+h;c._expectedHash=window.location.hash;return file.base64_decode(h)}else{return null}},onQuit:function(){c._finalize()},onRestart:function(){c._finalize();window.location.hash="";c._restart()},onWimpOut:function(g){window.setTimeout(g,50)},onFlagsChanged:function(g,h){if(g){throw new FatalError("To transcript not yet implemented!")}c._isFixedWidth=h},onSetStyle:function(j,i,h){switch(j){case -1:break;case 0:this._currStyles=["z-roman"];this._reverseVideo=false;break;case 1:this._reverseVideo=true;break;case 2:this._currStyles.push("z-bold");break;case 4:this._currStyles.push("z-italic");break;case 8:this._currStyles.push("z-fixed-pitch");break;default:throw new FatalError("Unknown style: "+j)}var g={0:null,1:"default",2:"black",3:"red",4:"green",5:"yellow",6:"blue",7:"magenta",8:"cyan",9:"white"};if(g[i]){this._foreground=g[i]}if(g[h]){this._background=g[h]}},onSetWindow:function(g){if(g==1){if(!c._console){c.onSplitWindow(1)}c._console.moveTo(0,0)}c._activeWindow=g},onEraseWindow:function(g){document.body.className="bg-"+c._background;if(g==-2){c._console.clear();c._eraseBottomWindow()}else{if(g==-1){c.onSplitWindow(0);c._eraseBottomWindow()}else{if(g==0){c._eraseBottomWindow()}else{if(g==1&&c._console){c._console.clear()}}}}},onSetCursor:function(g,h){if(c._console){c._console.moveTo(g-1,h-1)}},onSetBufferMode:function(g){c._bufferMode=g},onSplitWindow:function(h){if(h==0){if(c._console){c._console.close();c._console=null}}else{if(!c._console||c._version==3||!c._bufferMode){c._console=new Console(c._size[0],h,$("#top-window").get(0),c)}else{if(c._console.height!=h){var g=document.createElement("div");g.className="buffered-window";g.innerHTML=c._console.renderHtml();$(g).css({width:c._pixelWidth+"px",lineHeight:c._pixelLineHeight+"px"});$("#buffered-windows").append(g);c._windowResize();c._console.resize(h)}}}c._bufferMode=0},_calcFinalStyles:function(){var h=c._foreground;var i=c._background;if(c._reverseVideo){h=c._background;i=c._foreground;if(h=="default"){h="default-reversed"}if(i=="default"){i="default-reversed"}}var g=["fg-"+h,"bg-"+i];if(c._isFixedWidth){g.push("z-fixed-pitch")}return g.concat(c._currStyles).join(" ")},onPrint:function(k){var n=c._calcFinalStyles();c._log("print wind: "+c._activeWindow+" output: "+k.quote()+" style: "+n);if(c._activeWindow==0){var h=k.split("\n");for(var m=0;m<h.length;m++){if(h[m]){var l=h[m].entityify();var j=/ /g,g=/(\S) (\S)/g,o=/<&>/g;l=l.replace(g,"$1<&>$2");l=l.replace(j," ");l=l.replace(o,'<span class="z-breaking-whitespace"> </span>');l='<span class="'+n+'">'+l+"</span>";$("#content").append(l)}if(m<h.length-1){$("#content").append("<br/>")}}c._scrollBottomWindow()}else{c._console.write(k,n)}},onPrintTable:function(g){for(var h=0;h<g.length;h++){c.onPrint(g[h])}},_setFixedPitchSizes:function(){var k=document.createElement("div");k.className="buffered-window";for(var j=0;j<c._size[0];j++){k.innerHTML+="O"}k.innerHTML="<span>"+k.innerHTML+"</span>";$("#buffered-windows").append(k);c._pixelWidth=$(k).width();if(jQuery.browser.msie&&(jQuery.browser.version.length==1||jQuery.browser.version.charAt(1)==".")&&jQuery.browser.version<"7"){var h=-1,g=document.getElementById("top-window").currentStyle.fontSize.toLowerCase();if(g.substring(g.length-2)=="px"){h=0.6*parseInt(g)}else{if(g.substring(g.length-2)=="pt"){h=0.8*parseInt(g)}}if(h>0){c._pixelWidth=c._size[0]*h}}c._pixelLineHeight=$(k.firstChild).height();$("#buffered-windows").empty()}};for(name in b){c[name]=b[name]}c._setFixedPitchSizes();$("#top-window").css({width:c._pixelWidth+"px",lineHeight:c._pixelLineHeight+"px"});$("#content").css({width:c._pixelWidth+"px"});c._windowResize();c._bindEventHandlers();c._eraseBottomWindow();if(gIsIphone){$(document.body).append('<textarea class="iphone-visible" id="iphone-text-field" rows="1" cols="20" autocapitalize="off">Tap here to enter text.</textarea>');var d=-1*$("#iphone-text-field").height();$("#iphone-text-field").css({top:d+"px"});function f(){$(this).removeClass("iphone-visible");$(this).addClass("iphone-invisible");$(this).unbind("click",f)}$("#iphone-text-field").click(f)}}FatalError.prototype.onError=function(b){var a=b.message;if(typeof b.message=="string"){a=a.entityify()}$("#content").append('<div class="error">An error occurred:<br/><pre>'+a+"\n\n"+b.traceback+"</pre></div>")};(function(e){var g=IFF.extend({init:function a(o,j){this.title=j;if(o[0]<9){this.filetype="ok story naked zcode";this._super();this.chunks.push({type:"ZCOD",data:o});this.zcode=o}else{if(IFF.text_from(o,0)=="FORM"){this._super(o);if(this.type=="IFRS"){for(var m=0,h=this.chunks.length;m<h;m++){var n=this.chunks[m].type;if(n=="ZCOD"&&!this.zcode){this.zcode=this.chunks[m].data}else{if(n=="IFmd"){this.metadata=file.array_to_text(this.chunks[m].data);var k=$(this.metadata);if(k){if($("title",k)){this.title=$("title",k).text()}if($("ifid",k)){this.ifid=$("ifid",k).text()}if($("release",k)){this.release=$("release",k).text()}}}}}if(this.zcode){this.filetype="ok story blorbed zcode"}else{this.filetype="error: no zcode in blorb"}}else{if(this.type=="IFZS"){this.filetype="error: trying to load a Quetzal savefile"}else{this.filetype="error unknown iff"}}}else{this.filetype="error unknown general"}}},load:function b(h){if(this.zcode){h.loadStory(this.zcode)}}});var c=Class.extend({add:function(h){this[h.ifid]=h;if(h.url){this.url[h.url]=h}},url:{}});e.Library=Class.extend({load:function(k){var h=new Querystring(),i=h.get("story",parchment.options.default_story);storyName=f(i);storyName=storyName?storyName+" - Parchment":"Parchment";e.document.title=storyName;if(this.stories.url[i]){var j=this.stories.url[i]}else{$("#progress-text").html("Retrieving story file...");if(i.slice(-3).toLowerCase()==".js"){$.getScript(i)}else{$.getScript(parchment.options.zcode_appspot_url+"?url="+escape(i)+"&jsonp=processZcodeAppspotResponse")}}},stories:new c(),savefiles:{}});function f(i){var h=i.lastIndexOf("/");return i.slice(h+1)}e.gZcode=null;e.gStory="";e.processZcodeAppspotResponse=function(h){if(h.error){throw new FatalError("Error loading story: "+h.error.entityify())}processBase64Zcode(h.data)};e.processBase64Zcode=function(l,n){var k=50000,j,h=l.slice(0,k),o=l.slice(k);if(typeof(n)=="undefined"){n=[]}$("#progress-text").html("Decoding "+l.length+" more bytes...");file.base64_decode(h,n);if(o){j=function m(){processBase64Zcode(o,n)}}else{j=function i(){gZcode=n;$("#progress-text").html("Starting interpreter...");d()}}e.setTimeout(j,1)};function d(){var l=function(){};if(e.loadFirebugConsole){e.loadFirebugConsole()}if(e.console){l=function(m){console.log(m)}}e.engine=new GnustoEngine(l);var i=new WebZui(l);var k=new EngineRunner(engine,i,l);e.story=new g(gZcode.slice(),storyName);story.load(engine);l("Story type: "+story.filetype);if(e.location.hash){var h=new Beret(engine);var j=e.location.hash.slice(1);h.load(file.base64_decode(j));l("Load game story type: "+h.m_filetype)}k.run()}})(window);(function(a){var c=a.parchment;c.options={default_story:"stories/troll.z5.js",zcode_appspot_url:"http://zcode.appspot.com/"};function b(){if(a.parchment_options){$.extend(c.options,parchment_options)}var d=new Library();c.library=d;d.load();$.getScript("lib/gnusto.min.js");if(location.href.slice(0,31)=="http://parchment.googlecode.com"){$.getScript("http://www.google-analytics.com/ga.js",function(){gat._getTracker("UA-7949545-1")._trackPageview()})}}$(b)})(window);