/* Parchment ========= Built: 2014-04-21 Copyright (c) 2008-2014 The Parchment Contributors BSD licenced https://github.com/curiousdannii/parchment */ (function(){"use strict";var t,e,n=0,r=/xyz/.test(function(){})?/\b_super\b/:/.*/;for(e in{toString:1})t=1;Object.subClass=function(e){var i,o,a,s=this.prototype,c=!/native code/.test(""+e.toString)&&e.toString,h=function(t,e){return function(){var n,r=this._super;return this._super=s[t],n=e.apply(this,arguments),this._super=r,n}};n=1,i=new this,n=0;for(o in e)i[o]="function"==typeof e[o]&&"function"==typeof s[o]&&r.test(e[o])?h(o,e[o]):e[o];return!t&&c&&(i.toString=r.test(c)?h("toString",c):c),a=i.init?function(){n||this.init.apply(this,arguments)}:function(){},a.prototype=i,a.constructor=a,a.subClass=Object.subClass,a},window.Class=Object})(),function(){function t(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function e(t){return[255&t>>24,255&t>>16,255&t>>8,255&t]}function n(t,e){return String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3])}function r(t){return[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]}var i=Object.subClass({init:function(e){if(this.type="",this.chunks=[],e){if("FORM"!=n (e,0))throw Error("Not an IFF file");this.type=n(e,8);for(var r=12,i=e.length;i>r;){var o=t(e,r+4);if(0>o||o+r>i)throw Error("IFF: Chunk out of range");this.chunks.push({type:n(e,r),offset:r,data:e.slice(r+8,r+8+o)}),r+=8+o,o%2&&r++}}},write:function(){for(var t=r(this.type),n=0,i=this.chunks.length;i>n;n++){var o=this.chunks[n],a=o.data,s=a.length;t=t.concat(r(o.type),e(s),a),s%2&&t.push(0)}return r("FORM").concat(e(t.length),t)}});i.num_from=t,i.num_to_word=e,i.text_from=n,i.text_to_word=r,window.IFF=i}();var extend=function(t,e){for(var n in e)t[n]=e[n];return t},rBadBackground=/inh|tra|(\d+, ?){3}0/,$window=$(window),$doc=$(document),$body,bodylineheight;$(function(){$body=$("body");var t=$(" ").appendTo($body);bodylineheight=t.height(),t.remove()}),extend($.cssHooks,{bgcolor:{get:function(t){var e=$(t),n=e.css("background-color");return rBadBackground.test(n)?e.parent().css("bgcolor"):n},set:function(t,e){var n=$(t),r=n.parent();n.css("background-color",e),rBadBackground.test(r.css("ba ckground-color"))&&r.css("bgcolor",e)}}});var scrollPages=window.scrollByPages||function(t){var e=document.documentElement.clientHeight,n=e-Math.min(e/10,2*bodylineheight);scrollBy(0,n*t)},selection=window.getSelection||function(){return document.selection?document.selection.createRange().text:""},TextInput=Object.subClass({init:function(t){var e=this,n=$("",{"class":"TextInput",autocapitalize:"off",keydown:function(t){var n,r=e.keyCode=t.which;if("line"==e.mode)return 38==r&&(e.prev_next(1),n=1),40==r&&(e.prev_next(-1),n=1),33==r&&(scrollPages(-1),n=1),34==r&&(scrollPages(1),n=1),13==r&&(e.submitLine(),n=1),t.stopPropagation(),n?!1:void 0},keypress:function(t){return"char"==e.mode?(e.charCode=t.which,e.submitChar(),!1):void 0},keyup:function(){"char"==e.mode&&e.submitChar()}});e.lastinput=$('').appendTo(t),$doc.on("click.TextInput keydown.TextInput",function(t){if("INPUT"!=t.target.nodeName&&""==selection())if($window.scrollTop()+$window.height()-n.offset().top>-60)window.scr ollTo(0,9e9),t.target=n[0],n.focus().trigger(t),t.stopPropagation();else if("keydown"==t.type&&8==t.which)return!1}),e.history=[],e.input=n,e.container=t,e.statuswin=$("
"),e.scrollParent=/webkit/i.test(navigator.userAgent)?$body:$("html")},die:function(){$doc.off(".TextInput")},scroll:function(){this.scrollParent.scrollTop(this.lastinput.offset().top-this.statuswin.height()-bodylineheight)},getLine:function(t){var e,n=t.target.children().last(),r=this.input;this.order=t,this.mode="line",this.current=0,this.mutable_history=this.history.slice(),this.mutable_history.unshift(""),e=/^([\s\S]+
)(.+?)$/.exec(n.html()),e?(n.html(e[1]),e=n.clone().html(e[2]).appendTo(n)):e=n,r.width(20).val("").appendTo(e).width(t.target.offset().left+t.target.width()-r.offset().left),this.scroll()},submitLine:function(){var t=this.input.val();this.lastinput.appendTo(this.input.parent()),this.input.detach(),t!=this.history[0]&&/\S/.test(t)&&this.history.unshift(t),$doc.trigger({type:"TextInput",mode:"line",input:t}),this.mode =0,this.order.response=t,this.order.terminator=13,this.callback(this.order)},prev_next:function(t){var e=this.input,n=this.mutable_history,r=this.current,i=r+t;n.length>i&&i>=0&&(n[r]=e.val(),e.val(n[i]),this.current=i)},getChar:function(t){this.order=t,this.mode="char",this.keyCode=this.charCode=0,this.input.addClass("CharInput").appendTo(this.container),this.scroll()},submitChar:function(){var t=this.keyCode,e=this.charCode,n={keyCode:t,charCode:e};(t||e)&&(this.input.detach().removeClass("CharInput"),$doc.trigger({type:"TextInput",mode:"char",input:n}),this.mode=0,this.order.response=n,this.callback(this.order))}}),TextGrid=Object.subClass({init:function(t,e){var n=this;this.elem=t.addClass("TextGrid").on("stream",function(t){return n.stream(t.order.data),!1}).css("bgcolor","inherit"),this.lineheight=e.env.charheight,this.io=e,e.TextInput.statuswin=this.elem,this.lines=[],this.styles=[],this.cursor=[0,0]},stream:function(t){var e,n,r,i,o,a,s,c=this.elem,h=this.cursor[0],l=this.cursor[1],u=this.lines,d=thi s.styles,p=this.io.env,f=u.length;for(r=0;t.length>r;r++){if(e=t[r],n=e.code,"height"==n){for(;e.lines>u.length;)this.addline();if(e.lines").addClass("box").prependTo(this.io.target),window.scrollTo(0,9e9),a.css({top:$window.scrollTop()+this.lineheight*e.lines,left:a.offset().left-1}),this.write(a,u.slice(e.lines),d.slice(e.lines))}u.length=e.lines,d.length=e.lines,h>e.lines-1&&(h=0,l=0)}}if("clear"==n){for(i=0;u.length>i;)this.addline(i++);h=0,l=0}if("cursor"==n)for(h=e.to[0],l=e.to[1],0>h&&(h=0),0>l&&(l=0);h>=u.length;)this.addline();if("get_cursor"==n&&(e.pos=[h,l],this.io.input(e)),"stream"==n){for(;h>=u.length;)this.addline();for(s="",e.props&&(a=$("",e.props).appendTo(c),o=a.attr("style"),o&&(s+=' style="'+o+'"'),o=a.attr("class"),o&&(s+=' class="'+o+'"')),""===s&&(s=void 0),o=e.text,i=0;o.length>i;)a=o.charAt(i++),"\r"!=a&&(u[h][l]=a,d[h][l++]=s),("\r"==a||l==p.width)&&(h++,l=0,h>=u.length&&o.lengt h>i&&this.addline())}if("eraseline"==n)for(i=l;p.width>i;i++)u[h][i]=" ",d[h][i]=void 0}this.cursor=[h,l],this.write(c,u,d),u.length!=f&&$(".main").css("padding-top",c.height())},write:function(t,e,n){for(var r,i,o,a="",s=0;e.length>s;){for(i="",o=n[s][0],r=0;e[s].length>r;r++)n[s][r]==o?i+=e[s][r]:(a+=""+i+"",o=n[s][r],i=e[s][r]);a+=""+i+"",++s")}t.html(a)},addline:function(t){var e=this.io.env.width,n=[],r=0;for(t=t||this.lines.length;e>r++;)n.push(" ");this.lines[t]=n,this.styles[t]=Array(e)}}),basic_stream_handler=function(t){var e=t.order,n=t.io.structures[e.name]||{node:"span"},r=e.node||e.props&&e.props.node||n.node,i=$("<"+r+">",e.props||{}).appendTo(t.target);return e.name&&i.addClass(e.name),e.text&&i.text(e.text.replace(/\r/g,"\n")),n.func&&n.func(i,t.io),!1};StructIO=Object.subClass({init:function(t){t=extend({},t),this.env=t;var e=$(t.container),n=$("00000").appendTo(e),r=n.height(),i=n.width()/5,o=Math.min(Math.floor(e.width() /i),t.width||80);n.remove(),extend(t,{charheight:r,charwidth:i,width:o,fgcolour:e.css("color"),bgcolour:e.css("bgcolor")}),e.width(o*i+2),this.container=e,this.target=e,e.on("stream",basic_stream_handler),this.TextInput=new TextInput(e),this.structures={main:{node:"div"},status:{node:"div",func:function(t,e){new TextGrid(t,e)}}}},event:function(t){var e,n,r,i,o=this.target,a=this.TextInput;for(r=0;t.length>r;r++){if(e=t[r],n=e.code,"structures"==n&&(e.code=void 0,$.extend(this.structures,e)),"find"==n&&(this.target=o=$("."+e.name)),"stream"==n&&(e.to?$("."+e.to):o).trigger({type:"stream",io:this,order:e}),"clear"==n){var s,c=e.bg,i=e.name?$("."+e.name):o;i.empty(),c!==void 0&&("main"==e.name&&(i=$body),s=/zvm-bg-\d+/.exec(i.attr("class")),s&&i.removeClass(s[0]),isNaN(c)?i.css("background-color",c):i.addClass("zvm-bg-"+c))}"read"==n&&(e.target=o,a.getLine(e)),"char"==n&&a.getChar(e),"quit"==n&&a.scroll()}}}),function(t){t.StructIO=StructIO,StructIO.TextInput=TextInput}(window,jQuery);var Runner=Object.subClas s({init:function(t,e){var n=this;e=window.engine=this.e=new window[e],this.io=new StructIO(t),this.toEngine=this.io.TextInput.callback=function(t){e.inputEvent(t)},e.outputEvent=function(t){n.fromEngine(t)}},fromParchment:function(t){var e=t.code;"load"==e&&(t.env=this.io.env),this.toEngine(t)},fromEngine:function(t){var e,n,r,i=(this.e,0);for(this.io.event(t);t.length>i;i++){if(e=t[i],n=e.code,"quit"==n)return;("save"==n||"restore"==n)&&this.toParchment(e),"restart"==n&&(this.io.target=this.io.container.empty(),r=1),"tick"==n&&(r=1)}r&&this.toEngine(e)}});(function(t,e){"use strict";jQuery.ajaxSetup({cache:1,converters:{"* binary":!0}}),jQuery.ajaxPrefilter("script",function(t){t.isLocal&&(t.crossDomain=1)}),t.parchment={options:{container:"#parchment",lib_path:"lib/",page_title:1,panels:["search","url","about"],proxy_url:"http://zcode.appspot.com/proxy/"},lib:{}};var n=function(t){var e,n=0,r={};for(""==t[0]&&n++;t.length>n;)e=/([^=]+)(=(.*))?/.exec(t[n++]),r[e[1]]=e[3]?unescape(e[3]):!0;return r}(location .search.slice(1).split(/[&;]/g));(function(e){t.FatalError=function(t){this.message=t,this.traceback="",this.onError(this),e(".load").length>0&&e(".load").detach()},FatalError.prototype={onError:function(n){var r=n.message;e("#parchment").append('
An error occurred:
'+r+"\n\n"+n.traceback+"
"),t.console&&console.error(r)},_makeTraceback:function(t){for(var e="",n=0,r=100;null!=t&&r>n;){var i=""+t;if(i){var o=i.match(/function (\w*)/);e=o&&o[1]?"\n "+o[1]+e:"\n (anonymous function)"+e}else e="\n (anonymous function)"+e;try{t=t.caller}catch(a){t=null}n++}return n==r&&(e="..."+e),"Traceback (most recent call last):\n"+e}}})(jQuery),function(t,e){function n(t,n){e.ajax(t,{dataType:"binary"}).success(function(t,e,r){n(r.responseArray)})}t.execScript&&execScript("Function VBCStr(x)\nVBCStr=CStr(x)\nEnd Function\nFunction VBLastAsc(x)\nDim l\nl=LenB(x)\nIf l mod 2 Then\nVBLastAsc=AscB(MidB(x,l,1))\nElse\nVBLastAsc=-1\nEnd If\nEnd Function","VBScript");var r=/chrome\/(\d+)/i. exec(navigator.userAgent),i=r&&parseInt(r[1])>4,o=function(t){return t.replace(/\u20ac/g,"\u0080").replace(/\u201a/g,"\u0082").replace(/\u0192/g,"\u0083").replace(/\u201e/g,"\u0084").replace(/\u2026/g,"\u0085").replace(/\u2020/g,"\u0086").replace(/\u2021/g,"\u0087").replace(/\u02c6/g,"\u0088").replace(/\u2030/g,"\u0089").replace(/\u0160/g,"\u008a").replace(/\u2039/g,"\u008b").replace(/\u0152/g,"\u008c").replace(/\u017d/g,"\u008e").replace(/\u2018/g,"\u0091").replace(/\u2019/g,"\u0092").replace(/\u201c/g,"\u0093").replace(/\u201d/g,"\u0094").replace(/\u2022/g,"\u0095").replace(/\u2013/g,"\u0096").replace(/\u2014/g,"\u0097").replace(/\u02dc/g,"\u0098").replace(/\u2122/g,"\u0099").replace(/\u0161/g,"\u009a").replace(/\u203a/g,"\u009b").replace(/\u0153/g,"\u009c").replace(/\u017e/g,"\u009e").replace(/\u0178/g,"\u009f")},a=function(t,e){var n,e=e||[],r=0;for(n=t.length%8;n>r;++r)e.push(255&t.charCodeAt(r));for(n=t.length;n>r;)e.push(255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeA t(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++));return e},s=function(t,e){return(e||"")+String.fromCharCode.apply(1,t)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=function(){for(var t=[],e=0;c.length>e;e++)t[c.charAt(e)]=e;return t}(),l=function(e,n){if(t.atob)return a(atob(e),n);for(var r,i,o,s,c,l,u,n=n||[],d=0,p=e.length;p>d;)s=h[e.charAt(d++)],c=h[e.charAt(d++)],l=h[e.charAt(d++)],u=h[e.charAt(d++)],r=(s<<2)+(c>>4),i=((15&c)<<4)+(l>>2),o=((3&l)<<6)+u,n.push(r,i,o);return 64==u&&n.pop(),64==l&&n.pop(),n},u=function(e,n){if(t.btoa)return btoa(s(e,n));for(var r,i,o,a,h,l,u,n=n||"",d=0,p=e.length;p>d;)r=e[d++],i=e[d++],o=e[d++],a=r>>2,h=((3&r)<<4)+(i>>4),l=((15&i)<<2)+(o>>6),u=63&o,n+=c.charAt(a)+c.charAt(h)+c.charAt(l)+c.charAt(u);return isNaN(i)?n=n.slice(0,-2)+"==":isNaN(o)&&(n=n.slice(0,-1)+"="),n},d=function(t){for(var e,n=VBCStr(t),r=VBLastAsc(t),i=[],o=0,a=n.length%4;a>o;)i.push(255&(e=n.charCodeAt(o++)),e>>8);for(a=n.length; a>o;)i.push(255&(e=n.charCodeAt(o++)),e>>8,255&(e=n.charCodeAt(o++)),e>>8,255&(e=n.charCodeAt(o++)),e>>8,255&(e=n.charCodeAt(o++)),e>>8);return r>-1&&i.push(r),i},p=jQuery.ajaxSettings.xhr(),f={binary:p.overrideMimeType?"charset":"responseBody"in p?"responseBody":0},m=function(n,r,i){var s,c;n=e.trim(n),"base64"==i.mode?t.atob?(c=atob(n),s=a(c)):s=l(n):"charset"==i.mode?(c=o(n),s=a(c)):s=d(i.xhr.responseBody),i.responseArray=s,i.responseText=c};p=void 0,e.ajaxPrefilter("binary",function(t,n,r){var o=t.isLocal&&!t.crossDomain&&i?0:f.binary,a=t.xhr;return t.xhr=function(){return r.xhr=a.apply(t)},t.binary=o,r.done(m),t.jsonp=!1,t.jsonpCallback="processBase64Zcode",r.mode="base64",".js"==t.url.slice(-3).toLowerCase()?"jsonp":o&&!t.crossDomain?"text":t.legacy?(t.url=t.legacy,"jsonp"):(t.data="url="+t.url,t.url=parchment.options.proxy_url,o&&e.support.cors?"text":(t.data+="&encode=base64&callback=pproxy",t.jsonpCallback="pproxy","jsonp"))}),e.ajaxPrefilter("text",function(t,e,n){n.mode=t.binary,"charset"==n.mode& &(t.mimeType="text/plain; charset=windows-1252")}),t.file={text_to_array:a,array_to_text:s,base64_decode:l,base64_encode:u,support:f},t.file.download_to_array=n}(t,jQuery),function(t){var e='

'+t.desc+"

"};parchment.lib.UI=Object.subClass({init:function(e){this.library=e,this.panels={},this.load_indicator=t('

Parchment is loading.

> _

')},stylesheet_add:function(){var e,n=arguments;for(e=1;n.length>e;e++)document.createStyleSheet?document.createStyleSheet(n[e]):t("",{rel:"alternate stylesheet",href:n[e],title:n[0],type:"text/css"}).appendTo("head")[0].disabled=!0},stylesheet_switch:function(e,n){t('link[rel*="stylesheet"][title="'+e+'"]').each(function(){this.disabled=!n})},load_panels:function(){var e,r,i,o=parchment.options.panels,a=function(){var o=RegExp(r.val().replace(" ","( )?"),"i"),a=t.grep(e,function(t){return o.test(t.path+t.desc)});a=a. slice(0,30),i.html(t.map(a,n).join(""))};-1!=t.inArray("search",o)&&(this.panels.search=t(''),r=this.panels.search.find("input"),i=r.next(),r.keydown(function(){r.unbind("keydown"),t.getJSON("stories/if-archive.json").done(function(t){e=t,r.keyup(a),a()})})),-1!=t.inArray("url",o)&&(this.panels.url=t('
')),this.library.container.append(this.panels[o[0]]),this.panels.active=o[0]}})}(jQuery),function(t,e){var r=/([-\w\s_]+)(\.[\w]+(\.js)?)?$/,i=/\.js$/,o=function(){throw new FatalError("Parchment could not load the story. Check your connection, and that the URL is correct.")},a=function(n){e(".load").detach();var r=t.runner=new(t[n[2].vm.runner]||Runner)(parchment.options,n[2].vm.engine),i=location.hash;r.toParchment=function(t){n[2].library.fromRunner(r,t)},r.fromParchment({code:"load",data:new parchment.lib.Story(n[2].responseArray).data}),i&&"#"!=i?r.fromParchment({code:"restore",data:file.base64_decode(i.slice(1))}):r.fromParchment({code:"restart"})};parchment.lib.Story=IFF.subClass({init:function(t,n){if(this.title=n,9>t[0])this._super(),this.chunks.push({type:"ZCOD",data:t}),this.data=t;else if("Glul"==IFF.text_from(t,0))this._super(),this.chunks.push({type:"GLUL",data:t}),this.data=t;else if("FORM"==IFF.text_from(t,0)&&(this._super(t),"IFRS"==this.type))for(var r=0,i=this.chunks.length;i>r;r++){var o=this.chunks[r].type;if("ZCOD"!=o||this.zcode)if("GLUL"!=o||this.glulx){if("IFmd"==o){this.metadata=file.array_to_text(this.chunks[r].data);var a=e(this.metadata);a&&(e("title",a)&&(this.title=e("title",a).text()),e("ifid",a)&&(this.ifid=e("ifid",a) .text()),e("release",a)&&(this.release=e("release",a).text()))}}else this.data=this.chunks[r].data;else this.data=this.chunks[r].data}}});var s=Object.subClass({add:function(t){this[t.ifid]=t,t.url&&(this.url[t.url]=t)},url:{}}),c=Object.subClass({init:function(){this.container=e(parchment.options.container),this.ui=new parchment.lib.UI(this)},load:function(){var i,o,a=this,s=parchment.options,c=n.story,h=n.vm,l=0;if(s.lock_story){if(c=s.default_story,!c)throw new FatalError("Story file not specified")}else{if(!s.default_story&&!c)return this.ui.load_panels();c=c||s.default_story}if(e("#about").remove(),e("body").append(a.ui.load_indicator),e.isArray(c)||(c=[c,0]),o=c[0],a.url=o,i=r.exec(o),i=i?i[1]+" - Parchment":"Parchment",s.page_title&&(t.document.title=i),h)h=parchment.vms[h];else for(;parchment.vms.length>l;l++)if(parchment.vms[l].match.test(o)){h=parchment.vms[l];break}if(!h)throw new FatalError("File type is not supported!");try{this.launch(h,c)}catch(u){throw new FatalError(u)}},launch:function(t,n) {var r=this,s=[e.ajax(n[0],{dataType:"binary",legacy:n[1]}).done(function(e,n,i){i.library=r,i.vm=t}).fail(o)],c=[e.Deferred()],h=function(){if(0==t.files.length)return c[0].resolve(),void 0;var n=parchment.options.lib_path+t.files.shift();i.test(n)?e.getScript(n,h):(parchment.library.ui.stylesheet_add(t.id,n),h())};t.loaded||(t.loaded=1,h(),s[1]=e.when.apply(1,c)),e.when.apply(1,s).done(a)},fromRunner:function(t,e){var n=e.code,r=location.hash;"save"==n&&(location.hash=file.base64_encode(e.data)),"restore"==n&&r&&"#"!=r&&(e.data=file.base64_decode(r.slice(1))),t.fromParchment(e)},stories:new s,savefiles:{}});parchment.lib.Library=c,parchment.vms=[],parchment.add_vm=function(t){parchment.vms.push(t),parchment.vms[t.id]=t}}(t,jQuery),parchment.add_vm({id:"quixe",match:/(ulx|glb|(g|glulx.+)(blorb|blb))(.js)?$/i,files:["prototype.min.js","glkote.min.js","quixe.min.js","glkote.min.css"],runner:"QuixeRunner"}),parchment.add_vm({id:"zvm",match:/(z[58]|zlb|(z|zcode.+)(blorb|blb))(.js)?$/i,files:["zvm.min.js"],engin e:"ZVM"}),parchment.add_vm({id:"gnusto",match:/(z[1-8]|zlb|(z|zcode.+)(blorb|blb))(.js)?$/i,files:["gnusto.min.js"],runner:"GnustoRunner"}),e(function(){var r;t.parchment_options&&e.extend(parchment.options,parchment_options),!parchment.options.lock_options&&n.options&&e.extend(parchment.options,e.parseJSON(n.options)),parchment.options.debug=n.debug,r=new parchment.lib.Library,parchment.library=r,r.load(),-1!=location.href.indexOf("iplayif.com")&&e.getScript("http://google-analytics.com/ga.js",function(){_gat._getTracker("UA-7949545-3")._trackPageview()})})})(this,jQuery);