text: var jsvn=new Object;jsvn.memory={complete:0,storyObj:myVisualNovel,script:myVisualNovel.script,height:500,frame:0,prev:0,next:2,bgindex:1,timed:0,setTimer:0,choices:{},mode:{pos:{},dir:{},vis:{}}},jsvn.isEmpty=function(n){return!$.trim(n.html())},jsvn.devDisplay=function(n){$("#screen .jsvn-error").html(n).show()},jsvn.preload=function(){$("#screen").append('<div class="set"><div class="bg"></div></div><div class="portraits"><div class="portrait left"></div><div class="portrait right"></div></div><div class="text"><div class="speaker">Speaker</div><div class="line"></div></div><div class="startmenu menu"></div><div class="nav-button prev">prev</div><div class="nav-button next">next</div><div class="jsvn-error"></div>'),$(".bg, .startmenu, .text .speaker, .nav-button, .jsvn-error").hide(),"invert"===jsvn.memory.storyObj.style&&$("#screen").addClass("jsvn-theme-invert");var n=function(n){$loadImage=new Image,$loadImage.src=n};$.each(jsvn.memory.storyObj.backgrounds,function(e,t){jsvn.imgParse(t)&&n(t)}),$.each(jsvn.memory.storyObj.characters,function(e,t){$.each(t,function(e,t){jsvn.imgParse(t)&&n(t)})})},jsvn.imgParse=function(n){var e=/\.(gif|jpg|jpeg|tiff|png)$/i;return e.test(n)?!0:void 0},jsvn.textParse=function(n,e){for(var t,s,i=n,r=function(n,e){return i.replace(n,e)},a=/(?:^|\W)::(\w+)::(?!\w)/g;s=a.exec(n);)"Fetch"===s[1].substring(0,5)&&(t=s[1],t=t.replace("Fetch",""),t=jsvn.fetch(t),i="line"!==e?r(s[0],t):r(s[0]," "+t));return i},jsvn.save=function(n){var e=function(){if("erase"===n)jsvn.memory.choices={};else{var e=n.split(" ");jsvn.memory.choices[e[0]]="erase"===e[1]?"":e[1]}};e()},jsvn.fetch=function(n){return jsvn.memory.choices[n]?jsvn.memory.choices[n]:void 0},jsvn.display=function(n,e){var t=e[n],s=t.c,i=jsvn.memory.storyObj.characters[s];if(t.c&&(t.c=jsvn.textParse(t.c)),t.line)var r=jsvn.textParse(t.line,"line");t.bg&&(t.bg=jsvn.textParse(t.bg)),jsvn.display.mode=function(n){var e=function(n,e){jsvn.memory.mode[n][s]=e};n=n.split(" "),$.each(n,function(n,t){switch(t){case"left":e("pos","left");break;case"right":e("pos","right");break;case"clear":e("vis","clear");break;case"flip":e("dir","flip");break;case"unflip":e("dir","default");break;case"fadeout":e("vis","out");break;case"fadein":e("vis","in")}})},jsvn.display.background=function(n){var e=function(n){0===jsvn.memory.prev&&$(".set .bg").html(""),$(".set .bg").append($('<img src="'+n+'" class="'+t.bg+'" style="z-index: '+jsvn.memory.bgindex+'" />')).fadeIn()},s=function(n){$(".set .bg")&&$(".set .bg").fadeOut(300,function(){$(".set .bg img").remove()}),$("#screen .set").css({background:n})},i=jsvn.memory.storyObj.backgrounds[n];i||jsvn.devDisplay("Error: Background not found. Please check if background name was spelled and capitalized correctly."),jsvn.imgParse(i)?(jsvn.memory.bgindex=jsvn.memory.bgindex++,e(i)):"#"===i.substring(0,1)&&s(i)},jsvn.display.clearStage=function(n){$(n+" .sprite").fadeOut("slow",function(){$(n+" .sprite *").remove()})},jsvn.display.portrait=function(n,e){var e=jsvn.memory.mode.dir[s],n=jsvn.memory.mode.pos[s],r=".portraits ."+n;this.base=function(){$(r).append($('<div class="sprite"><img src="'+i.base+'" alt="" class="base '+e+'" /></div>').fadeIn())},this.emote=function(){$(r+" .sprite .emote").fadeOut("fast",function(){$(this).remove()}),$(r+" .sprite").append('<div class="emote"><img src="'+i[t.e]+'" alt="" class="'+e+'" /></div>').fadeIn("100"),"flip"===jsvn.memory.mode.dir[s]?$(r+" .sprite img").addClass("flip"):"default"===jsvn.memory.mode.dir[s]&&$(r+" .sprite img").hasClass("flip")&&$(r+" .sprite img").removeClass("flip")},this.vis=function(){"base"in i&&jsvn.isEmpty($(r+" .sprite"))&&this.base(),this.emote()},"clear"===jsvn.memory.mode.vis[s]?(this.clearStage(".portraits .portrait"),jsvn.memory.mode.vis[s]="default"):"out"===jsvn.memory.mode.vis[s]?this.clearStage(r):t.e&&this.vis(r+" .sprite",jsvn.memory.mode.vis[s])},jsvn.display.speaker=function(n){n?$(".text .speaker").html(n).show():$(".text .speaker").hide()},jsvn.display.text=function(n){n?($(".text .line").html(n),$(".text").show()):$(".text").is(":visible")&&$(".text").hide(),t.anitext&&jsvn.anim(".text",t.anitext)},jsvn.display.render=function(){0===jsvn.memory.frame&&$(".nav-button").hide(),1===jsvn.memory.frame&&($(".nav-button").show(),$(".startmenu").fadeOut(600,function(){$(".startmenu").hide()}),jsvn.memory.choices={saved:"default"}),t.jumpto&&jsvn.jump(t.jumpto),t.bg&&jsvn.display.background(t.bg),t.anibg&&jsvn.anim(".set .bg img:last-child",t.anibg),t.prompt&&jsvn.prompt.loadMenu(t.prompt),jsvn.display.portrait(),jsvn.display.text(r),jsvn.display.speaker(s),t.time&&(jsvn.memory.timed=1,jsvn.autoSkip(t.time))},t.mode&&jsvn.display.mode(t.mode),jsvn.display.render(t,this.scriptObj)},jsvn.anim=function(n,e){jsvn.anim.blink=function(n){!function(){setInterval(function(){$(n).fadeOut(500),$(n).fadeIn(500)},500)}()},jsvn.anim.float=function(n){!function(){setInterval(function(){$(n).animate({top:"+=5px"},"slow").animate({top:"-=5px"},"slow")},500)}()},jsvn.anim.shake=function(n){$(n).animate({left:"+=8px"},50).animate({left:"-=8px"},50).animate({left:"+=8px"},50).animate({left:"-=8px"},50)},jsvn.anim.bump=function(n){$(n).animate({bottom:"+=8px"},50).animate({bottom:"-=8px"},50).animate({bottom:"+=8px"},50).animate({bottom:"-=8px"},50)},jsvn.anim[e](n)},jsvn.Menu=function(){this.data="",this.container=".prompt",this.loadMenu=function(n){$(n).html('<ul class="list"></ul>'),$.each(this.data.menu,function(n,e){$(".list").append('<li class="item button-'+e.action+'"><span>'+e.button+"</span></li>")}),$(n).fadeIn()},this.blink=function(n){jsvn.anim(n,"blink")}},jsvn.start=new jsvn.Menu,jsvn.start.data=jsvn.memory.storyObj.start,jsvn.start.container=".startmenu",jsvn.start.hide=function(){$(jsvn.start.container).hide()},jsvn.start.show=function(){$(jsvn.start.container).show()},jsvn.start.loadMenu=function(n){$(n).html('<ul class="list"></ul>'),$.each(this.data.menu,function(n,e){$(".list").append('<li class="item button-'+e.action+'"><span>'+e.button+"</span></li>")}),jsvn.start.blink(".button-start span"),$(".button-credits")&&$(".button-credits").on("click",jsvn.credits.loadStage),$(".button-start")&&$(".button-start").on("click",function(){jsvn.router(1),$(".startmenu").fadeOut()}),$(n).fadeIn()},jsvn.prompt=new jsvn.Menu,jsvn.prompt.loadMenu=function(n){$("#screen").append('<div class="prompt"><div class="menu"><ul class="list"></ul></div></div>'),$.each(n,function(n,e){$(".list").append('<li class="item option-'+n+'"><span>'+e.option+"</span></li>"),$(".option-"+n).click(function(){$(".prompt").remove(),e.mem&&jsvn.save(e.mem,"choice"),e.jumpto?jsvn.jump(e.jumpto):jsvn.router(jsvn.memory.frame+1)})})},jsvn.Stage=function(){this.content="",this.title="New Stage",this.removeStage=function(n){$(n).remove()},this.screen=function(){$("#screen").append('<div class="info"><h3>'+this.title+'</h3><div class="content"><ul>'+this.content+"</ul></div></div>")},this.blink=function(n){jsvn.anim(n,"blink")}},jsvn.credits=new jsvn.Stage,jsvn.credits.data=jsvn.memory.storyObj.stages.credits.content,jsvn.credits.list=function(n){var e="<li><strong>Title</strong> : "+jsvn.memory.storyObj.title+"</li>";for(var t in n)e+="<li><strong>"+t+"</strong> : "+n[t]+"</li>";return e},jsvn.credits.content=jsvn.credits.list(jsvn.credits.data),jsvn.credits.title="Credits",jsvn.credits.returnButton=function(){$("#screen .info").append('<div class="returnButton"><span>Return to Main Menu</span></div>'),jsvn.credits.blink(".returnButton span"),$(".info .returnButton").on("click",function(){jsvn.credits.removeStage("#screen .info"),jsvn.start.show()})},jsvn.credits.loadStage=function(){jsvn.credits.screen(),jsvn.start.hide(),jsvn.credits.returnButton()},jsvn.jump=function(n){$returnFrame=0,$.each(jsvn.memory.script,function(e,t){n===t.ancor&&($returnFrame=e,jsvn.router($returnFrame))})},jsvn.autoSkip=function(n){"clear"===n?clearTimeout(jsvn.memory.setTimer):!isNaN(n)&&6e4>=n?(jsvn.memory.setTimer=setTimeout(function(){jsvn.router(jsvn.memory.next)},n),jsvn.memory.timed=0):jsvn.devDisplay("error: time delay value must be a number and 1 minute or less (60000 milliseconds)")},jsvn.router=function(n){$this=n,jsvn.memory.frame=$this>jsvn.memory.script.length-1?0:$this,jsvn.memory.frame===jsvn.memory.script.length-1?(jsvn.memory.next=0,jsvn.memory.complete=1):1===jsvn.memory.frame&&1===jsvn.memory.complete?jsvn.memory.complete=0:jsvn.memory.next=jsvn.memory.frame+1,jsvn.memory.prev=jsvn.memory.frame>0?jsvn.memory.frame-1:0,0===jsvn.memory.frame?(jsvn.start.loadMenu(jsvn.start.container),jsvn.display(0,jsvn.memory.storyObj.start.screen)):jsvn.display(jsvn.memory.frame,jsvn.memory.script)},jsvn.read=function(n){jsvn.memory.storyObj=n,jsvn.memory.script=n.script,jsvn.preload(),jsvn.start.loadMenu(jsvn.start.container),jsvn.router(jsvn.memory.frame),$(".set, .text, .next, .prev, .portraits").on("click",function(){jsvn.memory.timed&&(jsvn.autoSkip("clear"),jsvn.memory.timed=0),jsvn.router($(this).hasClass("prev")?jsvn.memory.frame-1:jsvn.memory.frame+1)})},jsvn.read(myVisualNovel);