Files
y2k/public/app.js
2020-06-09 08:49:22 -04:00

161 lines
106 KiB
JavaScript

/*!
* noVNC: HTML5 VNC client
* Copyright (C) 2012 Joel Martin
* Copyright (C) 2013 Samuel Mannehed for Cendio AB
* Copyright (C) 2013 NTT corp.
* Licensed under MPL 2.0 (see https://github.com/novnc/noVNC/blob/master/LICENSE.txt)
*/
"use strict";var Util={},addFunc=function(cl,name,func){cl.prototype[name]||Object.defineProperty(cl.prototype,name,{enumerable:!1,value:func})};addFunc(Array,"push8",(function(num){this.push(255&num)}));addFunc(Array,"push16",(function(num){this.push(num>>8&255,255&num)}));addFunc(Array,"push32",(function(num){this.push(num>>24&255,num>>16&255,num>>8&255,255&num)}));addFunc(Array,"map",(function(fun){var len=this.length;if("function"!=typeof fun)throw new TypeError;for(var res=new Array(len),thisp=arguments[1],i=0;i<len;i++)i in this&&(res[i]=fun.call(thisp,this[i],i,this));return res}));addFunc(Array,"indexOf",(function(elt){var len=this.length>>>0,from=Number(arguments[1])||0;(from=from<0?Math.ceil(from):Math.floor(from))<0&&(from+=len);for(;from<len;from++)if(from in this&&this[from]===elt)return from;return-1}));Object.keys||(Object.keys=function(){var hasOwnProperty=Object.prototype.hasOwnProperty,hasDontEnumBug=!{toString:null}.propertyIsEnumerable("toString"),dontEnums=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],dontEnumsLength=dontEnums.length;return function(obj){if("object"!=typeof obj&&("function"!=typeof obj||null===obj))throw new TypeError("Object.keys called on non-object");var prop,i,result=[];for(prop in obj)hasOwnProperty.call(obj,prop)&&result.push(prop);if(hasDontEnumBug)for(i=0;i<dontEnumsLength;i++)hasOwnProperty.call(obj,dontEnums[i])&&result.push(dontEnums[i]);return result}}());window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1e3/60)};Util._log_level="warn";Util.init_logging=function(level){void 0===level?level=Util._log_level:Util._log_level=level;void 0===window.console&&(void 0!==window.opera?window.console={log:window.opera.postError,warn:window.opera.postError,error:window.opera.postError}:window.console={log:function(){},warn:function(){},error:function(){}});Util.Debug=Util.Info=Util.Warn=Util.Error=function(){};switch(level){case"debug":Util.Debug=function(){};case"info":Util.Info=function(){};case"warn":Util.Warn=function(){};case"error":Util.Error=function(){};case"none":break;default:throw"invalid logging type '"+level+"'"}};Util.get_logging=function(){return Util._log_level};Util.init_logging();Util.conf_default=function(cfg,api,defaults,v,mode,type,defval,desc){var getter,setter;getter=function(idx){return type in{arr:1,array:1}&&void 0!==idx?cfg[v][idx]:cfg[v]};setter=function(val,idx){type in{boolean:1,bool:1}?val=!(!val||val in{0:1,no:1,false:1}):type in{integer:1,int:1}?val=parseInt(val,10):"str"===type?val=String(val):"func"===type&&(val||(val=function(){}));void 0!==idx?cfg[v][idx]=val:cfg[v]=val};api[v+"_description"]=desc;void 0===api["get_"+v]&&(api["get_"+v]=getter);void 0===api["set_"+v]&&(api["set_"+v]=function(val,idx){if(mode in{RO:1,ro:1})throw v+" is read-only";if(mode in{WO:1,wo:1}&&void 0!==cfg[v])throw v+" can only be set once";setter(val,idx)});void 0!==defaults[v]?defval=defaults[v]:!(type in{arr:1,array:1})||defval instanceof Array||(defval=[]);setter(defval)};Util.conf_defaults=function(cfg,api,defaults,arr){var i;for(i=0;i<arr.length;i++)Util.conf_default(cfg,api,defaults,arr[i][0],arr[i][1],arr[i][2],arr[i][3],arr[i][4])};Util.decodeUTF8=function(utf8string){return decodeURIComponent(escape(utf8string))};Util.getPosition=function(obj){var x=0,y=0;if(obj.offsetParent)do{x+=obj.offsetLeft;y+=obj.offsetTop;obj=obj.offsetParent}while(obj);return{x:x,y:y}};Util.getEventPosition=function(e,obj,scale){var evt,docX,docY,pos;if((evt=(evt=e||window.event).changedTouches?evt.changedTouches[0]:evt.touches?evt.touches[0]:evt).pageX||evt.pageY){docX=evt.pageX;docY=evt.pageY}else if(evt.clientX||evt.clientY){docX=evt.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;docY=evt.clientY+document.body.scrollTop+document.documentElement.scrollTop}void 0===scale&&(scale=1);var realx=docX-(pos=Util.getPosition(obj)).x,realy=docY-pos.y;return{x:Math.max(Math.min(realx,obj.width-1),0)/scale,y:Math.max(Math.min(realy,obj.height-1),0)/scale,realx:realx/scale,realy:realy/scale}};Util.addEvent=function(obj,evType,fn){if(obj.attachEvent)return obj.attachEvent("on"+evType,fn);if(obj.addEventListener){obj.addEventListener(evType,fn,!1);return!0}throw"Handler could not be attached"};Util.removeEvent=function(obj,evType,fn){if(obj.detachEvent)return obj.detachEvent("on"+evType,fn);if(obj.removeEventListener){obj.removeEventListener(evType,fn,!1);return!0}throw"Handler could not be removed"};Util.stopEvent=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0;e.preventDefault?e.preventDefault():e.returnValue=!1};Util.Features={xpath:!!document.evaluate,air:!!window.runtime,query:!!document.querySelector};Util.Engine={presto:!!window.opera,trident:!!window.ActiveXObject&&(window.XMLHttpRequest?document.querySelectorAll?6:5:4),webkit:function(){try{return!navigator.taintEnabled&&(Util.Features.xpath?Util.Features.query?525:420:419)}catch(e){return!1}}(),gecko:!(!document.getBoxObjectFor&&null==window.mozInnerScreenX)&&(document.getElementsByClassName?19:18)};Util.Engine.webkit&&(Util.Engine.webkit=function(v){var re=new RegExp("WebKit/([0-9.]*) ");v=(navigator.userAgent.match(re)||["",v])[1];return parseFloat(v,10)}(Util.Engine.webkit));var tinf,Base64={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode:function(data){var result="",toBase64Table=Base64.toBase64Table,length=data.length,lengthpad=length%3,i=0,j=0;for(i=0;i<length-2;i+=3){result+=toBase64Table[data[i]>>2];result+=toBase64Table[((3&data[i])<<4)+(data[i+1]>>4)];result+=toBase64Table[((15&data[i+1])<<2)+(data[i+2]>>6)];result+=toBase64Table[63&data[i+2]]}if(2===lengthpad){result+=toBase64Table[data[j=length-lengthpad]>>2];result+=toBase64Table[((3&data[j])<<4)+(data[j+1]>>4)];result+=toBase64Table[(15&data[j+1])<<2];result+=toBase64Table[64]}else if(1===lengthpad){result+=toBase64Table[data[j=length-lengthpad]>>2];result+=toBase64Table[(3&data[j])<<4];result+=toBase64Table[64];result+=toBase64Table[64]}return result},toBinaryTable:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1],decode:function(data,offset){offset=void 0!==offset?offset:0;var result,result_length,idx,i,c,padding,toBinaryTable=Base64.toBinaryTable,base64Pad=Base64.base64Pad,leftbits=0,leftdata=0,data_length=data.indexOf("=")-offset;data_length<0&&(data_length=data.length-offset);result_length=3*(data_length>>2)+Math.floor(data_length%4/1.5);result=new Array(result_length);for(idx=0,i=offset;i<data.length;i++){c=toBinaryTable[127&data.charCodeAt(i)];padding=data.charAt(i)===base64Pad;if(-1!==c){leftdata=leftdata<<6|c;if((leftbits+=6)>=8){leftbits-=8;padding||(result[idx++]=leftdata>>leftbits&255);leftdata&=(1<<leftbits)-1}}}if(leftbits)throw{name:"Base64-Error",message:"Corrupted base64 string"};return result}};
/*!
* This DES class has been extracted from package Acme.Crypto for use in VNC.
* The unnecessary odd parity code has been removed.
*
* These changes are:
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*
* DesCipher - the DES encryption method
*
* The meat of this code is by Dave Zimmerman <dzimm@widget.com>, and is:
*
* Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
* without fee is hereby granted, provided that this copyright notice is kept
* intact.
*
* WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
* OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
* THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
* CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
* PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
* NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
* SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
* SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
* PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP
* SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
* HIGH RISK ACTIVITIES.
*
*
* The rest is:
*
* Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Visit the ACME Labs Java page for up-to-date versions of this and other
* fine Java utilities: http://www.acme.com/java/
*/
function DES(passwd){var a,b,c,d,e,f,SP1,SP2,SP3,SP4,SP5,SP6,SP7,SP8,PC2=[13,16,10,23,0,4,2,27,14,5,20,9,22,18,11,3,25,7,15,6,26,19,12,1,40,51,30,36,46,54,29,39,50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31],totrot=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],keys=[];SP1=[(c=(a=65536)|(b=1<<24))|(e=1024),0,0|a,c|(f=(d=4)|e),c|d,a|f,0|d,0|a,0|e,c|e,c|f,0|e,b|f,c|d,0|b,0|d,0|f,b|e,b|e,a|e,a|e,0|c,0|c,b|f,a|d,b|d,b|d,a|d,0,0|f,a|f,0|b,0|a,c|f,0|d,0|c,c|e,0|b,0|b,0|e,c|d,0|a,a|e,b|d,0|e,0|d,b|f,a|f,c|f,a|d,0|c,b|f,b|d,0|f,a|f,c|e,0|f,b|e,b|e,0,a|d,a|e,0,c|d];SP2=[(c=(a=1<<20)|(b=1<<31))|(f=(d=32)|(e=32768)),b|e,0|e,a|f,0|a,0|d,c|d,b|f,b|d,c|f,c|e,0|b,b|e,0|a,0|d,c|d,a|e,a|d,b|f,0,0|b,0|e,a|f,0|c,a|d,b|d,0,a|e,0|f,c|e,0|c,0|f,0,a|f,c|d,0|a,b|f,0|c,c|e,0|e,0|c,b|e,0|d,c|f,a|f,0|d,0|e,0|b,0|f,c|e,0|a,b|d,a|d,b|f,b|d,a|d,a|e,0,b|e,0|f,0|b,c|d,c|f,a|e];SP3=[0|(f=(d=8)|(e=512)),(c=(a=1<<17)|(b=1<<27))|e,0,c|d,b|e,0,a|f,b|e,a|d,b|d,b|d,0|a,c|f,a|d,0|c,0|f,0|b,0|d,c|e,0|e,a|e,0|c,c|d,a|f,b|f,a|e,0|a,b|f,0|d,c|f,0|e,0|b,c|e,0|b,a|d,0|f,0|a,c|e,b|e,0,0|e,a|d,c|f,b|e,b|d,0|e,0,c|d,b|f,0|a,0|b,c|f,0|d,a|f,a|e,b|d,0|c,b|f,0|f,0|c,a|f,0|d,c|d,a|e];SP4=[(c=(a=8192)|(b=1<<23))|(d=1),a|(f=d|(e=128)),a|f,0|e,c|e,b|f,b|d,a|d,0,0|c,0|c,c|f,0|f,0,b|e,b|d,0|d,0|a,0|b,c|d,0|e,0|b,a|d,a|e,b|f,0|d,a|e,b|e,0|a,c|e,c|f,0|f,b|e,b|d,0|c,c|f,0|f,0,0,0|c,a|e,b|e,b|f,0|d,c|d,a|f,a|f,0|e,c|f,0|f,0|d,0|a,b|d,a|d,c|e,b|f,a|d,a|e,0|b,c|d,0|e,0|b,0|a,c|e];SP5=[0|(d=256),(a=1<<25)|(f=d|(e=1<<19)),a|e,(c=a|(b=1<<30))|d,0|e,0|d,0|b,a|e,b|f,0|e,a|d,b|f,c|d,c|e,0|f,0|b,0|a,b|e,b|e,0,b|d,c|f,c|f,a|d,c|e,b|d,0,0|c,a|f,0|a,0|c,0|f,0|e,c|d,0|d,0|a,0|b,a|e,c|d,b|f,a|d,0|b,c|e,a|f,b|f,0|d,0|a,c|e,c|f,0|f,0|c,c|f,a|e,0,b|e,0|c,0|f,a|d,b|d,0|e,0,b|e,a|f,b|d];SP6=[(b=1<<29)|(d=16),0|(c=(a=1<<22)|b),0|(e=16384),c|(f=d|e),0|c,0|d,c|f,0|a,b|e,a|f,0|a,b|d,a|d,b|e,0|b,0|f,0,a|d,b|f,0|e,a|e,b|f,0|d,c|d,c|d,0,a|f,c|e,0|f,a|e,c|e,0|b,b|e,0|d,c|d,a|e,c|f,0|a,0|f,b|d,0|a,b|e,0|b,0|f,b|d,c|f,a|e,0|c,a|f,c|e,0,c|d,0|d,0|e,0|c,a|f,0|e,a|d,b|f,0,c|e,0|b,a|d,b|f];SP7=[0|(a=1<<21),(c=a|(b=1<<26))|(d=2),b|(f=d|(e=2048)),0,0|e,b|f,a|f,c|e,c|f,0|a,0,b|d,0|d,0|b,c|d,0|f,b|e,a|f,a|d,b|e,b|d,0|c,c|e,a|d,0|c,0|e,0|f,c|f,a|e,0|d,0|b,a|e,0|b,a|e,0|a,b|f,b|f,c|d,c|d,0|d,a|d,0|b,b|e,0|a,c|e,0|f,a|f,c|e,0|f,b|d,c|f,0|c,a|e,0,0|d,c|f,0,a|f,0|c,0|e,b|d,b|e,0|e,a|d];SP8=[(b=1<<28)|(f=(d=64)|(e=4096)),0|e,0|(a=1<<18),(c=a|b)|f,0|b,b|f,0|d,0|b,a|d,0|c,c|f,a|e,c|e,a|f,0|e,0|d,0|c,b|d,b|e,0|f,a|e,a|d,c|d,c|e,0|f,0,0,c|d,b|d,b|e,a|f,0|a,a|f,0|a,c|e,0|e,0|d,c|d,0|e,a|f,b|e,0|d,b|d,0|c,c|d,0|b,0|a,b|f,0,c|f,a|d,b|d,0|c,b|e,b|f,0,c|f,a|e,a|e,0|f,0|f,a|d,0|b,c|e];function enc8(text){var fval,l,r,x,i=0,b=text.slice(),keysi=0;l=b[i++]<<24|b[i++]<<16|b[i++]<<8|b[i++];r=b[i++]<<24|b[i++]<<16|b[i++]<<8|b[i++];r^=x=252645135&(l>>>4^r);r^=x=65535&((l^=x<<4)>>>16^r);r^=(x=858993459&(r>>>2^(l^=x<<16)))<<2;r=(r^=(x=16711935&(r>>>8^(l^=x)))<<8)<<1|r>>>31&1;r^=x=2863311530&((l^=x)^r);l=(l^=x)<<1|l>>>31&1;for(i=0;i<8;++i){x=r<<28|r>>>4;x^=keys[keysi++];fval=SP7[63&x];fval|=SP5[x>>>8&63];fval|=SP3[x>>>16&63];fval|=SP1[x>>>24&63];x=r^keys[keysi++];fval|=SP8[63&x];fval|=SP6[x>>>8&63];fval|=SP4[x>>>16&63];x=(l^=fval|=SP2[x>>>24&63])<<28|l>>>4;x^=keys[keysi++];fval=SP7[63&x];fval|=SP5[x>>>8&63];fval|=SP3[x>>>16&63];fval|=SP1[x>>>24&63];x=l^keys[keysi++];fval|=SP8[63&x];fval|=SP6[x>>>8&63];fval|=SP4[x>>>16&63];r^=fval|=SP2[x>>>24&63]}r=r<<31|r>>>1;r^=x=2863311530&(l^r);r^=x=16711935&((l=(l^=x)<<31|l>>>1)>>>8^r);r^=x=858993459&((l^=x<<8)>>>2^r);r^=(x=65535&(r>>>16^(l^=x<<2)))<<16;x=[r^=(x=252645135&(r>>>4^(l^=x)))<<4,l^=x];for(i=0;i<8;i++){b[i]=(x[i>>>2]>>>8*(3-i%4))%256;b[i]<0&&(b[i]+=256)}return b}(function(keyBlock){var i,j,l,m,n,o,raw0,raw1,rawi,KnLi,pc1m=[],pcr=[],kn=[];for(j=0,l=56;j<56;++j,l-=8){m=7&(l+=l<-5?65:l<-3?31:l<-1?63:27===l?35:0);pc1m[j]=0!=(keyBlock[l>>>3]&1<<m)?1:0}for(i=0;i<16;++i){n=1+(m=i<<1);kn[m]=kn[n]=0;for(o=28;o<59;o+=28)for(j=o-28;j<o;++j){l=j+totrot[i];pcr[j]=l<o?pc1m[l]:pc1m[l-28]}for(j=0;j<24;++j){0!==pcr[PC2[j]]&&(kn[m]|=1<<23-j);0!==pcr[PC2[j+24]]&&(kn[n]|=1<<23-j)}}for(i=0,rawi=0,KnLi=0;i<16;++i){raw0=kn[rawi++];raw1=kn[rawi++];keys[KnLi]=(16515072&raw0)<<6;keys[KnLi]|=(4032&raw0)<<10;keys[KnLi]|=(16515072&raw1)>>>10;keys[KnLi]|=(4032&raw1)>>>6;++KnLi;keys[KnLi]=(258048&raw0)<<12;keys[KnLi]|=(63&raw0)<<16;keys[KnLi]|=(258048&raw1)>>>4;keys[KnLi]|=63&raw1;++KnLi}})(passwd);return{encrypt:function(t){return enc8(t.slice(0,8)).concat(enc8(t.slice(8,16)))}}}function Display(defaults){var rgbImageData,bgrxImageData,cmapImageData,setFillColor,rescale,scan_renderQ,that={},conf={},c_ctx=null,renderQ=[],fb_width=0,fb_height=0,viewport={x:0,y:0,w:0,h:0},cleanRect={x1:0,y1:0,x2:-1,y2:-1},c_prevStyle="",tile=null,tile16x16=null,tile_x=0,tile_y=0;Util.conf_defaults(conf,that,defaults,[["target","wo","dom",null,"Canvas element for rendering"],["context","ro","raw",null,"Canvas 2D context for rendering (read-only)"],["logo","rw","raw",null,'Logo to display when cleared: {"width": width, "height": height, "data": data}'],["true_color","rw","bool",!0,"Use true-color pixel data"],["colourMap","rw","arr",[],"Colour map array (when not true-color)"],["scale","rw","float",1,"Display area scale factor 0.0 - 1.0"],["viewport","rw","bool",!1,"Use a viewport set with viewportChange()"],["width","rw","int",null,"Display area width"],["height","rw","int",null,"Display area height"],["render_mode","ro","str","","Canvas rendering mode (read-only)"],["prefer_js","rw","str",null,"Prefer Javascript over canvas methods"],["cursor_uri","rw","raw",null,"Can we render cursor using data URI"]]);that.get_context=function(){return c_ctx};that.set_scale=function(scale){rescale(scale)};that.set_width=function(val){that.resize(val,fb_height)};that.get_width=function(){return fb_width};that.set_height=function(val){that.resize(fb_width,val)};that.get_height=function(){return fb_height};rescale=function(factor){var c,tp,x,y,properties=["transform","WebkitTransform","MozTransform",null];c=conf.target;tp=properties.shift();for(;tp&&void 0===c.style[tp];)tp=properties.shift();if(null!==tp){void 0===factor?factor=conf.scale:factor>1?factor=1:factor<.1&&(factor=.1);if(conf.scale!==factor){conf.scale=factor;x=c.width-c.width*factor;y=c.height-c.height*factor;c.style[tp]="scale("+conf.scale+") translate(-"+x+"px, -"+y+"px)"}}};setFillColor=function(color){var bgr,newStyle;if((newStyle="rgb("+(bgr=conf.true_color?color:conf.colourMap[color[0]])[2]+","+bgr[1]+","+bgr[0]+")")!==c_prevStyle){c_ctx.fillStyle=newStyle;c_prevStyle=newStyle}};that.viewportChange=function(deltaX,deltaY,width,height){var saveStyle,x1,y1,vx2,vy2,w,h,c=conf.target,v=viewport,cr=cleanRect,saveImg=null;if(!conf.viewport){deltaX=-v.w;deltaY=-v.h;width=fb_width;height=fb_height}void 0===deltaX&&(deltaX=0);void 0===deltaY&&(deltaY=0);void 0===width&&(width=v.w);void 0===height&&(height=v.h);width>fb_width&&(width=fb_width);height>fb_height&&(height=fb_height);if(v.w!==width||v.h!==height){width<v.w&&cr.x2>v.x+width-1&&(cr.x2=v.x+width-1);v.w=width;height<v.h&&cr.y2>v.y+height-1&&(cr.y2=v.y+height-1);v.h=height;v.w>0&&v.h>0&&c.width>0&&c.height>0&&(saveImg=c_ctx.getImageData(0,0,c.width<v.w?c.width:v.w,c.height<v.h?c.height:v.h));c.width=v.w;c.height=v.h;saveImg&&c_ctx.putImageData(saveImg,0,0)}vx2=v.x+v.w-1;vy2=v.y+v.h-1;deltaX<0&&v.x+deltaX<0&&(deltaX=-v.x);vx2+deltaX>=fb_width&&(deltaX-=vx2+deltaX-fb_width+1);v.y+deltaY<0&&(deltaY=-v.y);vy2+deltaY>=fb_height&&(deltaY-=vy2+deltaY-fb_height+1);if(0!==deltaX||0!==deltaY){v.x+=deltaX;vx2+=deltaX;v.y+=deltaY;vy2+=deltaY;v.x>cr.x1&&(cr.x1=v.x);vx2<cr.x2&&(cr.x2=vx2);v.y>cr.y1&&(cr.y1=v.y);vy2<cr.y2&&(cr.y2=vy2);if(deltaX<0){x1=0;w=-deltaX}else{x1=v.w-deltaX;w=deltaX}if(deltaY<0){y1=0;h=-deltaY}else{y1=v.h-deltaY;h=deltaY}saveStyle=c_ctx.fillStyle;c_ctx.fillStyle="rgb(255,255,255)";if(0!==deltaX){c_ctx.drawImage(c,0,0,v.w,v.h,-deltaX,0,v.w,v.h);c_ctx.fillRect(x1,0,w,v.h)}if(0!==deltaY){c_ctx.drawImage(c,0,0,v.w,v.h,0,-deltaY,v.w,v.h);c_ctx.fillRect(0,y1,v.w,h)}c_ctx.fillStyle=saveStyle}};that.getCleanDirtyReset=function(){var cleanBox,v=viewport,c=cleanRect,dirtyBoxes=[],vx2=v.x+v.w-1,vy2=v.y+v.h-1;cleanBox={x:c.x1,y:c.y1,w:c.x2-c.x1+1,h:c.y2-c.y1+1};if(c.x1>=c.x2||c.y1>=c.y2)dirtyBoxes.push({x:v.x,y:v.y,w:v.w,h:v.h});else{v.x<c.x1&&dirtyBoxes.push({x:v.x,y:v.y,w:c.x1-v.x+1,h:v.h});vx2>c.x2&&dirtyBoxes.push({x:c.x2+1,y:v.y,w:vx2-c.x2,h:v.h});v.y<c.y1&&dirtyBoxes.push({x:c.x1,y:v.y,w:c.x2-c.x1+1,h:c.y1-v.y});vy2>c.y2&&dirtyBoxes.push({x:c.x1,y:c.y2+1,w:c.x2-c.x1+1,h:vy2-c.y2})}cleanRect={x1:v.x,y1:v.y,x2:v.x+v.w-1,y2:v.y+v.h-1};return{cleanBox:cleanBox,dirtyBoxes:dirtyBoxes}};that.absX=function(x){return x+viewport.x};that.absY=function(y){return y+viewport.y};that.resize=function(width,height){c_prevStyle="";fb_width=width;fb_height=height;rescale(conf.scale);that.viewportChange()};that.clear=function(){if(conf.logo){that.resize(conf.logo.width,conf.logo.height);that.blitStringImage(conf.logo.data,0,0)}else{that.resize(640,20);c_ctx.clearRect(0,0,viewport.w,viewport.h)}renderQ=[]};that.fillRect=function(x,y,width,height,color){setFillColor(color);c_ctx.fillRect(x-viewport.x,y-viewport.y,width,height)};that.copyImage=function(old_x,old_y,new_x,new_y,w,h){var x1=old_x-viewport.x,y1=old_y-viewport.y,x2=new_x-viewport.x,y2=new_y-viewport.y;c_ctx.drawImage(conf.target,x1,y1,w,h,x2,y2,w,h)};that.startTile=function(x,y,width,height,color){var data,bgr,red,green,blue,i;tile_x=x;tile_y=y;data=(tile=16===width&&16===height?tile16x16:c_ctx.createImageData(width,height)).data;if(conf.prefer_js){red=(bgr=conf.true_color?color:conf.colourMap[color[0]])[2];green=bgr[1];blue=bgr[0];for(i=0;i<width*height*4;i+=4){data[i]=red;data[i+1]=green;data[i+2]=blue;data[i+3]=255}}else that.fillRect(x,y,width,height,color)};that.subTile=function(x,y,w,h,color){var data,p,bgr,red,green,blue,width,j,i,xend,yend;if(conf.prefer_js){data=tile.data;width=tile.width;red=(bgr=conf.true_color?color:conf.colourMap[color[0]])[2];green=bgr[1];blue=bgr[0];xend=x+w;yend=y+h;for(j=y;j<yend;j+=1)for(i=x;i<xend;i+=1){data[p=4*(i+j*width)]=red;data[p+1]=green;data[p+2]=blue;data[p+3]=255}}else that.fillRect(tile_x+x,tile_y+y,w,h,color)};that.finishTile=function(){conf.prefer_js&&c_ctx.putImageData(tile,tile_x-viewport.x,tile_y-viewport.y)};rgbImageData=function(x,y,vx,vy,width,height,arr,offset){var img,i,j,data;data=(img=c_ctx.createImageData(width,height)).data;for(i=0,j=offset;i<width*height*4;i+=4,j+=3){data[i]=arr[j];data[i+1]=arr[j+1];data[i+2]=arr[j+2];data[i+3]=255}c_ctx.putImageData(img,x-vx,y-vy)};bgrxImageData=function(x,y,vx,vy,width,height,arr,offset){var img,i,j,data;data=(img=c_ctx.createImageData(width,height)).data;for(i=0,j=offset;i<width*height*4;i+=4,j+=4){data[i]=arr[j+2];data[i+1]=arr[j+1];data[i+2]=arr[j];data[i+3]=255}c_ctx.putImageData(img,x-vx,y-vy)};cmapImageData=function(x,y,vx,vy,width,height,arr,offset){var img,i,j,data,bgr,cmap;data=(img=c_ctx.createImageData(width,height)).data;cmap=conf.colourMap;for(i=0,j=offset;i<width*height*4;i+=4,j+=1){bgr=cmap[arr[j]];data[i]=bgr[2];data[i+1]=bgr[1];data[i+2]=bgr[0];data[i+3]=255}c_ctx.putImageData(img,x-vx,y-vy)};that.blitImage=function(x,y,width,height,arr,offset){conf.true_color?bgrxImageData(x,y,viewport.x,viewport.y,width,height,arr,offset):cmapImageData(x,y,viewport.x,viewport.y,width,height,arr,offset)};that.blitRgbImage=function(x,y,width,height,arr,offset){conf.true_color?rgbImageData(x,y,viewport.x,viewport.y,width,height,arr,offset):cmapImageData(x,y,viewport.x,viewport.y,width,height,arr,offset)};that.blitStringImage=function(str,x,y){var img=new Image;img.onload=function(){c_ctx.drawImage(img,x-viewport.x,y-viewport.y)};img.src=str};that.drawImage=function(img,x,y){c_ctx.drawImage(img,x-viewport.x,y-viewport.y)};that.renderQ_push=function(action){renderQ.push(action);1===renderQ.length&&scan_renderQ()};scan_renderQ=function(){for(var a,ready=!0;ready&&renderQ.length>0;){switch((a=renderQ[0]).type){case"copy":that.copyImage(a.old_x,a.old_y,a.x,a.y,a.width,a.height);break;case"fill":that.fillRect(a.x,a.y,a.width,a.height,a.color);break;case"blit":that.blitImage(a.x,a.y,a.width,a.height,a.data,0);break;case"blitRgb":that.blitRgbImage(a.x,a.y,a.width,a.height,a.data,0);break;case"img":a.img.complete?that.drawImage(a.img,a.x,a.y):ready=!1}ready&&(a=renderQ.shift())}renderQ.length>0&&requestAnimFrame(scan_renderQ)};that.changeCursor=function(pixels,mask,hotx,hoty,w,h){!1!==conf.cursor_uri?conf.true_color?changeCursor(conf.target,pixels,mask,hotx,hoty,w,h):changeCursor(conf.target,pixels,mask,hotx,hoty,w,h,conf.colourMap):Util.Warn("changeCursor called but no cursor data URI support")};that.defaultCursor=function(){conf.target.style.cursor="default"};return function(){var c,i,curDat,curSave;Util.Engine;if(!conf.target)throw"target must be set";if("string"==typeof conf.target)throw"target must be a DOM element";if(!(c=conf.target).getContext)throw"no getContext method";c_ctx||(c_ctx=c.getContext("2d"));that.clear();if(!("createImageData"in c_ctx))throw"Canvas does not support createImageData";conf.render_mode="canvas rendering";if(null===conf.prefer_js){Util.Info("Prefering javascript operations");conf.prefer_js=!0}tile16x16=c_ctx.createImageData(16,16);curDat=[];for(i=0;i<256;i+=1)curDat.push(255);try{curSave=c.style.cursor;changeCursor(conf.target,curDat,curDat,2,2,8,8);if(c.style.cursor){null===conf.cursor_uri&&(conf.cursor_uri=!0);Util.Info("Data URI scheme cursor supported")}else{null===conf.cursor_uri&&(conf.cursor_uri=!1);Util.Warn("Data URI scheme cursor not supported")}c.style.cursor=curSave}catch(exc2){Util.Error("Data URI scheme cursor test exception: "+exc2);conf.cursor_uri=!1}return that}()}function changeCursor(target,pixels,mask,hotx,hoty,w0,h0,cmap){var rgb,RGBsz,ANDsz,XORsz,url,idx,alpha,x,y,cur=[],w=w0,h=h0;h<w?h=w:w=h;cur.push16le=function(num){this.push(255&num,num>>8&255)};cur.push32le=function(num){this.push(255&num,num>>8&255,num>>16&255,num>>24&255)};RGBsz=w*h*4;XORsz=Math.ceil(w*h/8);ANDsz=Math.ceil(w*h/8);cur.push16le(0);cur.push16le(2);cur.push16le(1);cur.push(w);cur.push(h);cur.push(0);cur.push(0);cur.push16le(hotx);cur.push16le(hoty);cur.push32le(40+RGBsz+XORsz+ANDsz);cur.push32le(22);cur.push32le(40);cur.push32le(w);cur.push32le(2*h);cur.push16le(1);cur.push16le(32);cur.push32le(0);cur.push32le(XORsz+ANDsz);cur.push32le(0);cur.push32le(0);cur.push32le(0);cur.push32le(0);for(y=h-1;y>=0;y-=1)for(x=0;x<w;x+=1)if(x>=w0||y>=h0){cur.push(0);cur.push(0);cur.push(0);cur.push(0)}else{alpha=mask[idx=y*Math.ceil(w0/8)+Math.floor(x/8)]<<x%8&128?255:0;if(cmap){rgb=cmap[pixels[idx=w0*y+x]];cur.push(rgb[2]);cur.push(rgb[1]);cur.push(rgb[0]);cur.push(alpha)}else{idx=4*(w0*y+x);cur.push(pixels[idx+2]);cur.push(pixels[idx+1]);cur.push(pixels[idx]);cur.push(alpha)}}for(y=0;y<h;y+=1)for(x=0;x<Math.ceil(w/8);x+=1)cur.push(0);for(y=0;y<h;y+=1)for(x=0;x<Math.ceil(w/8);x+=1)cur.push(0);url="data:image/x-icon;base64,"+Base64.encode(cur);target.style.cursor="url("+url+") "+hotx+" "+hoty+", default"}function Keyboard(defaults){var that={},conf={};Util.conf_defaults(conf,that,defaults,[["target","wo","dom",document,"DOM element that captures keyboard input"],["focused","rw","bool",!0,"Capture and send key events"],["onKeyPress","rw","func",null,"Handler for key press/release"]]);var k=KeyEventDecoder(kbdUtil.ModifierSync(),VerifyCharModifier(TrackKeyState(EscapeModifiers((function(evt){conf.onKeyPress&&conf.onKeyPress(evt.keysym.keysym,"keydown"==evt.type)})))));function onKeyDown(e){if(!conf.focused)return!0;if(k.keydown(e)){Util.stopEvent(e);return!1}return!0}function onKeyPress(e){if(!conf.focused)return!0;if(k.keypress(e)){Util.stopEvent(e);return!1}return!0}function onKeyUp(e){if(!conf.focused)return!0;if(k.keyup(e)){Util.stopEvent(e);return!1}return!0}function allKeysUp(){k.releaseAll()}that.grab=function(){var c=conf.target;Util.addEvent(c,"keydown",onKeyDown);Util.addEvent(c,"keyup",onKeyUp);Util.addEvent(c,"keypress",onKeyPress);Util.addEvent(window,"blur",allKeysUp)};that.ungrab=function(){var c=conf.target;Util.removeEvent(c,"keydown",onKeyDown);Util.removeEvent(c,"keyup",onKeyUp);Util.removeEvent(c,"keypress",onKeyPress);Util.removeEvent(window,"blur",allKeysUp);allKeysUp()};that.sync=function(e){k.syncModifiers(e)};return that}function Mouse(defaults){var that={},conf={},mouseCaptured=!1,doubleClickTimer=null,lastTouchPos=null;Util.conf_defaults(conf,that,defaults,[["target","ro","dom",document,"DOM element that captures mouse input"],["notify","ro","func",null,"Function to call to notify whenever a mouse event is received"],["focused","rw","bool",!0,"Capture and send mouse clicks/movement"],["scale","rw","float",1,"Viewport scale factor 0.0 - 1.0"],["onMouseButton","rw","func",null,"Handler for mouse button click/release"],["onMouseMove","rw","func",null,"Handler for mouse movement"],["touchButton","rw","int",1,"Button mask (1, 2, 4) for touch devices (0 means ignore clicks)"]]);function resetDoubleClickTimer(){doubleClickTimer=null}function onMouseButton(e,down){var evt,pos,bmask;if(!conf.focused)return!0;conf.notify&&conf.notify(e);evt=e||window.event;pos=Util.getEventPosition(e,conf.target,conf.scale);if(e.touches||e.changedTouches){if(1==down){if(null==doubleClickTimer)lastTouchPos=pos;else{clearTimeout(doubleClickTimer);var xs=lastTouchPos.x-pos.x,ys=lastTouchPos.y-pos.y;Math.sqrt(xs*xs+ys*ys)<20*window.devicePixelRatio&&(pos=lastTouchPos)}doubleClickTimer=setTimeout(resetDoubleClickTimer,500)}bmask=conf.touchButton}else bmask=evt.which?1<<evt.button:(1&evt.button)+2*(2&evt.button)+(4&evt.button)/2;conf.onMouseButton&&conf.onMouseButton(pos.x,pos.y,down,bmask);Util.stopEvent(e);return!1}function onMouseDown(e){(function(){conf.target.setCapture&&conf.target.setCapture();mouseCaptured=!0})();onMouseButton(e,1)}function onMouseUp(e){if(mouseCaptured){onMouseButton(e,0);(function(){conf.target.releaseCapture&&conf.target.releaseCapture();mouseCaptured=!1})()}}function onMouseWheel(e){var evt,pos,bmask;if(!conf.focused)return!0;conf.notify&&conf.notify(e);evt=e||window.event;pos=Util.getEventPosition(e,conf.target,conf.scale);bmask=(evt.detail?-1*evt.detail:evt.wheelDelta/40)>0?8:16;if(conf.onMouseButton){conf.onMouseButton(pos.x,pos.y,1,bmask);conf.onMouseButton(pos.x,pos.y,0,bmask)}Util.stopEvent(e);return!1}function onMouseMove(e){var pos;if(!conf.focused)return!0;conf.notify&&conf.notify(e);e||window.event;pos=Util.getEventPosition(e,conf.target,conf.scale);conf.onMouseMove&&conf.onMouseMove(pos.x,pos.y);Util.stopEvent(e);return!1}function onMouseDisable(e){var pos;if(!conf.focused)return!0;e||window.event;if((pos=Util.getEventPosition(e,conf.target,conf.scale)).realx>=0&&pos.realy>=0&&pos.realx<conf.target.offsetWidth&&pos.realy<conf.target.offsetHeight){Util.stopEvent(e);return!1}return!0}that.grab=function(){var c=conf.target;if("ontouchstart"in document.documentElement){Util.addEvent(c,"touchstart",onMouseDown);Util.addEvent(window,"touchend",onMouseUp);Util.addEvent(c,"touchend",onMouseUp);Util.addEvent(c,"touchmove",onMouseMove)}else{Util.addEvent(c,"mousedown",onMouseDown);Util.addEvent(window,"mouseup",onMouseUp);Util.addEvent(c,"mouseup",onMouseUp);Util.addEvent(c,"mousemove",onMouseMove);Util.addEvent(c,Util.Engine.gecko?"DOMMouseScroll":"mousewheel",onMouseWheel)}Util.addEvent(document,"click",onMouseDisable);Util.addEvent(document.body,"contextmenu",onMouseDisable)};that.ungrab=function(){var c=conf.target;if("ontouchstart"in document.documentElement){Util.removeEvent(c,"touchstart",onMouseDown);Util.removeEvent(window,"touchend",onMouseUp);Util.removeEvent(c,"touchend",onMouseUp);Util.removeEvent(c,"touchmove",onMouseMove)}else{Util.removeEvent(c,"mousedown",onMouseDown);Util.removeEvent(window,"mouseup",onMouseUp);Util.removeEvent(c,"mouseup",onMouseUp);Util.removeEvent(c,"mousemove",onMouseMove);Util.removeEvent(c,Util.Engine.gecko?"DOMMouseScroll":"mousewheel",onMouseWheel)}Util.removeEvent(document,"click",onMouseDisable);Util.removeEvent(document.body,"contextmenu",onMouseDisable)};return that}
/*!
* JSUnzip
*
* Copyright (c) 2011 by Erik Moller
* All Rights Reserved
*
* This software is provided 'as-is', without any express
* or implied warranty. In no event will the authors be
* held liable for any damages arising from the use of
* this software.
*
* Permission is granted to anyone to use this software
* for any purpose, including commercial applications,
* and to alter it and redistribute it freely, subject to
* the following restrictions:
*
* 1. The origin of this software must not be
* misrepresented; you must not claim that you
* wrote the original software. If you use this
* software in a product, an acknowledgment in
* the product documentation would be appreciated
* but is not required.
*
* 2. Altered source versions must be plainly marked
* as such, and must not be misrepresented as
* being the original software.
*
* 3. This notice may not be removed or altered from
* any source distribution.
*/
function JSUnzip(){this.getInt=function(offset,size){switch(size){case 4:return(255&this.data.charCodeAt(offset+3))<<24|(255&this.data.charCodeAt(offset+2))<<16|(255&this.data.charCodeAt(offset+1))<<8|255&this.data.charCodeAt(offset+0);case 2:return(255&this.data.charCodeAt(offset+1))<<8|255&this.data.charCodeAt(offset+0);default:return 255&this.data.charCodeAt(offset)}};this.getDOSDate=function(dosdate,dostime){hour=dostime>>11&31;return new Date(1980+(dosdate>>9&127),(dosdate>>5&15)-1,31&dosdate,hour,dostime>>5&63,2*(31&dostime))};this.open=function(data){this.data=data;this.files=[];if(this.data.length<22)return{status:!1,error:"Invalid data"};for(var endOfCentralDirectory=this.data.length-22;endOfCentralDirectory>=0&&101010256!=this.getInt(endOfCentralDirectory,4);)--endOfCentralDirectory;if(endOfCentralDirectory<0)return{status:!1,error:"Invalid data"};if(0!=this.getInt(endOfCentralDirectory+4,2)||0!=this.getInt(endOfCentralDirectory+6,2))return{status:!1,error:"No multidisk support"};var entriesInThisDisk=this.getInt(endOfCentralDirectory+8,2),centralDirectoryOffset=this.getInt(endOfCentralDirectory+16,4),globalCommentLength=this.getInt(endOfCentralDirectory+20,2);this.comment=this.data.slice(endOfCentralDirectory+22,endOfCentralDirectory+22+globalCommentLength);for(var fileOffset=centralDirectoryOffset,i=0;i<entriesInThisDisk;++i){if(33639248!=this.getInt(fileOffset+0,4))return{status:!1,error:"Invalid data"};if(this.getInt(fileOffset+6,2)>20)return{status:!1,error:"Unsupported version"};if(1&this.getInt(fileOffset+8,2))return{status:!1,error:"Encryption not implemented"};var compressionMethod=this.getInt(fileOffset+10,2);if(0!=compressionMethod&&8!=compressionMethod)return{status:!1,error:"Unsupported compression method"};var lastModFileTime=this.getInt(fileOffset+12,2),lastModFileDate=this.getInt(fileOffset+14,2),lastModifiedDate=this.getDOSDate(lastModFileDate,lastModFileTime),compressedSize=(this.getInt(fileOffset+16,4),this.getInt(fileOffset+20,4)),uncompressedSize=this.getInt(fileOffset+24,4),fileNameLength=this.getInt(fileOffset+28,2),extraFieldLength=this.getInt(fileOffset+30,2),fileCommentLength=this.getInt(fileOffset+32,2),relativeOffsetOfLocalHeader=this.getInt(fileOffset+42,4),fileName=this.data.slice(fileOffset+46,fileOffset+46+fileNameLength),fileComment=this.data.slice(fileOffset+46+fileNameLength+extraFieldLength,fileOffset+46+fileNameLength+extraFieldLength+fileCommentLength);if(67324752!=this.getInt(relativeOffsetOfLocalHeader+0,4))return{status:!1,error:"Invalid data"};var localFileContent=relativeOffsetOfLocalHeader+30+this.getInt(relativeOffsetOfLocalHeader+26,2)+this.getInt(relativeOffsetOfLocalHeader+28,2);this.files[fileName]={fileComment:fileComment,compressionMethod:compressionMethod,compressedSize:compressedSize,uncompressedSize:uncompressedSize,localFileContent:localFileContent,lastModifiedDate:lastModifiedDate};fileOffset+=46+fileNameLength+extraFieldLength+fileCommentLength}return{status:!0}};this.read=function(fileName){var fileInfo=this.files[fileName];if(fileInfo){if(8==fileInfo.compressionMethod){tinf||(tinf=new TINF).init();var result=tinf.uncompress(this.data,fileInfo.localFileContent);return result.status==tinf.OK?{status:!0,data:result.data}:{status:!1,error:result.error}}return{status:!0,data:this.data.slice(fileInfo.localFileContent,fileInfo.localFileContent+fileInfo.uncompressedSize)}}return{status:!1,error:"File '"+fileName+"' doesn't exist in zip"}}}
/*!
* tinflate - tiny inflate
*
* Copyright (c) 2003 by Joergen Ibsen / Jibz
* All Rights Reserved
*
* http://www.ibsensoftware.com/
*
* This software is provided 'as-is', without any express
* or implied warranty. In no event will the authors be
* held liable for any damages arising from the use of
* this software.
*
* Permission is granted to anyone to use this software
* for any purpose, including commercial applications,
* and to alter it and redistribute it freely, subject to
* the following restrictions:
*
* 1. The origin of this software must not be
* misrepresented; you must not claim that you
* wrote the original software. If you use this
* software in a product, an acknowledgment in
* the product documentation would be appreciated
* but is not required.
*
* 2. Altered source versions must be plainly marked
* as such, and must not be misrepresented as
* being the original software.
*
* 3. This notice may not be removed or altered from
* any source distribution.
*
*
* tinflate javascript port by Erik Moller in May 2011.
* emoller@opera.com
*
* read_bits() patched by mike@imidio.com to allow
* reading more then 8 bits (needed in some zlib streams)
*/
function TINF(){this.OK=0;this.DATA_ERROR=-3;this.WINDOW_SIZE=32768;this.TREE=function(){this.table=new Array(16);this.trans=new Array(288)};this.DATA=function(that){this.source="";this.sourceIndex=0;this.tag=0;this.bitcount=0;this.dest=[];this.history=[];this.ltree=new that.TREE;this.dtree=new that.TREE};this.sltree=new this.TREE;this.sdtree=new this.TREE;this.length_bits=new Array(30);this.length_base=new Array(30);this.dist_bits=new Array(30);this.dist_base=new Array(30);this.clcidx=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];this.build_bits_base=function(bits,base,delta,first){var i,sum;for(i=0;i<delta;++i)bits[i]=0;for(i=0;i<30-delta;++i)bits[i+delta]=Math.floor(i/delta);for(sum=first,i=0;i<30;++i){base[i]=sum;sum+=1<<bits[i]}};this.build_fixed_trees=function(lt,dt){var i;for(i=0;i<7;++i)lt.table[i]=0;lt.table[7]=24;lt.table[8]=152;lt.table[9]=112;for(i=0;i<24;++i)lt.trans[i]=256+i;for(i=0;i<144;++i)lt.trans[24+i]=i;for(i=0;i<8;++i)lt.trans[168+i]=280+i;for(i=0;i<112;++i)lt.trans[176+i]=144+i;for(i=0;i<5;++i)dt.table[i]=0;dt.table[5]=32;for(i=0;i<32;++i)dt.trans[i]=i};this.build_tree=function(t,lengths,loffset,num){var i,sum,offs=new Array(16);for(i=0;i<16;++i)t.table[i]=0;for(i=0;i<num;++i)t.table[lengths[loffset+i]]++;t.table[0]=0;for(sum=0,i=0;i<16;++i){offs[i]=sum;sum+=t.table[i]}for(i=0;i<num;++i)lengths[loffset+i]&&(t.trans[offs[lengths[loffset+i]]++]=i)};this.getbit=function(d){var bit;if(!d.bitcount--){d.tag=255&d.source[d.sourceIndex++];d.bitcount=7}bit=1&d.tag;d.tag>>=1;return bit};this.read_bits=function(d,num,base){if(!num)return base;var ret=function(source,bitcount,tag,idx,num){for(var val;bitcount<24;){tag|=(255&source[idx++])<<bitcount;bitcount+=8}val=tag&65535>>16-num;return[bitcount-=num,tag>>=num,idx,val]}(d.source,d.bitcount,d.tag,d.sourceIndex,num);d.bitcount=ret[0];d.tag=ret[1];d.sourceIndex=ret[2];return ret[3]+base};this.decode_symbol=function(d,t){for(;d.bitcount<16;){d.tag=d.tag|(255&d.source[d.sourceIndex++])<<d.bitcount;d.bitcount+=8}var sum=0,cur=0,len=0;do{cur=2*cur+((d.tag&1<<len)>>len);++len;sum+=t.table[len];cur-=t.table[len]}while(cur>=0);d.tag>>=len;d.bitcount-=len;return t.trans[sum+cur]};this.decode_trees=function(d,lt,dt){var hlit,hdist,hclen,i,num,length,code_tree=new this.TREE,lengths=new Array(320);hlit=this.read_bits(d,5,257);hdist=this.read_bits(d,5,1);hclen=this.read_bits(d,4,4);for(i=0;i<19;++i)lengths[i]=0;for(i=0;i<hclen;++i){var clen=this.read_bits(d,3,0);lengths[this.clcidx[i]]=clen}this.build_tree(code_tree,lengths,0,19);for(num=0;num<hlit+hdist;){var sym=this.decode_symbol(d,code_tree);switch(sym){case 16:var prev=lengths[num-1];for(length=this.read_bits(d,2,3);length;--length)lengths[num++]=prev;break;case 17:for(length=this.read_bits(d,3,3);length;--length)lengths[num++]=0;break;case 18:for(length=this.read_bits(d,7,11);length;--length)lengths[num++]=0;break;default:lengths[num++]=sym}}this.build_tree(lt,lengths,0,hlit);this.build_tree(dt,lengths,hlit,hdist)};this.inflate_block_data=function(d,lt,dt){for(var ddest=d.dest,ddestlength=ddest.length;;){var sym=this.decode_symbol(d,lt);if(256==sym)return this.OK;if(sym<256){ddest[ddestlength++]=sym;d.history.push(sym)}else{var length,dist,offs,i;sym-=257;length=this.read_bits(d,this.length_bits[sym],this.length_base[sym]);dist=this.decode_symbol(d,dt);if((offs=d.history.length-this.read_bits(d,this.dist_bits[dist],this.dist_base[dist]))<0)throw"Invalid zlib offset "+offs;for(i=offs;i<offs+length;++i){ddest[ddestlength++]=d.history[i];d.history.push(d.history[i])}}}};this.inflate_uncompressed_block=function(d){var length,i;if(d.bitcount>7){var overflow=Math.floor(d.bitcount/8);d.sourceIndex-=overflow;d.bitcount=0;d.tag=0}if((length=256*(length=d.source[d.sourceIndex+1])+d.source[d.sourceIndex])!=(65535&~(256*d.source[d.sourceIndex+3]+d.source[d.sourceIndex+2])))return this.DATA_ERROR;d.sourceIndex+=4;for(i=length;i;--i){d.history.push(d.source[d.sourceIndex]);d.dest[d.dest.length]=d.source[d.sourceIndex++]}d.bitcount=0;return this.OK};this.inflate_fixed_block=function(d){return this.inflate_block_data(d,this.sltree,this.sdtree)};this.inflate_dynamic_block=function(d){this.decode_trees(d,d.ltree,d.dtree);return this.inflate_block_data(d,d.ltree,d.dtree)};this.init=function(){this.build_fixed_trees(this.sltree,this.sdtree);this.build_bits_base(this.length_bits,this.length_base,4,3);this.build_bits_base(this.dist_bits,this.dist_base,2,1);this.length_bits[28]=0;this.length_base[28]=258;this.reset()};this.reset=function(){this.d=new this.DATA(this);delete this.header};this.uncompress=function(source,offset){var bfinal,d=this.d;d.source=source;d.sourceIndex=offset;d.bitcount=0;d.dest=[];void 0===this.header&&(this.header=this.read_bits(d,16,0));do{var res;bfinal=this.getbit(d);switch(this.read_bits(d,2,0)){case 0:res=this.inflate_uncompressed_block(d);break;case 1:res=this.inflate_fixed_block(d);break;case 2:res=this.inflate_dynamic_block(d);break;default:return{status:this.DATA_ERROR}}if(res!=this.OK)return{status:this.DATA_ERROR}}while(!bfinal&&d.sourceIndex<d.source.length);d.history=d.history.slice(-this.WINDOW_SIZE);return{status:this.OK,data:d.dest}}}var kbdUtil=function(){function substituteCodepoint(cp){return{536:350,537:351,538:354,539:355}[cp]||cp}function hasShortcutModifier(charModifier,currentModifiers){var mods={};for(var key in currentModifiers)65505!==parseInt(key)&&(mods[key]=currentModifiers[key]);var sum=0;for(var k in currentModifiers)mods[k]&&++sum;return hasCharModifier(charModifier,mods)?sum>charModifier.length:sum>0}function hasCharModifier(charModifier,currentModifiers){if(0===charModifier.length)return!1;for(var i=0;i<charModifier.length;++i)if(!currentModifiers[charModifier[i]])return!1;return!0}function getKeysym(evt){var codepoint;evt.char&&1===evt.char.length?codepoint=evt.char.charCodeAt():evt.charCode?codepoint=evt.charCode:evt.keyCode&&"keypress"===evt.type&&(codepoint=evt.keyCode);if(codepoint){var res=keysyms.fromUnicode(substituteCodepoint(codepoint));if(res)return res}return evt.keyCode?keysyms.lookup(keysymFromKeyCode(evt.keyCode,evt.shiftKey)):evt.which?keysyms.lookup(keysymFromKeyCode(evt.which,evt.shiftKey)):null}function keysymFromKeyCode(keycode,shiftPressed){if("number"!=typeof keycode)return null;if(keycode>=48&&keycode<=57)return keycode;if(keycode>=65&&keycode<=90)return shiftPressed?keycode:keycode+32;if(keycode>=96&&keycode<=105)return keycode-96+65456;switch(keycode){case 32:return 32;case 106:return 65450;case 107:return 65451;case 108:return 65452;case 109:return 65453;case 110:return 65454;case 111:return 65455;case 187:return 43;case 188:return 44;case 189:return 45;case 190:return 46}return nonCharacterKey({keyCode:keycode})}function nonCharacterKey(evt){if(!evt.keyCode)return null;var keycode=evt.keyCode;if(keycode>=112&&keycode<=135)return 65470+keycode-112;switch(keycode){case 8:return 65288;case 13:return 65293;case 9:return 65289;case 27:return 65307;case 46:return 65535;case 36:return 65360;case 35:return 65367;case 33:return 65365;case 34:return 65366;case 45:return 65379;case 37:return 65361;case 38:return 65362;case 39:return 65363;case 40:return 65364;case 16:return 65505;case 17:return 65507;case 18:return 65513;case 224:return 65031;case 225:return 65027;case 91:return 65516;case 92:return 65517;case 93:return 65383;default:return null}}return{hasShortcutModifier:hasShortcutModifier,hasCharModifier:hasCharModifier,ModifierSync:function(charModifier){var alt=65513;charModifier||(charModifier=navigator&&/mac/i.exec(navigator.platform)?[alt]:navigator&&/win/i.exec(navigator.platform)?[alt,65507]:navigator&&/linux/i.exec(navigator.platform)?[65027]:[]);var state={65507:!1,65513:!1,65027:!1,65505:!1,65511:!1};function sync(evt,keysym){var result=[];function syncKey(keysym){return{keysym:keysyms.lookup(keysym),type:state[keysym]?"keydown":"keyup"}}if(void 0!==evt.ctrlKey&&evt.ctrlKey!==state[65507]&&65507!==keysym){state[65507]=evt.ctrlKey;result.push(syncKey(65507))}if(void 0!==evt.altKey&&evt.altKey!==state[alt]&&keysym!==alt){state[alt]=evt.altKey;result.push(syncKey(alt))}if(void 0!==evt.altGraphKey&&evt.altGraphKey!==state[65027]&&65027!==keysym){state[65027]=evt.altGraphKey;result.push(syncKey(65027))}if(void 0!==evt.shiftKey&&evt.shiftKey!==state[65505]&&65505!==keysym){state[65505]=evt.shiftKey;result.push(syncKey(65505))}if(void 0!==evt.metaKey&&evt.metaKey!==state[65511]&&65511!==keysym){state[65511]=evt.metaKey;result.push(syncKey(65511))}return result}function syncKeyEvent(evt,down){var obj=getKeysym(evt),keysym=obj?obj.keysym:null;null!==keysym&&void 0!==state[keysym]&&(state[keysym]=down);return sync(evt,keysym)}return{keydown:function(evt){return syncKeyEvent(evt,!0)},keyup:function(evt){return syncKeyEvent(evt,!1)},syncAny:function(evt){return sync(evt)},hasShortcutModifier:function(){return hasShortcutModifier(charModifier,state)},activeCharModifier:function(){return hasCharModifier(charModifier,state)?charModifier:null}}},getKey:function(evt){return"keyCode"in evt&&"key"in evt?evt.key+":"+evt.keyCode:"keyCode"in evt?evt.keyCode:evt.key},getKeysym:getKeysym,keysymFromKeyCode:keysymFromKeyCode,nonCharacterKey:nonCharacterKey,substituteCodepoint:substituteCodepoint}}();function KeyEventDecoder(modifierState,next){function sendAll(evts){for(var i=0;i<evts.length;++i)next(evts[i])}function process(evt,type){var result={type:type},keyId=kbdUtil.getKey(evt);keyId&&(result.keyId=keyId);var keysym=kbdUtil.getKeysym(evt),hasModifier=modifierState.hasShortcutModifier()||!!modifierState.activeCharModifier();keysym&&("keydown"!==type||kbdUtil.nonCharacterKey(evt)||hasModifier)&&(result.keysym=keysym);var suppress=!(16===evt.keyCode||"Shift"===evt.key)&&("keydown"!==type||modifierState.hasShortcutModifier()||!!kbdUtil.nonCharacterKey(evt)),stall="keydown"===type&&modifierState.activeCharModifier()&&!kbdUtil.nonCharacterKey(evt),active=modifierState.activeCharModifier();if(active&&keysym){for(var isCharModifier=!1,i=0;i<active.length;++i)active[i]===keysym.keysym&&(isCharModifier=!0);"keypress"!==type||isCharModifier||(result.escape=modifierState.activeCharModifier())}stall&&next({type:"stall"});next(result);return suppress}return{keydown:function(evt){sendAll(modifierState.keydown(evt));return process(evt,"keydown")},keypress:function(evt){return process(evt,"keypress")},keyup:function(evt){sendAll(modifierState.keyup(evt));return process(evt,"keyup")},syncModifiers:function(evt){sendAll(modifierState.syncAny(evt))},releaseAll:function(){next({type:"releaseall"})}}}function VerifyCharModifier(next){var queue=[],timer=null;return function(evt){queue.push(evt);(function process(){if(!timer)for(;0!==queue.length;){var cur=queue[0];queue=queue.splice(1);switch(cur.type){case"stall":timer=setTimeout((function(){clearTimeout(timer);timer=null;process()}),5);return;case"keydown":if(0!==queue.length&&"keypress"===queue[0].type){!queue[0].escape||cur.keysym&&cur.keysym.keysym===queue[0].keysym.keysym||(cur.escape=queue[0].escape);cur.keysym=queue[0].keysym;queue=queue.splice(1)}}"stall"!==cur.type&&next(cur)}})()}}function TrackKeyState(next){var state=[];return function(evt){var last=0!==state.length?state[state.length-1]:null;switch(evt.type){case"keydown":if(!last||!evt.keyId||last.keyId!==evt.keyId){last={keyId:evt.keyId,keysyms:{}};state.push(last)}if(evt.keysym){last.keysyms[evt.keysym.keysym]=evt.keysym;last.ignoreKeyPress=!0;next(evt)}break;case"keypress":if(!last){last={keyId:evt.keyId,keysyms:{}};state.push(last)}evt.keysym;if(evt.keysym&&!last.ignoreKeyPress){last.keysyms[evt.keysym.keysym]=evt.keysym;evt.type="keydown";next(evt)}break;case"keyup":if(0===state.length)return;for(var idx=null,i=0;i!==state.length;++i)if(state[i].keyId===evt.keyId){idx=i;break}null===idx&&(idx=state.length-1);var item=state.splice(idx,1)[0];for(var key in item.keysyms){var out=function(){function Clone(){}return function(obj){Clone.prototype=obj;return new Clone}}()(evt);out.keysym=item.keysyms[key];next(out)}break;case"releaseall":for(i=0;i<state.length;++i)for(var key in state[i].keysyms){var keysym=state[i].keysyms[key];next({keyId:0,keysym:keysym,type:"keyup"})}state=[]}}}function EscapeModifiers(next){return function(evt){if("keydown"===evt.type&&void 0!==evt.escape){for(var i=0;i<evt.escape.length;++i)next({type:"keyup",keyId:0,keysym:keysyms.lookup(evt.escape[i])});next(evt);for(i=0;i<evt.escape.length;++i)next({type:"keydown",keyId:0,keysym:keysyms.lookup(evt.escape[i])})}else next(evt)}}var rfb,mode,test_state,frame_idx,frame_length,iteration,iterations,istart_time,send_array,next_iteration,queue_next_packet,do_packet,XK_VoidSymbol=16777215,XK_BackSpace=65288,XK_Tab=65289,XK_Linefeed=65290,XK_Clear=65291,XK_Return=65293,XK_Pause=65299,XK_Scroll_Lock=65300,XK_Sys_Req=65301,XK_Escape=65307,XK_Delete=65535,XK_Home=65360,XK_Left=65361,XK_Up=65362,XK_Right=65363,XK_Down=65364,XK_Prior=65365,XK_Page_Up=65365,XK_Next=65366,XK_Page_Down=65366,XK_End=65367,XK_Begin=65368,XK_Select=65376,XK_Print=65377,XK_Execute=65378,XK_Insert=65379,XK_Undo=65381,XK_Redo=65382,XK_Menu=65383,XK_Find=65384,XK_Cancel=65385,XK_Help=65386,XK_Break=65387,XK_Mode_switch=65406,XK_script_switch=65406,XK_Num_Lock=65407,XK_KP_Space=65408,XK_KP_Tab=65417,XK_KP_Enter=65421,XK_KP_F1=65425,XK_KP_F2=65426,XK_KP_F3=65427,XK_KP_F4=65428,XK_KP_Home=65429,XK_KP_Left=65430,XK_KP_Up=65431,XK_KP_Right=65432,XK_KP_Down=65433,XK_KP_Prior=65434,XK_KP_Page_Up=65434,XK_KP_Next=65435,XK_KP_Page_Down=65435,XK_KP_End=65436,XK_KP_Begin=65437,XK_KP_Insert=65438,XK_KP_Delete=65439,XK_KP_Equal=65469,XK_KP_Multiply=65450,XK_KP_Add=65451,XK_KP_Separator=65452,XK_KP_Subtract=65453,XK_KP_Decimal=65454,XK_KP_Divide=65455,XK_KP_0=65456,XK_KP_1=65457,XK_KP_2=65458,XK_KP_3=65459,XK_KP_4=65460,XK_KP_5=65461,XK_KP_6=65462,XK_KP_7=65463,XK_KP_8=65464,XK_KP_9=65465,XK_F1=65470,XK_F2=65471,XK_F3=65472,XK_F4=65473,XK_F5=65474,XK_F6=65475,XK_F7=65476,XK_F8=65477,XK_F9=65478,XK_F10=65479,XK_F11=65480,XK_L1=65480,XK_F12=65481,XK_L2=65481,XK_F13=65482,XK_L3=65482,XK_F14=65483,XK_L4=65483,XK_F15=65484,XK_L5=65484,XK_F16=65485,XK_L6=65485,XK_F17=65486,XK_L7=65486,XK_F18=65487,XK_L8=65487,XK_F19=65488,XK_L9=65488,XK_F20=65489,XK_L10=65489,XK_F21=65490,XK_R1=65490,XK_F22=65491,XK_R2=65491,XK_F23=65492,XK_R3=65492,XK_F24=65493,XK_R4=65493,XK_F25=65494,XK_R5=65494,XK_F26=65495,XK_R6=65495,XK_F27=65496,XK_R7=65496,XK_F28=65497,XK_R8=65497,XK_F29=65498,XK_R9=65498,XK_F30=65499,XK_R10=65499,XK_F31=65500,XK_R11=65500,XK_F32=65501,XK_R12=65501,XK_F33=65502,XK_R13=65502,XK_F34=65503,XK_R14=65503,XK_F35=65504,XK_R15=65504,XK_Shift_L=65505,XK_Shift_R=65506,XK_Control_L=65507,XK_Control_R=65508,XK_Caps_Lock=65509,XK_Shift_Lock=65510,XK_Meta_L=65511,XK_Meta_R=65512,XK_Alt_L=65513,XK_Alt_R=65514,XK_Super_L=65515,XK_Super_R=65516,XK_Hyper_L=65517,XK_Hyper_R=65518,XK_space=32,XK_exclam=33,XK_quotedbl=34,XK_numbersign=35,XK_dollar=36,XK_percent=37,XK_ampersand=38,XK_apostrophe=39,XK_quoteright=39,XK_parenleft=40,XK_parenright=41,XK_asterisk=42,XK_plus=43,XK_comma=44,XK_minus=45,XK_period=46,XK_slash=47,XK_0=48,XK_1=49,XK_2=50,XK_3=51,XK_4=52,XK_5=53,XK_6=54,XK_7=55,XK_8=56,XK_9=57,XK_colon=58,XK_semicolon=59,XK_less=60,XK_equal=61,XK_greater=62,XK_question=63,XK_at=64,XK_A=65,XK_B=66,XK_C=67,XK_D=68,XK_E=69,XK_F=70,XK_G=71,XK_H=72,XK_I=73,XK_J=74,XK_K=75,XK_L=76,XK_M=77,XK_N=78,XK_O=79,XK_P=80,XK_Q=81,XK_R=82,XK_S=83,XK_T=84,XK_U=85,XK_V=86,XK_W=87,XK_X=88,XK_Y=89,XK_Z=90,XK_bracketleft=91,XK_backslash=92,XK_bracketright=93,XK_asciicircum=94,XK_underscore=95,XK_grave=96,XK_quoteleft=96,XK_a=97,XK_b=98,XK_c=99,XK_d=100,XK_e=101,XK_f=102,XK_g=103,XK_h=104,XK_i=105,XK_j=106,XK_k=107,XK_l=108,XK_m=109,XK_n=110,XK_o=111,XK_p=112,XK_q=113,XK_r=114,XK_s=115,XK_t=116,XK_u=117,XK_v=118,XK_w=119,XK_x=120,XK_y=121,XK_z=122,XK_braceleft=123,XK_bar=124,XK_braceright=125,XK_asciitilde=126,XK_nobreakspace=160,XK_exclamdown=161,XK_cent=162,XK_sterling=163,XK_currency=164,XK_yen=165,XK_brokenbar=166,XK_section=167,XK_diaeresis=168,XK_copyright=169,XK_ordfeminine=170,XK_guillemotleft=171,XK_notsign=172,XK_hyphen=173,XK_registered=174,XK_macron=175,XK_degree=176,XK_plusminus=177,XK_twosuperior=178,XK_threesuperior=179,XK_acute=180,XK_mu=181,XK_paragraph=182,XK_periodcentered=183,XK_cedilla=184,XK_onesuperior=185,XK_masculine=186,XK_guillemotright=187,XK_onequarter=188,XK_onehalf=189,XK_threequarters=190,XK_questiondown=191,XK_Agrave=192,XK_Aacute=193,XK_Acircumflex=194,XK_Atilde=195,XK_Adiaeresis=196,XK_Aring=197,XK_AE=198,XK_Ccedilla=199,XK_Egrave=200,XK_Eacute=201,XK_Ecircumflex=202,XK_Ediaeresis=203,XK_Igrave=204,XK_Iacute=205,XK_Icircumflex=206,XK_Idiaeresis=207,XK_ETH=208,XK_Eth=208,XK_Ntilde=209,XK_Ograve=210,XK_Oacute=211,XK_Ocircumflex=212,XK_Otilde=213,XK_Odiaeresis=214,XK_multiply=215,XK_Oslash=216,XK_Ooblique=216,XK_Ugrave=217,XK_Uacute=218,XK_Ucircumflex=219,XK_Udiaeresis=220,XK_Yacute=221,XK_THORN=222,XK_Thorn=222,XK_ssharp=223,XK_agrave=224,XK_aacute=225,XK_acircumflex=226,XK_atilde=227,XK_adiaeresis=228,XK_aring=229,XK_ae=230,XK_ccedilla=231,XK_egrave=232,XK_eacute=233,XK_ecircumflex=234,XK_ediaeresis=235,XK_igrave=236,XK_iacute=237,XK_icircumflex=238,XK_idiaeresis=239,XK_eth=240,XK_ntilde=241,XK_ograve=242,XK_oacute=243,XK_ocircumflex=244,XK_otilde=245,XK_odiaeresis=246,XK_division=247,XK_oslash=248,XK_ooblique=248,XK_ugrave=249,XK_uacute=250,XK_ucircumflex=251,XK_udiaeresis=252,XK_yacute=253,XK_thorn=254,XK_ydiaeresis=255,keysyms=function(){var codepoints={32:32,33:33,34:34,35:35,36:36,37:37,38:38,39:39,40:40,41:41,42:42,43:43,44:44,45:45,46:46,47:47,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,58:58,59:59,60:60,61:61,62:62,63:63,64:64,65:65,66:66,67:67,68:68,69:69,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,82:82,83:83,84:84,85:85,86:86,87:87,88:88,89:89,90:90,91:91,92:92,93:93,94:94,95:95,96:96,97:97,98:98,99:99,100:100,101:101,102:102,103:103,104:104,105:105,106:106,107:107,108:108,109:109,110:110,111:111,112:112,113:113,114:114,115:115,116:116,117:117,118:118,119:119,120:120,121:121,122:122,123:123,124:124,125:125,126:126,160:160,161:161,162:162,163:163,164:164,165:165,166:166,167:167,168:168,169:169,170:170,171:171,172:172,173:173,174:174,175:175,176:176,177:177,178:178,179:179,180:180,181:181,182:182,183:183,184:184,185:185,186:186,187:187,188:188,189:189,190:190,191:191,192:192,193:193,194:194,195:195,196:196,197:197,198:198,199:199,200:200,201:201,202:202,203:203,204:204,205:205,206:206,207:207,208:208,209:209,210:210,211:211,212:212,213:213,214:214,215:215,216:216,217:217,218:218,219:219,220:220,221:221,222:222,223:223,224:224,225:225,226:226,227:227,228:228,229:229,230:230,231:231,232:232,233:233,234:234,235:235,236:236,237:237,238:238,239:239,240:240,241:241,242:242,243:243,244:244,245:245,246:246,247:247,248:248,249:249,250:250,251:251,252:252,253:253,254:254,255:255,256:960,257:992,258:451,259:483,260:417,261:433,262:454,263:486,264:710,265:742,266:709,267:741,268:456,269:488,270:463,271:495,272:464,273:496,274:938,275:954,278:972,279:1004,280:458,281:490,282:460,283:492,284:728,285:760,286:683,287:699,288:725,289:757,290:939,291:955,292:678,293:694,294:673,295:689,296:933,297:949,298:975,299:1007,300:16777516,301:16777517,302:967,303:999,304:681,305:697,308:684,309:700,310:979,311:1011,312:930,313:453,314:485,315:934,316:950,317:421,318:437,321:419,322:435,323:465,324:497,325:977,326:1009,327:466,328:498,330:957,331:959,332:978,333:1010,336:469,337:501,338:5052,339:5053,340:448,341:480,342:931,343:947,344:472,345:504,346:422,347:438,348:734,349:766,350:426,351:442,352:425,353:441,354:478,355:510,356:427,357:443,358:940,359:956,360:989,361:1021,362:990,363:1022,364:733,365:765,366:473,367:505,368:475,369:507,370:985,371:1017,372:16777588,373:16777589,374:16777590,375:16777591,376:5054,377:428,378:444,379:431,380:447,381:430,382:446,399:16777615,402:2294,415:16777631,416:16777632,417:16777633,431:16777647,432:16777648,437:16777653,438:16777654,439:16777655,466:16777681,486:16777702,487:16777703,601:16777817,629:16777845,658:16777874,711:439,728:418,729:511,731:434,733:445,901:1966,902:1953,904:1954,905:1955,906:1956,908:1959,910:1960,911:1963,912:1974,913:1985,914:1986,915:1987,916:1988,917:1989,918:1990,919:1991,920:1992,921:1993,922:1994,923:1995,924:1996,925:1997,926:1998,927:1999,928:2e3,929:2001,931:2002,932:2004,933:2005,934:2006,935:2007,936:2008,937:2009,938:1957,939:1961,940:1969,941:1970,942:1971,943:1972,944:1978,945:2017,946:2018,947:2019,948:2020,949:2021,950:2022,951:2023,952:2024,953:2025,954:2026,955:2027,956:2028,957:2029,958:2030,959:2031,960:2032,961:2033,962:2035,963:2034,964:2036,965:2037,966:2038,967:2039,968:2040,969:2041,970:1973,971:1977,972:1975,973:1976,974:1979,1025:1715,1026:1713,1027:1714,1028:1716,1029:1717,1030:1718,1031:1719,1032:1720,1033:1721,1034:1722,1035:1723,1036:1724,1038:1726,1039:1727,1040:1761,1041:1762,1042:1783,1043:1767,1044:1764,1045:1765,1046:1782,1047:1786,1048:1769,1049:1770,1050:1771,1051:1772,1052:1773,1053:1774,1054:1775,1055:1776,1056:1778,1057:1779,1058:1780,1059:1781,1060:1766,1061:1768,1062:1763,1063:1790,1064:1787,1065:1789,1066:1791,1067:1785,1068:1784,1069:1788,1070:1760,1071:1777,1072:1729,1073:1730,1074:1751,1075:1735,1076:1732,1077:1733,1078:1750,1079:1754,1080:1737,1081:1738,1082:1739,1083:1740,1084:1741,1085:1742,1086:1743,1087:1744,1088:1746,1089:1747,1090:1748,1091:1749,1092:1734,1093:1736,1094:1731,1095:1758,1096:1755,1097:1757,1098:1759,1099:1753,1100:1752,1101:1756,1102:1728,1103:1745,1105:1699,1106:1697,1107:1698,1108:1700,1109:1701,1110:1702,1111:1703,1112:1704,1113:1705,1114:1706,1115:1707,1116:1708,1118:1710,1119:1711,1168:1725,1169:1709,1170:16778386,1171:16778387,1174:16778390,1175:16778391,1178:16778394,1179:16778395,1180:16778396,1181:16778397,1186:16778402,1187:16778403,1198:16778414,1199:16778415,1200:16778416,1201:16778417,1202:16778418,1203:16778419,1206:16778422,1207:16778423,1208:16778424,1209:16778425,1210:16778426,1211:16778427,1240:16778456,1241:16778457,1250:16778466,1251:16778467,1256:16778472,1257:16778473,1262:16778478,1263:16778479,1329:16778545,1330:16778546,1331:16778547,1332:16778548,1333:16778549,1334:16778550,1335:16778551,1336:16778552,1337:16778553,1338:16778554,1339:16778555,1340:16778556,1341:16778557,1342:16778558,1343:16778559,1344:16778560,1345:16778561,1346:16778562,1347:16778563,1348:16778564,1349:16778565,1350:16778566,1351:16778567,1352:16778568,1353:16778569,1354:16778570,1355:16778571,1356:16778572,1357:16778573,1358:16778574,1359:16778575,1360:16778576,1361:16778577,1362:16778578,1363:16778579,1364:16778580,1365:16778581,1366:16778582,1370:16778586,1371:16778587,1372:16778588,1373:16778589,1374:16778590,1377:16778593,1378:16778594,1379:16778595,1380:16778596,1381:16778597,1382:16778598,1383:16778599,1384:16778600,1385:16778601,1386:16778602,1387:16778603,1388:16778604,1389:16778605,1390:16778606,1391:16778607,1392:16778608,1393:16778609,1394:16778610,1395:16778611,1396:16778612,1397:16778613,1398:16778614,1399:16778615,1400:16778616,1401:16778617,1402:16778618,1403:16778619,1404:16778620,1405:16778621,1406:16778622,1407:16778623,1408:16778624,1409:16778625,1410:16778626,1411:16778627,1412:16778628,1413:16778629,1414:16778630,1415:16778631,1417:16778633,1418:16778634,1488:3296,1489:3297,1490:3298,1491:3299,1492:3300,1493:3301,1494:3302,1495:3303,1496:3304,1497:3305,1498:3306,1499:3307,1500:3308,1501:3309,1502:3310,1503:3311,1504:3312,1505:3313,1506:3314,1507:3315,1508:3316,1509:3317,1510:3318,1511:3319,1512:3320,1513:3321,1514:3322,1548:1452,1563:1467,1567:1471,1569:1473,1570:1474,1571:1475,1572:1476,1573:1477,1574:1478,1575:1479,1576:1480,1577:1481,1578:1482,1579:1483,1580:1484,1581:1485,1582:1486,1583:1487,1584:1488,1585:1489,1586:1490,1587:1491,1588:1492,1589:1493,1590:1494,1591:1495,1592:1496,1593:1497,1594:1498,1600:1504,1601:1505,1602:1506,1603:1507,1604:1508,1605:1509,1606:1510,1607:1511,1608:1512,1609:1513,1610:1514,1611:1515,1612:1516,1613:1517,1614:1518,1615:1519,1616:1520,1617:1521,1618:1522,1619:16778835,1620:16778836,1621:16778837,1632:16778848,1633:16778849,1634:16778850,1635:16778851,1636:16778852,1637:16778853,1638:16778854,1639:16778855,1640:16778856,1641:16778857,1642:16778858,1648:16778864,1657:16778873,1662:16778878,1670:16778886,1672:16778888,1681:16778897,1688:16778904,1700:16778916,1705:16778921,1711:16778927,1722:16778938,1726:16778942,1729:16778945,1740:16778956,1746:16778962,1748:16778964,1776:16778992,1777:16778993,1778:16778994,1779:16778995,1780:16778996,1781:16778997,1782:16778998,1783:16778999,1784:16779e3,1785:16779001,3458:16780674,3459:16780675,3461:16780677,3462:16780678,3463:16780679,3464:16780680,3465:16780681,3466:16780682,3467:16780683,3468:16780684,3469:16780685,3470:16780686,3471:16780687,3472:16780688,3473:16780689,3474:16780690,3475:16780691,3476:16780692,3477:16780693,3478:16780694,3482:16780698,3483:16780699,3484:16780700,3485:16780701,3486:16780702,3487:16780703,3488:16780704,3489:16780705,3490:16780706,3491:16780707,3492:16780708,3493:16780709,3494:16780710,3495:16780711,3496:16780712,3497:16780713,3498:16780714,3499:16780715,3500:16780716,3501:16780717,3502:16780718,3503:16780719,3504:16780720,3505:16780721,3507:16780723,3508:16780724,3509:16780725,3510:16780726,3511:16780727,3512:16780728,3513:16780729,3514:16780730,3515:16780731,3517:16780733,3520:16780736,3521:16780737,3522:16780738,3523:16780739,3524:16780740,3525:16780741,3526:16780742,3530:16780746,3535:16780751,3536:16780752,3537:16780753,3538:16780754,3539:16780755,3540:16780756,3542:16780758,3544:16780760,3545:16780761,3546:16780762,3547:16780763,3548:16780764,3549:16780765,3550:16780766,3551:16780767,3570:16780786,3571:16780787,3572:16780788,3585:3489,3586:3490,3587:3491,3588:3492,3589:3493,3590:3494,3591:3495,3592:3496,3593:3497,3594:3498,3595:3499,3596:3500,3597:3501,3598:3502,3599:3503,3600:3504,3601:3505,3602:3506,3603:3507,3604:3508,3605:3509,3606:3510,3607:3511,3608:3512,3609:3513,3610:3514,3611:3515,3612:3516,3613:3517,3614:3518,3615:3519,3616:3520,3617:3521,3618:3522,3619:3523,3620:3524,3621:3525,3622:3526,3623:3527,3624:3528,3625:3529,3626:3530,3627:3531,3628:3532,3629:3533,3630:3534,3631:3535,3632:3536,3633:3537,3634:3538,3635:3539,3636:3540,3637:3541,3638:3542,3639:3543,3640:3544,3641:3545,3642:3546,3647:3551,3648:3552,3649:3553,3650:3554,3651:3555,3652:3556,3653:3557,3654:3558,3655:3559,3656:3560,3657:3561,3658:3562,3659:3563,3660:3564,3661:3565,3664:3568,3665:3569,3666:3570,3667:3571,3668:3572,3669:3573,3670:3574,3671:3575,3672:3576,3673:3577,4304:16781520,4305:16781521,4306:16781522,4307:16781523,4308:16781524,4309:16781525,4310:16781526,4311:16781527,4312:16781528,4313:16781529,4314:16781530,4315:16781531,4316:16781532,4317:16781533,4318:16781534,4319:16781535,4320:16781536,4321:16781537,4322:16781538,4323:16781539,4324:16781540,4325:16781541,4326:16781542,4327:16781543,4328:16781544,4329:16781545,4330:16781546,4331:16781547,4332:16781548,4333:16781549,4334:16781550,4335:16781551,4336:16781552,4337:16781553,4338:16781554,4339:16781555,4340:16781556,4341:16781557,4342:16781558,7682:16784898,7683:16784899,7690:16784906,7691:16784907,7710:16784926,7711:16784927,7734:16784950,7735:16784951,7744:16784960,7745:16784961,7766:16784982,7767:16784983,7776:16784992,7777:16784993,7786:16785002,7787:16785003,7808:16785024,7809:16785025,7810:16785026,7811:16785027,7812:16785028,7813:16785029,7818:16785034,7819:16785035,7840:16785056,7841:16785057,7842:16785058,7843:16785059,7844:16785060,7845:16785061,7846:16785062,7847:16785063,7848:16785064,7849:16785065,7850:16785066,7851:16785067,7852:16785068,7853:16785069,7854:16785070,7855:16785071,7856:16785072,7857:16785073,7858:16785074,7859:16785075,7860:16785076,7861:16785077,7862:16785078,7863:16785079,7864:16785080,7865:16785081,7866:16785082,7867:16785083,7868:16785084,7869:16785085,7870:16785086,7871:16785087,7872:16785088,7873:16785089,7874:16785090,7875:16785091,7876:16785092,7877:16785093,7878:16785094,7879:16785095,7880:16785096,7881:16785097,7882:16785098,7883:16785099,7884:16785100,7885:16785101,7886:16785102,7887:16785103,7888:16785104,7889:16785105,7890:16785106,7891:16785107,7892:16785108,7893:16785109,7894:16785110,7895:16785111,7896:16785112,7897:16785113,7898:16785114,7899:16785115,7900:16785116,7901:16785117,7902:16785118,7903:16785119,7904:16785120,7905:16785121,7906:16785122,7907:16785123,7908:16785124,7909:16785125,7910:16785126,7911:16785127,7912:16785128,7913:16785129,7914:16785130,7915:16785131,7916:16785132,7917:16785133,7918:16785134,7919:16785135,7920:16785136,7921:16785137,7922:16785138,7923:16785139,7924:16785140,7925:16785141,7926:16785142,7927:16785143,7928:16785144,7929:16785145,8194:2722,8195:2721,8196:2723,8197:2724,8199:2725,8200:2726,8201:2727,8202:2728,8210:2747,8211:2730,8212:2729,8213:1967,8215:3295,8216:2768,8217:2769,8218:2813,8220:2770,8221:2771,8222:2814,8224:2801,8225:2802,8226:2790,8229:2735,8230:2734,8240:2773,8242:2774,8243:2775,8248:2812,8254:1150,8304:16785520,8308:16785524,8309:16785525,8310:16785526,8311:16785527,8312:16785528,8313:16785529,8320:16785536,8321:16785537,8322:16785538,8323:16785539,8324:16785540,8325:16785541,8326:16785542,8327:16785543,8328:16785544,8329:16785545,8352:16785568,8353:16785569,8354:16785570,8355:16785571,8356:16785572,8357:16785573,8358:16785574,8359:16785575,8360:16785576,8361:3839,8362:16785578,8363:16785579,8364:8364,8453:2744,8470:1712,8471:2811,8478:2772,8482:2761,8531:2736,8532:2737,8533:2738,8534:2739,8535:2740,8536:2741,8537:2742,8538:2743,8539:2755,8540:2756,8541:2757,8542:2758,8592:2299,8593:2300,8594:2301,8595:2302,8658:2254,8660:2253,8706:2287,8709:16785925,8711:2245,8712:16785928,8713:16785929,8715:16785931,8728:3018,8730:2262,8731:16785947,8732:16785948,8733:2241,8734:2242,8743:2270,8744:2271,8745:2268,8746:2269,8747:2239,8748:16785964,8749:16785965,8756:2240,8757:16785973,8764:2248,8771:2249,8773:16785992,8775:16785991,8800:2237,8801:2255,8802:16786018,8803:16786019,8804:2236,8805:2238,8834:2266,8835:2267,8866:3068,8867:3036,8868:3010,8869:3022,8968:3027,8970:3012,8981:2810,8992:2212,8993:2213,9109:3020,9115:2219,9117:2220,9118:2221,9120:2222,9121:2215,9123:2216,9124:2217,9126:2218,9128:2223,9132:2224,9143:2209,9146:2543,9147:2544,9148:2546,9149:2547,9225:2530,9226:2533,9227:2537,9228:2531,9229:2532,9251:2732,9252:2536,9472:2211,9474:2214,9484:2210,9488:2539,9492:2541,9496:2538,9500:2548,9508:2549,9516:2551,9524:2550,9532:2542,9618:2529,9642:2791,9643:2785,9644:2779,9645:2786,9646:2783,9647:2767,9650:2792,9651:2787,9654:2781,9655:2765,9660:2793,9661:2788,9664:2780,9665:2764,9670:2528,9675:2766,9679:2782,9702:2784,9734:2789,9742:2809,9747:2762,9756:2794,9758:2795,9792:2808,9794:2807,9827:2796,9829:2798,9830:2797,9837:2806,9839:2805,10003:2803,10007:2804,10013:2777,10016:2800,10216:2748,10217:2750,10240:16787456,10241:16787457,10242:16787458,10243:16787459,10244:16787460,10245:16787461,10246:16787462,10247:16787463,10248:16787464,10249:16787465,10250:16787466,10251:16787467,10252:16787468,10253:16787469,10254:16787470,10255:16787471,10256:16787472,10257:16787473,10258:16787474,10259:16787475,10260:16787476,10261:16787477,10262:16787478,10263:16787479,10264:16787480,10265:16787481,10266:16787482,10267:16787483,10268:16787484,10269:16787485,10270:16787486,10271:16787487,10272:16787488,10273:16787489,10274:16787490,10275:16787491,10276:16787492,10277:16787493,10278:16787494,10279:16787495,10280:16787496,10281:16787497,10282:16787498,10283:16787499,10284:16787500,10285:16787501,10286:16787502,10287:16787503,10288:16787504,10289:16787505,10290:16787506,10291:16787507,10292:16787508,10293:16787509,10294:16787510,10295:16787511,10296:16787512,10297:16787513,10298:16787514,10299:16787515,10300:16787516,10301:16787517,10302:16787518,10303:16787519,10304:16787520,10305:16787521,10306:16787522,10307:16787523,10308:16787524,10309:16787525,10310:16787526,10311:16787527,10312:16787528,10313:16787529,10314:16787530,10315:16787531,10316:16787532,10317:16787533,10318:16787534,10319:16787535,10320:16787536,10321:16787537,10322:16787538,10323:16787539,10324:16787540,10325:16787541,10326:16787542,10327:16787543,10328:16787544,10329:16787545,10330:16787546,10331:16787547,10332:16787548,10333:16787549,10334:16787550,10335:16787551,10336:16787552,10337:16787553,10338:16787554,10339:16787555,10340:16787556,10341:16787557,10342:16787558,10343:16787559,10344:16787560,10345:16787561,10346:16787562,10347:16787563,10348:16787564,10349:16787565,10350:16787566,10351:16787567,10352:16787568,10353:16787569,10354:16787570,10355:16787571,10356:16787572,10357:16787573,10358:16787574,10359:16787575,10360:16787576,10361:16787577,10362:16787578,10363:16787579,10364:16787580,10365:16787581,10366:16787582,10367:16787583,10368:16787584,10369:16787585,10370:16787586,10371:16787587,10372:16787588,10373:16787589,10374:16787590,10375:16787591,10376:16787592,10377:16787593,10378:16787594,10379:16787595,10380:16787596,10381:16787597,10382:16787598,10383:16787599,10384:16787600,10385:16787601,10386:16787602,10387:16787603,10388:16787604,10389:16787605,10390:16787606,10391:16787607,10392:16787608,10393:16787609,10394:16787610,10395:16787611,10396:16787612,10397:16787613,10398:16787614,10399:16787615,10400:16787616,10401:16787617,10402:16787618,10403:16787619,10404:16787620,10405:16787621,10406:16787622,10407:16787623,10408:16787624,10409:16787625,10410:16787626,10411:16787627,10412:16787628,10413:16787629,10414:16787630,10415:16787631,10416:16787632,10417:16787633,10418:16787634,10419:16787635,10420:16787636,10421:16787637,10422:16787638,10423:16787639,10424:16787640,10425:16787641,10426:16787642,10427:16787643,10428:16787644,10429:16787645,10430:16787646,10431:16787647,10432:16787648,10433:16787649,10434:16787650,10435:16787651,10436:16787652,10437:16787653,10438:16787654,10439:16787655,10440:16787656,10441:16787657,10442:16787658,10443:16787659,10444:16787660,10445:16787661,10446:16787662,10447:16787663,10448:16787664,10449:16787665,10450:16787666,10451:16787667,10452:16787668,10453:16787669,10454:16787670,10455:16787671,10456:16787672,10457:16787673,10458:16787674,10459:16787675,10460:16787676,10461:16787677,10462:16787678,10463:16787679,10464:16787680,10465:16787681,10466:16787682,10467:16787683,10468:16787684,10469:16787685,10470:16787686,10471:16787687,10472:16787688,10473:16787689,10474:16787690,10475:16787691,10476:16787692,10477:16787693,10478:16787694,10479:16787695,10480:16787696,10481:16787697,10482:16787698,10483:16787699,10484:16787700,10485:16787701,10486:16787702,10487:16787703,10488:16787704,10489:16787705,10490:16787706,10491:16787707,10492:16787708,10493:16787709,10494:16787710,10495:16787711,12289:1188,12290:1185,12300:1186,12301:1187,12443:1246,12444:1247,12449:1191,12450:1201,12451:1192,12452:1202,12453:1193,12454:1203,12455:1194,12456:1204,12457:1195,12458:1205,12459:1206,12461:1207,12463:1208,12465:1209,12467:1210,12469:1211,12471:1212,12473:1213,12475:1214,12477:1215,12479:1216,12481:1217,12483:1199,12484:1218,12486:1219,12488:1220,12490:1221,12491:1222,12492:1223,12493:1224,12494:1225,12495:1226,12498:1227,12501:1228,12504:1229,12507:1230,12510:1231,12511:1232,12512:1233,12513:1234,12514:1235,12515:1196,12516:1236,12517:1197,12518:1237,12519:1198,12520:1238,12521:1239,12522:1240,12523:1241,12524:1242,12525:1243,12527:1244,12530:1190,12531:1245,12539:1189,12540:1200};function lookup(k){return k?{keysym:k,keyname:k}:void 0}return{fromUnicode:function(u){return lookup(codepoints[u])},lookup:lookup}}();send_array=function(){};next_iteration=function(){if(0===iteration){frame_length=VNC_frame_data.length;test_state="running"}else rfb.disconnect();if("running"===test_state)if((iteration+=1)>iterations)finish();else{frame_idx=0;istart_time=(new Date).getTime();rfb.connect("test",0,"bogus");queue_next_packet()}};queue_next_packet=function(){var frame,delay;if("running"===test_state){frame=VNC_frame_data[frame_idx];for(;frame_idx<frame_length&&"}"===frame.charAt(0);){frame_idx+=1;frame=VNC_frame_data[frame_idx]}if("EOF"!==frame)if(frame_idx>=frame_length)next_iteration();else if("realtime"===mode){(delay=frame.slice(1,frame.indexOf("{",1))-((new Date).getTime()-istart_time))<1&&(delay=1);setTimeout(do_packet,delay)}else setTimeout(do_packet,1);else next_iteration()}};var bytes_processed=0;do_packet=function(){var frame=VNC_frame_data[frame_idx],start=frame.indexOf("{",1)+1;bytes_processed+=frame.length-start;if("binary"===VNC_frame_encoding){for(var u8=new Uint8Array(frame.length-start),i=0;i<frame.length-start;i++)u8[i]=frame.charCodeAt(start+i);rfb.recv_message({data:u8})}else rfb.recv_message({data:frame.slice(start)});frame_idx+=1;queue_next_packet()};function RFB(defaults){var init_vars,updateState,fail,handle_message,init_msg,normal_msg,framebufferUpdate,print_stats,pixelFormat,clientEncodings,fbUpdateRequest,fbUpdateRequests,keyEvent,pointerEvent,clientCutText,getTightCLength,extract_data_uri,keyPress,mouseButton,mouseMove,checkEvents,that={},conf={},rfb_host="",rfb_port=5900,rfb_password="",rfb_path="",rfb_state="disconnected",rfb_version=0,rfb_auth_scheme="",rfb_tightvnc=!1,rfb_xvp_ver=0,encodings=[["COPYRECT",1],["TIGHT",7],["TIGHT_PNG",-260],["HEXTILE",5],["RRE",2],["RAW",0],["DesktopSize",-223],["Cursor",-239],["JPEG_quality_med",-26],["compress_hi",-247],["last_rect",-224],["xvp",-309]],encHandlers={},encNames={},encStats={},ws=null,display=null,keyboard=null,mouse=null,sendTimer=null,disconnTimer=null,msgTimer=null,FBU={rects:0,subrects:0,lines:0,tiles:0,bytes:0,x:0,y:0,width:0,height:0,encoding:0,subencoding:-1,background:null,zlibs:[]},fb_Bpp=4,fb_depth=3,fb_width=0,fb_height=0,fb_name="",timing={last_fbu:0,fbu_total:0,fbu_total_cnt:0,full_fbu_total:0,full_fbu_cnt:0,fbu_rt_start:0,fbu_rt_total:0,fbu_rt_cnt:0,pixels:0},test_mode=!1,mouse_buttonMask=0,mouse_arr=[],viewportDragging=!1,viewportDragPos={};Util.conf_defaults(conf,that,defaults,[["target","wo","dom",null,"VNC display rendering Canvas object"],["focusContainer","wo","dom",document,"DOM element that captures keyboard input"],["encrypt","rw","bool",!1,"Use TLS/SSL/wss encryption"],["true_color","rw","bool",!0,"Request true color pixel data"],["local_cursor","rw","bool",!1,"Request locally rendered cursor"],["shared","rw","bool",!0,"Request shared mode"],["view_only","rw","bool",!1,"Disable client mouse/keyboard"],["xvp_password_sep","rw","str","@","Separator for XVP password fields"],["disconnectTimeout","rw","int",3,"Time (s) to wait for disconnection"],["wsProtocols","rw","arr",["binary","base64"],"Protocols to use in the WebSocket connection"],["repeaterID","rw","str","","RepeaterID to connect to"],["viewportDrag","rw","bool",!1,"Move the viewport on mouse drags"],["onUpdateState","rw","func",function(){},"onUpdateState(rfb, state, oldstate, statusMsg): RFB state update/change "],["onPasswordRequired","rw","func",function(){},"onPasswordRequired(rfb): VNC password is required "],["onClipboard","rw","func",function(){},"onClipboard(rfb, text): RFB clipboard contents received"],["onBell","rw","func",function(){},"onBell(rfb): RFB Bell message received "],["onFBUReceive","rw","func",function(){},"onFBUReceive(rfb, fbu): RFB FBU received but not yet processed "],["onFBUComplete","rw","func",function(){},"onFBUComplete(rfb, fbu): RFB FBU received and processed "],["onFBResize","rw","func",function(){},"onFBResize(rfb, width, height): frame buffer resized"],["onDesktopName","rw","func",function(){},"onDesktopName(rfb, name): desktop name received"],["onXvpInit","rw","func",function(){},"onXvpInit(version): XVP extensions active for this connection"],["updateState","rw","func",function(){},"obsolete, use onUpdateState"],["clipboardReceive","rw","func",function(){},"obsolete, use onClipboard"]]);that.set_local_cursor=function(cursor){!cursor||cursor in{0:1,no:1,false:1}?conf.local_cursor=!1:display.get_cursor_uri()?conf.local_cursor=!0:Util.Warn("Browser does not support local cursor")};that.get_display=function(){return display};that.get_keyboard=function(){return keyboard};that.get_mouse=function(){return mouse};init_vars=function(){var i;ws.init();FBU.rects=0;FBU.subrects=0;FBU.lines=0;FBU.tiles=0;FBU.zlibs=[];mouse_buttonMask=0;mouse_arr=[];for(i=0;i<encodings.length;i+=1)encStats[encodings[i][1]][0]=0;for(i=0;i<4;i++){FBU.zlibs[i]=new TINF;FBU.zlibs[i].init()}};print_stats=function(){var i,s;Util.Info("Encoding stats for this connection:");for(i=0;i<encodings.length;i+=1)(s=encStats[encodings[i][1]])[0]+s[1]>0&&Util.Info(" "+encodings[i][0]+": "+s[0]+" rects");Util.Info("Encoding stats since page load:");for(i=0;i<encodings.length;i+=1)(s=encStats[encodings[i][1]])[0]+s[1]>0&&Util.Info(" "+encodings[i][0]+": "+s[1]+" rects")};updateState=function(state,statusMsg){var oldstate=rfb_state;if(state!==oldstate){if(state in{disconnected:1,loaded:1,connect:1,disconnect:1,failed:1,fatal:1}){if(sendTimer){clearInterval(sendTimer);sendTimer=null}if(msgTimer){clearTimeout(msgTimer);msgTimer=null}if(display&&display.get_context()){keyboard.ungrab();mouse.ungrab();display.defaultCursor();"debug"===Util.get_logging()&&"loaded"!==state||display.clear()}ws.close()}"fatal"===oldstate&&Util.Error("Fatal error, cannot continue");("failed"===state||"fatal"===state?Util.Error:Util.Warn)("New state '"+state+"', was '"+oldstate+"'."+(void 0!==statusMsg?" Msg: "+statusMsg:""));rfb_state="failed"===oldstate&&"disconnected"===state?"failed":state;if(disconnTimer&&"disconnect"!==rfb_state){clearTimeout(disconnTimer);disconnTimer=null}switch(state){case"normal":"disconnected"!==oldstate&&"failed"!==oldstate||Util.Error("Invalid transition from 'disconnected' or 'failed' to 'normal'");break;case"connect":init_vars();(function(){var uri;uri="undefined"!=typeof UsingSocketIO?"http":conf.encrypt?"wss":"ws";uri+="://"+rfb_host+":"+rfb_port+"/"+rfb_path;Util.Info("connecting to "+uri);ws.open(uri,conf.wsProtocols)})();break;case"disconnect":test_mode||(disconnTimer=setTimeout((function(){fail("Disconnect timeout")}),1e3*conf.disconnectTimeout));print_stats();break;case"failed":"disconnected"===oldstate&&Util.Error("Invalid transition from 'disconnected' to 'failed'");"normal"===oldstate&&Util.Error("Error while connected.");"init"===oldstate&&Util.Error("Error while initializing.");setTimeout((function(){updateState("disconnected")}),50)}if("failed"===oldstate&&"disconnected"===state){conf.updateState(that,state,oldstate);conf.onUpdateState(that,state,oldstate)}else{conf.updateState(that,state,oldstate,statusMsg);conf.onUpdateState(that,state,oldstate,statusMsg)}}};fail=function(msg){updateState("failed",msg);return!1};handle_message=function(){if(0!==ws.rQlen())switch(rfb_state){case"disconnected":case"failed":Util.Error("Got data while disconnected");break;case"normal":normal_msg()&&ws.rQlen()>0&&null===msgTimer&&(msgTimer=setTimeout((function(){msgTimer=null;handle_message()}),10));break;default:init_msg()}else Util.Warn("handle_message called on empty receive queue")};checkEvents=function(){if("normal"===rfb_state&&!viewportDragging&&mouse_arr.length>0){ws.send(mouse_arr);mouse_arr=[]}};keyPress=function(keysym,down){conf.view_only||ws.send(keyEvent(keysym,down))};mouseButton=function(x,y,down,bmask){down?mouse_buttonMask|=bmask:mouse_buttonMask^=bmask;if(conf.viewportDrag){if(down&&!viewportDragging){viewportDragging=!0;viewportDragPos={x:x,y:y};return}viewportDragging=!1}if(!conf.view_only){mouse_arr=mouse_arr.concat(pointerEvent(display.absX(x),display.absY(y)));ws.send(mouse_arr);mouse_arr=[]}};mouseMove=function(x,y){var deltaX,deltaY;if(viewportDragging){deltaX=viewportDragPos.x-x;deltaY=viewportDragPos.y-y;viewportDragPos={x:x,y:y};display.viewportChange(deltaX,deltaY)}else if(!conf.view_only){mouse_arr=mouse_arr.concat(pointerEvent(display.absX(x),display.absY(y)));checkEvents()}};init_msg=function(){var strlen,reason,length,sversion,cversion,repeaterID,types,num_types,challenge,response,bpp,depth,big_endian,red_max,green_max,blue_max,red_shift,green_shift,blue_shift,true_color,name_length,is_repeater,xvp_sep,xvp_auth,xvp_auth_str;switch(rfb_state){case"ProtocolVersion":if(ws.rQlen()<12)return fail("Incomplete protocol version");sversion=ws.rQshiftStr(12).substr(4,7);Util.Info("Server ProtocolVersion: "+sversion);is_repeater=0;switch(sversion){case"000.000":is_repeater=1;break;case"003.003":case"003.006":case"003.889":rfb_version=3.3;break;case"003.007":rfb_version=3.7;break;case"003.008":case"004.000":case"004.001":rfb_version=3.8;break;default:return fail("Invalid server version "+sversion)}if(is_repeater){repeaterID=conf.repeaterID;for(;repeaterID.length<250;)repeaterID+="\0";ws.send_string(repeaterID);break}rfb_version>3.8&&(rfb_version=3.8);test_mode||(sendTimer=setInterval((function(){ws.flush()}),50));cversion="00"+parseInt(rfb_version,10)+".00"+10*rfb_version%10;ws.send_string("RFB "+cversion+"\n");updateState("Security","Sent ProtocolVersion: "+cversion);break;case"Security":if(rfb_version>=3.7){num_types=ws.rQshift8();if(ws.rQwait("security type",num_types,1))return!1;if(0===num_types){strlen=ws.rQshift32();reason=ws.rQshiftStr(strlen);return fail("Security failure: "+reason)}rfb_auth_scheme=0;types=ws.rQshiftBytes(num_types);for(i=0;i<types.length;i+=1)types[i]>rfb_auth_scheme&&(types[i]<=16||22==types[i])&&(rfb_auth_scheme=types[i]);if(0===rfb_auth_scheme)return fail("Unsupported security types: "+types);ws.send([rfb_auth_scheme])}else{if(ws.rQwait("security scheme",4))return!1;rfb_auth_scheme=ws.rQshift32()}updateState("Authentication","Authenticating using scheme: "+rfb_auth_scheme);init_msg();break;case"Authentication":switch(rfb_auth_scheme){case 0:if(ws.rQwait("auth reason",4))return!1;strlen=ws.rQshift32();reason=ws.rQshiftStr(strlen);return fail("Auth failure: "+reason);case 1:if(rfb_version>=3.8){updateState("SecurityResult");return}break;case 22:xvp_sep=conf.xvp_password_sep;if((xvp_auth=rfb_password.split(xvp_sep)).length<3){updateState("password","XVP credentials required (user"+xvp_sep+"target"+xvp_sep+"password) -- got only "+rfb_password);conf.onPasswordRequired(that);return}xvp_auth_str=String.fromCharCode(xvp_auth[0].length)+String.fromCharCode(xvp_auth[1].length)+xvp_auth[0]+xvp_auth[1];ws.send_string(xvp_auth_str);rfb_password=xvp_auth.slice(2).join(xvp_sep);rfb_auth_scheme=2;case 2:if(0===rfb_password.length){updateState("password","Password Required");conf.onPasswordRequired(that);return}if(ws.rQwait("auth challenge",16))return!1;challenge=ws.rQshiftBytes(16);response=function(password,challenge){var i,passwd=[];for(i=0;i<password.length;i+=1)passwd.push(password.charCodeAt(i));return new DES(passwd).encrypt(challenge)}(rfb_password,challenge);ws.send(response);updateState("SecurityResult");return;case 16:if(ws.rQwait("num tunnels",4))return!1;var numTunnels=ws.rQshift32();rfb_tightvnc=!0;if(0!=numTunnels){fail("Protocol requested tunnels, not currently supported. numTunnels: "+numTunnels);return}var clientSupportedTypes={STDVNOAUTH__:1,STDVVNCAUTH_:2},serverSupportedTypes=[];if(ws.rQwait("sub auth count",4))return!1;for(var subAuthCount=ws.rQshift32(),i=0;i<subAuthCount;i++){if(ws.rQwait("sub auth capabilities "+i,16))return!1;ws.rQshift32();var capabilities=ws.rQshiftStr(12);serverSupportedTypes.push(capabilities)}for(var authType in clientSupportedTypes)if(-1!=serverSupportedTypes.indexOf(authType)){ws.send([0,0,0,clientSupportedTypes[authType]]);switch(authType){case"STDVNOAUTH__":updateState("SecurityResult");return;case"STDVVNCAUTH_":rfb_auth_scheme=2;init_msg();return;default:fail("Unsupported tiny auth scheme: "+authType);return}}return;default:fail("Unsupported auth scheme: "+rfb_auth_scheme);return}updateState("ClientInitialisation","No auth required");init_msg();break;case"SecurityResult":if(ws.rQwait("VNC auth response ",4))return!1;switch(ws.rQshift32()){case 0:break;case 1:if(rfb_version>=3.8){length=ws.rQshift32();if(ws.rQwait("SecurityResult reason",length,8))return!1;reason=ws.rQshiftStr(length);fail(reason)}else fail("Authentication failed");return;case 2:return fail("Too many auth attempts")}updateState("ClientInitialisation","Authentication OK");init_msg();break;case"ClientInitialisation":ws.send([conf.shared?1:0]);updateState("ServerInitialisation","Authentication OK");break;case"ServerInitialisation":if(ws.rQwait("server initialization",24))return!1;fb_width=ws.rQshift16();fb_height=ws.rQshift16();bpp=ws.rQshift8();depth=ws.rQshift8();big_endian=ws.rQshift8();true_color=ws.rQshift8();red_max=ws.rQshift16();green_max=ws.rQshift16();blue_max=ws.rQshift16();red_shift=ws.rQshift8();green_shift=ws.rQshift8();blue_shift=ws.rQshift8();ws.rQshiftStr(3);Util.Info("Screen: "+fb_width+"x"+fb_height+", bpp: "+bpp+", depth: "+depth+", big_endian: "+big_endian+", true_color: "+true_color+", red_max: "+red_max+", green_max: "+green_max+", blue_max: "+blue_max+", red_shift: "+red_shift+", green_shift: "+green_shift+", blue_shift: "+blue_shift);0!==big_endian&&Util.Warn("Server native endian is not little endian");16!==red_shift&&Util.Warn("Server native red-shift is not 16");0!==blue_shift&&Util.Warn("Server native blue-shift is not 0");name_length=ws.rQshift32();fb_name=Util.decodeUTF8(ws.rQshiftStr(name_length));conf.onDesktopName(that,fb_name);if(conf.true_color&&"Intel(r) AMT KVM"===fb_name){Util.Warn("Intel AMT KVM only support 8/16 bit depths. Disabling true color");conf.true_color=!1}if(rfb_tightvnc){var numServerMessages=ws.rQshift16(),numClientMessages=ws.rQshift16(),numEncodings=ws.rQshift16();ws.rQshift16();for(i=0;i<numServerMessages;i++)ws.rQshiftStr(16);for(i=0;i<numClientMessages;i++)ws.rQshiftStr(16);for(i=0;i<numEncodings;i++)ws.rQshiftStr(16)}display.set_true_color(conf.true_color);conf.onFBResize(that,fb_width,fb_height);display.resize(fb_width,fb_height);keyboard.grab();mouse.grab();if(conf.true_color){fb_Bpp=4;fb_depth=3}else{fb_Bpp=1;fb_depth=1}response=(response=(response=pixelFormat()).concat(clientEncodings())).concat(fbUpdateRequests());timing.fbu_rt_start=(new Date).getTime();timing.pixels=0;ws.send(response);checkEvents();conf.encrypt?updateState("normal","Connected (encrypted) to: "+fb_name):updateState("normal","Connected (unencrypted) to: "+fb_name)}};normal_msg=function(){var msg_type,length,text,c,first_colour,num_colours,red,green,blue,xvp_ver,xvp_msg,ret=!0;switch(msg_type=FBU.rects>0?0:ws.rQshift8()){case 0:(ret=framebufferUpdate())&&ws.send(fbUpdateRequests());break;case 1:ws.rQshift8();first_colour=ws.rQshift16();num_colours=ws.rQshift16();if(ws.rQwait("SetColourMapEntries",6*num_colours,6))return!1;for(c=0;c<num_colours;c+=1){red=ws.rQshift16();red=parseInt(red/256,10);green=parseInt(ws.rQshift16()/256,10);blue=parseInt(ws.rQshift16()/256,10);display.set_colourMap([blue,green,red],first_colour+c)}Util.Info("Registered "+num_colours+" colourMap entries");break;case 2:conf.onBell(that);break;case 3:if(ws.rQwait("ServerCutText header",7,1))return!1;ws.rQshiftBytes(3);length=ws.rQshift32();if(ws.rQwait("ServerCutText",length,8))return!1;text=ws.rQshiftStr(length);conf.clipboardReceive(that,text);conf.onClipboard(that,text);break;case 250:ws.rQshift8();xvp_ver=ws.rQshift8();switch(xvp_msg=ws.rQshift8()){case 0:updateState(rfb_state,"Operation failed");break;case 1:rfb_xvp_ver=xvp_ver;Util.Info("XVP extensions enabled (version "+rfb_xvp_ver+")");conf.onXvpInit(rfb_xvp_ver);break;default:fail("Disconnected: illegal server XVP message "+xvp_msg)}break;default:fail("Disconnected: illegal server message type "+msg_type)}return ret};framebufferUpdate=function(){var now,hdr,fbu_rt_diff,ret=!0;if(0===FBU.rects){if(ws.rQwait("FBU header",3)){ws.rQunshift8(0);return!1}ws.rQshift8();FBU.rects=ws.rQshift16();FBU.bytes=0;timing.cur_fbu=0;if(timing.fbu_rt_start>0){now=(new Date).getTime();Util.Info("First FBU latency: "+(now-timing.fbu_rt_start))}}for(;FBU.rects>0;){if("normal"!==rfb_state)return!1;if(ws.rQwait("FBU",FBU.bytes))return!1;if(0===FBU.bytes){if(ws.rQwait("rect header",12))return!1;hdr=ws.rQshiftBytes(12);FBU.x=(hdr[0]<<8)+hdr[1];FBU.y=(hdr[2]<<8)+hdr[3];FBU.width=(hdr[4]<<8)+hdr[5];FBU.height=(hdr[6]<<8)+hdr[7];FBU.encoding=parseInt((hdr[8]<<24)+(hdr[9]<<16)+(hdr[10]<<8)+hdr[11],10);conf.onFBUReceive(that,{x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height,encoding:FBU.encoding,encodingName:encNames[FBU.encoding]});if(!encNames[FBU.encoding]){fail("Disconnected: unsupported encoding "+FBU.encoding);return!1}}timing.last_fbu=(new Date).getTime();ret=encHandlers[FBU.encoding]();now=(new Date).getTime();timing.cur_fbu+=now-timing.last_fbu;if(ret){encStats[FBU.encoding][0]+=1;encStats[FBU.encoding][1]+=1;timing.pixels+=FBU.width*FBU.height}if(timing.pixels>=fb_width*fb_height){if(FBU.width===fb_width&&FBU.height===fb_height||timing.fbu_rt_start>0){timing.full_fbu_total+=timing.cur_fbu;timing.full_fbu_cnt+=1;Util.Info("Timing of full FBU, cur: "+timing.cur_fbu+", total: "+timing.full_fbu_total+", cnt: "+timing.full_fbu_cnt+", avg: "+timing.full_fbu_total/timing.full_fbu_cnt)}if(timing.fbu_rt_start>0){fbu_rt_diff=now-timing.fbu_rt_start;timing.fbu_rt_total+=fbu_rt_diff;timing.fbu_rt_cnt+=1;Util.Info("full FBU round-trip, cur: "+fbu_rt_diff+", total: "+timing.fbu_rt_total+", cnt: "+timing.fbu_rt_cnt+", avg: "+timing.fbu_rt_total/timing.fbu_rt_cnt);timing.fbu_rt_start=0}}if(!ret)return ret}conf.onFBUComplete(that,{x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height,encoding:FBU.encoding,encodingName:encNames[FBU.encoding]});return!0};encHandlers.RAW=function(){var cur_y,cur_height;0===FBU.lines&&(FBU.lines=FBU.height);FBU.bytes=FBU.width*fb_Bpp;if(ws.rQwait("RAW",FBU.bytes))return!1;cur_y=FBU.y+(FBU.height-FBU.lines);cur_height=Math.min(FBU.lines,Math.floor(ws.rQlen()/(FBU.width*fb_Bpp)));display.blitImage(FBU.x,cur_y,FBU.width,cur_height,ws.get_rQ(),ws.get_rQi());ws.rQshiftBytes(FBU.width*cur_height*fb_Bpp);FBU.lines-=cur_height;if(FBU.lines>0)FBU.bytes=FBU.width*fb_Bpp;else{FBU.rects-=1;FBU.bytes=0}return!0};encHandlers.COPYRECT=function(){FBU.bytes=4;if(ws.rQwait("COPYRECT",4))return!1;display.renderQ_push({type:"copy",old_x:ws.rQshift16(),old_y:ws.rQshift16(),x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height});FBU.rects-=1;FBU.bytes=0;return!0};encHandlers.RRE=function(){var color,x,y,width,height,chunk;if(0===FBU.subrects){FBU.bytes=4+fb_Bpp;if(ws.rQwait("RRE",4+fb_Bpp))return!1;FBU.subrects=ws.rQshift32();color=ws.rQshiftBytes(fb_Bpp);display.fillRect(FBU.x,FBU.y,FBU.width,FBU.height,color)}for(;FBU.subrects>0&&ws.rQlen()>=fb_Bpp+8;){color=ws.rQshiftBytes(fb_Bpp);x=ws.rQshift16();y=ws.rQshift16();width=ws.rQshift16();height=ws.rQshift16();display.fillRect(FBU.x+x,FBU.y+y,width,height,color);FBU.subrects-=1}if(FBU.subrects>0){chunk=Math.min(100,FBU.subrects);FBU.bytes=(fb_Bpp+8)*chunk}else{FBU.rects-=1;FBU.bytes=0}return!0};encHandlers.HEXTILE=function(){var subencoding,subrects,color,cur_tile,tile_x,x,w,tile_y,y,h,xy,s,sx,sy,wh,sw,sh,rQ=ws.get_rQ(),rQi=ws.get_rQi();if(0===FBU.tiles){FBU.tiles_x=Math.ceil(FBU.width/16);FBU.tiles_y=Math.ceil(FBU.height/16);FBU.total_tiles=FBU.tiles_x*FBU.tiles_y;FBU.tiles=FBU.total_tiles}for(;FBU.tiles>0;){FBU.bytes=1;if(ws.rQwait("HEXTILE subencoding",FBU.bytes))return!1;if((subencoding=rQ[rQi])>30){fail("Disconnected: illegal hextile subencoding "+subencoding);return!1}subrects=0;tile_x=(cur_tile=FBU.total_tiles-FBU.tiles)%FBU.tiles_x;tile_y=Math.floor(cur_tile/FBU.tiles_x);x=FBU.x+16*tile_x;y=FBU.y+16*tile_y;w=Math.min(16,FBU.x+FBU.width-x);h=Math.min(16,FBU.y+FBU.height-y);if(1&subencoding)FBU.bytes+=w*h*fb_Bpp;else{2&subencoding&&(FBU.bytes+=fb_Bpp);4&subencoding&&(FBU.bytes+=fb_Bpp);if(8&subencoding){FBU.bytes+=1;if(ws.rQwait("hextile subrects header",FBU.bytes))return!1;subrects=rQ[rQi+FBU.bytes-1];FBU.bytes+=16&subencoding?subrects*(fb_Bpp+2):2*subrects}}if(ws.rQwait("hextile",FBU.bytes))return!1;FBU.subencoding=rQ[rQi];rQi+=1;if(0===FBU.subencoding)1&FBU.lastsubencoding||display.fillRect(x,y,w,h,FBU.background);else if(1&FBU.subencoding){display.blitImage(x,y,w,h,rQ,rQi);rQi+=FBU.bytes-1}else{if(2&FBU.subencoding){FBU.background=rQ.slice(rQi,rQi+fb_Bpp);rQi+=fb_Bpp}if(4&FBU.subencoding){FBU.foreground=rQ.slice(rQi,rQi+fb_Bpp);rQi+=fb_Bpp}display.startTile(x,y,w,h,FBU.background);if(8&FBU.subencoding){subrects=rQ[rQi];rQi+=1;for(s=0;s<subrects;s+=1){if(16&FBU.subencoding){color=rQ.slice(rQi,rQi+fb_Bpp);rQi+=fb_Bpp}else color=FBU.foreground;sx=(xy=rQ[rQi])>>4;sy=15&xy;wh=rQ[rQi+=1];rQi+=1;sw=1+(wh>>4);sh=1+(15&wh);display.subTile(sx,sy,sw,sh,color)}}display.finishTile()}ws.set_rQi(rQi);FBU.lastsubencoding=FBU.subencoding;FBU.bytes=0;FBU.tiles-=1}0===FBU.tiles&&(FBU.rects-=1);return!0};getTightCLength=function(arr){var header=1,data=0;data+=127&arr[0];if(128&arr[0]){header+=1;data+=(127&arr[1])<<7;if(128&arr[1]){header+=1;data+=arr[2]<<14}}return[header,data]};function display_tight(isTightPNG){1===fb_depth&&fail("Tight protocol handler only implements true color mode");var ctl,cmode,clength,color,img,data,filterId=-1,resetStreams=0,streamId=-1,rQ=ws.get_rQ(),rQi=ws.get_rQi();FBU.bytes=1;if(ws.rQwait("TIGHT compression-control",FBU.bytes))return!1;var decompress=function(data){for(var i=0;i<4;i++)if(resetStreams>>i&1){FBU.zlibs[i].reset();Util.Info("Reset zlib stream "+i)}var uncompressed=FBU.zlibs[streamId].uncompress(data,0);0!==uncompressed.status&&Util.Error("Invalid data in zlib stream");return uncompressed.data};ctl=ws.rQpeek8();resetStreams=15&ctl;streamId=3&(ctl>>=4);if(8===ctl)cmode="fill";else if(9===ctl)cmode="jpeg";else if(10===ctl)cmode="png";else if(4&ctl)cmode="filter";else{if(!(ctl<4))return fail("Illegal tight compression received, ctl: "+ctl);cmode="copy"}if(isTightPNG&&("filter"===cmode||"copy"===cmode))return fail("filter/copy received in tightPNG mode");switch(cmode){case"fill":FBU.bytes+=fb_depth;break;case"jpeg":case"png":FBU.bytes+=3;break;case"filter":FBU.bytes+=2}if(ws.rQwait("TIGHT "+cmode,FBU.bytes))return!1;switch(cmode){case"fill":ws.rQshift8();color=ws.rQshiftBytes(fb_depth);display.renderQ_push({type:"fill",x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height,color:[color[2],color[1],color[0]]});break;case"png":case"jpeg":clength=getTightCLength(ws.rQslice(1,4));FBU.bytes=1+clength[0]+clength[1];if(ws.rQwait("TIGHT "+cmode,FBU.bytes))return!1;ws.rQshiftBytes(1+clength[0]);(img=new Image).src="data:image/"+cmode+extract_data_uri(ws.rQshiftBytes(clength[1]));display.renderQ_push({type:"img",img:img,x:FBU.x,y:FBU.y});img=null;break;case"filter":if(1!==(filterId=rQ[rQi+1]))throw"Unsupported tight subencoding received, filter: "+filterId;if(!function(){var numColors=rQ[rQi+2]+1,paletteSize=numColors*fb_depth;FBU.bytes+=paletteSize;if(ws.rQwait("TIGHT palette "+cmode,FBU.bytes))return!1;var bpp=numColors<=2?1:8,rowSize=Math.floor((FBU.width*bpp+7)/8),raw=!1;if(rowSize*FBU.height<12){raw=!0;clength=[0,rowSize*FBU.height]}else clength=getTightCLength(ws.rQslice(3+paletteSize,3+paletteSize+3));FBU.bytes+=clength[0]+clength[1];if(ws.rQwait("TIGHT "+cmode,FBU.bytes))return!1;ws.rQshiftBytes(3);var palette=ws.rQshiftBytes(paletteSize);ws.rQshiftBytes(clength[0]);var rgb=function(data,numColors,palette,width,height){var x,y,b,w,w1,dp,sp,dest=[];if(2===numColors){w=Math.floor((width+7)/8);w1=Math.floor(width/8);for(y=0;y<height;y++){for(x=0;x<w1;x++)for(b=7;b>=0;b--){dp=3*(y*width+8*x+7-b);sp=3*(data[y*w+x]>>b&1);dest[dp]=palette[sp];dest[dp+1]=palette[sp+1];dest[dp+2]=palette[sp+2]}for(b=7;b>=8-width%8;b--){dp=3*(y*width+8*x+7-b);sp=3*(data[y*w+x]>>b&1);dest[dp]=palette[sp];dest[dp+1]=palette[sp+1];dest[dp+2]=palette[sp+2]}}}else for(y=0;y<height;y++)for(x=0;x<width;x++){dp=3*(y*width+x);sp=3*data[y*width+x];dest[dp]=palette[sp];dest[dp+1]=palette[sp+1];dest[dp+2]=palette[sp+2]}return dest}(data=raw?ws.rQshiftBytes(clength[1]):decompress(ws.rQshiftBytes(clength[1])),numColors,palette,FBU.width,FBU.height);display.renderQ_push({type:"blitRgb",data:rgb,x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height});return!0}())return!1;break;case"copy":if(!function(){var raw=!1,uncompressedSize=FBU.width*FBU.height*fb_depth;if(uncompressedSize<12){raw=!0;clength=[0,uncompressedSize]}else clength=getTightCLength(ws.rQslice(1,4));FBU.bytes=1+clength[0]+clength[1];if(ws.rQwait("TIGHT "+cmode,FBU.bytes))return!1;ws.rQshiftBytes(1+clength[0]);data=raw?ws.rQshiftBytes(clength[1]):decompress(ws.rQshiftBytes(clength[1]));display.renderQ_push({type:"blitRgb",data:data,x:FBU.x,y:FBU.y,width:FBU.width,height:FBU.height});return!0}())return!1}FBU.bytes=0;FBU.rects-=1;return!0}extract_data_uri=function(arr){return";base64,"+Base64.encode(arr)};encHandlers.TIGHT=function(){return display_tight(!1)};encHandlers.TIGHT_PNG=function(){return display_tight(!0)};encHandlers.last_rect=function(){FBU.rects=0;return!0};encHandlers.DesktopSize=function(){fb_width=FBU.width;fb_height=FBU.height;conf.onFBResize(that,fb_width,fb_height);display.resize(fb_width,fb_height);timing.fbu_rt_start=(new Date).getTime();FBU.bytes=0;FBU.rects-=1;return!0};encHandlers.Cursor=function(){var x,y,w,h,pixelslength,masklength;x=FBU.x;y=FBU.y;pixelslength=(w=FBU.width)*(h=FBU.height)*fb_Bpp;masklength=Math.floor((w+7)/8)*h;FBU.bytes=pixelslength+masklength;if(ws.rQwait("cursor encoding",FBU.bytes))return!1;display.changeCursor(ws.rQshiftBytes(pixelslength),ws.rQshiftBytes(masklength),x,y,w,h);FBU.bytes=0;FBU.rects-=1;return!0};encHandlers.JPEG_quality_lo=function(){Util.Error("Server sent jpeg_quality pseudo-encoding")};encHandlers.compress_lo=function(){Util.Error("Server sent compress level pseudo-encoding")};pixelFormat=function(){var arr;(arr=[0]).push8(0);arr.push8(0);arr.push8(0);arr.push8(8*fb_Bpp);arr.push8(8*fb_depth);arr.push8(0);arr.push8(conf.true_color?1:0);arr.push16(255);arr.push16(255);arr.push16(255);arr.push8(16);arr.push8(8);arr.push8(0);arr.push8(0);arr.push8(0);arr.push8(0);return arr};clientEncodings=function(){var arr,i,encList=[];for(i=0;i<encodings.length;i+=1)("Cursor"!==encodings[i][0]||conf.local_cursor)&&("TIGHT"!==encodings[i][0]||conf.true_color?encList.push(encodings[i][1]):Util.Warn("Skipping tight, only support with true color"));(arr=[2]).push8(0);arr.push16(encList.length);for(i=0;i<encList.length;i+=1)arr.push32(encList[i]);return arr};fbUpdateRequest=function(incremental,x,y,xw,yw){void 0===x&&(x=0);void 0===y&&(y=0);void 0===xw&&(xw=fb_width);void 0===yw&&(yw=fb_height);var arr;(arr=[3]).push8(incremental);arr.push16(x);arr.push16(y);arr.push16(xw);arr.push16(yw);return arr};fbUpdateRequests=function(){var i,cb,db,cleanDirty=display.getCleanDirtyReset(),arr=[];(cb=cleanDirty.cleanBox).w>0&&cb.h>0&&(arr=arr.concat(fbUpdateRequest(1,cb.x,cb.y,cb.w,cb.h)));for(i=0;i<cleanDirty.dirtyBoxes.length;i++){db=cleanDirty.dirtyBoxes[i];arr=arr.concat(fbUpdateRequest(0,db.x,db.y,db.w,db.h))}return arr};keyEvent=function(keysym,down){var arr;(arr=[4]).push8(down);arr.push16(0);arr.push32(keysym);return arr};pointerEvent=function(x,y){var arr;(arr=[5]).push8(mouse_buttonMask);arr.push16(x);arr.push16(y);return arr};clientCutText=function(text){var arr,i,n;(arr=[6]).push8(0);arr.push8(0);arr.push8(0);arr.push32(text.length);n=text.length;for(i=0;i<n;i+=1)arr.push(text.charCodeAt(i));return arr};that.connect=function(host,port,password,path){rfb_port=port;rfb_password=void 0!==password?password:"";rfb_path=void 0!==path?path:"";if(!(rfb_host=host)||!rfb_port)return fail("Must set host and port");updateState("connect")};that.disconnect=function(){updateState("disconnect","Disconnecting")};that.sendPassword=function(passwd){rfb_password=passwd;rfb_state="Authentication";setTimeout(init_msg,1)};that.sendCtrlAltDel=function(){if("normal"!==rfb_state||conf.view_only)return!1;Util.Info("Sending Ctrl-Alt-Del");var arr=[];arr=(arr=(arr=(arr=(arr=(arr=arr.concat(keyEvent(65507,1))).concat(keyEvent(65513,1))).concat(keyEvent(65535,1))).concat(keyEvent(65535,0))).concat(keyEvent(65513,0))).concat(keyEvent(65507,0));ws.send(arr)};that.xvpOp=function(ver,op){if(rfb_xvp_ver<ver)return!1;Util.Info("Sending XVP operation "+op+" (version "+ver+")");ws.send_string("ú\0"+String.fromCharCode(ver)+String.fromCharCode(op));return!0};that.xvpShutdown=function(){return that.xvpOp(1,2)};that.xvpReboot=function(){return that.xvpOp(1,3)};that.xvpReset=function(){return that.xvpOp(1,4)};that.sendKey=function(code,down){if("normal"!==rfb_state||conf.view_only)return!1;var arr=[];if(void 0!==down){Util.Info("Sending key code ("+(down?"down":"up")+"): "+code);arr=arr.concat(keyEvent(code,down?1:0))}else{Util.Info("Sending key code (down + up): "+code);arr=(arr=arr.concat(keyEvent(code,1))).concat(keyEvent(code,0))}ws.send(arr)};that.clipboardPasteFrom=function(text){"normal"===rfb_state&&ws.send(clientCutText(text))};that.testMode=function(override_send,data_mode){test_mode=!0;that.recv_message=ws.testMode(override_send,data_mode);checkEvents=function(){};that.connect=function(host,port,password){rfb_host=host;rfb_port=port;rfb_password=password;init_vars();updateState("ProtocolVersion","Starting VNC handshake")}};return function(){var i,rmode;for(i=0;i<encodings.length;i+=1){encHandlers[encodings[i][1]]=encHandlers[encodings[i][0]];encNames[encodings[i][1]]=encodings[i][0];encStats[encodings[i][1]]=[0,0]}try{display=new Display({target:conf.target})}catch(exc){Util.Error("Display exception: "+exc);updateState("fatal","No working Display")}keyboard=new Keyboard({target:conf.focusContainer,onKeyPress:keyPress});mouse=new Mouse({target:conf.target,onMouseButton:mouseButton,onMouseMove:mouseMove,notify:keyboard.sync});rmode=display.get_render_mode();(ws=new Websock).on("message",handle_message);ws.on("open",(function(){"connect"===rfb_state?updateState("ProtocolVersion","Starting VNC handshake"):fail("Got unexpected WebSockets connection")}));ws.on("close",(function(e){Util.Warn("WebSocket on-close event");var msg="";if(e.code){msg=" (code: "+e.code;e.reason&&(msg+=", reason: "+e.reason);msg+=")"}"disconnect"===rfb_state?updateState("disconnected","VNC disconnected"+msg):"ProtocolVersion"===rfb_state?fail("Failed to connect to server"+msg):rfb_state in{failed:1,disconnected:1}?Util.Error("Received onclose while disconnected"+msg):fail("Server disconnected"+msg)}));ws.on("error",(function(){Util.Warn("WebSocket on-error event")}));init_vars();if(Websock_native){Util.Info("Using native WebSockets");updateState("loaded","noVNC ready: native WebSockets, "+rmode)}return that}()}
/*!
* Websock: high-performance binary WebSockets
* Copyright (C) 2012 Joel Martin
* Licensed under MPL 2.0 (see https://github.com/novnc/noVNC/blob/master/LICENSE.txt)
*/
window.Websock_native=!0;window.MozWebSocket&&(window.WebSocket=window.MozWebSocket);function Websock(){var api={},websocket=null,mode="base64",rQ=[],rQi=0,sQ=[],eventHandlers={message:function(){},open:function(){},close:function(){},error:function(){}},test_mode=!1;function get_sQ(){return sQ}function get_rQ(){return rQ}function get_rQi(){return rQi}function set_rQi(val){rQi=val}function rQlen(){return rQ.length-rQi}function rQpeek8(){return rQ[rQi]}function rQshift8(){return rQ[rQi++]}function rQunshift8(num){0===rQi?rQ.unshift(num):rQ[rQi-=1]=num}function rQshift16(){return(rQ[rQi++]<<8)+rQ[rQi++]}function rQshift32(){return(rQ[rQi++]<<24)+(rQ[rQi++]<<16)+(rQ[rQi++]<<8)+rQ[rQi++]}function rQshiftStr(len){void 0===len&&(len=rQlen());var arr=rQ.slice(rQi,rQi+len);rQi+=len;return String.fromCharCode.apply(null,arr)}function rQshiftBytes(len){void 0===len&&(len=rQlen());rQi+=len;return rQ.slice(rQi-len,rQi)}function rQslice(start,end){return end?rQ.slice(rQi+start,rQi+end):rQ.slice(rQi+start)}function rQwait(msg,num,goback){if(rQ.length-rQi<num){if(goback){if(rQi<goback)throw"rQwait cannot backup "+goback+" bytes";rQi-=goback}return!0}return!1}function flush(){websocket.bufferedAmount;if(websocket.bufferedAmount<api.maxBufferedAmount){if(sQ.length>0){websocket.send("binary"===mode?new Uint8Array(sQ).buffer:Base64.encode(sQ));sQ=[]}return!0}Util.Info("Delaying send, bufferedAmount: "+websocket.bufferedAmount);return!1}function send(arr){sQ=sQ.concat(arr);return flush()}function send_string(str){api.send(str.split("").map((function(chr){return chr.charCodeAt(0)})))}function recv_message(e){try{(function(data){if("binary"===mode)for(var u8=new Uint8Array(data),i=0;i<u8.length;i++)rQ.push(u8[i]);else rQ=rQ.concat(Base64.decode(data,0))})(e.data);if(rQlen()>0){eventHandlers.message();if(rQ.length>1e4){rQ=rQ.slice(rQi);rQi=0}}}catch(exc){void 0!==exc.stack?Util.Warn("recv_message, caught exception: "+exc.stack):void 0!==exc.description?Util.Warn("recv_message, caught exception: "+exc.description):Util.Warn("recv_message, caught exception:"+exc);void 0!==exc.name?eventHandlers.error(exc.name+": "+exc.message):eventHandlers.error(exc)}}function on(evt,handler){eventHandlers[evt]=handler}function init(protocols){rQ=[];rQi=0;sQ=[];websocket=null;"Uint8Array"in window&&Uint8Array.prototype;void 0===protocols&&(protocols=["binary","base64"]);return protocols}function open(uri,protocols){protocols=init(protocols);if(test_mode)websocket={};else{websocket=new WebSocket(uri,protocols);protocols.indexOf("binary")>=0&&(websocket.binaryType="arraybuffer")}websocket.onmessage=recv_message;websocket.onopen=function(){if(websocket.protocol){mode=websocket.protocol;Util.Info("Server chose sub-protocol: "+websocket.protocol)}else{mode="base64";Util.Error("Server select no sub-protocol!: "+websocket.protocol)}eventHandlers.open()};websocket.onclose=function(e){eventHandlers.close(e)};websocket.onerror=function(e){eventHandlers.error(e)}}function close(){if(websocket){if(websocket.readyState===WebSocket.OPEN||websocket.readyState===WebSocket.CONNECTING){Util.Info("Closing WebSocket connection");websocket.close()}websocket.onmessage=function(){}}}function testMode(override_send,data_mode){test_mode=!0;mode=data_mode;api.send=override_send;api.close=function(){};return recv_message}return function(){api.maxBufferedAmount=200;api.get_sQ=get_sQ;api.get_rQ=get_rQ;api.get_rQi=get_rQi;api.set_rQi=set_rQi;api.rQlen=rQlen;api.rQpeek8=rQpeek8;api.rQshift8=rQshift8;api.rQunshift8=rQunshift8;api.rQshift16=rQshift16;api.rQshift32=rQshift32;api.rQshiftStr=rQshiftStr;api.rQshiftBytes=rQshiftBytes;api.rQslice=rQslice;api.rQwait=rQwait;api.flush=flush;api.send=send;api.send_string=send_string;api.on=on;api.init=init;api.open=open;api.close=close;api.testMode=testMode;return api}()}var $D,WebUtil={};window.$D||(window.$D=function(id){return document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers?document.layers[id]:void 0});WebUtil.init_logging=function(level){Util._log_level=void 0!==level?level:(document.location.href.match(/logging=([A-Za-z0-9\._\-]*)/)||["",Util._log_level])[1];Util.init_logging()};
/*!
* Custom code for y2k.land, licensed under MIT:
* https://github.com/jakejarvis/y2k
*/
(function(){var e=document.getElementById("status"),t=document.getElementById("display"),n=Math.floor(20*Math.random());window.WebSocket?(new RFB({target:t,encrypt:!0}).connect("sandbox.y2k.land",443),document.body.style.backgroundImage="url('tiles/tile_"+n+".png')",e.innerHTML="Spinning up your very own personal computer, please wait!",setTimeout(function(){e.innerHTML='Oh dear, it looks like something went very wrong. :(<br><br><a href="https://status.jrvs.io/785127956" target="_blank" rel="noopener">Click here</a> to check the server status, or try again in a bit.'},2e4)):e.innerHTML="WebSockets must be enabled to enter Y2K Land!!!<br><br>Press the Any key to continue."})();