igv-rails 0.0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +135 -0
- data/Rakefile +2 -0
- data/igv-rails.gemspec +24 -0
- data/lib/igv/rails/version.rb +5 -0
- data/lib/igv/rails.rb +8 -0
- data/vendor/assets/javascripts/igv-all.js +25784 -0
- data/vendor/assets/javascripts/igv-all.min.js +19 -0
- data/vendor/assets/javascripts/igv-all.min.map +1 -0
- data/vendor/assets/stylesheets/igv.css +1151 -0
- metadata +99 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
function testOauth(){var url="https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/genomics&state=%2Fprofile&redirect_uri=http%3A%2F%2Flocalhost%2Figv-web%2FemptyPage.html&response_type=token&client_id=661332306814-8nt29308rppg325bkq372vli8nm3na14.apps.googleusercontent.com";$.ajax(url,{success:function(data,status,xhr){console.log(status)},error:function(xhr,options,e){xhr.statusCode();console.log(xhr.getResponseHeader("location"))},complete:function(xhr,status){console.log(status)}})}function ZStream(){}function Inflate(){this.was=[0]}function InfBlocks(z,checkfn,w){this.hufts=new Int32Array(3*MANY),this.window=new Uint8Array(w),this.end=w,this.checkfn=checkfn,this.mode=IB_TYPE,this.reset(z,null),this.left=0,this.table=0,this.index=0,this.blens=null,this.bb=new Int32Array(1),this.tb=new Int32Array(1),this.codes=new InfCodes,this.last=0,this.bitk=0,this.bitb=0,this.read=0,this.write=0,this.check=0,this.inftree=new InfTree}function InfCodes(){}function InfTree(){}function inflate_trees_fixed(bl,bd,tl,td,z){return bl[0]=fixed_bl,bd[0]=fixed_bd,tl[0]=fixed_tl,td[0]=fixed_td,Z_OK}function arrayCopy(src,srcOffset,dest,destOffset,count){if(0!=count){if(!src)throw"Undef src";if(!dest)throw"Undef dest";0==srcOffset&&count==src.length?arrayCopy_fast(src,dest,destOffset):hasSubarray?arrayCopy_fast(src.subarray(srcOffset,srcOffset+count),dest,destOffset):1==src.BYTES_PER_ELEMENT&&count>100?arrayCopy_fast(new Uint8Array(src.buffer,src.byteOffset+srcOffset,count),dest,destOffset):arrayCopy_slow(src,srcOffset,dest,destOffset,count)}}function arrayCopy_slow(src,srcOffset,dest,destOffset,count){for(var i=0;count>i;++i)dest[destOffset+i]=src[srcOffset+i]}function arrayCopy_fast(src,dest,destOffset){dest.set(src,destOffset)}function adler32(adler,buf,index,len){if(null==buf)return 1;for(var k,s1=65535&adler,s2=adler>>16&65535;len>0;){for(k=ADLER_NMAX>len?len:ADLER_NMAX,len-=k;k>=16;)s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,s1+=255&buf[index++],s2+=s1,k-=16;if(0!=k)do s1+=255&buf[index++],s2+=s1;while(0!=--k);s1%=ADLER_BASE,s2%=ADLER_BASE}return s2<<16|s1}function jszlib_inflate_buffer(buffer,start,length,afterUncOffset){buffer=start?new Uint8Array(buffer,start,length):new Uint8Array(buffer);var z=new ZStream;z.inflateInit(DEF_WBITS,!0),z.next_in=buffer,z.next_in_index=0,z.avail_in=buffer.length;for(var oBlockList=[],totalSize=0;;){var obuf=new Uint8Array(32e3);z.next_out=obuf,z.next_out_index=0,z.avail_out=obuf.length;var status=z.inflate(Z_NO_FLUSH);if(status!=Z_OK&&status!=Z_STREAM_END)throw z.msg;if(0!=z.avail_out){var newob=new Uint8Array(obuf.length-z.avail_out);arrayCopy(obuf,0,newob,0,obuf.length-z.avail_out),obuf=newob}if(oBlockList.push(obuf),totalSize+=obuf.length,status==Z_STREAM_END)break}if(afterUncOffset&&(afterUncOffset[0]=(start||0)+z.next_in_index),1==oBlockList.length)return oBlockList[0].buffer;for(var out=new Uint8Array(totalSize),cursor=0,i=0;i<oBlockList.length;++i){var b=oBlockList[i];arrayCopy(b,0,out,cursor,b.length),cursor+=b.length}return out.buffer}var igv=function(igv){var READ_PAIRED_FLAG=1,PROPER_PAIR_FLAG=2,READ_UNMAPPED_FLAG=4,MATE_UNMAPPED_FLAG=8,READ_STRAND_FLAG=16,MATE_STRAND_FLAG=32,FIRST_OF_PAIR_FLAG=64,SECOND_OF_PAIR_FLAG=128,NOT_PRIMARY_ALIGNMENT_FLAG=256,READ_FAILS_VENDOR_QUALITY_CHECK_FLAG=512,DUPLICATE_READ_FLAG=1024,SUPPLEMENTARY_ALIGNMENT_FLAG=2048;return igv.BamAlignment=function(){this.hidden=!1},igv.BamAlignment.prototype.isMapped=function(){return 0==(this.flags&READ_UNMAPPED_FLAG)},igv.BamAlignment.prototype.isPaired=function(){return 0!=(this.flags&READ_PAIRED_FLAG)},igv.BamAlignment.prototype.isProperPair=function(){return 0!=(this.flags&PROPER_PAIR_FLAG)},igv.BamAlignment.prototype.isFistOfPair=function(){return 0!=(this.flags&FIRST_OF_PAIR_FLAG)},igv.BamAlignment.prototype.isSecondOfPair=function(){return 0!=(this.flags&SECOND_OF_PAIR_FLAG)},igv.BamAlignment.prototype.isNotPrimary=function(){return 0!=(this.flags&NOT_PRIMARY_ALIGNMENT_FLAG)},igv.BamAlignment.prototype.isSupplementary=function(){return 0!=(this.flags&SUPPLEMENTARY_ALIGNMENT_FLAG)},igv.BamAlignment.prototype.isFailsVendorQualityCheck=function(){return 0!=(this.flags&READ_FAILS_VENDOR_QUALITY_CHECK_FLAG)},igv.BamAlignment.prototype.isDuplicate=function(){return 0!=(this.flags&DUPLICATE_READ_FLAG)},igv.BamAlignment.prototype.isMateMapped=function(){return 0==(this.flags&MATE_UNMAPPED_FLAG)},igv.BamAlignment.prototype.isNegativeStrand=function(){return 0!=(this.flags&READ_STRAND_FLAG)},igv.BamAlignment.prototype.isMateNegativeStrand=function(){return 0!=(this.flags&MATE_STRAND_FLAG)},igv.BamAlignment.prototype.tags=function(){function decodeTags(ba){for(var p=0,len=ba.length,tags={};len>p;){var value,tag=String.fromCharCode(ba[p])+String.fromCharCode(ba[p+1]),type=String.fromCharCode(ba[p+2]);if("A"==type)value=String.fromCharCode(ba[p+3]),p+=4;else if("i"==type||"I"==type)value=readInt(ba,p+3),p+=7;else if("c"==type||"C"==type)value=ba[p+3],p+=4;else if("s"==type||"S"==type)value=readShort(ba,p+3),p+=5;else{if("f"==type)throw"FIXME need floats";if("Z"==type)for(p+=3,value="";;){var cc=ba[p++];if(0==cc)break;value+=String.fromCharCode(cc)}}tags[tag]=value}return tags}this.tagDict||(this.tagBA?(this.tagDict=decodeTags(this.tagBA),this.tagBA=void 0):this.tagDict={})},igv.BamAlignment.prototype.popupData=function(genomicLocation){function yesNo(bool){return bool?"Yes":"No"}var isFirst;nameValues=[],nameValues.push({name:"Read Name",value:this.readName}),nameValues.push("<hr>"),nameValues.push({name:"Alignment Start",value:igv.numberFormatter(1+this.start),borderTop:!0}),nameValues.push({name:"Read Strand",value:!0===this.strand?"(+)":"(-)",borderTop:!0}),nameValues.push({name:"Cigar",value:this.cigar}),nameValues.push({name:"Mapped",value:yesNo(this.isMapped())}),nameValues.push({name:"Mapping Quality",value:this.mq}),nameValues.push({name:"Secondary",value:yesNo(this.isNotPrimary())}),nameValues.push({name:"Supplementary",value:yesNo(this.isSupplementary())}),nameValues.push({name:"Duplicate",value:yesNo(this.isDuplicate())}),nameValues.push({name:"Failed QC",value:yesNo(this.isFailsVendorQualityCheck())}),this.isPaired()&&(nameValues.push("<hr>"),nameValues.push({name:"First in Pair",value:!this.isSecondOfPair(),borderTop:!0}),nameValues.push({name:"Mate is Mapped",value:yesNo(this.isMateMapped())}),this.isMapped()&&(nameValues.push({name:"Mate Start",value:this.matePos}),nameValues.push({name:"Mate Strand",value:this.isMateNegativeStrand()?"(-)":"(+)"}),nameValues.push({name:"Insert Size",value:this.fragmentLength}))),nameValues.push("<hr>"),this.tags(),isFirst=!0;for(var key in this.tagDict)this.tagDict.hasOwnProperty(key)&&(isFirst?(nameValues.push({name:key,value:this.tagDict[key],borderTop:!0}),isFirst=!1):nameValues.push({name:key,value:this.tagDict[key]}));return nameValues},igv}(igv||{}),igv=function(igv){return igv.BamAlignmentRow=function(){this.alignments=[],this.score=void 0},igv.BamAlignmentRow.prototype.findCenterAlignment=function(bpStart,bpEnd){var centerAlignment=void 0;return this.alignments.forEach(function(a){void 0===centerAlignment&&(a.start+a.lengthOnRef<bpStart||a.start>bpEnd||(centerAlignment=a))}),centerAlignment},igv.BamAlignmentRow.prototype.updateScore=function(genomicLocation,genomicInterval,sortOption){this.score=this.caculateScore(genomicLocation,1+genomicLocation,genomicInterval,sortOption)},igv.BamAlignmentRow.prototype.caculateScore=function(bpStart,bpEnd,genomicInterval,sortOption){var baseScore,alignment;return alignment=this.findCenterAlignment(bpStart,bpEnd),void 0===alignment?Number.MAX_VALUE:"NUCLEOTIDE"===sortOption.sort?(baseScore=void 0,alignment.blocks.forEach(function(block){var reference,base,coverage,count,phred,sequence=genomicInterval.sequence,coverageMap=genomicInterval.coverageMap;if("*"!==block.seq)for(var i=0,indexReferenceSequence=block.start-genomicInterval.start,bpBlockSequence=block.start,lengthBlockSequence=block.seq.length;lengthBlockSequence>i;i++,indexReferenceSequence++,bpBlockSequence++)bpStart===bpBlockSequence&&(reference=sequence.charAt(indexReferenceSequence),base=block.seq.charAt(i),"="===base&&(base=reference),"N"===base?baseScore=2:base===reference?baseScore=3:"X"===base||base!==reference?(coverage=coverageMap.coverage[bpBlockSequence-coverageMap.bpStart],count=coverage["pos"+base]+coverage["neg"+base],phred=coverage.qual?coverage.qual:0,baseScore=-(count+phred/1e3)):console.log("BamAlignmentRow.caculateScore - huh?"));else baseScore=3}),void 0===baseScore?Number.MAX_VALUE:baseScore):"STRAND"===sortOption.sort?alignment.strand?1:-1:"START"===sortOption.sort?alignment.start:Number.MAX_VALUE},igv}(igv||{}),igv=function(igv){function reg2bins(beg,end){var k,list=[];for(end>=1<<29&&(end=1<<29),--end,list.push(0),k=1+(beg>>26);1+(end>>26)>=k;++k)list.push(k);for(k=9+(beg>>23);9+(end>>23)>=k;++k)list.push(k);for(k=73+(beg>>20);73+(end>>20)>=k;++k)list.push(k);for(k=585+(beg>>17);585+(end>>17)>=k;++k)list.push(k);for(k=4681+(beg>>14);4681+(end>>14)>=k;++k)list.push(k);return list}const BAI_MAGIC=21578050,TABIX_MAGIC=21578324;return igv.loadBamIndex=function(indexURL,config,continuation,tabix){var genome=igv.browser?igv.browser.genome:null;igvxhr.loadArrayBuffer(indexURL,{headers:config.headers,success:function(arrayBuffer){var magic,nbin,nintv,nref,parser,binIndex,linearIndex,binNumber,cs,ce,b,i,ref,sequenceIndexMap,indices=[],blockMin=Number.MAX_VALUE,blockMax=0;if(!arrayBuffer)return void continuation(null);if(tabix){var inflate=new Zlib.Gunzip(new Uint8Array(arrayBuffer));arrayBuffer=inflate.decompress().buffer}if(parser=new igv.BinaryParser(new DataView(arrayBuffer)),magic=parser.getInt(),!(magic===BAI_MAGIC||tabix&&magic===TABIX_MAGIC))throw new Error(indexURL+" is not a "+(tabix?"tabix":"bai")+" file");if(nref=parser.getInt(),tabix){{parser.getInt(),parser.getInt(),parser.getInt(),parser.getInt(),parser.getInt(),parser.getInt(),parser.getInt()}for(sequenceIndexMap={},i=0;nref>i;i++){var seq_name=parser.getString();genome&&(seq_name=genome.getChromosomeName(seq_name)),sequenceIndexMap[seq_name]=i}}for(ref=0;nref>ref;++ref){for(binIndex={},linearIndex=[],nbin=parser.getInt(),b=0;nbin>b;++b){binNumber=parser.getInt(),binIndex[binNumber]=[];var nchnk=parser.getInt();for(i=0;nchnk>i;i++)cs=parser.getVPointer(),ce=parser.getVPointer(),cs&&ce&&(cs.block<blockMin&&(blockMin=cs.block),ce.block>blockMax&&(blockMax=ce.block),binIndex[binNumber].push([cs,ce]))}for(nintv=parser.getInt(),i=0;nintv>i;i++)cs=parser.getVPointer(),linearIndex.push(cs);nbin>0&&(indices[ref]={binIndex:binIndex,linearIndex:linearIndex})}continuation(new igv.BamIndex(indices,blockMin,blockMax,sequenceIndexMap,tabix))}})},igv.BamIndex=function(indices,headerSize,blockMax,sequenceIndexMap,tabix){this.headerSize=headerSize,this.indices=indices,this.sequenceIndexMap=sequenceIndexMap,this.tabix=tabix,this.blockMax=blockMax},igv.BamIndex.prototype.blocksForRange=function(refId,min,max){var overlappingBins,leafChunks,otherChunks,nintv,lowest,minLin,lb,prunedOtherChunks,i,chnk,dif,intChunks,mergedChunks,bam=this,ba=bam.indices[refId];if(ba){for(overlappingBins=reg2bins(min,max),leafChunks=[],otherChunks=[],overlappingBins.forEach(function(bin){if(ba.binIndex[bin])for(var chunks=ba.binIndex[bin],nchnk=chunks.length,c=0;nchnk>c;++c){var cs=chunks[c][0],ce=chunks[c][1];(4681>bin?otherChunks:leafChunks).push({minv:cs,maxv:ce,bin:bin})}}),nintv=ba.linearIndex.length,lowest=null,minLin=Math.min(min>>14,nintv-1),maxLin=Math.min(max>>14,nintv-1),i=minLin;i<=maxLin;++i)lb=ba.linearIndex[i],lb&&(!lowest||lb.block<lowest.block||lb.offset<lowest.offset)&&(lowest=lb);if(prunedOtherChunks=[],null!=lowest)for(i=0;i<otherChunks.length;++i)chnk=otherChunks[i],chnk.maxv.block>=lowest.block&&chnk.maxv.offset>=lowest.offset&&prunedOtherChunks.push(chnk);for(intChunks=[],i=0;i<prunedOtherChunks.length;++i)intChunks.push(prunedOtherChunks[i]);for(i=0;i<leafChunks.length;++i)intChunks.push(leafChunks[i]);if(intChunks.sort(function(c0,c1){return dif=c0.minv.block-c1.minv.block,0!=dif?dif:c0.minv.offset-c1.minv.offset}),mergedChunks=[],intChunks.length>0){for(var cur=intChunks[0],i=1;i<intChunks.length;++i){var nc=intChunks[i];nc.minv.block-cur.maxv.block<65e3?cur={minv:cur.minv,maxv:nc.maxv}:(mergedChunks.push(cur),cur=nc)}mergedChunks.push(cur)}return mergedChunks}return null},igv}(igv||{}),igv=function(igv){function getContentLength(bam,continuation){bam.contentLength?continuation(bam.contentLength):igvxhr.getContentLength(bam.headPath,{headers:bam.headers,success:function(contentLength){bam.contentLength=contentLength,continuation(bam.contentLength)},error:function(unused,xhr){bam.contentLength=-1,continuation(bam.contentLength)}})}function getIndex(bam,continuation){bam.index;bam.index?continuation(bam.index):igv.loadBamIndex(bam.baiPath,bam.config,function(index){bam.index=index,bam.contentLength=index.blockMax,continuation(bam.index)})}function getChrIndex(bam,continuation){bam.chrToIndex?continuation(bam.chrToIndex):bam.readHeader(function(){continuation(bam.chrToIndex)})}function readInt(ba,offset){return ba[offset+3]<<24|ba[offset+2]<<16|ba[offset+1]<<8|ba[offset]}var SECRET_DECODER=["=","A","C","x","G","x","x","x","T","x","x","x","x","x","x","N"],CIGAR_DECODER=["M","I","D","N","S","H","P","=","X","?","?","?","?","?","?","?"],READ_STRAND_FLAG=16;const MAX_GZIP_BLOCK_SIZE=65536;return igv.BamReader=function(config){this.config=config,this.bamPath=config.url,this.baiPath=config.indexURL||this.bamPath+".bai",this.headPath=config.headURL||this.bamPath},igv.BamReader.prototype.readFeatures=function(chr,min,max,continuation,task){function decodeBamRecords(ba,offset,alignments,min,max,chrId){for(var blockSize,blockEnd,alignment,refID,pos,bmn,bin,mq,nl,flag_nc,flag,nc,lseq,mateRefID,matePos,readName,j,p,lengthOnRef,cigar,c,cigarArray,seq,seqBytes;;){if(blockSize=readInt(ba,offset),blockEnd=offset+blockSize+4,blockEnd>=ba.length)return;if(alignment=new igv.BamAlignment,refID=readInt(ba,offset+4),pos=readInt(ba,offset+8),refID>chrId||pos>max)return;if(!(chrId>refID)){for(bmn=readInt(ba,offset+12),bin=(4294901760&bmn)>>16,mq=(65280&bmn)>>8,nl=255&bmn,flag_nc=readInt(ba,offset+16),flag=(4294901760&flag_nc)>>16,nc=65535&flag_nc,alignment.flags=flag,alignment.strand=!(flag&READ_STRAND_FLAG),lseq=readInt(ba,offset+20),mateRefID=readInt(ba,offset+24),matePos=readInt(ba,offset+28),alignment.fragmentLength=readInt(ba,offset+32),readName="",j=0;nl-1>j;++j)readName+=String.fromCharCode(ba[offset+36+j]);for(p=offset+36+nl,lengthOnRef=0,cigar="",cigarArray=[],c=0;nc>c;++c){var cigop=readInt(ba,p),opLen=cigop>>4,opLtr=CIGAR_DECODER[15&cigop];("M"==opLtr||"EQ"==opLtr||"X"==opLtr||"D"==opLtr||"N"==opLtr||"="==opLtr)&&(lengthOnRef+=opLen),cigar=cigar+opLen+opLtr,p+=4,cigarArray.push({len:opLen,ltr:opLtr})}if(alignment.cigar=cigar,alignment.lengthOnRef=lengthOnRef,!(alignment.start+alignment.lengthOnRef<min)){for(seq="",seqBytes=lseq+1>>1,j=0;seqBytes>j;++j){var sb=ba[p+j];seq+=SECRET_DECODER[(240&sb)>>4],seq+=SECRET_DECODER[15&sb]}if(seq=seq.substring(0,lseq),p+=seqBytes,alignment.seq=seq,1===lseq&&"*"===String.fromCharCode(ba[p+j]+33));else for(alignment.qual=[],j=0;lseq>j;++j)alignment.qual.push(ba[p+j]);p+=lseq,alignment.start=pos,alignment.mq=mq,alignment.readName=readName,alignment.chr=bam.indexToChr[refID],mateRefID>=0&&(alignment.mate={chr:bam.indexToChr[mateRefID],position:matePos}),alignment.tagBA=new Uint8Array(ba.buffer.slice(p,blockEnd)),p+=blockEnd,(!min||alignment.start<=max&&alignment.start+alignment.lengthOnRef>=min)&&(void 0===chrId||refID==chrId)&&(alignment.blocks=makeBlocks(alignment,cigarArray),alignments.push(alignment)),offset=blockEnd}}}}function makeBlocks(record,cigarArray){for(var blockSeq,blockQuals,blocks=[],seqOffset=0,pos=record.start,len=cigarArray.length,i=0;len>i;i++){var c=cigarArray[i];switch(c.ltr){case"H":break;case"P":break;case"S":seqOffset+=c.len;break;case"N":pos+=c.len;break;case"D":pos+=c.len;break;case"I":seqOffset+=c.len;break;case"M":case"EQ":case"=":case"X":blockSeq="*"===record.seq?"*":record.seq.substr(seqOffset,c.len),blockQuals=record.qual?record.qual.slice(seqOffset,c.len):void 0,blocks.push({start:pos,len:c.len,seq:blockSeq,qual:blockQuals}),seqOffset+=c.len,pos+=c.len;break;default:console.log("Error processing cigar element: "+c.len+c.ltr)}}return blocks}var bam=this;getChrIndex(this,function(chrToIndex){var chunks,chrId=chrToIndex[chr];void 0===chrId?continuation([]):getIndex(bam,function(bamIndex){function loadNextChunk(chunkNumber){var c=chunks[chunkNumber],fetchMin=c.minv.block,fetchMax=c.maxv.block+65e3,range=bam.contentLength>0&&fetchMax>bam.contentLength?{start:fetchMin}:{start:fetchMin,size:fetchMax-fetchMin+1};igvxhr.loadArrayBuffer(bam.bamPath,{task:task,headers:bam.config.headers,range:range,success:function(compressed){try{var ba=new Uint8Array(igv.unbgzf(compressed))}catch(e){console.log(e),continuation(records)}decodeBamRecords(ba,chunks[chunkNumber].minv.offset,records,min,max,chrId),chunkNumber++,chunkNumber>=chunks.length?(chunkNumber>0&&records.length>1&&records.sort(function(a,b){return a.start-b.start}),continuation(records)):loadNextChunk(chunkNumber)}})}if(chunks=bamIndex.blocksForRange(chrId,min,max),!chunks)return void continuation(null,"Error in index fetch");if(0===chunks.length)return console.log("No chunks for range "+chrId+":"+min+"-"+max),void continuation([]);var records=[];loadNextChunk(0)})})},igv.BamReader.prototype.readHeader=function(continuation){var bam=this;getContentLength(bam,function(contentLength){getIndex(bam,function(index){var contentLength=index.blockMax,len=index.headerSize+MAX_GZIP_BLOCK_SIZE+100;0>=contentLength&&(contentLength=index.blockMax),bam.contentLength=contentLength,contentLength>0&&(len=Math.min(contentLength,len)),igvxhr.loadArrayBuffer(bam.bamPath,{headers:bam.config.headers,range:{start:0,size:len},success:function(compressedBuffer){for(var unc=igv.unbgzf(compressedBuffer,len),uncba=new Uint8Array(unc),samHeaderLen=(readInt(uncba,0),readInt(uncba,4)),samHeader="",genome=igv.browser?igv.browser.genome:null,i=0;samHeaderLen>i;++i)samHeader+=String.fromCharCode(uncba[i+8]);var nRef=readInt(uncba,samHeaderLen+8),p=samHeaderLen+12;bam.chrToIndex={},bam.indexToChr=[];for(var i=0;nRef>i;++i){for(var lName=readInt(uncba,p),name="",j=0;lName-1>j;++j)name+=String.fromCharCode(uncba[p+4+j]);{readInt(uncba,p+lName+4)}genome&&genome.getChromosomeName&&(name=genome.getChromosomeName(name)),bam.chrToIndex[name]=i,bam.indexToChr.push(name),p=p+8+lName}continuation()}})})})},igv}(igv||{}),igv=function(igv){function packAlignmentRows(genomicInterval,alignments){if(0===alignments.length)return[];var alignmentRow,index,bucket,alignment,bucketList=[],allocatedCount=0,nextStart=genomicInterval.start,alignmentSpace=8,packedAlignmentRows=[],bucketStart=alignments[0].start;for(alignments.forEach(function(alignment){var buckListIndex=alignment.start-bucketStart;void 0===bucketList[buckListIndex]&&(bucketList[buckListIndex]=[]),bucketList[buckListIndex].push(alignment)});allocatedCount<alignments.length;){for(alignmentRow=new igv.BamAlignmentRow;nextStart<=genomicInterval.end;){for(bucket=void 0;!bucket&&nextStart<=genomicInterval.end;)index=nextStart-bucketStart,void 0===bucketList[index]?++nextStart:bucket=bucketList[index];if(!bucket)break;alignment=bucket.pop(),0===bucket.length&&(bucketList[index]=void 0),alignmentRow.alignments.push(alignment),nextStart=alignment.start+alignment.lengthOnRef+alignmentSpace,++allocatedCount}alignmentRow.alignments.length>0&&packedAlignmentRows.push(alignmentRow),nextStart=bucketStart}return packedAlignmentRows}return igv.BamSource=function(config){this.config=config,this.bamReader="ga4gh"===config.sourceType?new igv.Ga4ghAlignmentReader(config):new igv.BamReader(config)},igv.BamSource.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){if(this.genomicInterval&&this.genomicInterval.contains(chr,bpStart,bpEnd))continuation(this.genomicInterval);else{var myself=this;this.bamReader.readFeatures(chr,bpStart,bpEnd,function(alignments){alignments&&(myself.genomicInterval=new igv.GenomicInterval(chr,bpStart,bpEnd),igv.browser.genome.sequence.getSequence(myself.genomicInterval.chr,myself.genomicInterval.start,myself.genomicInterval.end,function(sequence){sequence&&(myself.genomicInterval.coverageMap=new igv.CoverageMap(chr,bpStart,bpEnd,alignments,sequence),myself.genomicInterval.packedAlignmentRows=packAlignmentRows(myself.genomicInterval,alignments),myself.genomicInterval.features=void 0,myself.genomicInterval.sequence=sequence,continuation(myself.genomicInterval))},task))},task)}},igv}(igv||{}),igv=function(igv){function doSortAlignmentRows(genomicLocation,genomicInterval,sortOption){var alignmentRows=genomicInterval.packedAlignmentRows,sequence=genomicInterval.sequence;return sequence?(sequence=sequence.toUpperCase(),alignmentRows.forEach(function(alignmentRow){alignmentRow.updateScore(genomicLocation,genomicInterval,sortOption)}),void alignmentRows.sort(function(a,b){return a.score-b.score})):void console.log("No sequence, no traversal. No discussion!")}function shadedBaseColor(qual,nucleotide,genomicLocation){var color,alpha,minQ=5,maxQ=20,foregroundColor=igv.nucleotideColorComponents[nucleotide];if(foregroundColor)return alpha=minQ>qual?.1:Math.max(.1,Math.min(1,.1+.9*(qual-minQ)/(maxQ-minQ))),alpha=Math.round(10*alpha)/10,color=alpha>=1?igv.nucleotideColors[nucleotide]:"rgba("+foregroundColor[0]+","+foregroundColor[1]+","+foregroundColor[2]+","+alpha+")"}return igv.BAMTrack=function(config){igv.configTrack(this,config),this.visibilityWindow=config.visibilityWindow||3e4,this.alignmentRowHeight=config.alignmentRowHeight||14,this.coverageTrackHeight=config.coverageTrackHeight||50,this.alignmentColor=config.alignmentColor||"rgb(185, 185, 185)",this.negStrandColor=config.negStrandColor||"rgba(150, 150, 230, 0.75)",this.posStrandColor=config.posStrandColor||"rgba(230, 150, 150, 0.75)",this.firstInfPairColor="rgba(150, 150, 230, 0.75)",this.secondInPairColor="rgba(230, 150, 150, 0.75)",this.deletionColor=config.deletionColor||"black",this.skippedColor=config.skippedColor||"rgb(150, 170, 170)",this.coverageColor=config.coverageColor||this.alignmentColor,this.maxHeight=config.maxHeight||500,this.alignmentRowYInset=1,this.alignmentShading="none",this.sortOption=config.sortOption||{sort:"NUCLEOTIDE"},this.filterOption=config.filterOption||{name:"mappingQuality",params:[30,void 0]},this.featureSource=new igv.BamSource(config)},igv.BAMTrack.alignmentShadingOptions={none:function(bamTrack,alignment){return bamTrack.alignmentColor},strand:function(bamTrack,alignment){return alignment.strand?bamTrack.posStrandColor:bamTrack.negStrandColor},firstOfPairStrand:function(bamTrack,alignment){return alignment.isPaired()?alignment.isFistOfPair()?alignment.strand?bamTrack.posStrandColor:bamTrack.negStrandColor:alignment.isSecondOfPair()?alignment.strand?bamTrack.negStrandColor:bamTrack.posStrandColor:void console.log("ERROR. Paired alignments are either first or second."):bamTrack.alignmentColor}},igv.BAMTrack.counter=1,igv.BAMTrack.filters={noop:function(){return function(alignment){return!1}},strand:function(strand){return function(alignment){return alignment.strand===strand}},mappingQuality:function(lower,upper){return function(alignment){return lower&&alignment.mq<lower?!0:upper&&alignment.mq>upper?!0:!1}}},igv.BAMTrack.selectFilter=function(bamTrack,filterOption){var a,b;return"mappingQuality"===filterOption.name?(a=bamTrack.filterOption.params[0],b=bamTrack.filterOption.params[1],igv.BAMTrack.filters[filterOption.name](a,b)):"strand"===filterOption.name?(a=bamTrack.filterOption.params[0],igv.BAMTrack.filters[filterOption.name](a)):"noop"===filterOption.name?igv.BAMTrack.filters[filterOption.name]():void 0},igv.BAMTrack.prototype.filterAlignments=function(filterOption,callback){var pixelWidth,bpWidth,bpStart,bpEnd,filter;filter=igv.BAMTrack.selectFilter(this,filterOption),pixelWidth=3*this.trackView.canvas.width,bpWidth=Math.round(igv.browser.referenceFrame.toBP(pixelWidth)),bpStart=Math.max(0,Math.round(igv.browser.referenceFrame.start-bpWidth/3)),bpEnd=bpStart+bpWidth,this.featureSource.getFeatures(igv.browser.referenceFrame.chr,bpStart,bpEnd,function(genomicInterval){genomicInterval.packedAlignmentRows.forEach(function(alignmentRow){alignmentRow.alignments.forEach(function(alignment){alignment.hidden=filter(alignment)})}),callback()})},igv.BAMTrack.prototype.shiftClick=function(genomicLocation,event){var myself=this;this.filterAlignments(this.filterOption,function(){myself.trackView.update(),$(myself.trackView.viewportDiv).scrollTop(0)})},igv.BAMTrack.prototype.sortAlignmentRows=function(genomicLocation,sortOption){var myself=this;this.featureSource.getFeatures(igv.browser.referenceFrame.chr,genomicLocation,1+genomicLocation,function(genomicInterval){doSortAlignmentRows(genomicLocation,genomicInterval,sortOption),myself.trackView.update(),$(myself.trackView.viewportDiv).scrollTop(0)})},igv.BAMTrack.prototype.altClick=function(genomicLocation,event){this.sortAlignmentRows(genomicLocation,this.sortOption)},igv.BAMTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){return igv.browser.trackViewportWidthBP()>this.visibilityWindow?void continuation({exceedsVisibilityWindow:!0}):void this.featureSource.getFeatures(chr,bpStart,bpEnd,continuation,task)},igv.BAMTrack.prototype.draw=function(options){function drawCoverage(coverageMap){var bp,x,y,w,h,refBase,i,len,item,accumulatedHeight,sequence;if(coverageMap.refSeq&&(sequence=coverageMap.refSeq.toUpperCase()),coverageMap)for(w=Math.max(1,1/bpPerPixel),i=0,len=coverageMap.coverage.length;len>i;i++)if(bp=coverageMap.bpStart+i,!(bpStart>bp)){if(bp>bpEnd)break;item=coverageMap.coverage[i],item&&(h=item.total/coverageMap.maximum*myself.coverageTrackHeight,y=myself.coverageTrackHeight-h,x=(bp-bpStart)/bpPerPixel,igv.Canvas.setProperties.call(ctx,{fillStyle:myself.coverageColor,trokeStyle:myself.coverageColor}),igv.Canvas.fillRect.call(ctx,x,y,w,h),sequence&&(refBase=sequence[i],item.isMismatch(refBase)&&(igv.Canvas.setProperties.call(ctx,{fillStyle:igv.nucleotideColors[refBase]}),igv.Canvas.fillRect.call(ctx,x,y,w,h),accumulatedHeight=0,["A","C","T","G"].forEach(function(nucleotide){var count,hh;count=item["pos"+nucleotide]+item["neg"+nucleotide],hh=count/coverageMap.maximum*myself.coverageTrackHeight,y=myself.coverageTrackHeight-hh-accumulatedHeight,accumulatedHeight+=hh,igv.Canvas.setProperties.call(ctx,{fillStyle:igv.nucleotideColors[nucleotide]}),igv.Canvas.fillRect.call(ctx,x,y,w,hh)}))))}}function drawAlignments(genomicInterval){var packedAlignmentRows=genomicInterval.packedAlignmentRows,sequence=genomicInterval.sequence;sequence&&(sequence=sequence.toUpperCase()),packedAlignmentRows&&packedAlignmentRows.forEach(function(alignmentRow,i){var yStrokedLine,yRect,height,widthArrowHead=myself.alignmentRowHeight/2;yRect=myself.alignmentRowYInset+myself.coverageTrackHeight+myself.alignmentRowHeight*i+5,height=myself.alignmentRowHeight-2*myself.alignmentRowYInset,yStrokedLine=height/2+yRect,alignmentRow.alignments.forEach(function(alignment,indexAlignment){var xStart,xEnd,canvasColor;if(!0!==alignment.hidden&&!(alignment.start+alignment.lengthOnRef<bpStart||alignment.start>bpEnd)){if(xStart=(alignment.start-bpStart)/bpPerPixel,xEnd=(alignment.start+alignment.lengthOnRef-bpStart)/bpPerPixel,canvasColor=igv.BAMTrack.alignmentShadingOptions[myself.alignmentShading](myself,alignment),alignment.blocks.length>0)for(var c=0;c<alignment.cigar.length;c++){if("D"===alignment.cigar.charAt(c)){igv.Canvas.strokeLine.call(ctx,xStart,yStrokedLine,xEnd,yStrokedLine,{strokeStyle:deletionColor});break}if("N"===alignment.cigar.charAt(c)){igv.Canvas.strokeLine.call(ctx,xStart,yStrokedLine,xEnd,yStrokedLine,{strokeStyle:skippedColor});break}}igv.Canvas.setProperties.call(ctx,{fillStyle:canvasColor,strokeStyle:canvasColor}),alignment.blocks.forEach(function(block,indexBlocks){var refChar,readChar,readQual,xBase,widthBase,colorBase,x,y,refOffset=block.start-bpStart,seqOffset=block.start-genomicInterval.start,xBlockStart=refOffset/bpPerPixel,xBlockEnd=(block.start+block.len-bpStart)/bpPerPixel,widthBlock=Math.max(1,xBlockEnd-xBlockStart),blockSeq=block.seq.toUpperCase();if(!0===alignment.strand&&indexBlocks===alignment.blocks.length-1?(x=[xEnd,xEnd+widthArrowHead,xEnd,xEnd],y=[yRect,yRect+height/2,yRect+height,yRect],igv.Canvas.fillPolygon.call(ctx,x,y,{fillStyle:canvasColor})):!1===alignment.strand&&0===indexBlocks&&(x=[xBlockStart,xBlockStart-widthArrowHead,xBlockStart,xBlockStart],y=[yRect,yRect+height/2,yRect+height,yRect],igv.Canvas.fillPolygon.call(ctx,x,y,{fillStyle:canvasColor})),igv.Canvas.fillRect.call(ctx,xBlockStart,yRect,widthBlock,height,{fillStyle:"white"}),igv.Canvas.fillRect.call(ctx,xBlockStart,yRect,widthBlock,height,{fillStyle:canvasColor}),sequence&&"*"!==blockSeq)for(var i=0,len=blockSeq.length;len>i;i++)readChar=blockSeq.charAt(i),refChar=sequence.charAt(seqOffset+i),"="===readChar&&(readChar=refChar),("X"===readChar||refChar!==readChar)&&(block.qual&&block.qual.length>i?(readQual=block.qual[i],colorBase=shadedBaseColor(readQual,readChar,i+block.start)):colorBase=igv.nucleotideColors[readChar],colorBase&&(xBase=(block.start+i-bpStart)/bpPerPixel,widthBase=Math.max(1,1/bpPerPixel),igv.Canvas.fillRect.call(ctx,xBase,yRect,widthBase,height,{fillStyle:colorBase})))})}})})}var genomicInterval=options.features,ctx=options.context,bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,pixelWidth=options.pixelWidth,skippedColor=(options.pixelHeight,this.skippedColor),deletionColor=this.deletionColor,bpEnd=bpStart+pixelWidth*bpPerPixel+1,myself=this,zoomInNoticeFontStyle={font:"16px PT Sans",fillStyle:"rgba(64, 64, 64, 1)",strokeStyle:"rgba(64, 64, 64, 1)"};if(genomicInterval.exceedsVisibilityWindow)for(var x=200;pixelWidth>x;x+=400)igv.Canvas.fillText.call(ctx,"Zoom in to see alignments",x,20,zoomInNoticeFontStyle);else genomicInterval&&(drawCoverage(genomicInterval.coverageMap),drawAlignments(genomicInterval))},igv.BAMTrack.prototype.popupData=function(genomicLocation,xOffset,yOffset){var coverageMapIndex,coverage,packedAlignmentsIndex,alignmentRow,alignment,coverageMap=this.featureSource.genomicInterval.coverageMap,packedAlignmentRows=this.featureSource.genomicInterval.packedAlignmentRows,nameValues=[];if(packedAlignmentsIndex=Math.floor((yOffset-(this.alignmentRowYInset+this.coverageTrackHeight))/this.alignmentRowHeight),0>packedAlignmentsIndex)coverageMapIndex=genomicLocation-coverageMap.bpStart,coverage=coverageMap.coverage[coverageMapIndex],coverage&&(nameValues.push(igv.browser.referenceFrame.chr+":"+igv.numberFormatter(1+genomicLocation)),nameValues.push({name:"Total Count",value:coverage.total}),tmp=coverage.posA+coverage.negA,tmp>0&&(tmp=tmp.toString()+" ("+Math.floor((coverage.posA+coverage.negA)/coverage.total*100)+"%)"),nameValues.push({name:"A",value:tmp}),tmp=coverage.posC+coverage.negC,tmp>0&&(tmp=tmp.toString()+" ("+Math.floor(tmp/coverage.total*100)+"%)"),nameValues.push({name:"C",value:tmp}),tmp=coverage.posG+coverage.negG,tmp>0&&(tmp=tmp.toString()+" ("+Math.floor(tmp/coverage.total*100)+"%)"),nameValues.push({name:"G",value:tmp}),tmp=coverage.posT+coverage.negT,tmp>0&&(tmp=tmp.toString()+" ("+Math.floor(tmp/coverage.total*100)+"%)"),nameValues.push({name:"T",value:tmp}),tmp=coverage.posN+coverage.negN,tmp>0&&(tmp=tmp.toString()+" ("+Math.floor(tmp/coverage.total*100)+"%)"),nameValues.push({name:"N",value:tmp}));else if(packedAlignmentsIndex<packedAlignmentRows.length){alignmentRow=packedAlignmentRows[packedAlignmentsIndex],
|
2
|
+
alignment=void 0;for(var tmp,i=0,len=alignmentRow.alignments.length;len>i;i++)if(tmp=alignmentRow.alignments[i],tmp.start<=genomicLocation&&tmp.start+tmp.lengthOnRef>=genomicLocation){alignment=tmp;break}if(alignment)return alignment.popupData(genomicLocation)}return nameValues},igv.BAMTrack.prototype.popupMenuItems=function(popover){var myself=this,menuItems=[],lut={none:"Color: None",strand:"Color: Read Strand",firstOfPairStrand:"Color: 1st of Pair Strand"},checkMark='<i class="fa fa-check fa-check-shim"></i>',checkMarkNone='<i class="fa fa-check fa-check-shim fa-check-hidden"></i>',trackMenuItem='<div class="igv-track-menu-item">',trackMenuItemFirst='<div class="igv-track-menu-item igv-track-menu-border-top">';return["none","strand","firstOfPairStrand"].forEach(function(alignmentShading,index){var chosen,str;chosen=0===index?trackMenuItemFirst:trackMenuItem,str=alignmentShading===myself.alignmentShading?chosen+checkMark+lut[alignmentShading]+"</div>":chosen+checkMarkNone+lut[alignmentShading]+"</div>",menuItems.push({object:$(str),click:function(){popover.hide(),myself.alignmentShading=alignmentShading,myself.trackView.update()}})}),menuItems},igv.BAMTrack.prototype.computePixelHeight=function(features){return features.packedAlignmentRows?this.alignmentRowYInset+this.coverageTrackHeight+this.alignmentRowHeight*features.packedAlignmentRows.length+5:this.height},igv}(igv||{}),igv=function(igv){return igv.BGZip=function(url,headers){},igv.unbgzf=function(data,lim){var oBlockList=[],ptr=[0],totalSize=0;for(lim=lim||data.byteLength-18;ptr[0]<lim;){var ba=new Uint8Array(data,ptr[0],18),xlen=ba[11]<<8|ba[10],bsize=(ba[12],ba[13],ba[15]<<8|ba[14],ba[17]<<8|ba[16]+1),start=12+xlen+ptr[0],length=data.byteLength-start;if(bsize+8>length)break;var unc=jszlib_inflate_buffer(data,start,length,ptr);ptr[0]+=8,totalSize+=unc.byteLength,oBlockList.push(unc)}if(1==oBlockList.length)return oBlockList[0];for(var out=new Uint8Array(totalSize),cursor=0,i=0;i<oBlockList.length;++i){var b=new Uint8Array(oBlockList[i]);arrayCopy(b,0,out,cursor,b.length),cursor+=b.length}return out.buffer},igv}(igv||{}),igv=function(igv){function Coverage(){this.posA=0,this.negA=0,this.posT=0,this.negT=0,this.posC=0,this.negC=0,this.posG=0,this.negG=0,this.posN=0,this.negN=0,this.pos=0,this.neg=0,this.qualA=0,this.qualT=0,this.qualC=0,this.qualG=0,this.qualN=0,this.qual=0,this.total=0}return igv.CoverageMap=function(chr,start,end,alignments,refSeq){var myself=this;this.refSeq=refSeq,this.chr=chr,this.bpStart=start,this.length=end-start,this.coverage=new Array(this.length),this.maximum=0,alignments.forEach(function(alignment){alignment.blocks.forEach(function(block){var key,base,i,j,q;for(i=block.start-myself.bpStart,j=0;j<block.len;i++,j++)myself.coverage[i]||(myself.coverage[i]=new Coverage),base=block.seq.charAt(j),key=alignment.strand?"pos"+base:"neg"+base,q=block.qual[j],myself.coverage[i][key]+=1,myself.coverage[i]["qual"+base]+=q,myself.coverage[i].total+=1,myself.coverage[i].qual+=q,myself.maximum=Math.max(myself.coverage[i].total,myself.maximum)})})},igv.CoverageMap.threshold=.2,igv.CoverageMap.qualityWeight=!0,Coverage.prototype.isMismatch=function(refBase){var mismatchQualitySum,myself=this,threshold=igv.CoverageMap.threshold*(igv.CoverageMap.qualityWeight&&this.qual?this.qual:this.total);return mismatchQualitySum=0,["A","T","C","G"].forEach(function(base){base!==refBase&&(mismatchQualitySum+=igv.CoverageMap.qualityWeight&&myself.qual?myself["qual"+base]:myself["pos"+base]+myself["neg"+base])}),mismatchQualitySum>=threshold},igv}(igv||{}),igv=function(igv){return igv.BufferedReader=function(config,contentLength,bufferSize){this.path=config.url,this.contentLength=contentLength,this.bufferSize=bufferSize?bufferSize:512e3,this.range={start:-1,size:-1},this.config=config},igv.BufferedReader.prototype.dataViewForRange=function(requestedRange,continutation,asUint8){function subbuffer(bufferedReader,requestedRange,asUint8){var len=bufferedReader.data.byteLength,bufferStart=requestedRange.start-bufferedReader.range.start,result=asUint8?new Uint8Array(bufferedReader.data,bufferStart,len-bufferStart):new DataView(bufferedReader.data,bufferStart,len-bufferStart);continutation(result)}var bufferSize,loadRange,bufferedReader=this,hasData=this.data&&this.range.start<=requestedRange.start&&this.range.start+this.range.size>=requestedRange.start+requestedRange.size;hasData?subbuffer(bufferedReader,requestedRange,asUint8):(bufferSize=Math.max(this.bufferSize,requestedRange.size),loadRange=this.contentLength>0&&requestedRange.start+bufferSize>this.contentLength?{start:requestedRange.start}:{start:requestedRange.start,size:bufferSize},igvxhr.loadArrayBuffer(bufferedReader.path,{headers:this.config.headers,range:loadRange,success:function(arrayBuffer){bufferedReader.data=arrayBuffer,bufferedReader.range=loadRange,subbuffer(bufferedReader,requestedRange,asUint8)}}))},igv}(igv||{}),igv=function(igv){return igv.BPTree=function(binaryParser,treeOffset){function readTreeNode(byteBuffer,offset,keySize,dictionary){offset>=0&&(byteBuffer.position=offset);var i,key,chromId,chromSize,childOffset,bufferOffset,type=byteBuffer.getByte(),count=(byteBuffer.getByte(),byteBuffer.getShort());if(1==type)for(i=0;count>i;i++)key=byteBuffer.getString(keySize),genome&&(key=genome.getChromosomeName(key)),chromId=byteBuffer.getInt(),chromSize=byteBuffer.getInt(),dictionary[key]=chromId;else for(i=0;count>i;i++)childOffset=byteBuffer.nextLong(),bufferOffset=childOffset-self.treeOffset,readTreeNode(byteBuffer,offset,keySize,dictionary)}var genome=igv.browser?igv.browser.genome:null;this.treeOffset=treeOffset,this.header={},this.header.magic=binaryParser.getInt(),this.header.blockSize=binaryParser.getInt(),this.header.keySize=binaryParser.getInt(),this.header.valSize=binaryParser.getInt(),this.header.itemCount=binaryParser.getLong(),this.header.reserved=binaryParser.getLong(),this.dictionary={},readTreeNode(binaryParser,-1,this.header.keySize,this.dictionary)},igv}(igv||{}),igv=function(igv){function RPTreeNode(items){this.items=items;var i,item,minChromId=Number.MAX_VALUE,maxChromId=0,minStartBase=Number.MAX_VALUE,maxEndBase=0;for(i=0;i<items.length;i++)item=items[i],minChromId=Math.min(minChromId,item.startChrom),maxChromId=Math.max(maxChromId,item.endChrom),minStartBase=Math.min(minStartBase,item.startBase),maxEndBase=Math.max(maxEndBase,item.endBase);this.startChrom=minChromId,this.endChrom=maxChromId,this.startBase=minStartBase,this.endBase=maxEndBase}function overlaps(item,chrIdx,startBase,endBase){return item?(chrIdx>item.startChrom||chrIdx==item.startChrom&&endBase>=item.startBase)&&(chrIdx<item.endChrom||chrIdx==item.endChrom&&startBase<item.endBase):(console.log("null item"),!1)}var RPTREE_HEADER_SIZE=48,RPTREE_NODE_LEAF_ITEM_SIZE=32;RPTREE_NODE_CHILD_ITEM_SIZE=24;var BUFFER_SIZE=512e3;return igv.RPTree=function(fileOffset,contentLength,config,littleEndian){this.config=config,this.filesize=contentLength,this.fileOffset=fileOffset,this.path=config.url,this.littleEndian=littleEndian},igv.RPTree.prototype.load=function(continuation){var tree=this,rootNodeOffset=this.fileOffset+RPTREE_HEADER_SIZE,bufferedReader=new igv.BufferedReader(this.config,this.filesize,BUFFER_SIZE);this.readNode(rootNodeOffset,bufferedReader,function(node){tree.rootNode=node,continuation(tree)})},igv.RPTree.prototype.readNode=function(filePosition,bufferedReader,continuation){bufferedReader.dataViewForRange({start:filePosition,size:4},function(dataView){var binaryParser=new igv.BinaryParser(dataView,this.littleEndian),type=binaryParser.getByte(),isLeaf=1===type?!0:!1,count=(binaryParser.getByte(),binaryParser.getShort());filePosition+=4;var bytesRequired=count*(isLeaf?RPTREE_NODE_LEAF_ITEM_SIZE:RPTREE_NODE_CHILD_ITEM_SIZE),range2={start:filePosition,size:bytesRequired};bufferedReader.dataViewForRange(range2,function(dataView){var i,items=new Array(count),binaryParser=new igv.BinaryParser(dataView);if(isLeaf){for(i=0;count>i;i++){var item={isLeaf:!0,startChrom:binaryParser.getInt(),startBase:binaryParser.getInt(),endChrom:binaryParser.getInt(),endBase:binaryParser.getInt(),dataOffset:binaryParser.getLong(),dataSize:binaryParser.getLong()};items[i]=item}continuation(new RPTreeNode(items))}else{for(i=0;count>i;i++){var item={isLeaf:!1,startChrom:binaryParser.getInt(),startBase:binaryParser.getInt(),endChrom:binaryParser.getInt(),endBase:binaryParser.getInt(),childOffset:binaryParser.getLong()};items[i]=item}continuation(new RPTreeNode(items))}})})},igv.RPTree.prototype.findLeafItemsOverlapping=function(chrIdx,startBase,endBase,continuation){function findLeafItems(node,nodeId){if(overlaps(node,chrIdx,startBase,endBase)){var items=node.items;items.forEach(function(item){overlaps(item,chrIdx,startBase,endBase)&&(item.isLeaf?leafItems.push(item):item.childNode?findLeafItems(item.childNode):(processing.add(item.childOffset),rpTree.readNode(item.childOffset,bufferedReader,function(node){item.childNode=node,findLeafItems(node,item.childOffset)})))})}void 0!=nodeId&&processing["delete"](nodeId),processing.isEmpty()&&continuation(leafItems)}var rpTree=this,leafItems=[],processing=new Set;bufferedReader=new igv.BufferedReader(this.config,this.filesize,BUFFER_SIZE),processing.add(0),findLeafItems(this.rootNode,0)},igv}(igv||{}),igv=function(igv){function loadZoomHeadersAndChrTree(continutation){var startOffset=BBFILE_HEADER_SIZE,self=this;igvxhr.loadArrayBuffer(this.path,{headers:self.config.headers,range:{start:startOffset,size:this.header.fullDataOffset-startOffset+5},success:function(data){var i,zoomNumber,zlh,nZooms=self.header.nZoomLevels,binaryParser=new igv.BinaryParser(new DataView(data));for(self.zoomLevelHeaders=[],self.firstZoomDataOffset=Number.MAX_VALUE,i=0;nZooms>i;i++)zoomNumber=nZooms-i,zlh=new ZoomLevelHeader(zoomNumber,binaryParser),self.firstZoomDataOffset=Math.min(zlh.dataOffset,self.firstZoomDataOffset),self.zoomLevelHeaders.push(zlh);self.header.autoSqlOffset>0&&(binaryParser.position=self.header.autoSqlOffset-startOffset,self.autoSql=binaryParser.getString()),self.header.totalSummaryOffset>0&&(binaryParser.position=self.header.totalSummaryOffset-startOffset,self.totalSummary=new igv.BWTotalSummary(binaryParser)),self.header.chromTreeOffset>0&&(binaryParser.position=self.header.chromTreeOffset-startOffset,self.chromTree=new igv.BPTree(binaryParser,0)),binaryParser.position=self.header.fullDataOffset-startOffset,self.dataCount=binaryParser.getInt(),continutation()}})}var BIGWIG_MAGIC_LTH=2291137574,BIGWIG_MAGIC_HTL=654085990,BIGBED_MAGIC_LTH=2273964779,BIGBED_MAGIC_HTL=3958540679,BBFILE_HEADER_SIZE=64;igv.BWReader=function(config){this.path=config.url,this.headPath=config.headURL||this.path,this.rpTreeCache={},this.config=config},igv.BWReader.prototype.getZoomHeaders=function(continuation){var reader=this;this.zoomLevelHeaders?continuation(reader.zoomLevelHeaders):this.loadHeader(function(){continuation(reader.zoomLevelHeaders)})},igv.BWReader.prototype.loadHeader=function(continuation){var self=this;igvxhr.loadArrayBuffer(self.path,{headers:self.config.headers,range:{start:0,size:BBFILE_HEADER_SIZE},success:function(data){if(data){self.littleEndian=!0;var binaryParser=new igv.BinaryParser(new DataView(data)),magic=binaryParser.getUInt();if(magic===BIGWIG_MAGIC_LTH)self.type="BigWig";else if(magic==BIGBED_MAGIC_LTH)self.type="BigBed";else{self.littleEndian=!1,binaryParser.littleEndian=!1,binaryParser.position=0;var magic=binaryParser.getUInt();magic===BIGWIG_MAGIC_HTL?self.type="BigWig":magic==BIGBED_MAGIC_HTL&&(self.type="BigBed")}self.header={},self.header.bwVersion=binaryParser.getShort(),self.header.nZoomLevels=binaryParser.getShort(),self.header.chromTreeOffset=binaryParser.getLong(),self.header.fullDataOffset=binaryParser.getLong(),self.header.fullIndexOffset=binaryParser.getLong(),self.header.fieldCount=binaryParser.getShort(),self.header.definedFieldCount=binaryParser.getShort(),self.header.autoSqlOffset=binaryParser.getLong(),self.header.totalSummaryOffset=binaryParser.getLong(),self.header.uncompressBuffSize=binaryParser.getInt(),self.header.reserved=binaryParser.getLong(),loadZoomHeadersAndChrTree.call(self,continuation)}}})},igv.BWReader.prototype.loadRPTree=function(offset,continuation){var rpTree=this.rpTreeCache[offset];rpTree?continuation(rpTree):(rpTree=new igv.RPTree(offset,this.contentLength,this.config,this.littleEndian),this.rpTreeCache[offset]=rpTree,rpTree.load(function(){continuation(rpTree)}))};var ZoomLevelHeader=function(index,byteBuffer){this.index=index,this.reductionLevel=byteBuffer.getInt(),this.reserved=byteBuffer.getInt(),this.dataOffset=byteBuffer.getLong(),this.indexOffset=byteBuffer.getLong()};return igv}(igv||{}),igv=function(igv){function zoomLevelForScale(bpPerPixel,zoomLevelHeaders){var i,zl,level=null;for(i=0;i<zoomLevelHeaders.length;i++)if(zl=zoomLevelHeaders[i],zl.reductionLevel>bpPerPixel){level=zl;break}return null==level&&(level=zoomLevelHeaders[zoomLevelHeaders.length-1]),level.reductionLevel<4*bpPerPixel?level:null}function decodeWigData(data,chr,chrIdx,bpStart,bpEnd,featureArray){var value,binaryParser=new igv.BinaryParser(data),chromId=binaryParser.getInt(),chromStart=binaryParser.getInt(),chromEnd=binaryParser.getInt(),itemStep=binaryParser.getInt(),itemSpan=binaryParser.getInt(),type=binaryParser.getByte(),itemCount=(binaryParser.getByte(),binaryParser.getShort());if(chromId===chrIdx)for(;itemCount-->0;){switch(type){case 1:chromStart=binaryParser.getInt(),chromEnd=binaryParser.getInt(),value=binaryParser.getFloat(),chromEnd=chromStart+itemSpan;break;case 2:chromStart=binaryParser.getInt(),value=binaryParser.getFloat(),chromEnd=chromStart+itemSpan;break;case 3:value=binaryParser.getFloat(),chromEnd=chromStart+itemSpan,chromStart+=itemStep}if(chromStart>=bpEnd)break;chromEnd>bpStart&&featureArray.push({chr:chr,start:chromStart,end:chromEnd,value:value})}}function decodeZoomData(data,chr,chrIdx,bpStart,bpEnd,featureArray){for(var chromId,chromStart,chromEnd,validCount,minVal,maxVal,sumData,sumSquares,value,binaryParser=new igv.BinaryParser(data),minSize=32;binaryParser.remLength()>=minSize;)if(chromId=binaryParser.getInt(),chromId===chrIdx){if(chromStart=binaryParser.getInt(),chromEnd=binaryParser.getInt(),validCount=binaryParser.getInt(),minVal=binaryParser.getFloat(),maxVal=binaryParser.getFloat(),sumData=binaryParser.getFloat(),sumSquares=binaryParser.getFloat(),value=0==validCount?0:sumData/validCount,chromStart>=bpEnd)break;chromEnd>bpStart&&featureArray.push({chr:chr,start:chromStart,end:chromEnd,value:value})}}function decodeBedData(data,chr,chrIdx,bpStart,bpEnd,featureArray){for(var chromId,chromStart,chromEnd,rest,tokens,feature,exonCount,exonSizes,exonStarts,exons,eStart,eEnd,binaryParser=new igv.BinaryParser(data),minSize=13;binaryParser.remLength()>=minSize;)if(chromId=binaryParser.getInt(),chromId==chrIdx&&(chromStart=binaryParser.getInt(),chromEnd=binaryParser.getInt(),rest=binaryParser.getString(),feature={chr:chr,start:chromStart,end:chromEnd},bpEnd>chromStart&&chromEnd>=bpStart&&(featureArray.push(feature),tokens=rest.split(" "),tokens.length>0&&(feature.name=tokens[0]),tokens.length>1&&(feature.score=parseFloat(tokens[1])),tokens.length>2&&(feature.strand=tokens[2]),tokens.length>3&&(feature.cdStart=parseInt(tokens[3])),tokens.length>4&&(feature.cdEnd=parseInt(tokens[4])),tokens.length>5&&(feature.rgb=tokens[5]),tokens.length>8))){exonCount=parseInt(tokens[6]),exonSizes=tokens[7].split(","),exonStarts=tokens[8].split(","),exons=[];for(var i=0;exonCount>i;i++)eStart=start+parseInt(exonStarts[i]),eEnd=eStart+parseInt(exonSizes[i]),exons.push({start:eStart,end:eEnd});feature.exons=exons}}return igv.BWSource=function(config){this.reader=new igv.BWReader(config),this.bufferedReader=new igv.BufferedReader(config)},igv.BWSource.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation){var bwSource=this;this.reader.getZoomHeaders(function(zoomLevelHeaders){var treeOffset,decodeFunction,bwReader=bwSource.reader,bufferedReader=bwSource.bufferedReader,bpPerPixel=igv.browser.referenceFrame.bpPerPixel,zoomLevelHeader=zoomLevelForScale(bpPerPixel,zoomLevelHeaders),features=[];zoomLevelHeader?(treeOffset=zoomLevelHeader.indexOffset,decodeFunction=decodeZoomData):(treeOffset=bwReader.header.fullIndexOffset,decodeFunction="BigWig"===bwReader.type?decodeWigData:decodeBedData),bwReader.loadRPTree(treeOffset,function(rpTree){var chrIdx=bwSource.reader.chromTree.dictionary[chr];void 0===chrIdx?continuation(null):rpTree.findLeafItemsOverlapping(chrIdx,bpStart,bpEnd,function(leafItems){leafItems&&0!=leafItems.length||continuation([]);var leafItemsCount=leafItems.length;leafItems.sort(function(i1,i2){return i1.startBase-i2.startBase}),leafItems.forEach(function(item){bufferedReader.dataViewForRange({start:item.dataOffset,size:item.dataSize},function(uint8Array){var inflate=new Zlib.Inflate(uint8Array),plain=inflate.decompress();decodeFunction(new DataView(plain.buffer),chr,chrIdx,bpStart,bpEnd,features),leafItemsCount--,0==leafItemsCount&&continuation(features)},!0)})})})})},igv}(igv||{}),igv=function(igv){function computeStats(){var n=this.basesCovered;n>0&&(this.mean=this.sumData/n,this.stddev=Math.sqrt((this.sumSquares-this.sumData/n*this.sumData)/(n-1)))}return igv.BWTotalSummary=function(byteBuffer){byteBuffer?(this.basesCovered=byteBuffer.getLong(),this.minVal=byteBuffer.getDouble(),this.maxVal=byteBuffer.getDouble(),this.sumData=byteBuffer.getDouble(),this.sumSquares=byteBuffer.getDouble(),computeStats.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)},igv.BWTotalSummary.prototype.updateStats=function(stats){this.basesCovered+=stats.count,this.sumData+=status.sumData,this.sumSquares+=sumSquares,this.minVal=MIN(_minVal,min),this.maxVal=MAX(_maxVal,max),computeStats.call(this)},igv}(igv||{}),igv=function(igv){function VPointer(block,offset){this.block=block,this.offset=offset}return igv.BinaryParser=function(dataView,littleEndian){this.littleEndian=littleEndian?littleEndian:!0,this.position=0,this.view=dataView,this.length=dataView.byteLength},igv.BinaryParser.prototype.remLength=function(){return this.length-this.position},igv.BinaryParser.prototype.hasNext=function(){return this.position<this.length-1},igv.BinaryParser.prototype.getByte=function(){var retValue=this.view.getUint8(this.position,this.littleEndian);return this.position++,retValue},igv.BinaryParser.prototype.getShort=function(){var retValue=this.view.getInt16(this.position,this.littleEndian);return this.position+=2,retValue},igv.BinaryParser.prototype.getInt=function(){var retValue=this.view.getInt32(this.position,this.littleEndian);return this.position+=4,retValue},igv.BinaryParser.prototype.getUInt=function(){var retValue=this.view.getUint32(this.position,this.littleEndian);return this.position+=4,retValue},igv.BinaryParser.prototype.getLong=function(){var byte1=255&this.view.getUint8(this.position++),byte2=255&this.view.getUint8(this.position++),byte3=255&this.view.getUint8(this.position++),byte4=255&this.view.getUint8(this.position++),byte5=255&this.view.getUint8(this.position++),byte6=255&this.view.getUint8(this.position++),byte7=255&this.view.getUint8(this.position++),byte8=255&this.view.getUint8(this.position++);return(byte8<<56)+(byte7<<56>>>8)+(byte6<<56>>>16)+(byte5<<56>>>24)+(byte4<<56>>>32)+(byte3<<56>>>40)+(byte2<<56>>>48)+(byte1<<56>>>56)},igv.BinaryParser.prototype.getString=function(len){for(var c,s="";0!=(c=this.view.getUint8(this.position++))&&(s+=String.fromCharCode(c),!len||s.length!=len););return s},igv.BinaryParser.prototype.getFloat=function(){var retValue=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,retValue},igv.BinaryParser.prototype.getDouble=function(){var retValue=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,retValue},igv.BinaryParser.prototype.skip=function(n){return this.position+=n,this.position},igv.BinaryParser.prototype.getVPointer=function(){var position=this.position,offset=this.view.getUint8(position+1)<<8|this.view.getUint8(position),byte6=4294967296*(255&this.view.getUint8(position+6)),byte5=16777216*(255&this.view.getUint8(position+5)),byte4=65536*(255&this.view.getUint8(position+4)),byte3=256*(255&this.view.getUint8(position+3)),byte2=255&this.view.getUint8(position+2),block=byte6+byte5+byte4+byte3+byte2;return this.position+=8,0==block&&0==offset?null:new VPointer(block,offset)},VPointer.prototype.print=function(){return""+this.block+":"+this.offset},igv}(igv||{}),igv=function(igv){function addTrackContainerHandlers(trackContainerDiv){var isRulerTrack=!1,isMouseDown=!1,lastMouseX=void 0,mouseDownX=void 0;$(trackContainerDiv).mousedown(function(e){var coords=igv.translateMouseCoordinates(e,trackContainerDiv);isRulerTrack=$(e.target).parent().parent().parent()[0].dataset.rulerTrack?!0:!1,isRulerTrack||(isMouseDown=!0,lastMouseX=coords.x,mouseDownX=lastMouseX)}),$(trackContainerDiv).mousemove(igv.throttle(function(e){var maxEnd,maxStart,coords=igv.translateMouseCoordinates(e,trackContainerDiv),referenceFrame=igv.browser.referenceFrame,isCursor=igv.browser.cursorModel;if(!isRulerTrack&&referenceFrame&&isMouseDown){if(mouseDownX&&Math.abs(coords.x-mouseDownX)>igv.constants.dragThreshold){if(referenceFrame.shiftPixels(lastMouseX-coords.x),referenceFrame.start=Math.max(0,referenceFrame.start),isCursor)maxEnd=igv.browser.cursorModel.filteredRegions.length,maxStart=maxEnd-igv.browser.trackViewportWidth()/igv.browser.cursorModel.framePixelWidth;else{var chromosome=igv.browser.genome.getChromosome(referenceFrame.chr);maxEnd=chromosome.bpLength,maxStart=maxEnd-igv.browser.trackViewportWidth()*referenceFrame.bpPerPixel}referenceFrame.start>maxStart&&(referenceFrame.start=maxStart),igv.browser.updateLocusSearch(referenceFrame),igv.browser.repaint()}lastMouseX=coords.x}},10)),$(trackContainerDiv).mouseup(function(e){isRulerTrack||(mouseDownX=void 0,isMouseDown=!1,lastMouseX=void 0)}),$(trackContainerDiv).mouseleave(function(e){isRulerTrack||(isMouseDown=!1,lastMouseX=void 0,mouseDownX=void 0)}),$(trackContainerDiv).dblclick(function(e){if(!isRulerTrack&&!e.altKey){e=$.event.fix(e);var canvasCoords=igv.translateMouseCoordinates(e,trackContainerDiv),referenceFrame=igv.browser.referenceFrame;if(referenceFrame){var newCenter=Math.round(referenceFrame.start+canvasCoords.x*referenceFrame.bpPerPixel);referenceFrame.bpPerPixel/=2,igv.browser.cursorModel&&(igv.browser.cursorModel.framePixelWidth*=2),igv.browser["goto"](referenceFrame.chr,newCenter)}}})}return igv.Browser=function(options,trackContainer){igv.browser=this,this.div=$('<div id="igvRootDiv" class="igv-root-div">')[0],this.flanking=options.flanking,this.controlPanelWidth=options.controlPanelWidth||50,this.type=options.type||"IGV",this.searchURL=options.searchURL||"//www.broadinstitute.org/webservices/igv/locus?genome=hg19&name=",$("input[id='trackHeightInput']").val(this.trackHeight),this.trackContainerDiv=trackContainer,addTrackContainerHandlers(trackContainer),this.trackViews=[],this.nextTrackOrder=0,window.onresize=igv.throttle(function(){igv.browser.resize()},10)},igv.Browser.prototype.trackLabelWithPath=function(path){var label,parser=document.createElement("a");return parser.href=path,label=parser.pathname.split("/"),label[label.length-1].split(".")[0]},igv.Browser.prototype.loadTrack=function(config){var myself=this;config.url&&!config.sourceType?igvxhr.isReachable(config.url,function(success,requestStatus){var parts;!0===success?myself.doLoadTrack(config):(parts=igv.parseUri(config.url),myself.userFeedback.bodyCopy("<p>ERROR: Track file "+parts.file+" is unreachable<p><p>HTTP request status: "+requestStatus+"<p>"),myself.userFeedback.show())}):myself.doLoadTrack(config)},igv.Browser.prototype.doLoadTrack=function(config){function loadHeader(track){track.getHeader?track.getHeader(function(header){browser.addTrack(track)}):browser.addTrack(newTrack)}var browser=this;if(!this.isDuplicateTrack(config)){config.type||(config.type=igv.inferFileType(config.url||config.localFile&&config.localFile.name));var newTrack,path=config.url,type=config.type;if("t2d"===type)newTrack=new igv.T2dTrack(config);else if("bed"===type||"vcf"===type||"arc"==type||"FusionJuncSpan"==type)newTrack=new igv.FeatureTrack(config);else if("bam"===type)newTrack=new igv.BAMTrack(config);else if("wig"===type||"bigwig"===type||"bedgraph"===type)newTrack=new igv.WIGTrack(config);else if("sequence"===type)newTrack=new igv.SequenceTrack(config);else if("eqtl"===type)newTrack=new igv.EqtlTrack(config);else if("seg"===type)newTrack=new igv.SegTrack(config);else{if("aneu"!==type)return alert("Unknown file type: "+path),null;newTrack=new igv.AneuTrack(config)}loadHeader(newTrack)}},igv.Browser.prototype.isDuplicateTrack=function(config){var attemptedDuplicateTrackAddition=!1;return this.trackViews.forEach(function(tp){!1===attemptedDuplicateTrackAddition&&JSON.stringify(config)===JSON.stringify(tp.track.config)&&(attemptedDuplicateTrackAddition=!0)}),!0===attemptedDuplicateTrackAddition?(window.alert("Attempt to load duplicate track."),!0):!1},igv.Browser.prototype.addTrack=function(track){var myself=this,trackView=new igv.TrackView(track,this);igv.popover&&igv.popover.hide(),track.trackView=trackView,void 0===track.order&&(track.order=this.nextTrackOrder++),this.trackViews.push(trackView),this.reorderTracks(),this.cursorModel?this.cursorModel.initializeHistogram(trackView.track,function(){myself.designatedTrack===track&&myself.selectDesignatedTrack(myself.designatedTrack.trackFilter.trackPanel),track.config&&track.config.trackFilter&&track.trackFilter.setWithJSON(track.config.trackFilter),myself.resize()}):this.resize()},igv.Browser.prototype.reorderTracks=function(){var myself=this;this.trackViews.sort(function(a,b){var aOrder=a.track.order||0,bOrder=b.track.order||0;return aOrder-bOrder}),$(this.trackContainerDiv).children().detach(),this.trackViews.forEach(function(trackView,index,trackViews){myself.trackContainerDiv.appendChild("CURSOR"===myself.type?trackView.cursorTrackContainer:trackView.trackDiv)})},igv.Browser.prototype.removeTrack=function(track){for(var trackPanelRemoved,i=0;i<this.trackViews.length;i++)if(track===this.trackViews[i].track){trackPanelRemoved=this.trackViews[i];break}trackPanelRemoved&&(this.trackViews.splice(this.trackViews.indexOf(trackPanelRemoved),1),this.trackContainerDiv.removeChild("CURSOR"===this.type?trackPanelRemoved.cursorTrackContainer:trackPanelRemoved.trackDiv))},igv.Browser.prototype.reduceTrackOrder=function(trackView){var raisable,raiseableOrder,indices=[];1!==this.trackViews.length&&(this.trackViews.forEach(function(tv,i,tvs){indices.push({trackView:tv,index:i}),trackView===tv&&(raisable=indices[i])}),0!==raisable.index&&(raiseableOrder=raisable.trackView.track.order,raisable.trackView.track.order=indices[raisable.index-1].trackView.track.order,indices[raisable.index-1].trackView.track.order=raiseableOrder,this.reorderTracks()))},igv.Browser.prototype.increaseTrackOrder=function(trackView){var raisable,raiseableOrder,indices=[];1!==this.trackViews.length&&(this.trackViews.forEach(function(tv,i,tvs){indices.push({trackView:tv,index:i}),trackView===tv&&(raisable=indices[i])}),this.trackViews.length-1!==raisable.index&&(raiseableOrder=raisable.trackView.track.order,raisable.trackView.track.order=indices[1+raisable.index].trackView.track.order,indices[1+raisable.index].trackView.track.order=raiseableOrder,this.reorderTracks()))},igv.Browser.prototype.setTrackHeight=function(newHeight){this.trackHeight=newHeight,this.trackViews.forEach(function(panel){panel.setTrackHeight(newHeight)})},igv.Browser.prototype.resize=function(){this.ideoPanel&&this.ideoPanel.resize(),this.karyoPanel&&this.karyoPanel.resize(),this.trackViews.forEach(function(panel){panel.resize()})},igv.Browser.prototype.repaint=function(){this.ideoPanel&&this.ideoPanel.repaint(),this.karyoPanel&&this.karyoPanel.repaint(),this.trackViews.forEach(function(trackView){trackView.repaint()}),this.cursorModel&&this.horizontalScrollbar.update()},igv.Browser.prototype.update=function(){this.updateLocusSearch(this.referenceFrame),this.ideoPanel&&this.ideoPanel.repaint(),this.karyoPanel&&this.karyoPanel.repaint(),this.trackViews.forEach(function(trackPanel){trackPanel.update()}),this.cursorModel&&this.horizontalScrollbar.update()},igv.Browser.prototype.updateLocusSearch=function(referenceFrame){var chr,ss,ee,str,end,chromosome;this.searchInput&&(chr=referenceFrame.chr,ss=igv.numberFormatter(Math.floor(referenceFrame.start+1)),end=referenceFrame.start+this.trackViewportWidthBP(),this.genome&&(chromosome=this.genome.getChromosome(chr),chromosome&&(end=Math.min(end,chromosome.bpLength))),ee=igv.numberFormatter(Math.floor(end)),str=chr+":"+ss+"-"+ee,this.searchInput.val(str))},igv.Browser.prototype.trackViewportWidth=function(){var width;return width=this.trackViews&&this.trackViews.length>0?this.trackViews[0].viewportDiv.clientWidth:this.trackContainerDiv.clientWidth},igv.Browser.prototype.pixelPerBasepairThreshold=function(){return 14},igv.Browser.prototype.trackViewportWidthBP=function(){return this.referenceFrame.bpPerPixel*this.trackViewportWidth()},igv.Browser.prototype.removeAllTracks=function(){for(var tracks=this.trackViews,i=0;i<tracks.length;i++){var track=this.trackViews[i].track;this.removeTrack(track)}},igv.Browser.prototype.setGotoCallback=function(gotocallback){this.gotocallback=gotocallback},igv.Browser.prototype["goto"]=function(chr,start,end){"undefined"!=typeof this.gotocallback&&this.gotocallback(chr,start,end);var w,chromosome,viewportWidth=this.trackViewportWidth();if(igv.popover&&igv.popover.hide(),this.genome&&(chr=this.genome.getChromosomeName(chr)),this.referenceFrame.chr=chr,end?this.referenceFrame.bpPerPixel=(end-start)/viewportWidth:(w=Math.round(viewportWidth*this.referenceFrame.bpPerPixel/2),start=Math.max(0,start-w)),this.genome)if(chromosome=this.genome.getChromosome(this.referenceFrame.chr)){chromosome.bpLength||(chromosome.bpLength=1);var maxBpPerPixel=chromosome.bpLength/viewportWidth;this.referenceFrame.bpPerPixel>maxBpPerPixel&&(this.referenceFrame.bpPerPixel=maxBpPerPixel),end||(end=start+viewportWidth*this.referenceFrame.bpPerPixel),chromosome&&end>chromosome.bpLength&&(start-=end-chromosome.bpLength)}else console&&console.log&&console.log("Could not find chromsome "+this.referenceFrame.chr);this.referenceFrame.start=start,this.update()},igv.Browser.prototype.zoomIn=function(){var newScale,center,viewportWidth;viewportWidth=this.trackViewportWidth(),newScale=Math.max(1/this.pixelPerBasepairThreshold(),this.referenceFrame.bpPerPixel/2),newScale!==this.referenceFrame.bpPerPixel&&(center=this.referenceFrame.start+this.referenceFrame.bpPerPixel*viewportWidth/2,this.referenceFrame.start=center-newScale*viewportWidth/2,this.referenceFrame.bpPerPixel=newScale,this.update())},igv.Browser.prototype.zoomOut=function(){var newScale,maxScale,center,chrLength,widthBP,viewportWidth;if(viewportWidth=this.trackViewportWidth(),newScale=2*this.referenceFrame.bpPerPixel,chrLength=25e7,this.genome){var chromosome=this.genome.getChromosome(this.referenceFrame.chr);chromosome&&(chrLength=chromosome.bpLength)}maxScale=chrLength/viewportWidth,newScale>maxScale&&(newScale=maxScale),center=this.referenceFrame.start+this.referenceFrame.bpPerPixel*viewportWidth/2,widthBP=newScale*viewportWidth,this.referenceFrame.start=Math.round(center-widthBP/2),this.referenceFrame.start<0?this.referenceFrame.start=0:this.referenceFrame.start>chrLength-widthBP&&(this.referenceFrame.start=chrLength-widthBP),this.referenceFrame.bpPerPixel=newScale,this.update()},igv.Browser.prototype.search=function(feature,continuation){function fireOnsearch(feature,type){this.trackViews.forEach(function(tp){var track=tp.track;track.onsearch&&track.onsearch(feature,type)})}var type,chr,posTokens,start,end,source,f,tokens,url,chromosome;feature.contains(":")&&feature.contains("-")||this.genome.getChromosome(feature)?(type="locus",
|
3
|
+
tokens=feature.split(":"),chr=this.genome.getChromosomeName(tokens[0]),1==tokens.length?(chromosome=this.genome.getChromosome(feature),start=0,end=chromosome.bpLength):(posTokens=tokens[1].split("-"),start=parseInt(posTokens[0].replace(/,/g,""))-1,end=parseInt(posTokens[1].replace(/,/g,""))),end>start&&(this["goto"](chr,start,end),fireOnsearch.call(igv.browser,feature,type)),continuation&&continuation()):this.searchURL&&(url=this.searchURL+feature,igv.loadData(url,function(data){for(var line,tokens,locusTokens,rangeTokens,lines=data.splitLines(),len=lines.length,lineNo=0,foundFeature=!1;len>lineNo;)line=lines[lineNo++],tokens=line.split(" "),tokens.length>=3&&(f=tokens[0],f.toUpperCase()===feature.toUpperCase()&&(source=tokens[2].trim(),type=source,locusTokens=tokens[1].split(":"),chr=igv.browser.genome.getChromosomeName(locusTokens[0].trim()),"GTEX"===igv.browser.type&&(igv.browser.selection=new igv.GtexSelection("gtex"==type?{snp:feature}:{gene:feature})),rangeTokens=locusTokens[1].split("-"),start=parseInt(rangeTokens[0].replace(/,/g,"")),end=parseInt(rangeTokens[1].replace(/,/g,"")),igv.browser.flanking&&(start-=igv.browser.flanking,end+=igv.browser.flanking),igv.browser["goto"](chr,start,end),foundFeature=!0));foundFeature?fireOnsearch.call(igv.browser,feature,type):alert('No feature found with name "'+feature+'"'),continuation&&continuation()}))},igv}(igv||{}),igv=function(igv){function gatherAllFeatureCaches(cursorTrackList,continuation){var trackCount=cursorTrackList.length,trackFeatureMap=[];cursorTrackList.forEach(function(cursorTrack){cursorTrack.featureSource.getFeatureCache(function(featureCache){trackFeatureMap.push(featureCache),console.log(trackFeatureMap.length),trackFeatureMap.length===trackCount&&continuation(trackFeatureMap)})})}return igv.CursorIdeoPanel=function(){this.div=document.createElement("div"),this.div.style.height="40px";var contentHeight=this.div.clientHeight,contentWidth=this.div.clientWidth,canvas=document.createElement("canvas");canvas.style.position="absolute",canvas.style.width="100%",canvas.style.height=contentHeight+"px",canvas.setAttribute("width",contentWidth),canvas.setAttribute("height",contentHeight),this.canvas=canvas,this.div.appendChild(canvas),this.ctx=canvas.getContext("2d")},igv.CursorIdeoPanel.prototype.resize=function(){var contentHeight=this.div.clientHeight,contentWidth=this.div.clientWidth,canvas=this.canvas;canvas.style.width="100%",canvas.style.height=contentHeight,canvas.setAttribute("width",contentWidth),canvas.setAttribute("height",contentHeight),this.ideograms={},this.repaint()},igv.CursorIdeoPanel.prototype.repaint=function(){return},igv.testGatherAllFeatureCacches=function(trackList,continuation){gatherAllFeatureCaches(trackList,continuation)},igv}(igv||{}),cursor=function(cursor){return cursor.CursorHistogram=function(cursorHistogramContainer,track){this.track=track,this.canvasFillStyle=igv.greyScale(255),this.minMaxfillStyle=igv.rgbaColor(64,64,64,.5),this.minMaxEdgefillStyle=igv.rgbaColor(32,32,32,1),cursorHistogramContainer?this.createMarkupAndSetBinLength(cursorHistogramContainer):(this.bins=[],this.bins.length=100),this.maxCount=0,this.initializeBins()},cursor.CursorHistogram.prototype.initializeBins=function(){var i,len;for(i=0,len=this.bins.length;len>i;i++)this.bins[i]=0;this.maxCount=0},cursor.CursorHistogram.prototype.insertScore=function(score){if(!(0>score)){var index=this.scoreIndex(score);this.bins[index]+=1,this.maxCount=Math.max(this.maxCount,this.bins[index])}},cursor.CursorHistogram.prototype.scoreIndex=function(score){var value,maxScore=this.track.max;return score>=maxScore?this.bins.length-1:(value=score/maxScore,value*=this.bins.length,Math.floor(value))},cursor.CursorHistogram.prototype.render=function(track){var myself=this,renderMinimumOverlay=function(minimum){var height=minimum/track.max*myself.bins.length;igv.Canvas.fillRect.call(myself.ctx,0,myself.bins.length-height,myself.canvasWidth,height,{fillStyle:myself.minMaxfillStyle})},renderMaximumOverlay=function(maximum){var height=myself.bins.length-maximum/track.max*myself.bins.length;igv.Canvas.fillRect.call(myself.ctx,0,0,myself.canvasWidth,height,{fillStyle:myself.minMaxfillStyle})};this.fillCanvasWithFillStyle(this.canvasFillStyle),this.bins.forEach(function(count,index,counts){var x,y,width,height,percent,color;count&&(percent=count/this.maxCount,x=(1-percent)/2*this.canvasWidth,width=percent*this.canvasWidth,y=counts.length-1-index,height=1,color=track.color?track.color:igv.rgbColor(128,128,128),igv.Canvas.fillRect.call(myself.ctx,x,y,width,height,{fillStyle:color}))},this);var renderTrackFilterOverlays=track.trackFilter.makeTrackFilterOverlayRenderer(renderMinimumOverlay,renderMaximumOverlay);renderTrackFilterOverlays()},cursor.CursorHistogram.prototype.fillCanvasWithFillStyle=function(fillStyle){igv.Canvas.fillRect.call(this.ctx,this.canvasWidth,this.canvasHeight,{fillStyle:fillStyle})},cursor.CursorHistogram.prototype.createMarkupAndSetBinLength=function(parentDiv){this.canvas=this.createCanvasAndSetBinLength(parentDiv),this.ctx=this.canvas.getContext("2d"),this.fillCanvasWithFillStyle(this.canvasFillStyle)},cursor.CursorHistogram.prototype.createCanvasAndSetBinLength=function(parentDiv){var cursorHistogramDiv=document.createElement("div");return parentDiv.appendChild(cursorHistogramDiv),cursorHistogramDiv.className="igv-cursor-histogram-div",this.cursorHistogramDiv=cursorHistogramDiv,this.bins=[],this.bins.length=cursorHistogramDiv.clientHeight,this.createDOMCanvasWithParent(this.cursorHistogramDiv)},cursor.CursorHistogram.prototype.createDOMCanvasWithParent=function(parentDiv){var DOMCanvas;return DOMCanvas=document.createElement("canvas"),parentDiv.appendChild(DOMCanvas),this.canvasWidth=parentDiv.clientWidth,this.canvasHeight=parentDiv.clientHeight,DOMCanvas.setAttribute("width",parentDiv.clientWidth),DOMCanvas.setAttribute("height",parentDiv.clientHeight),DOMCanvas},cursor.CursorHistogram.prototype.updateHeightAndInitializeHistogramWithTrack=function(track){this.canvasHeight=this.cursorHistogramDiv.clientHeight,this.canvas.setAttribute("height",this.cursorHistogramDiv.clientHeight),this.bins=[],this.bins.length=this.cursorHistogramDiv.clientHeight,track.cursorModel.initializeHistogram(track)},cursor}(cursor||{}),cursor=function(cursor){function resevoirSampledRegionList(regions,max){var i,j,elem,subsampledRegions=[],len=regions.length,cnt=0;for(i=0;len>i;i++)elem=regions[i],subsampledRegions.length<max?subsampledRegions.push(elem):(j=Math.floor(Math.random()*cnt),max>j&&(subsampledRegions[j]=elem)),cnt++;return subsampledRegions}const resevoirSampledRegionListLength=1e4;return cursor.CursorModel=function(browser){this.browser=browser,this.regionWidth=100,$("input[id='regionSizeInput']").val(this.regionWidth),this.framePixelWidth=24,$("input[id='frameWidthInput']").val(this.framePixelWidth),this.frameMargin=6,this.tracks=[],this.regions=[],this.filteredRegions=this.regions},cursor.CursorModel.prototype.updateRegionDisplay=function(){var igvCursorUIHeaderBlurb=$(".igv-cursor-ui-header-blurb"),trackLabelSpan=igvCursorUIHeaderBlurb.find("span")[1],regionCountSpan=igvCursorUIHeaderBlurb.find("span")[0],filteredRegionCountSpan=igvCursorUIHeaderBlurb.find("span")[2];igvCursorUIHeaderBlurb.css({display:"block"}),$(trackLabelSpan).text(this.browser.designatedTrack?this.browser.designatedTrack.label:"unnamed"),$(trackLabelSpan).css({color:this.browser.highlightColor}),$(regionCountSpan).text(igv.numberFormatter(this.regions.length)),$(regionCountSpan).css({color:this.browser.highlightColor}),$(filteredRegionCountSpan).text(igv.numberFormatter(this.filteredRegions.length)),$(filteredRegionCountSpan).css({color:"rgba(3, 116, 178, 1.0)"})},cursor.CursorModel.prototype.regionsToRender=function(){return void 0===this.subSampledFilteredRegions?this.filteredRegions:this.subSampledFilteredRegions},cursor.CursorModel.prototype.setRegions=function(features){var featuresLength,i;for(this.regions=[],i=0,featuresLength=features.length;featuresLength>i;i++)this.regions.push(new cursor.CursorRegion(features[i]));this.filteredRegions=this.regions,this.updateRegionDisplay(),this.filterRegions()},cursor.CursorModel.prototype.initializeHistogram=function(track,continutation){var myself=this;track.cursorHistogram.initializeBins(),(void 0===this.regions||0===this.regions.length)&&continutation&&continutation(),track.getFeatureCache(function(featureCache){myself.regions.forEach(function(region){var score=region.getScore(featureCache,myself.regionWidth);track.cursorHistogram.insertScore(score)}),track.cursorHistogram.render(track),continutation&&continutation()})},cursor.CursorModel.prototype.filterRegions=function(){function runFilters(){if(0===filterPackages.length?myself.filteredRegions=myself.regions:(myself.filteredRegions=[],myself.regions.forEach(function(region){var success,passFilter=!0;trackPackages.forEach(function(trackPackage){!0===passFilter&&(success=trackPackage.trackFilter.evaluate(trackPackage.featureCache,region,myself.regionWidth),!1===success&&(passFilter=!1))}),passFilter&&myself.filteredRegions.push(region)})),0===myself.filteredRegions.length)return myself.browser.update(),void myself.browser.fitToScreen();var thresholdFramePixelWidth=myself.browser.trackViewportWidth()/myself.filteredRegions.length;void 0!==thresholdFramePixelWidth&&trackViewThatIsSorted?(myself.browser.presentSortStatus(trackViewThatIsSorted),myself.sortRegions(trackViewThatIsSorted.track.featureSource,myself.browser.sortDirection,function(){myself.framePixelWidth<thresholdFramePixelWidth?myself.browser.setFrameWidth(thresholdFramePixelWidth):myself.browser.update()})):(myself.subSampledFilteredRegions=myself.filteredRegions.length>=Number.MAX_VALUE?resevoirSampledRegionList(myself.filteredRegions,resevoirSampledRegionListLength):myself.filteredRegions,myself.framePixelWidth<thresholdFramePixelWidth?myself.browser.setFrameWidth(thresholdFramePixelWidth):myself.browser.update()),myself.updateRegionDisplay(),myself.browser.fitToScreen(),trackPackages.forEach(function(trackPackage){trackPackage.cursorHistogram.initializeBins(),myself.regions.forEach(function(region){var score,doIncludeRegionForHistogramRender=!0;filterPackages.forEach(function(filterPackage){var success;trackPackage.trackFilter===filterPackage.trackFilter||!0===doIncludeRegionForHistogramRender&&(success=filterPackage.trackFilter.evaluate(filterPackage.featureCache,region,myself.regionWidth),!1===success&&(doIncludeRegionForHistogramRender=!1))}),doIncludeRegionForHistogramRender&&(score=region.getScore(trackPackage.featureCache,myself.regionWidth),trackPackage.cursorHistogram.insertScore(score))}),trackPackage.cursorHistogram.render(trackPackage.track)})}var trackViewThatIsSorted,trackPackages=[],filterPackages=[],howmany=0,myself=this;$(this.browser.trackContainerDiv).find("i.fa-signal").each(function(){var me=$(this);me.hasClass("igv-control-sort-fa-selected")&&me.removeClass("igv-control-sort-fa-selected")}),this.browser.trackViews.forEach(function(trackView,tpIndex,trackViews){trackView.track.getFeatureCache(function(featureCache){trackPackages.push({track:trackView.track,trackFilter:trackView.track.trackFilter,featureCache:featureCache,cursorHistogram:trackView.track.cursorHistogram}),trackView.track.isSortTrack()&&(trackViewThatIsSorted=trackView),trackView.track.trackFilter.isFilterActive&&filterPackages.push({trackFilter:trackView.track.trackFilter,featureCache:featureCache}),++howmany===trackViews.length&&runFilters()})})},cursor.CursorModel.prototype.sortRegions=function(featureSource,sortDirection,continuation){"use strict";var myself=this,regionWidth=this.regionWidth;this.filteredRegions&&0!==this.filteredRegions.length||continuation(),myself.subSampledFilteredRegions=myself.filteredRegions.length>=Number.MAX_VALUE?resevoirSampledRegionList(myself.filteredRegions,resevoirSampledRegionListLength):myself.filteredRegions,featureSource.getFeatureCache(function(featureCache){myself.subSampledFilteredRegions.forEach(function(region){region.sortScore=region.getScore(featureCache,regionWidth)});var compFunction=function(cursorRegion1,cursorRegion2){var s1=cursorRegion1.sortScore,s2=cursorRegion2.sortScore;return sortDirection*(s1===s2?0:s1>s2?-1:1)};myself.subSampledFilteredRegions.shuffle(),myself.subSampledFilteredRegions.length>1e3?myself.subSampledFilteredRegions.heapSort(compFunction):myself.subSampledFilteredRegions.sort(compFunction),continuation()})},cursor.CursorRegion=function(feature){this.chr=feature.chr,this.location=(feature.start+feature.end)/2},cursor.CursorRegion.prototype.getScore=function(featureCache,regionWidth){var score,featureCacheQueryResults,features,regionStart=this.location-regionWidth/2,regionEnd=this.location+regionWidth/2;return featureCacheQueryResults=featureCache.queryFeatures(this.chr,regionStart,regionEnd),featureCacheQueryResults&&0!==featureCacheQueryResults.length?(features=[],featureCacheQueryResults.forEach(function(f){f.end>=regionStart&&f.start<regionEnd&&features.push(f)}),0===features?-1:(score=0,featureCacheQueryResults.forEach(function(feature){score=void 0===feature.score?1e3:Math.max(feature.score,score)}),-1===score&&console.log("Features "+featureList.length+". Should not return score = -1 for filter consideration."),score)):-1},cursor.CursorRegion.prototype.isRegionEmpty=function(featureCache,regionWidth){var featureList,halfWidth=regionWidth/2;return featureList=featureCache.queryFeatures(this.chr,this.location-halfWidth,this.location+halfWidth),featureList?!0:!1},cursor.CursorRegion.prototype.exportRegion=function(regionWidth){var halfWidth=regionWidth/2,ss=Math.floor(this.location-halfWidth),ee=Math.floor(1+this.location+halfWidth);return this.chr+" "+ss+" "+ee+"\n"},cursor}(cursor||{}),cursor=function(cursor){function percentile(featureList,per){var idx=Math.floor(featureList.length*per/100);return featureList.sort(function(a,b){return a.score>b.score?1:a.score<b.score?-1:0}),featureList[idx].score}var MAX_FEATURE_COUNT=1e8;return cursor.CursorTrack=function(config,browser){this.config=config,this.url=config.url,this.config.indexed=!1,this.featureSource=new igv.FeatureSource(config),this.featureSource.maxFeatureCount=MAX_FEATURE_COUNT,this.label=config.label,this.height=config.trackHeight||100,this.color=config.color||cursor.defaultColor(),this.cursorModel=browser.cursorModel,this.referenceFrame=browser.referenceFrame,this.cursorHistogram=void 0,this.id=""},cursor.CursorTrack.prototype.jsonRepresentation=function(){var json;return json={label:this.label,color:this.color,order:this.order,height:this.height,path:this.featureSource.config.url,trackFilter:this.trackFilter.jsonRepresentation()}},cursor.defaultColor=function(){return"rgb( 3, 116, 178)"},cursor.CursorTrack.prototype.isSortTrack=function(){var success=this===this.cursorModel.browser.sortTrack;return success},cursor.CursorTrack.prototype.getFeatureCache=function(continuation){function setHeader(header){header?(myself.header=header,header.name&&!myself.config.label&&(myself.label=header.name,myself.trackLabelDiv&&(myself.trackLabelDiv.innerHTML=header.name,myself.trackLabelDiv.title=header.label)),header.color&&!myself.config.color&&(myself.color="rgb("+header.color+")",myself.cursorHistogram&&myself.cursorHistogram.render(this)),header.height&&!myself.config.trackHeight&&(myself.height=header.height)):this.header=null}var myself=this;this.featureCache?continuation(this.featureCache):void 0===myself.header&&myself.featureSource.getHeader?myself.featureSource.getHeader(function(header){setHeader.call(myself,header),myself.getFeatureCache(continuation)}):this.featureSource.getFeatureCache(function(featureCache){var allFeatures;allFeatures=featureCache.allFeatures(),myself.max=percentile(allFeatures,98),myself.featureCache=featureCache,continuation(featureCache)})},cursor.CursorTrack.prototype.draw=function(ctx,refFrame,start,end,width,height,continuation){function drawFeatures(featureCache){var regionNumber,region,regions,len,cursorModel,framePixelWidth,regionWidth,scale,frameMargin,sampleInterval,chr,pxStart,pxEnd,maxFeatureHeight,regionFeatures,i,flen,feature,score,pStart,pEnd,pw,fh,regionBpStart,regionBpEnd,top;for(regions=this.cursorModel.regionsToRender(),regions||continuation(),cursorModel=this.cursorModel,framePixelWidth=cursorModel.framePixelWidth,regionWidth=cursorModel.regionWidth,frameMargin=cursorModel.frameMargin,frameMargin=Math.floor(Math.min(framePixelWidth/4),frameMargin),sampleInterval=Math.max(1,Math.floor(1/framePixelWidth)),frameMargin>0&&igv.Canvas.fillRect.call(ctx,0,0,width,height,{fillStyle:"rgb(255, 255, 255)"}),igv.Canvas.setProperties.call(ctx,{fillStyle:this.color,strokeStyle:this.color}),regionNumber=Math.floor(start),len=regions.length;len>regionNumber&&end>regionNumber;regionNumber+=sampleInterval)if(region=regions[regionNumber],chr=region.chr,regionBpStart=region.location-regionWidth/2,regionBpEnd=region.location+regionWidth/2,pxStart=Math.floor((regionNumber-start)*framePixelWidth+frameMargin/2),pxEnd=framePixelWidth>1?Math.floor((regionNumber+1-start)*framePixelWidth-frameMargin/2):pxStart+1,maxFeatureHeight=height,framePixelWidth>2)for(regionFeatures=featureCache.queryFeatures(region.chr,regionBpStart,regionBpEnd),i=0,flen=regionFeatures.length;flen>i;i++)feature=regionFeatures[i],feature.end>=regionBpStart&&feature.start<regionBpEnd&&(score=feature.score,scale=regionWidth/(framePixelWidth-frameMargin),pStart=Math.min(pxEnd,Math.max(pxStart,pxStart+(feature.start-regionBpStart)/scale)),pEnd=Math.min(pxEnd,pxStart+(feature.end-regionBpStart)/scale),pw=Math.max(1,pEnd-pStart),score?(fh=Math.round(score/this.max*maxFeatureHeight),top=height-fh):(top=0,fh=height),score>this.max&&console.log(score),igv.Canvas.fillRect.call(ctx,pStart,top,pw,fh));else pw=pxEnd-pxStart,score=region.getScore(featureCache,regionWidth),score>0&&(fh=Math.round(score/myself.max*maxFeatureHeight),top=height-fh,igv.Canvas.fillRect.call(ctx,pxStart,top,pw,fh));continuation()}var myself=this;this.getFeatureCache(function(featureCache){drawFeatures.call(myself,featureCache)})},cursor.CursorTrack.prototype.drawLabel=function(ctx){},cursor}(cursor||{}),cursor=function(cursor){var minimumHorizontalScrollBarDraggableWidth=6;return cursor.HorizontalScrollbar=function(browser,horizontalScrollBarContainer){this.browser=browser,this.markupWithParentDivObject(horizontalScrollBarContainer)},cursor.HorizontalScrollbar.prototype.update=function(){var regionBoundsWidth,trackLeft,scrollBarDraggableLeft,scrollBarDraggableWidth,scrollBarWidth=$(".igv-horizontal-scrollbar-div").first().width(),scrollBarDraggable=$(".igv-horizontal-scrollbar-draggable-div").first(),framePixelWidth=this.browser.cursorModel.framePixelWidth,regionListLength=this.browser.cursorModel.filteredRegions.length,referenceFrame=this.browser.referenceFrame;regionBoundsWidth=framePixelWidth*regionListLength,scrollBarDraggableWidth=Math.max(minimumHorizontalScrollBarDraggableWidth,scrollBarWidth/regionBoundsWidth*scrollBarWidth),trackLeft=referenceFrame.toPixels(referenceFrame.start),scrollBarDraggableLeft=scrollBarWidth/regionBoundsWidth*trackLeft,scrollBarDraggableLeft+scrollBarDraggableWidth>scrollBarWidth&&(scrollBarDraggableLeft-=scrollBarDraggableLeft+scrollBarDraggableWidth-scrollBarWidth,scrollBarDraggableWidth=scrollBarWidth-scrollBarDraggableLeft,referenceFrame.start=referenceFrame.toBP(regionBoundsWidth/scrollBarWidth*scrollBarDraggableLeft),this.browser.ideoPanel&&this.browser.ideoPanel.repaint(),this.browser.karyoPanel&&this.browser.karyoPanel.repaint(),this.browser.trackViews.forEach(function(trackPanel){trackPanel.update()})),$(scrollBarDraggable).css({left:Math.floor(scrollBarDraggableLeft)+"px",width:Math.floor(scrollBarDraggableWidth)+"px"})},cursor.HorizontalScrollbar.prototype.markupWithParentDivObject=function(horizontalScrollBarContainer){var horizontalScrollBar,horizontalScrollBarShim,horizontalScrollBarDraggable,anyViewport,myself=this,isMouseDown=void 0,lastMouseX=void 0,isMouseIn=void 0;horizontalScrollBarShim=$('<div class="igv-horizontal-scrollbar-shim-div">')[0],horizontalScrollBarContainer.append(horizontalScrollBarShim),anyViewport=$("div.igv-viewport-div").first(),$(horizontalScrollBarShim).css("left",anyViewport.css("left")),$(horizontalScrollBarShim).css("right",anyViewport.css("right")),horizontalScrollBar=$('<div class="igv-horizontal-scrollbar-div">')[0],$(horizontalScrollBarShim).append(horizontalScrollBar),horizontalScrollBarDraggable=$('<div class="igv-horizontal-scrollbar-draggable-div">')[0],$(horizontalScrollBar).append(horizontalScrollBarDraggable),$(document).mousedown(function(e){lastMouseX=e.screenX,isMouseIn=!0}),$(horizontalScrollBarDraggable).mousedown(function(e){isMouseDown=!0}),$(document).mousemove(function(e){var maxRegionPixels,left;isMouseDown&&isMouseIn&&void 0!==lastMouseX&&(left=$(horizontalScrollBarDraggable).position().left,left+=e.screenX-lastMouseX,left=Math.max(0,left),left=Math.min($(horizontalScrollBar).width()-$(horizontalScrollBarDraggable).outerWidth(),left),$(horizontalScrollBarDraggable).css({left:left+"px"}),maxRegionPixels=myself.browser.cursorModel.framePixelWidth*myself.browser.cursorModel.filteredRegions.length,myself.browser.referenceFrame.start=myself.browser.referenceFrame.toBP(left)*(maxRegionPixels/$(horizontalScrollBar).width()),myself.browser.ideoPanel&&myself.browser.ideoPanel.repaint(),myself.browser.karyoPanel&&myself.browser.karyoPanel.repaint(),myself.browser.trackViews.forEach(function(trackPanel){trackPanel.update()}),lastMouseX=e.screenX)}),$(document).mouseup(function(e){isMouseDown=!1,lastMouseX=void 0})},cursor}(cursor||{}),igv=function(igv){function addCursorBrowserExtensions(browser){function frameWidthNumberFormatter(frameWidth){var divisor;return divisor=1>frameWidth?1e3:100>frameWidth?100:10,Math.round(frameWidth*divisor)/divisor}function cursorTrackWithConfig(config,browser){function cursorGetType(path){return path.endsWith(".bed")||path.endsWith(".bed.gz")||path.endsWith(".broadPeak")||path.endsWith(".broadPeak.gz")?"bed":void 0}var path,type,track;return browser.isDuplicateTrack(config)?void 0:(path=config.url,type=config.type,type||(type=cursorGetType(path)),"bed"!==type?void window.alert("Bad Track type"):(track=new cursor.CursorTrack(config,browser),config.designatedTrack&&!0===config.designatedTrack&&(browser.designatedTrack=track),track))}browser.crossDomainProxy="php/simpleProxy.php",browser.loadTrackWithConfigurations=function(configurations){var tracks=[];configurations.forEach(function(configuration){var track=cursorTrackWithConfig(configuration,browser);void 0!==track&&tracks.push(track)}),0!==tracks.length&&(void 0===browser.designatedTrack&&(browser.designatedTrack=tracks[0]),browser.getFeaturesForTracks(tracks,function(){tracks.forEach(function(track){browser.addTrack(track)})}))},browser.initializeWithTrackConfigurations=function(configurations){var tracks=[];configurations.forEach(function(configuration){var track=cursorTrackWithConfig(configuration,browser);void 0!==track&&tracks.push(track)}),0!==tracks.length&&(void 0===browser.designatedTrack&&(browser.designatedTrack=tracks[0]),browser.getFeaturesForTracks(tracks,function(){tracks.forEach(function(track){browser.addTrack(track)}),browser.designatedTrack.featureSource.allFeatures(function(features){var horizontalScrollBarContainer=$("div.igv-horizontal-scrollbar-container-div");browser.horizontalScrollbar=new cursor.HorizontalScrollbar(browser,$(horizontalScrollBarContainer)),browser.cursorModel.setRegions(features),browser.horizontalScrollbar.update()})}))},browser.initializeWithSession=function(session){var tracks;browser.sessionTeardown(),browser.cursorModel.regionWidth=session.regionWidth,$("input[id='regionSizeInput']").val(browser.cursorModel.regionWidth),tracks=[],session.tracks.forEach(function(trackSession){var track,config={type:"bed",url:trackSession.path,color:trackSession.color,label:trackSession.label,order:trackSession.order,trackHeight:trackSession.height,trackFilter:trackSession.trackFilter,designatedTrack:trackSession.designatedTrack};track=cursorTrackWithConfig(config,browser),void 0!==track&&tracks.push(track),config.designatedTrack&&!0===config.designatedTrack&&(browser.designatedTrack=track)}),0!==tracks.length&&(void 0===browser.designatedTrack&&(browser.designatedTrack=tracks[0]),browser.getFeaturesForTracks(tracks,function(){tracks.forEach(function(track){browser.addTrack(track)}),browser.designatedTrack.featureSource.allFeatures(function(features){var horizontalScrollBarContainer=$("div.igv-horizontal-scrollbar-container-div");browser.horizontalScrollbar=new cursor.HorizontalScrollbar(browser,$(horizontalScrollBarContainer)),browser.cursorModel.setRegions(features),browser.setFrameWidth(browser.trackViewportWidth()*session.framePixelWidthUnitless),browser.referenceFrame.bpPerPixel=1/browser.cursorModel.framePixelWidth,browser.fitToScreen(),browser.horizontalScrollbar.update()})}))},browser.session=function(){var dev_null,session={start:Math.floor(browser.referenceFrame.start),end:Math.floor(browser.referenceFrame.bpPerPixel*browser.trackViewportWidth()+browser.referenceFrame.start),regionWidth:browser.cursorModel.regionWidth,framePixelWidthUnitless:browser.cursorModel.framePixelWidth/browser.trackViewportWidth(),tracks:[]};return dev_null=browser.trackViewportWidth(),browser.trackViews.forEach(function(trackView){var jsonRepresentation=trackView.track.jsonRepresentation();jsonRepresentation&&(browser.designatedTrack&&browser.designatedTrack===trackView.track&&(jsonRepresentation.designatedTrack=!0),session.tracks.push(jsonRepresentation))}),JSON.stringify(session,void 0,4)},browser.sessionTeardown=function(){for(var trackView,horizontalScrollBarContainer;this.trackViews.length>0;)trackView=this.trackViews[this.trackViews.length-1],this.removeTrack(trackView.track);horizontalScrollBarContainer=$("div.igv-horizontal-scrollbar-container-div"),$(horizontalScrollBarContainer).empty(),this.horizontalScrollbar=void 0},browser.getFeaturesForTracks=function(tracks,continuation){var trackCount=tracks.length;igv.startSpinnerAtParentElement(browser.div),tracks.forEach(function(track){track.getFeatureCache(function(ignored){--trackCount,0===trackCount&&(igv.stopSpinnerAtParentElement(browser.div),continuation())})})},browser.presentSortStatus=function(trackView){$(trackView.track.sortButton).addClass("igv-control-sort-fa-selected"),$(browser.trackContainerDiv).find("i.fa-signal").each(function(){var me=$(this);1===browser.sortDirection?me.addClass("fa-flip-horizontal"):me.removeClass("fa-flip-horizontal")})},browser.selectDesignatedTrack=function(trackView){var currentDesignatedTrackView,bullseyeInner,bullseyeOuter,trackLabelDiv;browser.designatedTrack&&browser.designatedTrack.trackFilter.trackPanel!==trackView&&(currentDesignatedTrackView=browser.designatedTrack.trackFilter.trackPanel,bullseyeInner=$(currentDesignatedTrackView.trackDiv).find("i.fa-circle"),bullseyeInner.removeClass("igv-control-bullseye-fa-selected"),bullseyeInner.addClass("igv-control-bullseye-fa"),bullseyeOuter=$(currentDesignatedTrackView.trackDiv).find("i.fa-circle-thin"),bullseyeOuter.removeClass("igv-control-bullseye-fa-selected"),trackLabelDiv=$(currentDesignatedTrackView.trackDiv).find("div.igv-track-label-div"),trackLabelDiv.removeClass("igv-track-label-selected-div")),browser.designatedTrack=trackView.track,bullseyeInner=$(trackView.trackDiv).find("i.fa-circle"),bullseyeInner.removeClass("igv-control-bullseye-fa"),bullseyeInner.addClass("igv-control-bullseye-fa-selected"),bullseyeOuter=$(trackView.trackDiv).find("i.fa-circle-thin"),bullseyeOuter.addClass("igv-control-bullseye-fa-selected"),trackLabelDiv=$(trackView.trackDiv).find("div.igv-track-label-div"),trackLabelDiv.addClass("igv-track-label-selected-div")},browser.setFrameWidth=function(frameWidthString){if(!igv.isNumber(frameWidthString))return void console.log("bogus "+frameWidthString);var frameWidth=parseFloat(frameWidthString);frameWidth>0&&(browser.cursorModel.framePixelWidth=frameWidth,browser.referenceFrame.bpPerPixel=1/frameWidth,$("input[id='frameWidthInput']").val(frameWidthNumberFormatter(frameWidth)),browser.update())},browser.setRegionSize=function(regionSizeString){var regionSize=parseFloat(regionSizeString);regionSize>0&&(browser.cursorModel.regionWidth=regionSize,$("input[id='regionSizeInput']").val(browser.cursorModel.regionWidth),browser.cursorModel.filterRegions())},browser.zoomIn=function(){browser.setFrameWidth(2*browser.cursorModel.framePixelWidth),browser.update()},browser.zoomOut=function(){var thresholdFramePixelWidth=browser.trackViewportWidth()/browser.cursorModel.regionsToRender().length;browser.setFrameWidth(Math.max(thresholdFramePixelWidth,.5*browser.cursorModel.framePixelWidth)),browser.update()},browser.fitToScreen=function(){var frameWidth;browser.cursorModel&&browser.cursorModel.regions&&browser.cursorModel.regionsToRender().length>0&&(frameWidth=browser.trackViewportWidth()/browser.cursorModel.regionsToRender().length,browser.referenceFrame.start=0,browser.setFrameWidth(frameWidth))},browser.trackContentWidth=function(){var width;return width=this.trackViews&&this.trackViews.length>0?this.trackViews[0].contentDiv.clientWidth:this.trackContainerDiv.clientWidth},browser.resize=function(){var ratio;browser.horizontalScrollbar?(ratio=browser.cursorModel.framePixelWidth/browser.trackContentWidth(),this.__proto__.resize.call(this),browser.setFrameWidth(ratio*browser.trackContentWidth()),browser.horizontalScrollbar.update()):this.__proto__.resize.call(this)},browser.removeTrack=function(track){this.__proto__.removeTrack.call(this,track),track===this.designatedTrack&&(this.designatedTrack=void 0),this.cursorModel.filterRegions()}}function addCursorTrackViewExtensions(browser){igv.TrackView.prototype.viewportCreationHelper=function(viewportDiv){},igv.TrackView.prototype.leftHandGutterCreationHelper=function(leftHandGutter){var trackFilterButtonDiv,trackLabelDiv,sortButton,bullseyeStackSpan,bullseyeOuterIcon,bullseyeInnerIcon,trackView=this,track=trackView.track;trackLabelDiv=$('<div class="igv-track-label-div">')[0],trackLabelDiv.innerHTML=track.label,trackLabelDiv.title=track.label,$(trackView.leftHandGutter).append(trackLabelDiv),track.trackLabelDiv=trackLabelDiv,bullseyeStackSpan=document.createElement("span"),$(trackView.leftHandGutter).append($(bullseyeStackSpan)),bullseyeStackSpan.className="fa-stack igv-control-bullseye-stack-fa",track.bullseyeStackSpan=bullseyeStackSpan,bullseyeOuterIcon=document.createElement("i"),bullseyeStackSpan.appendChild(bullseyeOuterIcon),bullseyeOuterIcon.className="fa fa-stack-2x fa-circle-thin",bullseyeInnerIcon=document.createElement("i"),bullseyeStackSpan.appendChild(bullseyeInnerIcon),bullseyeInnerIcon.className="fa fa-stack-1x fa-circle igv-control-bullseye-fa",bullseyeStackSpan.onclick=function(){browser.designatedTrack&&browser.designatedTrack===trackView.track||(browser.selectDesignatedTrack(trackView),browser.cursorModel&&browser.designatedTrack.featureSource.allFeatures(function(featureList){browser.referenceFrame.start=0,browser.cursorModel.setRegions(featureList)}))},trackFilterButtonDiv=document.createElement("div"),$(trackView.leftHandGutter).append($(trackFilterButtonDiv)),trackFilterButtonDiv.className="igv-track-filter-button-div",trackView.track.trackFilter=new igv.TrackFilter(trackView),trackView.track.trackFilter.createTrackFilterWidgetWithParentElement(trackFilterButtonDiv),browser.sortDirection=void 0,browser.sortTrack=void 0,sortButton=document.createElement("i"),$(trackView.leftHandGutter).append($(sortButton)),sortButton.className="fa fa-signal igv-control-sort-fa fa-flip-horizontal",track.sortButton=sortButton,sortButton.onclick=function(){browser.sortTrack===track?browser.sortDirection=void 0===browser.sortDirection?1:-1*browser.sortDirection:(browser.sortTrack=track,void 0===browser.sortDirection&&(browser.sortDirection=1)),browser.cursorModel.sortRegions(track.featureSource,browser.sortDirection,function(regions){
|
4
|
+
browser.update(),browser.trackViews.forEach(function(tp){1===browser.sortDirection?$(tp.track.sortButton).addClass("fa-flip-horizontal"):$(tp.track.sortButton).removeClass("fa-flip-horizontal"),track===tp.track?$(tp.track.sortButton).addClass("igv-control-sort-fa-selected"):$(tp.track.sortButton).removeClass("igv-control-sort-fa-selected")})})}},igv.TrackView.prototype.rightHandGutterCreationHelper=function(trackManipulationIconBox){var removeButton,myself=this;$(trackManipulationIconBox).append($('<i class="fa fa-chevron-circle-up igv-track-menu-move-up">')[0]),$(trackManipulationIconBox).append($('<i class="fa fa-chevron-circle-down igv-track-menu-move-down">')[0]),$(trackManipulationIconBox).find("i.fa-chevron-circle-up").click(function(){myself.browser.reduceTrackOrder(myself)}),$(trackManipulationIconBox).find("i.fa-chevron-circle-down").click(function(){myself.browser.increaseTrackOrder(myself)}),removeButton=$('<i class="fa fa-times igv-track-menu-discard">')[0],$(trackManipulationIconBox).append(removeButton),$(removeButton).click(function(){myself.browser.removeTrack(myself.track)})},igv.TrackView.prototype.repaint=function(){function Tile(chr,tileStart,tileEnd,scale,image){this.chr=chr,this.startBP=tileStart,this.endBP=tileEnd,this.scale=scale,this.image=image}if(this.track&&this.browser&&this.browser.referenceFrame){var tileWidth,tileStart,tileEnd,buffer,ctx,myself=this,referenceFrame=this.browser.referenceFrame,refFrameStart=referenceFrame.start,refFrameEnd=refFrameStart+referenceFrame.toBP(this.canvas.width);if(!this.tile||!this.tile.containsRange(referenceFrame.chr,refFrameStart,refFrameEnd,referenceFrame.bpPerPixel))if(myself.currentTask&&!myself.currentTask.complete&&myself.currentTask.end>=refFrameEnd&&myself.currentTask.start<=refFrameStart);else if(myself.currentTask&&(myself.currentTask.complete||myself.currentTask.abort(),myself.currentTask=null),myself.currentTask={canceled:!1,chr:referenceFrame.chr,start:tileStart,end:tileEnd,abort:function(){this.canceled=!0,this.xhrRequest&&this.xhrRequest.abort()}},buffer=document.createElement("canvas"),buffer.width=3*this.canvas.width,buffer.height=this.canvas.height,ctx=buffer.getContext("2d"),tileWidth=Math.round(referenceFrame.toBP(buffer.width)),tileStart=Math.max(0,Math.round(referenceFrame.start-tileWidth/3)),tileEnd=tileStart+tileWidth,myself.track.draw(ctx,referenceFrame,tileStart,tileEnd,buffer.width,buffer.height,function(task){myself.currentTask&&myself.currentTask.canceled||(myself.tile=new Tile(referenceFrame.chr,tileStart,tileEnd,referenceFrame.bpPerPixel,buffer),myself.paintImage()),myself.currentTask=void 0},myself.currentTask),myself.track.paintControl){var buffer2=document.createElement("canvas");buffer2.width=this.controlCanvas.width,buffer2.height=this.controlCanvas.height;var ctx2=buffer2.getContext("2d");myself.track.paintControl(ctx2,buffer2.width,buffer2.height),myself.controlCtx.drawImage(buffer2,0,0)}this.tile&&this.tile.chr===referenceFrame.chr?this.paintImage():this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),Tile.prototype.containsRange=function(chr,start,end,scale){var hit=this.scale==scale&&start>=this.startBP&&end<=this.endBP&&chr===this.chr;return hit}}}}return igv.createCursorBrowser=function(options){function configureTrackWithLocalFileOrPath(config){0===igv.browser.trackViews.length?(config.designatedTrack=!0,igv.browser.initializeWithTrackConfigurations([config])):igv.browser.loadTrackWithConfigurations([config])}var horizontalScrollBarContainer,contentHeader,trackContainer,browser,thang;document.getElementById("zoomOut").onclick=function(e){browser.zoomOut()},document.getElementById("zoomIn").onclick=function(){browser.zoomIn()},document.getElementById("fitToScreen").onclick=function(){browser.fitToScreen()},document.getElementById("regionSizeInput").onchange=function(e){var value=$("#regionSizeInput").val();return igv.isNumber(value)?void browser.setRegionSize(parseFloat(value,10)):void console.log("bogus "+value)},document.getElementById("frameWidthInput").onchange=function(e){var value=$("input[id='frameWidthInput']").val();return igv.isNumber(value)?void browser.setFrameWidth(parseFloat(value,10)):void console.log("bogus "+value)},document.getElementById("trackHeightInput").onchange=function(e){var value=$("#trackHeightInput").val();return igv.isNumber(value)?void browser.setTrackHeight(Math.round(parseFloat(value,10))):void console.log("bogus "+value)},$("#igvExportRegionsModalForm").submit(function(event){var exportedRegions="",downloadInput=$("#igvExportRegionsModalForm").find('input[name="downloadContent"]');browser.cursorModel.filteredRegions.forEach(function(region){exportedRegions+=region.exportRegion(browser.cursorModel.regionWidth)}),downloadInput.val(exportedRegions),$("#igvExportRegionsModal").modal("hide")}),$("#igvSaveSessionModalForm").submit(function(event){var session,downloadInput;session=browser.session(),downloadInput=$("#igvSaveSessionModalForm").find('input[name="downloadContent"]'),downloadInput.val(session),$("#igvSaveSessionModal").modal("hide")});var sessionInput=document.getElementById("igvSessionLoad");sessionInput.addEventListener("change",function(e){var sessionFile,fileReader=new FileReader;sessionFile=sessionInput.files[0],fileReader.onload=function(e){var json=e.target.result,session=JSON.parse(json);$("#igvSessionLoad").val(""),$("#igvSessionLoadModal").modal("hide"),browser.initializeWithSession(session)},fileReader.readAsText(sessionFile)}),document.getElementById("igvFileUpload").onchange=function(e){var localFile=$(this)[0].files[0];configureTrackWithLocalFileOrPath({type:"bed",localFile:localFile,label:localFile.name}),$(this).val(""),$("#igvFileUploadModal").modal("hide")},document.getElementById("igvLoadURL").onchange=function(e){var path=$(this).val();configureTrackWithLocalFileOrPath({type:"bed",url:path,label:igv.browser.trackLabelWithPath(path)}),$(this).val(""),$("#igvLoadURLModal").modal("hide")},encode.createEncodeDataTablesDataSet("resources/peaks.hg19.txt",function(dataSet){var encodeModalTable=$("#encodeModalTable"),myDataTable=encodeModalTable.dataTable({data:dataSet,scrollY:"400px",scrollCollapse:!0,paging:!1,columns:[{title:"cell"},{title:"dataType"},{title:"antibody"},{title:"view"},{title:"replicate"},{title:"type"},{title:"lab"},{title:"path"}]});encodeModalTable.find("tbody").on("click","tr",function(){$(this).hasClass("selected")?$(this).removeClass("selected"):$(this).addClass("selected")}),$("#encodeModalTopCloseButton").on("click",function(){myDataTable.$("tr.selected").removeClass("selected")}),$("#encodeModalBottomCloseButton").on("click",function(){myDataTable.$("tr.selected").removeClass("selected")}),$("#encodeModalGoButton").on("click",function(){var tableRow,tableRows,tableCell,tableCells,record={},configurations=[];if(tableRows=myDataTable.$("tr.selected"),0<tableRows.length){tableRows.removeClass("selected");for(var i=0;i<tableRows.length;i++)tableRow=tableRows[i],tableCells=$("td",tableRow),tableCells.each(function(){var key,val,index;tableCell=$(this)[0],index=tableCell.cellIndex,key=encode.dataTableRowLabels[index],val=tableCell.innerHTML,record[key]=val}),configurations.push({type:"bed",url:record.path,label:encode.encodeTrackLabel(record),color:encode.encodeAntibodyColor(record.antibody)});0===browser.trackViews.length?(configurations[0].designatedTrack=!0,igv.browser.initializeWithTrackConfigurations(configurations)):igv.browser.loadTrackWithConfigurations(configurations)}})}),$("#encodeModalBody").html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="encodeModalTable"></table>'),trackContainer=$('<div id="igvTrackContainerDiv" class="igv-track-container-div">')[0],browser=new igv.Browser(options,trackContainer),browser.div.appendChild(igv.spinner()),igv.stopSpinnerAtParentElement(browser.div),document.getElementById("igvContainerDiv").appendChild(browser.div),contentHeader=$('<div class="row"></div>')[0],$(browser.div).append(contentHeader),horizontalScrollBarContainer=$('<div class="igv-horizontal-scrollbar-container-div">')[0],$(browser.div).append(horizontalScrollBarContainer),thang=$('<div class="igv-utility-div">'),$(browser.div).append(thang[0]),thang.append($('<div class="igv-control-panel-header-div">Track Summary</div>')[0]),$(browser.div).append(trackContainer),igv.addAjaxExtensions(),addCursorBrowserExtensions(browser),addCursorTrackViewExtensions(browser),browser.cursorModel=new cursor.CursorModel(browser),browser.referenceFrame=new igv.ReferenceFrame("",0,1/browser.cursorModel.framePixelWidth),browser.highlightColor="rgb(204, 51, 0)";var sessionJSONPath=igv.getQueryValue("session");if(sessionJSONPath)$.getJSON(sessionJSONPath,function(session){console.log("launchSession: "+JSON.stringify(session)),browser.initializeWithSession(session)});else{if(void 0===options.tracks||0===options.tracks.length)return;browser.initializeWithTrackConfigurations(options.tracks)}return browser},igv}(igv||{}),igv=function(igv){return igv.DataLoader=function(url){this.url=url},igv.DataLoader.prototype.loadBinaryString=function(continuation,task){if(this.url.endsWith(".gz"))this.loadArrayBuffer(function(data){for(var inflate=new Zlib.Gunzip(new Uint8Array(data)),plain=inflate.decompress(),result="",i=0,len=plain.length;len>i;i++)result+=String.fromCharCode(plain[i]);continuation(result)},task);else{var loader=this,oReq=new XMLHttpRequest;if(task&&(task.xhrRequest=oReq),oReq.open("GET",this.url),this.range){var rangeEnd=this.range.start+this.range.size-1;oReq.setRequestHeader("Range","bytes="+this.range.start+"-"+rangeEnd),oReq.setRequestHeader("Cache-control","no-cache"),oReq.setRequestHeader("If-None-Match",Math.random().toString(36))}oReq.overrideMimeType("text/plain; charset=x-user-defined"),oReq.onload=function(event){loader.status=oReq.status;var data=oReq.responseText;continuation(data)},oReq.onerror=function(event){console.log("Error: "+event),continuation(null)},oReq.ontimeout=function(event){},oReq.send()}},igv.DataLoader.prototype.loadArrayBuffer=function(continuation,task){var oReq=new XMLHttpRequest;if(task&&(task.xhrRequest=oReq),oReq.open("GET",this.url),this.range){var rangeEnd=this.range.start+this.range.size-1;oReq.setRequestHeader("Range","bytes="+this.range.start+"-"+rangeEnd),oReq.setRequestHeader("Cache-control","no-cache"),oReq.setRequestHeader("If-None-Match",Math.random().toString(36))}oReq.responseType="arraybuffer";var loader=this;oReq.onload=function(event){loader.status=oReq.status;var arrayBuffer=oReq.response;continuation(arrayBuffer)},oReq.onerror=function(event){loader.onerror?loader.onerror(event):continuation(null)},oReq.ontimeout=function(event){},oReq.onabort=function(event){console.log("Aborted"),continuation(null)},oReq.send()},igv.DataLoader.prototype.loadHeader=function(continuation){function parseResponseHeaders(headerStr){var headers={};if(!headerStr)return headers;for(var headerPairs=headerStr.split("\r\n"),i=0,len=headerPairs.length;len>i;i++){var headerPair=headerPairs[i],index=headerPair.indexOf(": ");if(index>0){var key=headerPair.substring(0,index),val=headerPair.substring(index+2);headers[key]=val}}return headers}var loader=this,oReq=new XMLHttpRequest;oReq.open("HEAD",this.url),oReq.onload=function(event){loader.status=oReq.status;var headerStr=oReq.getAllResponseHeaders(),headerDictionary=parseResponseHeaders(headerStr);continuation(headerDictionary)},oReq.onerror=function(event){console.log("XMLHttpRequest - Error loading"+loader.url),loader.onerror?loader.onerror(event):continuation(null)},oReq.ontimeout=function(event){},oReq.send()},igv.DataLoader.prototype.getContentLength=function(continuation){var loader=this;loader.onerror=function(){continuation(-1)},loader.loadHeader(function(header){var contentLengthString=header?header["Content-Length"]:null;continuation(contentLengthString?parseInt(contentLengthString):-1)})},igv.loadData=function(url,callback,range){var loader=new igv.DataLoader(url);range&&(loader.range=range),loader.loadBinaryString(callback)},createCORSRequest=function(url){var xhr=new XMLHttpRequest;return"withCredentials"in xhr?xhr.open("GET",url,!0):"undefined"!=typeof XDomainRequest?(xhr=new XDomainRequest,xhr.open(method,url)):xhr=null,xhr},igv}(igv||{}),encode=function(encode){var antibodyColors={H3K27AC:"rgb(200, 0, 0)",H3K27ME3:"rgb(130, 0, 4)",H3K36ME3:"rgb(0, 0, 150)",H3K4ME1:"rgb(0, 150, 0)",H3K4ME2:"rgb(0, 150, 0)",H3K4ME3:"rgb(0, 150, 0)",H3K9AC:"rgb(100, 0, 0)",H3K9ME1:"rgb(100, 0, 0)"};return parseEncodeTableFile=function(file,continuation){var dataLoader=new igv.DataLoader(file);dataLoader.loadBinaryString(function(data){var path,lines=data.splitLines(),dataSet=[];encode.dataTableRowLabels=lines[0].split(" "),encode.dataTableRowLabels.pop(),path=encode.dataTableRowLabels.shift(),encode.dataTableRowLabels.push(path),lines.slice(1,lines.length-1).forEach(function(line){var tokens,row=[];tokens=line.split(" "),tokens.pop(),path=tokens.shift(),tokens.push(path),tokens.forEach(function(token,index,tks){row.push(void 0===token||""===token?"-":token)}),dataSet.push(row)}),continuation(dataSet)})},encode.createEncodeDataTablesDataSet=function(file,continuation){parseEncodeTableFile(file,function(dataSet){continuation&&continuation(dataSet)})},encode.encodeTrackLabel=function(record){return record.antibody?record.antibody+" "+record.cell+" "+record.replicate:record.cell+record.dataType+" "+record.view+" "+record.replicate},encode.encodeAntibodyColor=function(antibody){var key;return antibody&&""!==antibody?(key=antibody.toUpperCase(),antibodyColors[key]?antibodyColors[key]:cursor.defaultColor()):cursor.defaultColor()},encode}(encode||{}),igv=function(igv){return igv.FastaSequence=function(file,indexFile){indexFile||(indexFile=file+".fai"),this.file=file,this.indexFile=indexFile},igv.FastaSequence.prototype.getSequence=function(chr,start,end,continuation,task){function getSequenceFromInterval(interval,start,end){var offset=start-interval.start,n=end-start,seq=interval.features?interval.features.substr(offset,n):null;return seq}var myself=this,interval=myself.interval;if(interval&&interval.contains(chr,start,end))continuation(getSequenceFromInterval(interval,start,end));else{var qstart=start,qend=end;if(1e5>end-start){var w=end-start,center=Math.round(start+w/2);qstart=Math.max(0,center-5e4),qend=center+5e4}this.readSequence(chr,qstart,qend,function(seqBytes){myself.interval=new igv.GenomicInterval(chr,qstart,qend,seqBytes),continuation(getSequenceFromInterval(myself.interval,start,end))},task)}},igv.FastaSequence.prototype.loadIndex=function(continuation){var sequence=this;igv.loadData(this.indexFile,function(data){var lines=data.splitLines(),len=lines.length,lineNo=0;for(sequence.chromosomeNames=[],sequence.index={};len>lineNo;){var tokens=lines[lineNo++].split(" "),nTokens=tokens.length;if(5==nTokens){var chr=tokens[0],size=parseInt(tokens[1]),position=parseInt(tokens[2]),basesPerLine=parseInt(tokens[3]),bytesPerLine=parseInt(tokens[4]),indexEntry={size:size,position:position,basesPerLine:basesPerLine,bytesPerLine:bytesPerLine};sequence.chromosomeNames.push(chr),sequence.index[chr]=indexEntry}}continuation&&continuation(sequence.index)})},igv.FastaSequence.prototype.readSequence=function(chr,qstart,qend,continuation,task){var fasta=this;if(this.index){var idxEntry=this.index[chr];if(idxEntry){var start=Math.max(0,qstart),end=Math.min(idxEntry.size,qend),bytesPerLine=idxEntry.bytesPerLine,basesPerLine=idxEntry.basesPerLine,position=idxEntry.position,nEndBytes=bytesPerLine-basesPerLine,startLine=Math.floor(start/basesPerLine),endLine=Math.floor(end/basesPerLine),base0=startLine*basesPerLine,offset=start-base0,startByte=position+startLine*bytesPerLine+offset,base1=endLine*basesPerLine,offset1=end-base1,endByte=position+endLine*bytesPerLine+offset1-1,byteCount=endByte-startByte+1;if(0>=byteCount)return;var dataLoader=new igv.DataLoader(fasta.file);dataLoader.range={start:startByte,size:byteCount},dataLoader.loadBinaryString(function(allBytes){var nBases,seqBytes="",srcPos=0,desPos=0,allBytesLength=allBytes.length;for(offset>0&&(nBases=Math.min(end-start,basesPerLine-offset),seqBytes+=allBytes.substr(srcPos,nBases),srcPos+=nBases+nEndBytes,desPos+=nBases);allBytesLength>srcPos;)nBases=Math.min(basesPerLine,allBytesLength-srcPos),seqBytes+=allBytes.substr(srcPos,nBases),srcPos+=nBases+nEndBytes,desPos+=nBases;continuation(seqBytes)},task)}else console.log("No index entry for chr: "+chr),fasta.interval=new igv.GenomicInterval(chr,qstart,qend,null),continuation(null)}else this.loadIndex(function(){fasta.readSequence(chr,qstart,qend,continuation,task)})},igv}(igv||{}),igv=function(igv){function getParser(type){return new igv.FeatureParser(type)}return igv.AneuFeatureSource=function(config,thefilename){this.config=config||{};var getPath=function(urlorfile){var last=urlorfile.lastIndexOf("/"),path=urlorfile.substring(0,last+1);return path};if(config.localFile){var path=getPath(config.localFile.name);this.localFile=config.localFile,this.filename=path+thefilename}else{var path=getPath(config.url);this.url=path+thefilename,this.filename=thefilename,this.headURL=config.headURL||this.filename}this.type=config.type?config.type:igv.inferFileType(this.filename),this.parser=getParser(this.type)},igv.AneuFeatureSource.prototype.getFeatures=function(chr,bpStart,bpEnd,success,task){var myself=this,range=new igv.GenomicInterval(chr,bpStart,bpEnd),featureCache=this.featureCache;if(featureCache&&(void 0===featureCache.range||featureCache.range.containsRange(range))){var features=this.featureCache.queryFeatures(chr,bpStart,bpEnd);success(features)}else this.loadFeatures(function(featureList){myself.featureCache=new igv.FeatureCache(featureList);var features=myself.featureCache.queryFeatures(chr,bpStart,bpEnd);success(features)},task,range)},igv.AneuFeatureSource.prototype.allFeatures=function(success){this.getFeatureCache(function(featureCache){success(featureCache.allFeatures())})},igv.AneuFeatureSource.prototype.getFeatureCache=function(success){var myself=this;this.featureCache?success(this.featureCache):this.loadFeatures(function(featureList){myself.featureCache=new igv.FeatureCache(featureList),success(myself.featureCache)})},igv.AneuFeatureSource.prototype.loadFeatures=function(success,task,range){var myself=this,parser=myself.parser,options={headers:myself.config.headers,tokens:myself.config.tokens,success:function(data){myself.header=parser.parseHeader(data);var features=parser.parseFeatures(data);success(features)},error:function(msg){console.log("Error loading: "+msg)},task:task};myself.localFile?igvxhr.loadStringFromFile(myself.localFile,options):igvxhr.loadString(myself.url,options)},igv}(igv||{}),igv=function(igv){var debug=!1,log=function(msg){if(debug){var d=new Date,time=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();"undefined"!=typeof copy&©(msg),"undefined"!=typeof console&&console.log("AneuTrack: "+time+" "+msg)}},sortDirection=1;return igv.AneuTrack=function(config){igv.configTrack(this,config),this.maxHeight=config.maxHeight-2||500,this.sampleSquishHeight=config.sampleSquishHeight||20,this.sampleExpandHeight=config.sampleExpandHeight||125,this.sampleHeight=this.sampleExpandHeight,this.highColor=config.highColor||"rgb(30,30,255)",this.lowColor=config.lowColor||"rgb(220,0,0)",this.midColor=config.midColor||"rgb(150,150,150)",this.posColorScale=config.posColorScale||new igv.GradientColorScale({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=config.negColorScale||new igv.GradientColorScale({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),this.sampleCount=0,this.samples={},this.sampleNames=[],log("AneuTrack: config: "+JSON.stringify(config));this.config=config},igv.AneuTrack.prototype.popupMenuItems=function(popover){return[]},igv.AneuTrack.prototype.getSummary=function(chr,bpStart,bpEnd,continuation,task){var filtersummary=function(redlinedata){var summarydata=[];for(i=0,len=redlinedata.length;i<len;i++){var feature=redlinedata[i];Math.abs(feature.score-2)>.5&&feature.end-feature.start>5e6&&summarydata.push(feature)}continuation(summarydata)};this.featureSourceRed?this.featureSourceRed.getFeatures(chr,bpStart,bpEnd,filtersummary,task):(log("Aneu track has no summary data yet"),continuation(null))},igv.AneuTrack.prototype.loadSummary=function(chr,bpStart,bpEnd,continuation,task){var me=this;if(!this.featureSourceRed){var afterJsonLoaded=function(json){json&&(json=JSON.parse(json),me.featureSourceRed=new igv.AneuFeatureSource(config,json.redline),me.getSummary(chr,bpStart,bpEnd,continuation,task))};afterload={headers:me.config.headers,tokens:me.config.tokens,success:afterJsonLoaded};var config=me.config;return config.localFile?igvxhr.loadStringFromFile(config.localFile,afterload):igvxhr.loadString(config.url,afterload),null}this.featureSourceRed.getFeatures(chr,bpStart,bpEnd,continuation,task)},igv.AneuTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){var me=this;if(this.featureSourceRed){var loadsecondfile=function(redlinedata){me.redlinedata=redlinedata,me.featureSource.getFeatures(chr,bpStart,bpEnd,continuation,task)};this.featureSourceRed.getFeatures(chr,bpStart,bpEnd,loadsecondfile,task)}else{log("Data is not loaded yet. Loading json first");var afterJsonLoaded=function(json){json=JSON.parse(json),log("Got json: "+json+", diff :"+json.diff),me.featureSource=new igv.AneuFeatureSource(config,json.diff),me.featureSourceRed=new igv.AneuFeatureSource(config,json.redline),me.getFeatures(chr,bpStart,bpEnd,continuation,task)};afterload={headers:me.config.headers,tokens:me.config.tokens,success:afterJsonLoaded};var config=me.config;config.localFile?igvxhr.loadStringFromFile(config.localFile,afterload):igvxhr.loadString(config.url,afterload)}},igv.AneuTrack.prototype.getColor=function(value){var expected=2;return color=expected>value?this.lowColor:value>expected?this.highColor:this.midColor,color},igv.AneuTrack.prototype.paintControl=function(ctx,pixelWidth,pixelHeight){function computeH(min,max,value,maxpixels){return maxpixels-Math.round((value-min)/max*maxpixels)}var track=this,font=((track.maxLogP-track.minLogP)/pixelHeight,{font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"});igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:"rgb(255, 255, 255)"});var max=track.max;max||(max=8);var min=0,x=49;igv.Canvas.strokeLine.call(ctx,x,computeH(min,max,0,track.maxheight),x,computeH(min,max,max,track.maxheight),font),x-=5;for(var p=0;max>=p;p+=1){var h=computeH(min,max,p,track.maxheight);igv.Canvas.strokeLine.call(ctx,x,h,x+5,h,font),p>0&&max>p&&igv.Canvas.fillText.call(ctx,p,x-4,h+3,font)}font.textAlign="center",igv.Canvas.fillText.call(ctx,"ploidy",x-15,pixelHeight/2,font,{rotate:{angle:-90}})},igv.AneuTrack.prototype.draw=function(options){function computeH(min,max,value,maxpixels){return maxpixels-Math.round((value-min)/max*maxpixels)}function checkForLog(featureList){var i;if(void 0===myself.isLog)for(myself.isLog=!1,i=0;i<featureList.length;i++)if(featureList[i].value<0)return void(myself.isLog=!0)}var canvas,bpPerPixel,bpStart,pixelWidth,pixelHeight,bpEnd,segment,len,sample,i,y,color,value,px,px1,pw,xScale,myself=this;canvas=options.context,ctx=options.context,pixelWidth=options.pixelWidth,pixelHeight=options.pixelHeight;var max=4,min=0,PLOIDYMAX=10;igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:"rgb(255, 255, 255)"});var track=this;window.track=track;var computeMinMax=function(featureList){for(i=0,len=featureList.length;len>i;i++){sample=featureList[i].sample;var value=featureList[i].value;value>max&&(max=value),min>value&&(min=value)}max>PLOIDYMAX&&(max=PLOIDYMAX),min=Math.max(min,0),track.max=max},drawFeatureList=function(ctx,featureList,debug){for(bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,bpEnd=bpStart+pixelWidth*bpPerPixel+1,xScale=bpPerPixel,i=0,len=featureList.length;len>i;i++)sample=featureList[i].sample,sample&&this.samples&&this.samples.hasOwnProperty(sample)&&(this.samples[sample]=myself.sampleCount,this.sampleNames.push(sample),this.sampleCount++);checkForLog(featureList);var expected=2;myself.isLog&&(min=0,expected=0);var maxheight=myself.height-4;myself.maxheight=maxheight;var len=featureList.length;for(i=0;len>i;i++)if(segment=featureList[i],!(segment.end<bpStart)){if(segment.start>bpEnd)break;if(segment.sample?(y=myself.samples[segment.sample]*myself.sampleHeight,log("Got sample y="+y)):y=0,value=segment.score,color=myself.midColor,myself.isLog?(value=Math.log2(value/2),expected-.1>value?color=myself.negColorScale.getColor(value):value>expected+.1&&(color=myself.posColorScale.getColor(value))):expected-.2>value?color=myself.lowColor:value>expected+.2&&(color=myself.highColor),px=Math.round((segment.start-bpStart)/xScale),px1=Math.round((segment.end-bpStart)/xScale),pw=Math.max(2,px1-px),max>=value){var h=computeH(min,max,value,maxheight);1==debug&&log(" Got value "+value+", h="+h+", y+h="+(y+h)+", px="+px+", px1="+px1+", pw="+pw+", color="+color+", maxh="+maxheight),igv.Canvas.fillRect.call(ctx,px,y+h,pw,2,{fillStyle:color})}}},maxheight=myself.height-4,font={font:"normal 10px Arial",textAlign:"right",strokeStyle:"rgb(150,150,150)",fillStyle:"rgb(150,150,150)"};if(options.features&&computeMinMax(options.features),this.redlinedata&&computeMinMax(this.redlinedata),2>min&&max>2){var mid=computeH(min,max,2,maxheight);console.log("drawing dashed line and solid line at "+mid+" to "+pixelWidth),igv.Canvas.dashedLine.call(ctx,20,mid,pixelWidth,mid,4,font);var zero=computeH(min,max,0,maxheight);igv.Canvas.strokeLine.call(ctx,20,zero,pixelWidth,zero,font)}else log("NOT drawing line at 2");options.features?drawFeatureList(ctx,options.features,!1):console.log("No diff feature list. options="+JSON.stringify(options)),this.redlinedata?drawFeatureList(ctx,this.redlinedata,!1):console.log("No redline feature list")},igv.AneuTrack.prototype.computePixelHeight=function(features){for(i=0,len=features.length;i<len;i++)sample=features[i].sample,this.samples&&!this.samples.hasOwnProperty(sample)&&(this.samples[sample]=this.sampleCount,this.sampleNames.push(sample),this.sampleCount++);this.sampleCount=Math.max(1,this.sampleCount);var h=Math.max(30,this.sampleCount*this.sampleHeight);return this.height=h,h},igv.AneuTrack.prototype.sortSamples=function(chr,bpStart,bpEnd,direction,callback){var segment,min,max,f,i,s,sampleNames,myself=this,len=bpEnd-bpStart,scores={};this.featureSource.getFeatures(chr,bpStart,bpEnd,function(featureList){for(i=0,len=featureList.length;len>i;i++)if(segment=featureList[i],!(segment.end<bpStart)){if(segment.start>bpEnd)break;min=Math.max(bpStart,segment.start),max=Math.min(bpEnd,segment.end),f=(max-min)/len,s=scores[segment.sample],s||(s=0),scores[segment.sample]=s+f*segment.value}for(sampleNames=Object.keys(myself.samples),sampleNames.sort(function(a,b){var s1=scores[a],s2=scores[b];return s1||(s1=Number.MAX_VALUE),s2||(s2=Number.MAX_VALUE),s1==s2?0:s1>s2?direction:-1*direction}),i=0;i<sampleNames.length;i++)myself.samples[sampleNames[i]]=i;myself.sampleNames=sampleNames,callback()})},igv.AneuTrack.prototype.altClick=function(genomicLocation,event){var refFrame=igv.browser.referenceFrame,bpWidth=refFrame.toBP(2.5),bpStart=genomicLocation-bpWidth,bpEnd=genomicLocation+bpWidth,chr=refFrame.chr,track=this;this.sortSamples(chr,bpStart,bpEnd,sortDirection,function(){track.trackView.update()}),sortDirection*=-1},igv.AneuTrack.prototype.popupData=function(genomicLocation,xOffset,yOffset){var sampleName,items,row=Math.floor(yOffset/this.sampleHeight);if(log("popupData for row "+row+", sampleNames="+JSON.stringify(this.sampleNames)),row<this.sampleNames.length){if(sampleName=this.sampleNames[row],items=sampleName?[{name:"Sample",value:sampleName}]:[],this.featureSource.featureCache){var chr=igv.browser.referenceFrame.chr,featureList=this.featureSource.featureCache.queryFeatures(chr,genomicLocation,genomicLocation);featureList.forEach(function(f){f.sample===sampleName&&(items.push({name:"Value",value:f.value}),items.push({name:"Start",value:f.start}),items.push({name:"End",value:f.end}))})}if(this.featureSourceRed.featureCache){var chr=igv.browser.referenceFrame.chr,featureList=this.featureSourceRed.featureCache.queryFeatures(chr,genomicLocation,genomicLocation);featureList.forEach(function(f){f.sample===sampleName&&(items.push({name:"Value",value:f.value}),items.push({name:"Start",value:f.start}),items.push({name:"End",value:f.end}))})}return items}return null},igv}(igv||{}),igv=function(igv){function buildTreeMap(featureList){var featureCache={},chromosomes=[],treeMap={},genome=igv.browser?igv.browser.genome:null;if(featureList)for(featureList.forEach(function(feature){var geneList,chr=feature.chr;genome&&(chr=genome.getChromosomeName(chr)),geneList=featureCache[chr],geneList||(chromosomes.push(chr),geneList=[],featureCache[chr]=geneList),geneList.push(feature)}),i=0;i<chromosomes.length;i++)chr=chromosomes[i],treeMap[chr]=buildIntervalTree(featureCache[chr]);return treeMap}function buildIntervalTree(featureList){var i,e,iStart,iEnd,tree,chunkSize,len,subArray;for(tree=new igv.IntervalTree,len=featureList.length,chunkSize=Math.max(10,Math.round(len/100)),featureList.sort(function(f1,f2){return f1.start===f2.start?0:f1.start>f2.start?1:-1}),i=0;len>i;i+=chunkSize)e=Math.min(len,i+chunkSize),subArray=featureList.slice(i,e),iStart=subArray[0].start,iEnd=iStart,subArray.forEach(function(feature){iEnd=Math.max(iEnd,feature.end)}),tree.insert(iStart,iEnd,subArray);return tree}return igv.FeatureCache=function(featureList,range){this.treeMap=buildTreeMap(featureList),this.range=range},igv.FeatureCache.prototype.queryFeatures=function(chr,start,end){var featureList,intervalFeatures,feature,len,i,tree,intervals;return(tree=this.treeMap[chr])?(intervals=tree.findOverlapping(start,end),0==intervals.length?[]:(featureList=[],intervals.forEach(function(interval){for(intervalFeatures=interval.value,len=intervalFeatures.length,i=0;len>i&&(feature=intervalFeatures[i],!(feature.start>end));i++)feature.end>=start&&featureList.push(feature)}),featureList)):[]},igv.FeatureCache.prototype.allFeatures=function(){var allFeatures=[],treeMap=this.treeMap;if(treeMap)for(var key in treeMap)if(treeMap.hasOwnProperty(key)){var tree=treeMap[key];tree.mapIntervals(function(interval){allFeatures=allFeatures.concat(interval.value)})}return allFeatures},igv}(igv||{}),igv=function(igv){function getParser(type,decode){return"vcf"===type?new igv.VcfParser:"seg"===type?new igv.SegParser:new igv.FeatureParser(type,decode)}function isIndexable(){var configIndexURL=this.config.indexURL,type=this.type,configIndexed=this.config.indexed;return configIndexURL||"wig"!=type&&0!=configIndexed}function loadIndex(continuation){var idxFile=this.indexURL;this.url.endsWith(".gz")?(idxFile||(idxFile=this.url+".tbi"),igv.loadBamIndex(idxFile,this.config,continuation,!0)):(idxFile||(idxFile=this.url+".idx"),igv.loadTribbleIndex(idxFile,this.config,continuation))}function loadFeaturesNoIndex(continuation,task){var parser=this.parser,self=this,options={headers:this.config.headers,success:function(data){self.header=parser.parseHeader(data),continuation(parser.parseFeatures(data))},task:task};this.localFile?igvxhr.loadStringFromFile(this.localFile,options):igvxhr.loadString(this.url,options)}return igv.FeatureFileReader=function(config){this.config=config||{},config.localFile?(this.localFile=config.localFile,this.filename=config.localFile.name):(this.url=config.url,this.filename=config.url,this.indexURL=config.indexURL,this.headURL=config.headURL||this.filename),this.type=config.type?config.type:igv.inferFileType(this.filename),this.parser=getParser(this.type,config.decode)},igv.FeatureFileReader.prototype.readHeader=function(continuation){function loadHeaderWithIndex(index,continuation){function getContentLength(continuation){myself.contentLength?continuation(myself.contentLength):igvxhr.getContentLength(myself.headURL,{
|
5
|
+
headers:myself.config.headers,success:function(contentLength){console.log("CL = "+contentLength),myself.contentLength=contentLength,continuation(contentLength)},error:function(){myself.contentLength=-1,continuation(myself.contentLength)}})}getContentLength(function(contentLength){0>=contentLength&&index.blockMax&&(myself.contentLength=index.blockMax);var options={headers:myself.config.headers,bgz:index.tabix,success:function(data){myself.header=myself.parser.parseHeader(data),continuation(myself.header)}};(0>=contentLength||contentLength>65e3)&&(options.range={start:0,size:65e3}),myself.localFile?igvxhr.loadStringFromFile(myself.localFile,options):igvxhr.loadString(myself.url,options)})}var myself=this,isIndeedIndexible=isIndexable.call(this);return void 0===this.indexed&&isIndeedIndexible?void loadIndex.call(this,function(index){index?(myself.index=index,myself.indexed=!0):myself.indexed=!1,myself.readHeader(continuation)}):void(this.index?loadHeaderWithIndex(this.index,continuation):loadFeaturesNoIndex.call(this,function(features){continuation(myself.header)}))},igv.FeatureFileReader.prototype.readFeatures=function(success,task,range){function packFeatures(features){success(features)}function loadFeaturesWithIndex(index,continuation){console.log("Using index");var blocks,processed,allFeatures,tabix=index&&index.tabix,refId=tabix?index.sequenceIndexMap[range.chr]:range.chr;blocks=index.blocksForRange(refId,range.start,range.end),blocks&&0!==blocks.length?(allFeatures=[],processed=0,blocks.forEach(function(block){var startPos=block.minv.block,startOffset=block.minv.offset,endPos=block.maxv.block+(index.tabix?65636:0);options={headers:myself.config.headers,range:{start:startPos,size:endPos-startPos+1},success:function(data){{var inflated,slicedData;data.byteLength}processed++,inflated=index.tabix?igv.arrayBufferToString(igv.unbgzf(data)):data,slicedData=startOffset?inflated.slice(startOffset):inflated,allFeatures=allFeatures.concat(myself.parser.parseFeatures(slicedData)),processed===blocks.length&&(allFeatures.sort(function(a,b){return a.start-b.start}),continuation(allFeatures))},task:task},myself.localFile?igvxhr.loadStringFromFile(myself.localFile,options):index.tabix?igvxhr.loadArrayBuffer(myself.url,options):igvxhr.loadString(myself.url,options)})):success(null)}var myself=this;this.index?loadFeaturesWithIndex(this.index,packFeatures):loadFeaturesNoIndex.call(this,packFeatures,task)},igv}(igv||{}),igv=function(igv){function decodeAneu(tokens,ignore){var chr,start,end,feature;return tokens.length<4?null:(chr=tokens[1],start=parseInt(tokens[2]),end=tokens.length>3?parseInt(tokens[3]):start+1,feature={chr:chr,start:start,end:end},tokens.length>4&&(feature.score=parseFloat(tokens[4]),feature.value=feature.score),feature.popupData=function(){return[{name:"Name",value:feature.name}]},feature)}function parseFixedStep(line){var tokens=line.split(/\s+/),cc=tokens[1].split("=")[1],ss=parseInt(tokens[2].split("=")[1],10),step=parseInt(tokens[3].split("=")[1],10),span=tokens.length>4?parseInt(tokens[4].split("=")[1],10):1;return{type:"fixedStep",chrom:cc,start:ss,step:step,span:span,index:0}}function parseVariableStep(line){var tokens=line.split(/\s+/),cc=tokens[1].split("=")[1],span=tokens.length>2?parseInt(tokens[2].split("=")[1],10):1;return{type:"variableStep",chrom:cc,span:span}}function parseTrackLine(line){var i,tk,curr,properties={},tokens=line.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g),tmp=[];for(i=1;i<tokens.length;i++)tokens[i]&&0!==tokens[i].trim().length&&(tk=tokens[i].trim(),tk.endsWith("=")>0?curr=tk:curr?(tmp.push(curr+tk),curr=void 0):tmp.push(tk));return tmp.forEach(function(str){if(str){var kv=str.split("=",2);2==kv.length&&(properties[kv[0]]=kv[1])}}),properties}function decodeBed(tokens,ignore){var chr,start,end,id,name,tmp,idName,exonCount,exonSizes,exonStarts,exons,feature,eStart,eEnd;if(tokens.length<3)return null;if(chr=tokens[0],start=parseInt(tokens[1]),end=tokens.length>2?parseInt(tokens[2]):start+1,feature={chr:chr,start:start,end:end,score:1e3},tokens.length>3){tmp=tokens[3].replace(/"/g,""),idName=tmp.split(";");for(var i=0;i<idName.length;i++){var kv=idName[i].split("=");"gene_id"==kv[0]&&(id=kv[1]),"gene_name"==kv[0]&&(name=kv[1])}feature.id=id?id:tmp,feature.name=name?name:tmp}if(tokens.length>4&&(feature.score=parseFloat(tokens[4])),tokens.length>5&&(feature.strand=tokens[5]),tokens.length>6&&(feature.cdStart=parseInt(tokens[6])),tokens.length>7&&(feature.cdEnd=parseInt(tokens[7])),tokens.length>8&&(feature.rgb=tokens[8]),tokens.length>11){exonCount=parseInt(tokens[9]),exonSizes=tokens[10].split(","),exonStarts=tokens[11].split(","),exons=[];for(var i=0;exonCount>i;i++)eStart=start+parseInt(exonStarts[i]),eEnd=eStart+parseInt(exonSizes[i]),exons.push({start:eStart,end:eEnd});feature.exons=exons}return feature.popupData=function(){return[{name:"Name",value:feature.name}]},feature}function decodePeak(tokens,ignore){var tokenCount,chr,start,end,strand,name,score,qValue,signal,pValue;return tokenCount=tokens.length,9>tokenCount?null:(chr=tokens[0],start=parseInt(tokens[1]),end=parseInt(tokens[2]),name=tokens[3],score=parseFloat(tokens[4]),strand=tokens[5].trim(),signal=parseFloat(tokens[6]),pValue=parseFloat(tokens[7]),qValue=parseFloat(tokens[8]),{chr:chr,start:start,end:end,name:name,score:score,strand:strand,signal:signal,pValue:pValue,qValue:qValue})}function decodeBedGraph(tokens,ignore){var chr,start,end,value;return tokens.length<3?null:(chr=tokens[0],start=parseInt(tokens[1]),end=parseInt(tokens[2]),value=parseFloat(tokens[3]),{chr:chr,start:start,end:end,value:value})}function decodeWig(tokens,wig){var ss,ee,value;return"fixedStep"===wig.type?(ss=wig.index*wig.step+wig.start,ee=ss+wig.span,value=parseFloat(tokens[0]),++wig.index,isNaN(value)?null:{chr:wig.chrom,start:ss,end:ee,value:value}):"variableStep"===wig.type?tokens.length<2?null:(ss=parseInt(tokens[0],10),ee=ss+wig.span,value=parseFloat(tokens[1]),isNaN(value)?null:{chr:wig.chrom,start:ss,end:ee,value:value}):decodeBedGraph(tokens)}function decodeFusionJuncSpan(tokens,ignore){var chr=tokens[0],fusion_name=tokens[1],junction_left=parseInt(tokens[2]),junction_right=parseInt(tokens[3]),num_junction_reads=parseInt(tokens[4]),num_spanning_frags=parseInt(tokens[5]),spanning_frag_coords_text=tokens[6],feature={chr:chr,name:fusion_name,junction_left:junction_left,junction_right:junction_right,num_junction_reads:num_junction_reads,num_spanning_frags:num_spanning_frags,spanning_frag_coords:[],start:-1,end:-1},min_coord=junction_left,max_coord=junction_right;if(num_spanning_frags>0)for(var coord_pairs=spanning_frag_coords_text.split(","),i=0;i<coord_pairs.length;i++){var split_coords=coord_pairs[i].split("-"),span_left=split_coords[0],span_right=split_coords[1];min_coord>span_left&&(min_coord=span_left),span_right>max_coord&&(max_coord=span_right),feature.spanning_frag_coords.push({left:span_left,right:span_right})}return feature.start=min_coord,feature.end=max_coord,feature.popupData=function(){return[{name:"Name",value:feature.name}]},feature}var maxFeatureCount=Number.MAX_VALUE;return igv.FeatureParser=function(type,decode){this.type=type,this.skipRows=0,decode?this.decode=decode:"narrowPeak"===type||"broadPeak"===type?this.decode=decodePeak:"bedgraph"===type?this.decode=decodeBedGraph:"wig"===type?this.decode=decodeWig:"aneu"===type?this.decode=decodeAneu:"FusionJuncSpan"===type?this.decode=decodeFusionJuncSpan:"gtexGWAS"===type?this.skipRows=1:this.decode=decodeBed},igv.FeatureParser.prototype.parseHeader=function(data){var line,i,header,lines=data.splitLines(),len=lines.length;for(i=0;len>i&&(line=lines[i],line.startsWith("track")||line.startsWith("#")||line.startsWith("browser"));i++)line.startsWith("track")&&(header=parseTrackLine(line));return header},igv.FeatureParser.prototype.parseFeatures=function(data){if(!data)return null;var wig,feature,tokens,line,i,j,lines=data.splitLines(),len=lines.length,allFeatures=[],cnt=0,decode=this.decode,type=this.type;for(i=this.skipRows;len>i;i++)line=lines[i],line.startsWith("track")||line.startsWith("#")||line.startsWith("browser")||("wig"===type&&line.startsWith("fixedStep")?wig=parseFixedStep(line):"wig"===type&&line.startsWith("variableStep")?wig=parseVariableStep(line):(tokens=lines[i].split(/\s+/),tokens.length<1||(feature=decode(tokens,wig),feature&&(allFeatures.length<maxFeatureCount?allFeatures.push(feature):(j=Math.floor(Math.random()*cnt),maxFeatureCount>j&&(allFeatures[j]=feature)),cnt++))));return allFeatures},igv}(igv||{}),igv=function(igv){function packFeatures(features,maxRows){function pack(featureList,maxRows){var rows=[];featureList.sort(function(a,b){return a.start-b.start}),rows.push(-1e3),featureList.forEach(function(feature){var r,len=Math.min(rows.length,maxRows),start=feature.start;for(r=0;len>r;r++)if(start>rows[r])return feature.row=r,void(rows[r]=feature.end);feature.row=r,rows[r]=feature.end})}if(null!=features&&0!==features.length){var chrFeatureMap={},chrs=[];features.forEach(function(feature){var chr=feature.chr,flist=chrFeatureMap[chr];flist||(flist=[],chrFeatureMap[chr]=flist,chrs.push(chr)),flist.push(feature)}),chrs.forEach(function(chr){pack(chrFeatureMap[chr],maxRows)})}}return igv.FeatureSource=function(config){if(this.config=config||{},"ga4gh"===config.sourceType){var wrappedReader=new igv.Ga4ghVariantReader(config);this.reader={readFeatures:function(success,task,range){return wrappedReader.readFeatures(range.chr,range.start,range.end,success,task)}}}else this.reader="immvar"===config.sourceType?new igv.ImmVarReader(config):"eqtl"===config.type?new igv.GtexReader(config):new igv.FeatureFileReader(config);this.type=config.type?config.type:igv.inferFileType(this.filename)},igv.FeatureSource.prototype.getHeader=function(continuation){this.reader.readHeader?this.reader.readHeader(continuation):continuation(null)},igv.FeatureSource.prototype.getFeatures=function(chr,bpStart,bpEnd,success,task){var myself=this,genomicInterval=new igv.GenomicInterval(chr,bpStart,bpEnd),featureCache=this.featureCache,maxRows=this.config.maxRows||500;featureCache&&(void 0===featureCache.range||featureCache.range.containsRange(genomicInterval))?success(this.featureCache.queryFeatures(chr,bpStart,bpEnd)):this.reader.readFeatures(function(featureList){function isIndexed(){return myself.reader.indexed||"ga4gh"===myself.config.sourceType||"immvar"===myself.config.sourceType||"gtex"===myself.config.sourceType}myself.featureCache=isIndexed()?new igv.FeatureCache(featureList,genomicInterval):new igv.FeatureCache(featureList),packFeatures(featureList,maxRows),success(myself.featureCache.queryFeatures(chr,bpStart,bpEnd))},task,genomicInterval)},igv.FeatureSource.prototype.allFeatures=function(success){this.getFeatureCache(function(featureCache){success(featureCache.allFeatures())})},igv.FeatureSource.prototype.getFeatureCache=function(success){var myself=this;this.featureCache?success(this.featureCache):this.reader.readFeatures(function(featureList){myself.featureCache=new igv.FeatureCache(featureList),success(myself.featureCache)})},igv}(igv||{}),igv=function(igv){function renderFeature(feature,bpStart,xScale,pixelHeight,ctx){var px,px1,pw,exonCount,cy,direction,exon,ePx,ePx1,ePw,transform,fontStyle,py=5,step=8,h=10;if(px=Math.round((feature.start-bpStart)/xScale),px1=Math.round((feature.end-bpStart)/xScale),pw=px1-px,3>pw&&(pw=3,px-=1),"SQUISHED"===this.displayMode&&void 0!=feature.row?py=this.squishedRowHeight*feature.row:"EXPANDED"===this.displayMode&&void 0!=feature.row&&(py=this.expandedRowHeight*feature.row),exonCount=feature.exons?feature.exons.length:0,0==exonCount)ctx.fillRect(px,py,pw,h);else{cy=py+5,igv.Canvas.strokeLine.call(ctx,px,cy,px1,cy),direction="+"==feature.strand?1:-1;for(var x=px+step/2;px1>x;x+=step)igv.Canvas.strokeLine.call(ctx,x-2*direction,cy-2,x,cy),igv.Canvas.strokeLine.call(ctx,x-2*direction,cy+2,x,cy);for(var e=0;exonCount>e;e++)exon=feature.exons[e],ePx=Math.round((exon.start-bpStart)/xScale),ePx1=Math.round((exon.end-bpStart)/xScale),ePw=Math.max(1,ePx1-ePx),ctx.fillRect(ePx,py,ePw,h)}fontStyle={font:"10px PT Sans",fillStyle:this.color,strokeStyle:this.color};var geneColor;if(igv.browser.selection&&(geneColor=igv.browser.selection.colorForGene(feature.name)),(px1-px>20||geneColor)&&"SQUISHED"!=this.displayMode){var geneFontStyle;geneFontStyle=geneColor?{font:"10px PT Sans",fillStyle:geneColor,strokeStyle:geneColor}:fontStyle,"COLLAPSED"===this.displayMode&&"SLANT"===this.labelDisplayMode&&(transform={rotate:{angle:45}});var labelY=transform?py+20:py+25;igv.Canvas.fillText.call(ctx,feature.name,px+(px1-px)/2,labelY,geneFontStyle,transform)}}function renderVariant(variant,bpStart,xScale,pixelHeight,ctx){var px,px1,pw,py=20,h=10;px=Math.round((variant.start-bpStart)/xScale),px1=Math.round((variant.end-bpStart)/xScale),pw=Math.max(1,px1-px),3>pw&&(pw=3,px-=1),ctx.fillRect(px,py,pw,h)}function renderFusionJuncSpan(feature,bpStart,xScale,pixelHeight,ctx){var px=Math.round((feature.start-bpStart)/xScale),px1=Math.round((feature.end-bpStart)/xScale);pw=px1-px,pw<3&&(pw=3,px-=1);var py=5;"SQUISHED"===this.displayMode&&void 0!=feature.row?py=this.squishedRowHeight*feature.row:"EXPANDED"===this.displayMode&&void 0!=feature.row&&(py=this.expandedRowHeight*feature.row);var cy=py+5,top_y=cy-5,bottom_y=cy+5,junction_left_px=Math.round((feature.junction_left-bpStart)/xScale),junction_right_px=Math.round((feature.junction_right-bpStart)/xScale);ctx.beginPath(),ctx.moveTo(junction_left_px,cy),ctx.bezierCurveTo(junction_left_px,top_y,junction_right_px,top_y,junction_right_px,cy),ctx.lineWidth=1,ctx.strokeStyle="blue",ctx.stroke();for(var spanning_coords=feature.spanning_frag_coords,i=0;i<spanning_coords.length;i++){var spanning_info=spanning_coords[i],span_left_px=Math.round((spanning_info.left-bpStart)/xScale),span_right_px=Math.round((spanning_info.right-bpStart)/xScale);ctx.beginPath(),ctx.moveTo(span_left_px,cy),ctx.bezierCurveTo(span_left_px,bottom_y,span_right_px,bottom_y,span_right_px,cy),ctx.lineWidth=1,ctx.strokeStyle="purple",ctx.stroke()}}return igv.FeatureTrack=function(config){igv.configTrack(this,config),this.displayMode=config.displayMode||"COLLAPSED",this.labelDisplayMode=config.labelDisplayMode,this.collapsedHeight=config.collapsedHeight||this.height,this.expandedRowHeight=config.expandedRowHeight||30,this.squishedRowHeight=config.squishedRowHeight||15,this.maxRows=config.maxRows||500,this.featureSource=new igv.FeatureSource(this.config),this.render=config.render?config.render:"vcf"===this.type?renderVariant:"FusionJuncSpan"==this.type?renderFusionJuncSpan:renderFeature,"FusionJuncSpan"==this.type&&(this.height=config.height||50,this.autoHeight=!1)},igv.FeatureTrack.prototype.getHeader=function(continuation){var track=this;this.featureSource.getHeader(function(header){header&&(header.name&&!track.config.label&&(track.label=header.name),header.color&&!track.config.color&&(track.color="rgb("+header.color+")")),continuation(header)})},igv.FeatureTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){this.visibilityWindow&&igv.browser.trackViewportWidthBP()>this.visibilityWindow?continuation({exceedsVisibilityWindow:!0}):this.featureSource.getFeatures(chr,bpStart,bpEnd,continuation,task)},igv.FeatureTrack.prototype.computePixelHeight=function(features){if("COLLAPSED"===this.displayMode)return 1*this.expandedRowHeight;var maxRow=0;return features.forEach(function(feature){feature.row&&feature.row>maxRow&&(maxRow=feature.row)}),(maxRow+1)*("SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)},igv.FeatureTrack.prototype.draw=function(options){var track=this,featureList=options.features,ctx=options.context,bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,pixelWidth=options.pixelWidth,pixelHeight=options.pixelHeight,bpEnd=bpStart+pixelWidth*bpPerPixel+1,zoomInNoticeFontStyle={font:"16px PT Sans",fillStyle:"rgba(64, 64, 64, 1)",strokeStyle:"rgba(64, 64, 64, 1)"};if(igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:"rgb(255, 255, 255)"}),options.features.exceedsVisibilityWindow)for(var x=200;pixelWidth>x;x+=400)igv.Canvas.fillText.call(ctx,"Zoom in to see features",x,20,zoomInNoticeFontStyle);else if(featureList){igv.Canvas.setProperties.call(ctx,{fillStyle:track.color,strokeStyle:track.color});for(var gene,i=0,len=featureList.length;len>i;i++)if(gene=featureList[i],!(gene.end<bpStart)){if(gene.start>bpEnd)break;track.render.call(this,gene,bpStart,bpPerPixel,pixelHeight,ctx)}}else console.log("No feature list")},igv.FeatureTrack.prototype.popupData=function(genomicLocation,xOffset,yOffset){if(this.featureSource.featureCache){var row,chr=igv.browser.referenceFrame.chr,tolerance=igv.browser.referenceFrame.bpPerPixel,featureList=this.featureSource.featureCache.queryFeatures(chr,genomicLocation-tolerance,genomicLocation+tolerance);if("COLLAPSED"!=this.displayMode&&(row=Math.floor("SQUISHED"===this.displayMode?yOffset/this.squishedRowHeight:yOffset/this.expandedRowHeight)),featureList&&featureList.length>0){var popupData=[];return featureList.forEach(function(feature){if(feature.popupData&&feature.end>=genomicLocation-tolerance&&feature.start<=genomicLocation+tolerance&&(void 0===row||void 0===feature.row||row===feature.row)){var featureData=feature.popupData(genomicLocation);featureData&&(popupData.length>0&&popupData.push("<HR>"),Array.prototype.push.apply(popupData,featureData))}}),popupData}}return null},igv.FeatureTrack.prototype.popupMenuItems=function(popover){var myself=this,menuItems=[],lut={COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"},checkMark='<i class="fa fa-check fa-check-shim"></i>',checkMarkNone='<i class="fa fa-check fa-check-shim fa-check-hidden"></i>',trackMenuItem='<div class="igv-track-menu-item">',trackMenuItemFirst='<div class="igv-track-menu-item igv-track-menu-border-top">';return menuItems.push(igv.colorPickerMenuItem(popover,this.trackView,"Set feature color",this.color)),["COLLAPSED","SQUISHED","EXPANDED"].forEach(function(displayMode,index){var chosen,str;chosen=0===index?trackMenuItemFirst:trackMenuItem,str=displayMode===myself.displayMode?chosen+checkMark+lut[displayMode]+"</div>":chosen+checkMarkNone+lut[displayMode]+"</div>",menuItems.push({object:$(str),click:function(){popover.hide(),myself.displayMode=displayMode,myself.trackView.update()}})}),menuItems},igv}(igv||{}),igv=function(igv){var sampleColumn=(Number.MAX_VALUE,0),chrColumn=1,startColumn=2,endColumn=3;return igv.SegParser=function(){},igv.SegParser.prototype.parseHeader=function(data){var line,i,tokens,lines=data.splitLines(),len=lines.length;for(i=0;len>i;i++)if(line=lines[i],!line.startsWith("#"))return tokens=line.split(" "),this.header={headings:tokens,lineCount:i+1},this.header;return this.header},igv.SegParser.prototype.parseFeatures=function(data){var tokens,line,i,dataColumn,lines=data?data.splitLines():[],len=lines.length,allFeatures=[];for(this.header||(this.header=this.parseHeader(data)),dataColumn=this.header.headings.length-1,i=this.header.lineCount;len>i;i++)line=lines[i],tokens=lines[i].split(" "),tokens.length>dataColumn&&allFeatures.push({sample:tokens[sampleColumn],chr:tokens[chrColumn],start:parseInt(tokens[startColumn]),end:parseInt(tokens[endColumn]),value:parseFloat(tokens[dataColumn])});return allFeatures},igv}(igv||{}),igv=function(igv){var sortDirection=1;return igv.SegTrack=function(config){igv.configTrack(this,config),this.displayMode=config.displayMode||"SQUISHED",this.maxHeight=config.maxHeight||500,this.sampleSquishHeight=config.sampleSquishHeight||2,this.sampleExpandHeight=config.sampleExpandHeight||12,this.posColorScale=config.posColorScale||new igv.GradientColorScale({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=config.negColorScale||new igv.GradientColorScale({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),this.sampleCount=0,this.samples={},this.sampleNames=[],this.featureSource=new igv.FeatureSource(this.config)},igv.SegTrack.prototype.popupMenuItems=function(popover){var myself=this;return[{label:"SQUISHED"===this.displayMode?"Expand sample hgt":"Squish sample hgt",click:function(){popover.hide(),myself.toggleSampleHeight()}}]},igv.SegTrack.prototype.toggleSampleHeight=function(){this.displayMode="SQUISHED"===this.displayMode?"EXPANDED":"SQUISHED",this.trackView.update()},igv.SegTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){this.featureSource.getFeatures(chr,bpStart,bpEnd,continuation,task)},igv.SegTrack.prototype.draw=function(options){function checkForLog(featureList){var i;if(void 0===myself.isLog)for(myself.isLog=!1,i=0;i<featureList.length;i++)if(featureList[i].value<0)return void(myself.isLog=!0)}var featureList,ctx,bpPerPixel,bpStart,pixelWidth,pixelHeight,bpEnd,segment,len,sample,i,y,color,value,px,px1,pw,xScale,sampleHeight,myself=this;if(sampleHeight="SQUISHED"===this.displayMode?this.sampleSquishHeight:this.sampleExpandHeight,ctx=options.context,pixelWidth=options.pixelWidth,pixelHeight=options.pixelHeight,igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:"rgb(255, 255, 255)"}),featureList=options.features){for(bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,bpEnd=bpStart+pixelWidth*bpPerPixel+1,xScale=bpPerPixel,i=0,len=featureList.length;len>i;i++)sample=featureList[i].sample,this.samples.hasOwnProperty(sample)||(this.samples[sample]=myself.sampleCount,this.sampleNames.push(sample),this.sampleCount++);for(checkForLog(featureList),i=0,len=featureList.length;len>i;i++)if(segment=featureList[i],!(segment.end<bpStart)){if(segment.start>bpEnd)break;y=myself.samples[segment.sample]*sampleHeight,value=segment.value,myself.isLog||(value=Math.log2(value/2)),color=-.1>value?myself.negColorScale.getColor(value):value>.1?myself.posColorScale.getColor(value):"white",px=Math.round((segment.start-bpStart)/xScale),px1=Math.round((segment.end-bpStart)/xScale),pw=Math.max(1,px1-px),igv.Canvas.fillRect.call(ctx,px,y,pw,sampleHeight,{fillStyle:color})}}else console.log("No feature list")},igv.SegTrack.prototype.computePixelHeight=function(features){var sampleHeight="SQUISHED"===this.displayMode?this.sampleSquishHeight:this.sampleExpandHeight;for(i=0,len=features.length;i<len;i++)sample=features[i].sample,this.samples.hasOwnProperty(sample)||(this.samples[sample]=this.sampleCount,this.sampleNames.push(sample),this.sampleCount++);return this.sampleCount*sampleHeight},igv.SegTrack.prototype.sortSamples=function(chr,bpStart,bpEnd,direction,callback){var segment,min,max,f,i,s,sampleNames,myself=this,len=bpEnd-bpStart,scores={};this.featureSource.getFeatures(chr,bpStart,bpEnd,function(featureList){for(i=0,len=featureList.length;len>i;i++)if(segment=featureList[i],!(segment.end<bpStart)){if(segment.start>bpEnd)break;min=Math.max(bpStart,segment.start),max=Math.min(bpEnd,segment.end),f=(max-min)/len,s=scores[segment.sample],s||(s=0),scores[segment.sample]=s+f*segment.value}for(sampleNames=Object.keys(myself.samples),sampleNames.sort(function(a,b){var s1=scores[a],s2=scores[b];return s1||(s1=Number.MAX_VALUE),s2||(s2=Number.MAX_VALUE),s1==s2?0:s1>s2?direction:-1*direction}),i=0;i<sampleNames.length;i++)myself.samples[sampleNames[i]]=i;myself.sampleNames=sampleNames,callback()})},igv.SegTrack.prototype.altClick=function(genomicLocation,event){var refFrame=igv.browser.referenceFrame,bpWidth=refFrame.toBP(2.5),bpStart=genomicLocation-bpWidth,bpEnd=genomicLocation+bpWidth,chr=refFrame.chr,myself=this;this.sortSamples(chr,bpStart,bpEnd,sortDirection,function(){myself.trackView.update(),$(myself.trackView.viewportDiv).scrollTop(0)}),sortDirection*=-1},igv.SegTrack.prototype.popupData=function(genomicLocation,xOffset,yOffset){var sampleName,row,items,sampleHeight="SQUISHED"===this.displayMode?this.sampleSquishHeight:this.sampleExpandHeight;if(row=Math.floor(yOffset/sampleHeight),row<this.sampleNames.length){if(sampleName=this.sampleNames[row],items=[{name:"Sample",value:sampleName}],this.featureSource.featureCache){var chr=igv.browser.referenceFrame.chr,featureList=this.featureSource.featureCache.queryFeatures(chr,genomicLocation,genomicLocation);featureList.forEach(function(f){f.sample===sampleName&&items.push({name:"Value",value:f.value})})}return items}return null},igv}(igv||{}),igv=function(igv){return igv.loadTribbleIndex=function(indexFile,config,continuation){function readHeader(parser){{var version=(parser.getInt(),parser.getInt(),parser.getInt());parser.getString(),parser.getLong(),parser.getLong(),parser.getString()}if(flags=parser.getInt(),3>version&&(flags&SEQUENCE_DICTIONARY_FLAG)==SEQUENCE_DICTIONARY_FLAG,version>=3)for(var nProperties=parser.getInt();nProperties-->0;){parser.getString(),parser.getString()}}function readLinear(parser){var chr=parser.getString(),blockMax=0;genome&&(chr=genome.getChromosomeName(chr));for(var nBins=(parser.getInt(),parser.getInt()),blocks=(parser.getInt(),parser.getInt()>0,parser.getInt(),new Array),pos=parser.getLong(),blocks=new Array,binNumber=0;nBins>binNumber;binNumber++){var nextPos=parser.getLong();blocks.push({min:pos,max:nextPos}),pos=nextPos,nextPos>blockMax&&(blockMax=nextPos)}return{chr:chr,blocks:blocks}}var genome=igv.browser?igv.browser.genome:null;console.log("Loading "+indexFile),igvxhr.loadArrayBuffer(indexFile,{headers:config.headers,success:function(arrayBuffer){if(arrayBuffer){var index={},parser=new igv.BinaryParser(new DataView(arrayBuffer));readHeader(parser);for(var nChrs=parser.getInt();nChrs-->0;){var chrIdx=readLinear(parser);index[chrIdx.chr]=chrIdx}continuation(new igv.TribbleIndex(index))}else continuation(null)},error:function(ignore,xhr){continuation(null)}})},igv.TribbleIndex=function(chrIndexTable){this.chrIndex=chrIndexTable},igv.TribbleIndex.prototype.blocksForRange=function(queryChr,min,max){var chrIdx=this.chrIndex[queryChr];if(chrIdx){var blocks=chrIdx.blocks,lastBlock=blocks[blocks.length-1],mergedBlock={minv:{block:blocks[0].min,offset:0},maxv:{block:lastBlock.max,offset:0}};return[mergedBlock]}return null},igv}(igv||{}),igv=function(igv){function translateCigar(cigar){var cigarUnit,opLen,opLtr,lengthOnRef=0,cigarArray=[];for(i=0;i<cigar.length;i++)cigarUnit=cigar[i],opLtr=CigarOperationTable[cigarUnit.operation],opLen=parseInt(cigarUnit.operationLength),("M"==opLtr||"EQ"==opLtr||"X"==opLtr||"D"==opLtr||"N"==opLtr||"="==opLtr)&&(lengthOnRef+=opLen),cigarArray.push({len:opLen,ltr:opLtr});return{lengthOnRef:lengthOnRef,array:cigarArray}}function makeBlocks(record,cigarArray){for(var blockSeq,blockQuals,blocks=[],seqOffset=0,pos=record.start,len=cigarArray.length,i=0;len>i;i++){var c=cigarArray[i];switch(c.ltr){case"H":break;case"P":break;case"S":seqOffset+=c.len;break;case"N":pos+=c.len;break;case"D":pos+=c.len;break;case"I":seqOffset+=c.len;break;case"M":case"EQ":case"=":case"X":blockSeq="*"===record.seq?"*":record.seq.substr(seqOffset,c.len),blockQuals="*"===record.qual?"*":record.qual.slice(seqOffset,c.len),blocks.push({start:pos,len:c.len,seq:blockSeq,qual:blockQuals}),seqOffset+=c.len,pos+=c.len;break;default:console.log("Error processing cigar element: "+c.len+c.ltr)}}return blocks}function translateCigar(cigar){var cigarUnit,opLen,opLtr,lengthOnRef=0,cigarArray=[];for(i=0;i<cigar.length;i++)cigarUnit=cigar[i],opLtr=CigarOperationTable[cigarUnit.operation],opLen=parseInt(cigarUnit.operationLength),("M"==opLtr||"EQ"==opLtr||"X"==opLtr||"D"==opLtr||"N"==opLtr||"="==opLtr)&&(lengthOnRef+=opLen),cigarArray.push({len:opLen,ltr:opLtr});return{lengthOnRef:lengthOnRef,array:cigarArray}}function makeBlocks(record,cigarArray){for(var blockSeq,blockQuals,blocks=[],seqOffset=0,pos=record.start,len=cigarArray.length,i=0;len>i;i++){var c=cigarArray[i];switch(c.ltr){case"H":break;case"P":break;case"S":seqOffset+=c.len;break;case"N":pos+=c.len;break;case"D":pos+=c.len;break;case"I":seqOffset+=c.len;break;case"M":case"EQ":case"=":case"X":blockSeq="*"===record.seq?"*":record.seq.substr(seqOffset,c.len),blockQuals="*"===record.qual?"*":record.qual.slice(seqOffset,c.len),blocks.push({start:pos,len:c.len,seq:blockSeq,qual:blockQuals}),seqOffset+=c.len,pos+=c.len;break;default:console.log("Error processing cigar element: "+c.len+c.ltr)}}return blocks}var CigarOperationTable={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};return igv.Ga4ghAlignment=function(json,genome){this.readName=json.fragmentName,this.properPlacement=json.properPlacement,this.duplicateFragment=json.duplicateFragment,this.numberReads=json.numberReads,this.fragmentLength=json.fragmentLength,this.readNumber=json.readNumber,this.failedVendorQualityChecks=json.failedVendorQualityChecks,this.secondaryAlignment=json.secondaryAlignment,this.supplementaryAlignment=json.supplementaryAlignment,this.seq=json.alignedSequence,this.qual=json.alignedQuality,this.tagDict=json.info,alignment=json.alignment,alignment?(this.mapped=!0,this.chr=json.alignment.position.referenceName,genome&&(this.chr=genome.getChromosomeName(this.chr)),this.start=parseInt(json.alignment.position.position),this.strand=!json.alignment.position.reverseStrand,this.mq=json.alignment.mappingQuality,cigarDecoded=translateCigar(json.alignment.cigar),this.lengthOnRef=cigarDecoded.lengthOnRef,this.blocks=makeBlocks(this,cigarDecoded.array)):this.mapped=!1,json.nextMatePosition&&(this.mate={chr:json.nextMatePosition.referenceFrame,position:parseInt(json.nextMatePosition.position),strand:!json.nextMatePosition.reverseStrand},this.info=json.info)},igv.Ga4ghAlignment.prototype.isMapped=function(){return this.mapped},igv.Ga4ghAlignment.prototype.isPaired=function(){return this.numberReads&&this.numberReads>1},igv.Ga4ghAlignment.prototype.isProperPair=function(){return void 0===this.properPlacement||this.properPlacement},igv.Ga4ghAlignment.prototype.isFistOfPair=function(){return this.readNumber&&0===this.readNumber},igv.Ga4ghAlignment.prototype.isSecondOfPair=function(){return this.readNumber&&1===this.readNumber},igv.Ga4ghAlignment.prototype.isNotPrimary=function(){return this.secondaryAlignment},igv.Ga4ghAlignment.prototype.isSupplementary=function(){return this.supplementaryAlignment},igv.Ga4ghAlignment.prototype.isFailsVendorQualityCheck=function(){return this.failedVendorQualityChecks},igv.Ga4ghAlignment.prototype.isDuplicate=function(){return this.duplicateFragment},igv.Ga4ghAlignment.prototype.isMateMapped=function(){return this.mate},igv.Ga4ghAlignment.prototype.mateStrand=function(){return this.mate&&this.mate.strand},igv.Ga4ghAlignment.prototype.tags=function(){return this.info},igv.Ga4ghAlignment.prototype.popupData=function(genomicLocation){function yesNo(bool){return bool?"Yes":"No"}var isFirst;nameValues=[],nameValues.push({name:"Read Name",value:this.readName}),nameValues.push("<hr>"),nameValues.push({name:"Alignment Start",value:igv.numberFormatter(1+this.start),borderTop:!0}),nameValues.push({name:"Read Strand",value:!0===this.strand?"(+)":"(-)",borderTop:!0}),nameValues.push({name:"Cigar",value:this.cigar}),nameValues.push({name:"Mapped",value:yesNo(this.isMapped())}),nameValues.push({name:"Mapping Quality",value:this.mq}),nameValues.push({name:"Secondary",value:yesNo(this.isNotPrimary())}),nameValues.push({name:"Supplementary",value:yesNo(this.isSupplementary())}),nameValues.push({name:"Duplicate",value:yesNo(this.isDuplicate())}),nameValues.push({name:"Failed QC",value:yesNo(this.isFailsVendorQualityCheck())}),this.isPaired()&&(nameValues.push("<hr>"),nameValues.push({name:"First in Pair",value:!this.isSecondOfPair(),borderTop:!0}),nameValues.push({name:"Mate is Mapped",value:yesNo(this.isMateMapped())}),this.isMapped()&&(nameValues.push({name:"Mate Start",value:this.matePos}),nameValues.push({name:"Mate Strand",value:this.mateStrand()?"(-)":"(+)"}),nameValues.push({name:"Insert Size",value:this.fragmentLength}))),nameValues.push("<hr>"),this.tags(),isFirst=!0;for(var key in this.tagDict)this.tagDict.hasOwnProperty(key)&&(isFirst?(nameValues.push({
|
6
|
+
name:key,value:this.tagDict[key],borderTop:!0}),isFirst=!1):nameValues.push({name:key,value:this.tagDict[key]}));return nameValues},igv}(igv||{}),igv=function(igv){return igv.Ga4ghAlignmentReader=function(config){this.config=config,this.url=config.url,this.readGroupSetIds=config.readGroupSetIds,this.authKey=config.authKey},igv.Ga4ghAlignmentReader.prototype.readFeatures=function(chr,bpStart,bpEnd,success,task){function getChrNameMap(continuation){self.chrNameMap?continuation(self.chrNameMap):self.readMetadata(function(json){if(self.chrNameMap={},igv.browser){var readURL=self.url+"/references/search";self.authKey&&(readURL=readURL+"?key="+self.authKey),igv.ga4ghSearch({url:readURL,body:{referenceSetId:json.referenceSetId},decode:function(j){return j.references},success:function(references){references.forEach(function(ref){var refName=ref.name,alias=igv.browser.genome.getChromosomeName(refName);self.chrNameMap[alias]=refName}),continuation(self.chrNameMap)},task:task})}else continuation(self.chrNameMap)})}var self=this;getChrNameMap(function(chrNameMap){var queryChr=chrNameMap.hasOwnProperty(chr)?chrNameMap[chr]:chr,readURL=self.url+"/reads/search";self.authKey&&(readURL=readURL+"?key="+self.authKey),igv.ga4ghSearch({url:readURL,body:{readGroupSetIds:[self.readGroupSetIds],referenceName:queryChr,start:bpStart,end:bpEnd,pageSize:"10000"},decode:igv.decodeGa4ghReads,success:success,task:task})})},igv.Ga4ghAlignmentReader.prototype.readMetadata=function(success,task){igv.ga4ghGet({url:this.url,entity:"readgroupsets",entityId:this.readGroupSetIds,authKey:this.authKey,success:success,task:task})},igv}(igv||{}),igv=function(igv){function ga4ghHeaders(){var headers={},acToken=oauth.google.access_token;return headers["Cache-Control"]="no-cache",acToken&&(headers.Authorization="Bearer "+acToken),headers}return igv.ga4ghGet=function(requestJson){var options,url=requestJson.url+"/"+requestJson.entity+"/"+requestJson.entityId,acToken=oauth.google.access_token,paramSeparator="?";requestJson.authKey&&(url=url+paramSeparator+"key="+requestJson.authKey,paramSeparator="&"),acToken&&(url=url+paramSeparator+"access_token="+encodeURIComponent(acToken)),options={success:requestJson.success,task:requestJson.task,headers:ga4ghHeaders()},igvxhr.loadJson(url,options)},igv.ga4ghSearch=function(requestJson){function loadChunk(pageToken){pageToken?body.pageToken=pageToken:void 0!=body.pageToken&&delete body.pageToken;var sendData=JSON.stringify(body);igvxhr.loadJson(url,{sendData:sendData,task:task,contentType:"application/json",headers:ga4ghHeaders(),success:function(json){var nextPageToken,tmp;json?(tmp=decode?decode(json):json,tmp.forEach(function(a){var keep=!0;keep&&results.push(a)}),nextPageToken=json.nextPageToken,nextPageToken?loadChunk(nextPageToken):success(results)):success(results)}})}var results=[],url=requestJson.url,body=requestJson.body,decode=requestJson.decode,success=requestJson.success,task=requestJson.task,acToken=oauth.google.access_token,paramSeparator="?";requestJson.authKey&&(url=url+paramSeparator+"key="+requestJson.authKey,paramSeparator="&"),acToken&&(url=url+paramSeparator+"access_token="+encodeURIComponent(acToken)),loadChunk()},igv}(igv||{}),igv=function(igv){function encodeCigar(cigarArray){return""}function encodeFlags(json){return 0}function translateCigar(cigar){var cigarUnit,opLen,opLtr,lengthOnRef=0,cigarArray=[];for(i=0;i<cigar.length;i++)cigarUnit=cigar[i],opLtr=CigarOperationTable[cigarUnit.operation],opLen=parseInt(cigarUnit.operationLength),("M"==opLtr||"EQ"==opLtr||"X"==opLtr||"D"==opLtr||"N"==opLtr||"="==opLtr)&&(lengthOnRef+=opLen),cigarArray.push({len:opLen,ltr:opLtr});return{lengthOnRef:lengthOnRef,array:cigarArray}}function makeBlocks(record,cigarArray){for(var blockSeq,blockQuals,blocks=[],seqOffset=0,pos=record.start,len=cigarArray.length,i=0;len>i;i++){var c=cigarArray[i];switch(c.ltr){case"H":break;case"P":break;case"S":seqOffset+=c.len;break;case"N":pos+=c.len;break;case"D":pos+=c.len;break;case"I":seqOffset+=c.len;break;case"M":case"EQ":case"=":case"X":blockSeq="*"===record.seq?"*":record.seq.substr(seqOffset,c.len),blockQuals="*"===record.qual?"*":record.qual.slice(seqOffset,c.len),blocks.push({start:pos,len:c.len,seq:blockSeq,qual:blockQuals}),seqOffset+=c.len,pos+=c.len;break;default:console.log("Error processing cigar element: "+c.len+c.ltr)}}return blocks}var CigarOperationTable={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};return igv.decodeGa4ghReads=function(json){var i,json,read,alignment,cigarDecoded,mate,jsonRecords=json.alignments,len=jsonRecords.length,alignments=[],genome=igv.browser.genome;for(i=0;len>i;i++)json=jsonRecords[i],read=new igv.BamAlignment,read.readName=json.fragmentName,read.properPlacement=json.properPlacement,read.duplicateFragment=json.duplicateFragment,read.numberReads=json.numberReads,read.fragmentLength=json.fragmentLength,read.readNumber=json.readNumber,read.failedVendorQualityChecks=json.failedVendorQualityChecks,read.secondaryAlignment=json.secondaryAlignment,read.supplementaryAlignment=json.supplementaryAlignment,read.seq=json.alignedSequence,read.qual=json.alignedQuality,read.matePos=json.nextMatePosition,read.tagDict=json.info,read.flags=encodeFlags(json),alignment=json.alignment,alignment?(read.mapped=!0,read.chr=json.alignment.position.referenceName,genome&&(read.chr=genome.getChromosomeName(read.chr)),read.start=parseInt(json.alignment.position.position),read.strand=!json.alignment.position.reverseStrand,read.mq=json.alignment.mappingQuality,read.cigar=encodeCigar(json.alignment.cigar),cigarDecoded=translateCigar(json.alignment.cigar),read.lengthOnRef=cigarDecoded.lengthOnRef,read.blocks=makeBlocks(read,cigarDecoded.array)):read.mapped=!1,mate=json.nextMatePosition,mate&&(read.mate={chr:mate.referenceFrame,position:parseInt(mate.position),strand:!mate.reverseStrand}),alignments.push(read);return alignments},igv.decodeGa4ghReadset=function(json){var sequenceNames=[],fileData=json.fileData;return fileData.forEach(function(fileObject){var refSequences=fileObject.refSequences;refSequences.forEach(function(refSequence){sequenceNames.push(refSequence.name)})}),sequenceNames},igv}(igv||{}),igv=function(igv){return igv.Ga4ghVariantReader=function(config){this.config=config,this.url=config.url,this.variantSetId=config.variantSetId,this.authKey=config.authKey},igv.Ga4ghVariantReader.prototype.readFeatures=function(chr,bpStart,bpEnd,success,task){function getChrNameMap(continuation){myself.chrNameMap?continuation(myself.chrNameMap):myself.readMetadata(function(json){myself.metadata=json.metadata,myself.chrNameMap={},json.referenceBounds&&igv.browser&&json.referenceBounds.forEach(function(rb){var refName=rb.referenceName,alias=igv.browser.genome.getChromosomeName(refName);myself.chrNameMap[alias]=refName}),continuation(myself.chrNameMap)})}var myself=this;getChrNameMap(function(chrNameMap){var queryChr=chrNameMap.hasOwnProperty(chr)?chrNameMap[chr]:chr,readURL=myself.url+"/variants/search";myself.authKey&&(readURL=readURL+"?key="+myself.authKey,readURL+="&fields=nextPageToken,variants(alternateBases,filter,info,names,quality,referenceBases,referenceName,start)"),igv.ga4ghSearch({url:readURL,body:{variantSetIds:[myself.variantSetId],referenceName:queryChr,start:bpStart.toString(),end:bpEnd.toString(),pageSize:"10000"},decode:function(json){var variants=[];return json.variants.forEach(function(json){variants.push(igv.createGAVariant(json))}),variants},success:success,task:task})})},igv.Ga4ghVariantReader.prototype.readMetadata=function(success,task){igv.ga4ghGet({url:this.url,entity:"variantsets",entityId:this.variantSetId,authKey:this.authKey,success:success,task:task})},igv}(igv||{}),igv=function(igv){return igv.Genome=function(sequence,chromosomeNames,chromosomes){this.sequence=sequence,this.chromosomeNames=chromosomeNames,this.chromosomes=chromosomes;var chrAliasTable={};chromosomeNames.forEach(function(name){var alias=name.startsWith("chr")?name.substring(3):"chr"+name;chrAliasTable[alias]=name}),chrAliasTable.chrM="MT",chrAliasTable.MT="chrM",this.chrAliasTable=chrAliasTable},igv.Genome.prototype.getChromosomeName=function(str){var chr=this.chrAliasTable[str];return chr?chr:str},igv.Genome.prototype.getChromosome=function(chr){return this.chromosomes[chr]},igv.Genome.prototype.getChromosomes=function(){return this.chromosomes},igv.Chromosome=function(name,order,bpLength){this.name=name,this.order=order,this.bpLength=bpLength},igv.Cytoband=function(start,end,name,typestain){this.start=start,this.end=end,this.label=name,this.stain=0,"acen"==typestain?this.type="c":(this.type=typestain.charAt(1),"p"==this.type&&(this.stain=parseInt(typestain.substring(4))))},igv.GenomicInterval=function(chr,start,end,features){this.chr=chr,this.start=start,this.end=end,this.features=features},igv.GenomicInterval.prototype.contains=function(chr,start,end){return this.chr==chr&&this.start<=start&&this.end>=end},igv.GenomicInterval.prototype.containsRange=function(range){return this.chr===range.chr&&this.start<=range.start&&this.end>=range.end},igv.loadGenome=function(fastaUrl,cytobandUrl,continuation){var sequence=new igv.FastaSequence(fastaUrl);sequence.loadIndex(function(fastaIndex){var chrNames=sequence.chromosomeNames,chromosomes={},order=0;chrNames.forEach(function(chrName){var bpLength=fastaIndex[chrName].size;chromosomes[chrName]=new igv.Chromosome(chrName,order++,bpLength)}),cytobandUrl?igvxhr.loadString(cytobandUrl,{success:function(data){for(var chromosome,lastChr,tmpCytoboands={},bands=[],n=0,c=1,lines=data.splitLines(),len=lines.length,i=0;len>i;i++){var tokens=lines[i].split(" "),chr=tokens[0];if(lastChr||(lastChr=chr),chr!=lastChr&&(chromosome=chromosomes[lastChr],chromosome&&(chromosome.cytobands=bands),tmpCytoboands[lastChr]=bands,bands=[],lastChr=chr,n=0,c++),5==tokens.length){var chr=tokens[0],start=parseInt(tokens[1]),end=parseInt(tokens[2]),name=tokens[3],stain=tokens[4];bands[n++]=new igv.Cytoband(start,end,name,stain)}}continuation(new igv.Genome(sequence,chrNames,chromosomes))}}):continuation(new igv.Genome(sequence,chrNames,chromosomes))})},igv}(igv||{}),igv=function(igv){function selectedFeature(feature,source){console.log(feature+" "+source);var type="gtex"===source?"snp":"gene";this.selection=new GtexSelection("gene"==type?{gene:feature}:{snp:feature}),igv.browser.update()}igv.EqtlTrack=function(config){var url=config.url,label=config.label;this.config=config,this.url=url,this.label=label,this.pValueField=config.pValueField||"pValue",this.geneField=config.geneField||"geneName",this.minLogP=config.minLogP||3.5,this.maxLogP=config.maxLogP||25,this.background=config.background,this.divider=config.divider||"rgb(225,225,225)",this.dotSize=config.dotSize||2,this.height=config.height||100,this.autoHeight=!1,this.disableButtons=config.disableButtons,this.featureSource=new igv.FeatureSource(config),this.onsearch=function(feature,source){selectedFeature.call(this,feature,source)}},igv.EqtlTrack.prototype.paintControl=function(ctx,pixelWidth,pixelHeight){var track=this,yScale=(track.maxLogP-track.minLogP)/pixelHeight,font={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:"rgb(255, 255, 255)"});for(var p=4;p<=track.maxLogP;p+=2){var yp=pixelHeight-Math.round((p-track.minLogP)/yScale);igv.Canvas.strokeLine.call(ctx,45,yp-2,50,yp-2,font),igv.Canvas.fillText.call(ctx,p,44,yp+2,font)}font.textAlign="center",igv.Canvas.fillText.call(ctx,"-log10(pvalue)",pixelWidth/2,pixelHeight/2,font,{rotate:{angle:-90}})},igv.EqtlTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){this.featureSource.getFeatures(chr,bpStart,bpEnd,continuation,task)},igv.EqtlTrack.prototype.draw=function(options){function drawEqtls(drawSelected){var eqtl,i,px,py,color,isSelected,snp,geneName,selection,radius=drawSelected?2*track.dotSize:track.dotSize;for(igv.Canvas.setProperties.call(ctx,{fillStyle:"rgb(180, 180, 180)",strokeStyle:"rgb(180, 180, 180)"}),i=0;len>i;i++)if(eqtl=featureList[i],snp=eqtl.snp.toUpperCase(),geneName=eqtl[track.geneField].toUpperCase(),selection=igv.browser.selection,isSelected=selection&&(selection.snp===snp||selection.gene===geneName),!(drawSelected&&!isSelected||(selection&&selection.snp===snp&&selection.addGene(geneName),drawSelected&&selection&&(color=selection.colorForGene(geneName)),drawSelected&&void 0===color||(px=Math.round(eqtl.position-bpStart+.5)/bpPerPixel,0>px)))){if(px>pixelWidth)break;var mLogP=-Math.log(eqtl[track.pValueField])/Math.LN10;mLogP<track.minLogP||(py=Math.max(0,pixelHeight-Math.round((mLogP-track.minLogP)/yScale)),eqtl.px=px,eqtl.py=py,color&&igv.Canvas.setProperties.call(ctx,{fillStyle:color,strokeStyle:"black"}),igv.Canvas.fillCircle.call(ctx,px,py,radius),igv.Canvas.strokeCircle.call(ctx,px,py,radius))}}var track=this,featureList=options.features,ctx=options.context,bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,pixelWidth=options.pixelWidth,pixelHeight=options.pixelHeight,yScale=(track.maxLogP-track.minLogP)/pixelHeight;if(this.background&&igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:this.background}),igv.Canvas.strokeLine.call(ctx,0,pixelHeight-1,pixelWidth,pixelHeight-1,{strokeStyle:this.divider}),ctx){var len=featureList.length;ctx.save(),drawEqtls(!1),drawEqtls(!0),ctx.restore()}},GtexSelection=function(selection){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,selection.gene&&(this.gene=selection.gene.toUpperCase(),this.geneColors[this.gene]=brewer[this.genesCount++]),selection.snp&&(this.snp=selection.snp.toUpperCase())},GtexSelection.prototype.addGene=function(geneName){this.geneColors[geneName.toUpperCase()]||(this.geneColors[geneName.toUpperCase()]=brewer[this.genesCount++])},GtexSelection.prototype.colorForGene=function(geneName){return this.geneColors[geneName.toUpperCase()]};var brewer=new Array;return brewer.push("rgb(228,26,28)"),brewer.push("rgb(55,126,184)"),brewer.push("rgb(77,175,74)"),brewer.push("rgb(166,86,40)"),brewer.push("rgb(152,78,163)"),brewer.push("rgb(255,127,0)"),brewer.push("rgb(247,129,191)"),brewer.push("rgb(153,153,153)"),brewer.push("rgb(255,255,51)"),brewer.push("rgb(102, 194, 165"),brewer.push("rgb(252, 141, 98"),brewer.push("rgb(141, 160, 203"),brewer.push("rgb(231, 138, 195"),brewer.push("rgb(166, 216, 84"),brewer.push("rgb(255, 217, 47"),brewer.push("rgb(229, 196, 148"),brewer.push("rgb(179, 179, 179"),brewer.push("rgb( 141, 211, 199"),brewer.push("rgb(255, 255, 179"),brewer.push("rgb(190, 186, 218"),brewer.push("rgb(251, 128, 114"),brewer.push("rgb(128, 177, 211"),brewer.push("rgb(253, 180, 98"),brewer.push("rgb(179, 222, 105"),brewer.push("rgb(252, 205, 229"),brewer.push("rgb(217, 217, 217"),brewer.push("rgb(188, 128, 189"),brewer.push("rgb(204, 235, 197"),brewer.push("rgb(255, 237, 111"),igv}(igv||{}),igv=function(igv){function createGtexControls(browser,options){var goBoxDiv,goBoxInput,goBoxButton,controlDiv=$('<div id="igvControlDiv" class="igv-control-div">')[0],tissueEqtlMappingURL=options.tissueEqtlMappingURL,selectionDiv=$('<div style="margin-bottom:20px">')[0],widgetDiv=$('<div style="height: 40px">')[0],zoomDiv=$('<div style="float:right">')[0],zoomOutButton=$('<button style="margin-right:5px">Zoom Out </button>')[0],zoomInButton=$("<button>Zoom In </button>")[0],trackHeightDiv=$('<div style="float:left">Track height: </div>')[0],heightBoxInput=$('<input type="text" id="igvTrackHeightInput" value="100"/>')[0];return zoomOutButton.onclick=function(){igv.browser.zoomOut()},zoomInButton.onclick=function(){igv.browser.zoomIn()},heightBoxInput.onchange=function(){igv.browser.trackViews.forEach(function(panel){panel.track instanceof igv.FeatureTrack||panel.track instanceof igv.SequenceTrack||panel.track instanceof igv.RulerTrack||panel.setTrackHeight(heightBoxInput.value)})},$(trackHeightDiv).append(heightBoxInput),$(zoomDiv).append(zoomOutButton),$(zoomDiv).append(zoomInButton),$(widgetDiv).append(trackHeightDiv),$(widgetDiv).append(zoomDiv),$(controlDiv).append(selectionDiv),$(controlDiv).append(widgetDiv),options.dev&&(goBoxDiv=$('<div style="margin-left:auto;margin-right:auto;width:20%">')[0],goBoxInput=$('<input type="text" id="goBox" value="PDE8B"/>')[0],goBoxButton=$('<button name="goButton"">Go</button>')[0],goBoxInput.onChange=function(){igv.browser.search(goBoxInput.value)},goBoxButton.onclick=function(){igv.browser.search(goBoxInput.value)},$(goBoxDiv).append(goBoxInput),$(goBoxDiv).append(goBoxButton),$(controlDiv).append(goBoxDiv)),loadGtexTissueMappings(tissueEqtlMappingURL,function(records){records.forEach(function(record){var containerDiv=$('<span style="margin-right: 30px">')[0],cb=$('<input type="checkbox"">')[0];cb.tissueRecord=record,cb.onclick=function(e){var track,record=e.currentTarget.tissueRecord;e.currentTarget.checked?browser.loadTrack({type:"eqtl",sourceType:"gtex",url:record.url,label:record.label,disableButtons:!0,height:100}):(track=findTrackWithURL(browser,record.url),track&&browser.removeTrack(track))},$(containerDiv).append(cb);var span=$("<span>"+record.label+"</span>")[0];$(containerDiv).append(span),$(selectionDiv).append(containerDiv)})}),controlDiv}function findTrackWithURL(browser,url){var i,len=browser.trackViews.length;for(i=0;len>i;i++)if(browser.trackViews[i].track.url===url)return browser.trackViews[i].track;return null}function loadGtexTissueMappings(url,continuation){var dataLoader=new igv.DataLoader(url);dataLoader.loadBinaryString(function(data){var i,tokens,lines=data.splitLines(),len=lines.length,records=[];for(i=0;len>i;i++)tokens=lines[i].split(" "),2==tokens.length&&records.push({label:tokens[0],url:tokens[1]});continuation(records)},function(errorEvent){continuation(null)})}igv.createGtexBrowser=function(parentDiv,options){return options||(options={}),options.type="GTEX",options.showKaryo=!1,options.fastaUrl||(options.fastaURL="//dn7ywbm9isq8j.cloudfront.net/genomes/seq/hg19/hg19.fasta"),options.cytobandURL||(options.cytobandURL="//dn7ywbm9isq8j.cloudfront.net/genomes/seq/hg19/cytoBand.txt"),options.tracks||(options.tracks=[{type:"sequence",order:9999},{url:"//dn7ywbm9isq8j.cloudfront.net/annotations/hg19/genes/gencode.v18.collapsed.bed",label:"Genes",order:1e4}]),options.createControls||(options.createControls=createGtexControls),options.tissueEqtlMappingURL||(options.tissueEqtlMappingURL="http://www.gtexportal.org/igv/assets/eqtl/tissueEqtlMappings.txt"),igv.createBrowser(parentDiv,options)},igv.GtexSelection=function(selection){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,selection.gene&&(this.gene=selection.gene.toUpperCase(),this.geneColors[this.gene]=brewer[this.genesCount++]),selection.snp&&(this.snp=selection.snp.toUpperCase())},igv.GtexSelection.prototype.addGene=function(geneName){this.geneColors[geneName.toUpperCase()]||(this.geneColors[geneName.toUpperCase()]=brewer[this.genesCount++])},igv.GtexSelection.prototype.colorForGene=function(geneName){return this.geneColors[geneName.toUpperCase()]};var brewer=new Array;return brewer.push("rgb(228,26,28)"),brewer.push("rgb(55,126,184)"),brewer.push("rgb(77,175,74)"),brewer.push("rgb(166,86,40)"),brewer.push("rgb(152,78,163)"),brewer.push("rgb(255,127,0)"),brewer.push("rgb(247,129,191)"),brewer.push("rgb(153,153,153)"),brewer.push("rgb(255,255,51)"),brewer.push("rgb(102, 194, 165"),brewer.push("rgb(252, 141, 98"),brewer.push("rgb(141, 160, 203"),brewer.push("rgb(231, 138, 195"),brewer.push("rgb(166, 216, 84"),brewer.push("rgb(255, 217, 47"),brewer.push("rgb(229, 196, 148"),brewer.push("rgb(179, 179, 179"),brewer.push("rgb( 141, 211, 199"),brewer.push("rgb(255, 255, 179"),brewer.push("rgb(190, 186, 218"),brewer.push("rgb(251, 128, 114"),brewer.push("rgb(128, 177, 211"),brewer.push("rgb(253, 180, 98"),brewer.push("rgb(179, 222, 105"),brewer.push("rgb(252, 205, 229"),brewer.push("rgb(217, 217, 217"),brewer.push("rgb(188, 128, 189"),brewer.push("rgb(204, 235, 197"),brewer.push("rgb(255, 237, 111"),igv}(igv||{}),igv=function(igv){igv.GtexReader=function(config){this.file=config.url,this.codec=this.file.endsWith(".bin")?createEqtlBinary:createEQTL,this.cache={},this.binary=this.file.endsWith(".bin"),this.compressed=this.file.endsWith(".compressed.bin")},igv.GtexReader.prototype.readFeatures=function(continuation,task,genomicRange){function loadWithIndex(index,chr,continuation){var chrIdx=index[chr];if(chrIdx){var blocks=chrIdx.blocks,lastBlock=blocks[blocks.length-1],endPos=lastBlock.startPos+lastBlock.size,len=endPos-blocks[0].startPos,range={start:blocks[0].startPos,size:len};igvxhr.loadArrayBuffer(file,{task:task,range:range,success:function(arrayBuffer){if(arrayBuffer){var data=new DataView(arrayBuffer),parser=new igv.BinaryParser(data),featureList=[];for(parser.offset;parser.hasNext();){var feature=createEqtlBinary(parser);featureList.push(feature)}continuation(featureList)}else continuation(null)}})}else continuation([]);var createEqtlBinary=function(parser){var snp=parser.getString(),chr=parser.getString(),position=parser.getInt(),geneId=parser.getString(),geneName=parser.getString(),pValue=parser.getFloat();return new Eqtl(snp,chr,position,geneId,geneName,pValue)}}function Eqtl(snp,chr,position,geneId,geneName,pValue){this.snp=snp,this.chr=chr,this.position=position,this.start=position,this.end=position+1,this.geneId=geneId,this.geneName=geneName,this.pValue=pValue}function loadIndex(url,continuation){var genome=igv.browser?igv.browser.genome:null;igvxhr.loadArrayBuffer(url,{range:{start:0,size:200},success:function(arrayBuffer){var data=new DataView(arrayBuffer),parser=new igv.BinaryParser(data),indexPosition=(parser.getInt(),parser.getInt(),parser.getLong()),indexSize=parser.getInt();igvxhr.loadArrayBuffer(url,{range:{start:indexPosition,size:indexSize},success:function(arrayBuffer2){for(var data2=new DataView(arrayBuffer2),index=null,parser=new igv.BinaryParser(data2),index={},nChrs=parser.getInt();nChrs-->0;){var chr=parser.getString();genome&&(chr=genome.getChromosomeName(chr));var position=parser.getLong(),size=parser.getInt(),blocks=new Array;blocks.push(new Block(position,size)),index[chr]=new ChrIdx(chr,blocks)}continuation(index)}})}})}var chr=genomicRange.chr,self=this,file=this.file,index=self.index;index?loadWithIndex(index,chr,continuation):loadIndex(self.file,function(index){self.index=index,loadWithIndex(index,chr,continuation)}),Eqtl.prototype.description=function(){return"<b>snp</b>: "+this.snp+"<br/><b>location</b>: "+this.chr+":"+formatNumber(this.position+1)+"<br/><b>gene</b>: "+this.geneName+"<br/><b>pValue</b>: "+this.pValue+"<br/><b>mLogP</b>: "+this.mLogP},Block=function(startPos,size){this.startPos=startPos,this.size=size},ChrIdx=function(chr,blocks){this.chr=chr,this.blocks=blocks}};var createEQTL=function(tokens){var snp=tokens[0],chr=tokens[1],position=parseInt(tokens[2])-1,geneId=tokens[3],geneName=tokens[4],genePosition=tokens[5],fStat=parseFloat(tokens[6]),pValue=parseFloat(tokens[7]);return new Eqtl(snp,chr,position,geneId,geneName,genePosition,fStat,pValue)},createEqtlBinary=function(parser){var snp=parser.getString(),chr=parser.getString(),position=parser.getInt(),geneId=parser.getString(),geneName=parser.getString(),pValue=parser.getFloat();return new Eqtl(snp,chr,position,geneId,geneName,pValue)};return igv}(igv||{}),igv=function(igv){return igv.ImmVarReader=function(config){this.url=config.url,this.cellConditionId=config.cellConditionId,this.valueThreshold=config.valueThreshold?config.valueThreshold:.05},igv.ImmVarReader.prototype.readFeatures=function(success,task,range){var queryChr=range.chr,queryStart=range.start,queryEnd=range.end,queryURL=this.url+"?chromosome="+queryChr+"&start="+queryStart+"&end="+queryEnd+"&cell_condition_id="+this.cellConditionId;igvxhr.loadJson(queryURL,{task:task,success:function(json){json?(json.eqtls.forEach(function(eqtl){eqtl.chr=eqtl.chromosome,eqtl.start=eqtl.position,eqtl.end=eqtl.position+1}),success(json.eqtls)):success(null)}})},igv}(igv||{}),igv=function(igv){const VARIANT="VARIANT",TRAIT="TRAIT";igv.T2DVariantSource=function(config){this.proxy=config.proxy?config.proxy:"//www.broadinstitute.org/igvdata/t2d/postJson.php",this.url=config.url,this.trait=config.trait,this.valueThreshold=config.valueThreshold?config.valueThreshold:.05,this.type=this.url.contains("variant")?VARIANT:TRAIT,this.pvalue=config.pvalue?config.pvalue:"PVALUE"},igv.T2DVariantSource.prototype.getFeatures=function(chr,bpStart,bpEnd,success,task){function loadFeatures(){var tmp,window=Math.max(bpEnd-bpStart,1e7)/2,center=(bpEnd+bpStart)/2,queryChr=chr.startsWith("chr")?chr.substring(3):chr,queryStart=Math.max(0,center-window),queryEnd=center+window,queryURL=this.proxy?this.proxy:this.url,filters=[{operand:"CHROM",operator:"EQ",value:queryChr,filter_type:"STRING"},{operand:"POS",operator:"GT",value:queryStart,filter_type:"FLOAT"},{operand:"POS",operator:"LT",value:queryEnd,filter_type:"FLOAT"},{operand:source.pvalue,operator:"LTE",value:source.valueThreshold,filter_type:"FLOAT"}],columns=source.type===TRAIT?["CHROM","POS","DBSNP_ID","PVALUE","ZSCORE"]:["CHROM","POS",source.pvalue,"DBSNP_ID"],data={user_group:"ui",filters:filters,columns:columns};source.type===TRAIT&&(data.trait=source.trait),tmp=this.proxy?"url="+this.url+"&data="+JSON.stringify(data):JSON.stringify(data),igvxhr.loadJson(queryURL,{sendData:tmp,task:task,success:function(json){var variants;json?(variants=json.variants,variants.sort(function(a,b){return a.POS-b.POS}),source.cache=new FeatureCache(chr,queryStart,queryEnd,variants),success(variants)):success(null)}})}var source=this;this.cache&&this.cache.chr===chr&&this.cache.end>bpEnd&&this.cache.start<bpStart?success(this.cache.featuresBetween(bpStart,bpEnd)):loadFeatures.call(this)};var FeatureCache=function(chr,start,end,features){var i,bin,lastBin;for(this.chr=chr,this.start=start,this.end=end,this.binSize=(end-start)/100,this.binIndeces=[0],this.features=features,lastBin=0,i=0;i<features.length;i++)bin=Math.max(0,Math.floor((features[i].POS-this.start)/this.binSize)),bin>lastBin&&(this.binIndeces.push(i),lastBin=bin)};return FeatureCache.prototype.featuresBetween=function(start,end){{var startBin=Math.max(0,Math.min(Math.floor((start-this.start)/this.binSize)-1,this.binIndeces.length-1)),endBin=Math.max(0,Math.min(Math.floor((end-this.start)/this.binSize),this.binIndeces.length-1));this.binIndeces[startBin],this.binIndeces[endBin]}return this.features},igv}(igv||{}),igv=function(igv){const POPOVER_WINDOW=3e7;return igv.T2dTrack=function(config){this.config=config,this.url=config.url,this.featureSource=new igv.T2DVariantSource(config),this.label=config.label,this.trait=config.trait,this.height=config.height||100,this.minLogP=config.minLogP||0,this.maxLogP=config.maxLogP||15,this.background=config.background,this.divider=config.divider||"rgb(225,225,225)",this.dotSize=config.dotSize||4,this.description=config.description,this.proxy=config.proxy,this.portalURL=config.portalURL?config.portalURL:window.location.origin;var cs=config.colorScale||{thresholds:[5e-8,5e-4,.5],colors:["rgb(255,50,50)","rgb(251,100,100)","rgb(251,170,170)","rgb(227,238,249)"]};this.pvalue=config.pvalue?config.pvalue:"PVALUE",this.colorScale=new igv.BinnedColorScale(cs)},igv.T2dTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){this.featureSource.getFeatures(chr,bpStart,bpEnd,continuation,task)},igv.T2dTrack.prototype.draw=function(options){var track=this,featureList=options.features,ctx=options.context,bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,pixelWidth=options.pixelWidth,pixelHeight=options.pixelHeight,bpEnd=bpStart+pixelWidth*bpPerPixel+1,yScale=(track.maxLogP-track.minLogP)/pixelHeight,enablePopover=POPOVER_WINDOW>bpEnd-bpStart;this.po=enablePopover?[]:void 0,this.background&&igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:this.background}),igv.Canvas.strokeLine.call(ctx,0,pixelHeight-1,pixelWidth,pixelHeight-1,{strokeStyle:this.divider});var variant,len,xScale,px,py,color,pvalue,val;if(featureList){len=featureList.length,py=20;for(var i=0;len>i;i++)if(variant=featureList[i],!(variant.POS<bpStart)){if(variant.POS>bpEnd)break;pvalue=variant[track.pvalue],pvalue&&(color=track.colorScale.getColor(pvalue),val=-Math.log(pvalue)/2.302585092994046,xScale=bpPerPixel,px=Math.round((variant.POS-bpStart)/xScale),py=Math.max(track.dotSize,pixelHeight-Math.round((val-track.minLogP)/yScale)),color&&igv.Canvas.setProperties.call(ctx,{fillStyle:color,strokeStyle:"black"}),igv.Canvas.fillCircle.call(ctx,px,py,track.dotSize),enablePopover&&track.po.push({x:px,y:py,feature:variant}))}}},igv.T2dTrack.prototype.paintControl=function(ctx,pixelWidth,pixelHeight){var track=this,yScale=(track.maxLogP-track.minLogP)/pixelHeight,font={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};igv.Canvas.fillRect.call(ctx,0,0,pixelWidth,pixelHeight,{fillStyle:"rgb(255, 255, 255)"});for(var p=2;p<track.maxLogP;p+=2){var yp=pixelHeight-Math.round((p-track.minLogP)/yScale);igv.Canvas.strokeLine.call(ctx,45,yp-2,50,yp-2,font),igv.Canvas.strokeLine.call(ctx,p,44,yp+2,font)}font.textAlign="center",igv.Canvas.fillText.call(ctx.ctx,"-log10(pvalue)",pixelWidth/2,pixelHeight/2,font,{rotate:{angle:-90}})},igv.T2dTrack.prototype.popupData=function(genomicLocation,xOffset,yOffset){var i,len,p,dbSnp,url,data=[];if(this.po)for(i=0,len=this.po.length;len>i;i++)p=this.po[i],Math.abs(xOffset-p.x)<this.dotSize&&Math.abs(yOffset-p.y)<=this.dotSize&&(dbSnp=p.feature.DBSNP_ID,dbSnp&&data.push("<a target='_blank' href='"+url+"' >"+p.feature.DBSNP_ID+"</a>"),data.push("chr"+p.feature.CHROM+":"+p.feature.POS.toString()),data.push({name:"p-value",value:p.feature[this.pvalue]}),p.feature.ZSCORE&&data.push({name:"z-score",value:p.feature.ZSCORE}),dbSnp&&(url=this.portalURL+"/trait/traitInfo/"+dbSnp,data.push("<a target='_blank' href='"+url+"'>see all available statistics for this variant</a>")),len-1>i&&data.push("<p/>"));else data.push("Popover not available at this resolution.");return data},igv}(igv||{}),igv=function(igv){return igv.IdeoPanel=function(parentElement){this.ideograms={},this.div=$('<div class="igv-ideogram-div"></div>'),$(parentElement).append(this.div[0]);var chromosomeNameDiv=$('<div class="igv-ideogram-chr-div"></div>');this.div.append(chromosomeNameDiv[0]),this.chromosomeNameLabel=$("<div>")[0],$(chromosomeNameDiv).append(this.chromosomeNameLabel),this.contentDiv=$('<div class="igv-ideogram-content-div"></div>'),$(this.div).append(this.contentDiv[0]);var myself=this;this.contentDiv.click(function(e){var xy,xPercentage,chr,chrLength,locusLength,chrCoveragePercentage,locus;xy=igv.translateMouseCoordinates(e,myself.contentDiv),xPercentage=xy.x/myself.contentDiv.width(),locusLength=igv.browser.trackViewportWidthBP(),chr=igv.browser.genome.getChromosome(igv.browser.referenceFrame.chr),chrLength=chr.bpLength,chrCoveragePercentage=locusLength/chrLength,0>xPercentage-chrCoveragePercentage/2&&(xPercentage=chrCoveragePercentage/2),xPercentage+chrCoveragePercentage/2>1&&(xPercentage=1-chrCoveragePercentage/2),locus=igv.browser.referenceFrame.chr+":"+igv.numberFormatter(1+Math.floor((xPercentage-chrCoveragePercentage/2)*chrLength))+"-"+igv.numberFormatter(Math.floor((xPercentage+chrCoveragePercentage/2)*chrLength)),igv.browser.search(locus,void 0)}),this.contentDiv.css({left:igv.browser.controlPanelWidth+"px"}),this.canvas=$('<canvas class="igv-ideogram-canvas"></canvas>')[0],$(this.contentDiv).append(this.canvas),this.canvas.setAttribute("width",this.contentDiv.width()),this.canvas.setAttribute("height",this.contentDiv.height()),this.ctx=this.canvas.getContext("2d")},igv.IdeoPanel.prototype.resize=function(){this.canvas.setAttribute("width",this.div.width()),this.canvas.setAttribute("height",this.div.height()),this.ideograms={},this.repaint()},igv.IdeoPanel.prototype.repaint=function(){function drawIdeogram(bufferCtx,ideogramWidth,ideogramHeight){
|
7
|
+
var ideogramTop=0;if(genome){var chromosome=genome.getChromosome(referenceFrame.chr);if(chromosome){var cytobands=chromosome.cytobands;if(cytobands){var center=ideogramTop+ideogramHeight/2,xC=[],yC=[],len=cytobands.length;if(0==len)return;for(var chrLength=cytobands[len-1].end,scale=ideogramWidth/chrLength,lastPX=-1,i=0;i<cytobands.length;i++){var cytoband=cytobands[i],start=scale*cytoband.start,end=scale*cytoband.end;end>lastPX&&("c"==cytoband.type?("p"==cytoband.label.charAt(0)?(xC[0]=start,yC[0]=ideogramHeight+ideogramTop,xC[1]=start,yC[1]=ideogramTop,xC[2]=end,yC[2]=center):(xC[0]=end,yC[0]=ideogramHeight+ideogramTop,xC[1]=end,yC[1]=ideogramTop,xC[2]=start,yC[2]=center),bufferCtx.fillStyle="rgb(150, 0, 0)",bufferCtx.strokeStyle="rgb(150, 0, 0)",bufferCtx.polygon(xC,yC,1,0)):(bufferCtx.fillStyle=getCytobandColor(cytoband),bufferCtx.fillRect(start,ideogramTop,end-start,ideogramHeight)))}}bufferCtx.strokeStyle="black",bufferCtx.roundRect(0,ideogramTop,ideogramWidth,ideogramHeight,ideogramHeight/2,0,1),lastPX=end}}}function getCytobandColor(data){if("c"==data.type)return"rgb(150, 10, 10)";var stain=data.stain,shade=230;"p"==data.type&&(shade=Math.floor(230-stain/100*230));var c=stainColors[shade];return null==c&&(c="rgb("+shade+","+shade+","+shade+")",stainColors[shade]=c),c}try{var y,image,bufferCtx,chromosome,widthPercentage,xPercentage,width,widthBP,x,xBP,genome=igv.browser.genome,referenceFrame=igv.browser.referenceFrame,stainColors=[];if(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),!(genome&&referenceFrame&&genome.getChromosome(referenceFrame.chr)))return;image=this.ideograms[igv.browser.referenceFrame.chr],image||(image=document.createElement("canvas"),image.width=this.canvas.width,image.height=13,bufferCtx=image.getContext("2d"),drawIdeogram(bufferCtx,this.canvas.width,image.height),this.ideograms[igv.browser.referenceFrame.chr]=image),y=(this.canvas.height-image.height)/2,this.ctx.drawImage(image,0,y),this.ctx.save(),chromosome=igv.browser.genome.getChromosome(igv.browser.referenceFrame.chr),widthBP=Math.floor(igv.browser.trackViewportWidthBP()),xBP=igv.browser.referenceFrame.start,widthBP<chromosome.bpLength&&(widthPercentage=widthBP/chromosome.bpLength,xPercentage=xBP/chromosome.bpLength,x=Math.floor(xPercentage*this.canvas.width),width=Math.floor(widthPercentage*this.canvas.width),x=Math.max(0,x),x=Math.min(this.canvas.width-width,x),this.ctx.strokeStyle="red",this.ctx.lineWidth=2,this.ctx.strokeRect(x,y,width,image.height+this.ctx.lineWidth-1),this.ctx.restore()),this.chromosomeNameLabel.innerHTML=referenceFrame.chr}catch(e){console.log("Error painting ideogram: "+e.message)}},igv}(igv||{}),igv=function(igv){var debug=!1,log=function(msg){if(debug){var d=new Date,time=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();"undefined"!=typeof copy&©(msg),"undefined"!=typeof console&&console.log("igv-canvas: "+time+" "+msg)}};return igv.Canvas={setProperties:function(properties){for(var key in properties)if(properties.hasOwnProperty(key)){var value=properties[key];this[key]=value}},strokeLine:function(x1,y1,x2,y2,properties){x1=Math.floor(x1)+.5,y1=Math.floor(y1)+.5,x2=Math.floor(x2)+.5,y2=Math.floor(y2)+.5,log("stroke line, prop: "+properties),this.save(),properties&&igv.Canvas.setProperties.call(this,properties),this.beginPath(),this.moveTo(x1,y1),this.lineTo(x2,y2),this.stroke(),this.restore()},fillRect:function(x,y,w,h,properties){x=Math.round(x),y=Math.round(y),log("fillRect"),properties&&(this.save(),igv.Canvas.setProperties.call(this,properties)),this.fillRect(x,y,w,h),properties&&this.restore()},fillPolygon:function(x,y,properties){var i,len=x.length;for(i=0;len>i;i++)x[i]=Math.round(x[i]),y[i]=Math.round(y[i]);for(this.save(),properties&&igv.Canvas.setProperties.call(this,properties),this.beginPath(),this.moveTo(x[0],y[0]),i=1;len>i;i++)this.lineTo(x[i],y[i]);this.closePath(),this.fill(),this.restore()},fillText:function(text,x,y,properties,transforms){if(properties&&(this.save(),igv.Canvas.setProperties.call(this,properties)),this.save(),this.translate(x,y),transforms)for(var transform in transforms){var value=transforms[transform];"translate"==transform&&this.translate(value.x,value.y),"rotate"==transform&&this.rotate(value.angle*Math.PI/180)}this.fillText(text,0,0),this.restore(),properties&&this.restore()},strokeText:function(text,x,y,properties,transforms){if(this.save(),properties&&igv.Canvas.setProperties.call(this,properties),this.translate(x,y),transforms)for(var transform in transforms){var value=transforms[transform];"translate"==transform&&this.translate(value.x,value.y),"rotate"==transform&&this.rotate(value.angle*Math.PI/180)}this.strokeText(text,0,0),this.restore()},strokeCircle:function(x,y,radius){this.beginPath(),this.arc(x,y,radius,0,2*Math.PI),this.stroke()},fillCircle:function(x,y,radius){this.beginPath(),this.arc(x,y,radius,0,2*Math.PI),this.fill()},drawArrowhead:function(x,y,size,lineWidth){this.save(),size||(size=5),lineWidth&&(this.lineWidth=lineWidth),this.beginPath(),this.moveTo(x,y-size/2),this.lineTo(x,y+size/2),this.lineTo(x+size,y),this.lineTo(x,y-size/2),this.closePath(),this.fill(),this.restore()},roundRect:function(x,y,width,height,radius,fill,stroke){this.save(),"undefined"==typeof stroke&&(stroke=!0),"undefined"==typeof radius&&(radius=5),this.beginPath(),this.moveTo(x+radius,y),this.lineTo(x+width-radius,y),this.quadraticCurveTo(x+width,y,x+width,y+radius),this.lineTo(x+width,y+height-radius),this.quadraticCurveTo(x+width,y+height,x+width-radius,y+height),this.lineTo(x+radius,y+height),this.quadraticCurveTo(x,y+height,x,y+height-radius),this.lineTo(x,y+radius),this.quadraticCurveTo(x,y,x+radius,y),this.closePath(),stroke&&this.stroke(),fill&&this.fill(),this.restore()},polygon:function(x,y,fill,stroke){this.save(),"undefined"==typeof stroke&&(stroke=!0),this.beginPath();var len=x.length;this.moveTo(x[0],y[0]);for(var i=1;len>i;i++)this.lineTo(x[i],y[i]);this.closePath(),stroke&&this.stroke(),fill&&this.fill(),this.restore()},dashedLine:function(x1,y1,x2,y2,dashLen,properties){this.save(),x1=Math.round(x1),y1=Math.round(y1),x2=Math.round(x2),y2=Math.round(y2),dashLen=Math.round(dashLen),log("dashedLine"),properties&&igv.Canvas.setProperties.call(this,properties),void 0==dashLen&&(dashLen=2),this.moveTo(x1,y1);for(var dX=x2-x1,dY=y2-y1,dashes=Math.floor(Math.sqrt(dX*dX+dY*dY)/dashLen),dashX=dX/dashes,dashY=dY/dashes,q=0;q++<dashes;)x1+=dashX,y1+=dashY,this[q%2==0?"moveTo":"lineTo"](x1,y1);this[q%2==0?"moveTo":"lineTo"](x2,y2),this.restore()},lineTo:function(x,y,properties){log("lineTo"),this.save(),x=Math.round(x),y=Math.round(y),properties&&igv.Canvas.setProperties.call(this,properties),this.lineTo(x,y),this.restore()},moveTo:function(x,y,properties){log("moveTo"),this.save(),x=Math.round(x),y=Math.round(y),properties&&igv.Canvas.setProperties.call(this,properties),this.moveTo(x,y),this.restore()}},igv}(igv||{}),igv=function(igv){function clamp(value,min,max){return Math.min(Math.max(value,min),max)}return igv.rgbaColor=function(r,g,b,a){return r=clamp(r,0,255),g=clamp(g,0,255),b=clamp(b,0,255),a=clamp(a,0,1),"rgba("+r+","+g+","+b+","+a+")"},igv.rgbColor=function(r,g,b){return r=clamp(r,0,255),g=clamp(g,0,255),b=clamp(b,0,255),"rgb("+r+","+g+","+b+")"},igv.greyScale=function(value){var grey=clamp(value,0,255);return"rgb("+grey+","+grey+","+grey+")"},igv.randomGrey=function(min,max){min=clamp(min,0,255),max=clamp(max,0,255);var g=Math.round(igv.random(min,max)).toString(10);return"rgb("+g+","+g+","+g+")"},igv.randomRGB=function(min,max){min=clamp(min,0,255),max=clamp(max,0,255);var r=Math.round(igv.random(min,max)).toString(10),g=Math.round(igv.random(min,max)).toString(10),b=Math.round(igv.random(min,max)).toString(10);return"rgb("+r+","+g+","+b+")"},igv.nucleotideColorComponents={A:[0,200,0],C:[0,0,200],T:[255,0,0],G:[209,113,5],a:[0,200,0],c:[0,0,200],t:[255,0,0],g:[209,113,5]},igv.nucleotideColors={A:"rgb( 0, 200, 0)",C:"rgb( 0, 0, 200)",T:"rgb(255, 0, 0)",G:"rgb(209, 113, 5)",a:"rgb( 0, 200, 0)",c:"rgb( 0, 0, 200)",t:"rgb(255, 0, 0)",g:"rgb(209, 113, 5)"},igv.getCompositeColor=function(dest,src,alpha){var r=Math.floor(alpha*src[0]+(1-alpha)*dest[0]),g=Math.floor(alpha*src[1]+(1-alpha)*dest[1]),b=Math.floor(alpha*src[2]+(1-alpha)*dest[2]);return"rgb("+r+","+g+","+b+")"},igv.BinnedColorScale=function(cs){this.thresholds=cs.thresholds,this.colors=cs.colors},igv.BinnedColorScale.prototype.getColor=function(value){var i,len=this.thresholds.length;for(i=0;len>i;i++)if(value<this.thresholds[i])return this.colors[i];return this.colors[this.colors.length-1]},igv.GradientColorScale=function(scale){this.scale=scale,this.lowColor="rgb("+scale.lowR+","+scale.lowG+","+scale.lowB+")",this.highColor="rgb("+scale.highR+","+scale.highG+","+scale.highB+")",this.diff=scale.high-scale.low},igv.GradientColorScale.prototype.getColor=function(value){var r,g,b,frac,scale=this.scale;return value<=scale.low?this.lowColor:value>=scale.high?this.highColor:(frac=(value-scale.low)/this.diff,r=Math.floor(scale.lowR+frac*(scale.highR-scale.lowR)),g=Math.floor(scale.lowG+frac*(scale.highG-scale.lowG)),b=Math.floor(scale.lowB+frac*(scale.highB-scale.lowB)),"rgb("+r+","+g+","+b+")")},igv}(igv||{}),igv=function(igv){return igv.constants={dragThreshold:3},igv}(igv||{});CanvasRenderingContext2D.prototype.strokeLine=function(x1,y1,x2,y2,lineWidth){this.save(),this.beginPath(),lineWidth&&(this.lineWidth=lineWidth),this.moveTo(x1,y1),this.lineTo(x2,y2),this.stroke(),this.restore()},CanvasRenderingContext2D.prototype.drawArrowhead=function(x,y,size,lineWidth){this.save(),size||(size=5),lineWidth&&(this.lineWidth=lineWidth),this.beginPath(),this.moveTo(x,y-size/2),this.lineTo(x,y+size/2),this.lineTo(x+size,y),this.lineTo(x,y-size/2),this.closePath(),this.fill(),this.restore()},CanvasRenderingContext2D.prototype.roundRect=function(x,y,width,height,radius,fill,stroke){this.save(),"undefined"==typeof stroke&&(stroke=!0),"undefined"==typeof radius&&(radius=5),this.beginPath(),this.moveTo(x+radius,y),this.lineTo(x+width-radius,y),this.quadraticCurveTo(x+width,y,x+width,y+radius),this.lineTo(x+width,y+height-radius),this.quadraticCurveTo(x+width,y+height,x+width-radius,y+height),this.lineTo(x+radius,y+height),this.quadraticCurveTo(x,y+height,x,y+height-radius),this.lineTo(x,y+radius),this.quadraticCurveTo(x,y,x+radius,y),this.closePath(),stroke&&this.stroke(),fill&&this.fill(),this.restore()},CanvasRenderingContext2D.prototype.polygon=function(x,y,fill,stroke){this.save(),"undefined"==typeof stroke&&(stroke=!0),this.beginPath();var len=x.length;this.moveTo(x[0],y[0]);for(var i=1;len>i;i++)this.lineTo(x[i],y[i]);this.closePath(),stroke&&this.stroke(),fill&&this.fill(),this.restore()},CanvasRenderingContext2D.prototype.eqTriangle=function(side,cx,cy){this.save();var h=side*(Math.sqrt(3)/2);this.beginPath(),this.moveTo(cx,cy-h/2),this.lineTo(cx-side/2,cy+h/2),this.lineTo(cx+side/2,cy+h/2),this.lineTo(cx,cy-h/2),this.closePath(),this.stroke(),this.fill(),this.restore()},String.prototype.startsWith||(String.prototype.startsWith=function(aString){return this.length<aString.length?!1:this.substr(0,aString.length)==aString}),String.prototype.endsWith||(String.prototype.endsWith=function(aString){return this.length<aString.length?!1:this.substr(this.length-aString.length,aString.length)==aString}),String.prototype.contains||(String.prototype.contains=function(it){return-1!=this.indexOf(it)}),String.prototype.splitLines||(String.prototype.splitLines=function(){return this.split(/\r\n|\n|\r/gm)}),Array.prototype.shuffle||(Array.prototype.shuffle=function(){for(var j,x,i=this.length;i;j=parseInt(Math.random()*i),x=this[--i],this[i]=this[j],this[j]=x);return this}),Array.prototype.swap||(Array.prototype.swap=function(a,b){var tmp=this[a];this[a]=this[b],this[b]=tmp}),Array.prototype.heapSort||(Array.prototype.heapSort=function(compare){function heapify(array,index,heapSize){var left=2*index+1,right=2*index+2,largest=index;if(heapSize>left&&compare(array[left],array[index])>0&&(largest=left),heapSize>right&&compare(array[right],array[largest])>0&&(largest=right),largest!==index){var temp=array[index];array[index]=array[largest],array[largest]=temp,heapify(array,largest,heapSize)}}function buildMaxHeap(array){for(var i=Math.floor(array.length/2);i>=0;i-=1)heapify(array,i,array.length);return array}var temp,array=this,size=this.length;buildMaxHeap(array);for(var i=size-1;i>0;i-=1)temp=array[0],array[0]=array[i],array[i]=temp,size-=1,heapify(array,0,size);return array}),Uint8Array.prototype.toText||(Uint8Array.prototype.toText=function(){var i,len,str;for(str="",i=0,len=this.byteLength;len>i;i++)str+=String.fromCharCode(this[i]);return str});var log2=Math.log(2);Math.log2||(Math.log2=function(x){return Math.log(x)/log2}),Function.prototype.bind||(Function.prototype.bind=function(){var fn=this,args=Array.prototype.slice.call(arguments),object=args.shift();return function(){return fn.apply(object,args.concat(Array.prototype.slice.call(arguments)))}});var igv=function(igv){return igv.parseUri=function(str){for(var o=igv.parseUri.options,m=o.parser[o.strictMode?"strict":"loose"].exec(str),uri={},i=14;i--;)uri[o.key[i]]=m[i]||"";return uri[o.q.name]={},uri[o.key[12]].replace(o.q.parser,function($0,$1,$2){$1&&(uri[o.q.name][$1]=$2)}),uri},igv.parseUri.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},igv.trackMenuItems=function(popover,trackView){var trackMenuPopupDialog,trackItems,trackHeight=trackView.trackDiv.clientHeight,menuItems=[{object:$('<div class="igv-track-menu-item">Set track name</div>'),click:function(){trackMenuPopupDialog=new igv.TrackMenuPopupDialog(popover,"Track name",trackView.track.label,function(){trackMenuPopupDialog.name.val()?(igv.setTrackLabel(trackView.track,trackMenuPopupDialog.name.val()),trackMenuPopupDialog.dialogForm.dialog("close")):(trackMenuPopupDialog.name.addClass("ui-state-error"),trackMenuPopupDialog.updateTips("may not be blank"))}),trackMenuPopupDialog.dialogForm.dialog("open")}},{object:$('<div class="igv-track-menu-item">Set track height</div>'),click:function(){trackMenuPopupDialog=new igv.TrackMenuPopupDialog(popover,"Track height",trackHeight.toString(),function(){var str,numberString=trackMenuPopupDialog.name.val(),number=parseFloat(numberString,10),minHeight=trackView.track.minHeight||25,maxHeight=trackView.track.maxHeight||1e3;$.isNumeric(numberString)?minHeight>number||number>maxHeight?(trackMenuPopupDialog.name.addClass("ui-state-error"),str="must be between "+minHeight+" and "+igv.numberFormatter(maxHeight),trackMenuPopupDialog.updateTips(str)):(trackView.setTrackHeight(number),trackMenuPopupDialog.dialogForm.dialog("close")):(trackMenuPopupDialog.name.addClass("ui-state-error"),str=numberString+" is not a valid number",trackMenuPopupDialog.updateTips(str))},320,256),trackMenuPopupDialog.dialogForm.dialog("open")}}];return trackView.track.popupMenuItems&&(trackItems=trackView.track.popupMenuItems(popover),trackItems&&trackItems.length>0&&trackItems.forEach(function(trackItem,i){var str;trackItem.label?(str=0===i?'<div class="igv-track-menu-item igv-track-menu-border-top">':'<div class="igv-track-menu-item">',str=str+trackItem.label+"</div>",menuItems.push({object:$(str),click:trackItem.click,init:trackItem.init})):0===i?(trackItem.object.addClass("igv-track-menu-border-top"),menuItems.push(trackItem)):menuItems.push(trackItem)})),menuItems.push({object:$('<div class="igv-track-menu-item igv-track-menu-border-top">Remove track</div>'),click:function(){popover.hide(),trackView.browser.removeTrack(trackView.track)}}),menuItems},igv.colorPickerMenuItem=function(popover,trackView,trackLabel,trackColor){return{object:$('<div id="featureColorPicker" class="igv-track-menu-item">'+trackLabel+"</div>"),init:function(){$("#featureColorPicker").colorpicker({title:"Feature Color Picker",color:trackColor,parts:["header","map","bar","hsv","rgb","preview","swatches","footer"],okOnEnter:!0,inline:!1,ok:function(event,color){var r=Math.floor(255*color.rgb.r),g=Math.floor(255*color.rgb.g),b=Math.floor(255*color.rgb.b);igv.setTrackColor(trackView.track,igv.rgbColor(r,g,b)),trackView.update(),popover.hide()}})}}},igv.spinner=function(){var spinner=document.createElement("i");return spinner.className="fa fa-spinner fa-spin fa-24px igv-spinner-fa",spinner},igv.getSpinnerObjectWithParentElement=function(parentElement){return $(parentElement).find("i.fa-spinner")},igv.isSpinning=function(spinnerObject){return spinnerObject&&spinnerObject.hasClass("fa-spin")},igv.startSpinnerAtParentElement=function(parentElement){var spinnerObject=igv.getSpinnerObjectWithParentElement(parentElement);spinnerObject&&spinnerObject.show()},igv.stopSpinnerAtParentElement=function(parentElement){var spinnerObject=igv.getSpinnerObjectWithParentElement(parentElement);spinnerObject&&spinnerObject.hide()},igv.domElementRectAsString=function(element){return" x "+element.clientLeft+" y "+element.clientTop+" w "+element.clientWidth+" h "+element.clientHeight},igv.isNumber=function(n){return""===n?!1:void 0===n?!1:!isNaN(parseFloat(n))&&isFinite(n)},igv.guid=function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)},igv.random=function(min,max){return Math.random()*(max-min)+min},igv.numberFormatter=function(rawNumber){var dec=String(rawNumber).split(/[.,]/),sep=",",decsep=".";return dec[0].split("").reverse().reduce(function(prev,now,i){return i%3===0?prev+sep+now:prev+now}).split("").reverse().join("")+(dec[1]?decsep+dec[1]:"")},igv.numberUnFormatter=function(formatedNumber){return formatedNumber.split(",").join().replace(",","","g")},igv.translateMouseCoordinates=function(e,target){var eFixed=$.event.fix(e),posx=eFixed.pageX-$(target).offset().left,posy=eFixed.pageY-$(target).offset().top;return{x:posx,y:posy}},igv.formatPopoverText=function(nameValueArray){var markup='<table class="igv-popover-table">';return nameValueArray.forEach(function(nameValue){markup+=nameValue.name?'<tr><td class="igv-popover-td"><div class="igv-popoverNameValue"><span class="igv-popoverName">'+nameValue.name+'</span><span class="igv-popoverValue">'+nameValue.value+"</span></div></td></tr>":"<tr><td>"+nameValue.toString()+"</td></tr>"}),markup+="</table>"},igv.throttle=function(fn,threshhold,scope){threshhold||(threshhold=200);var last,deferTimer;return function(){var context=scope||this,now=+new Date,args=arguments;last&&last+threshhold>now?(clearTimeout(deferTimer),deferTimer=setTimeout(function(){last=now,fn.apply(context,args)},threshhold)):(last=now,fn.apply(context,args))}},igv.splitStringRespectingQuotes=function(string,delim){var i,c,tokens=[],len=string.length,n=0,quote=!1;if(len>0)for(tokens[n]=string.charAt(0),i=1;len>i;i++)c=string.charAt(i),'"'===c?quote=!quote:quote||c!==delim?tokens[n]+=c:(n++,tokens[n]="");return tokens},igv.addAjaxExtensions=function(){$.ajaxTransport("+binary",function(options,originalOptions,jqXHR){return{send:function(_,callback){{var xhr=new XMLHttpRequest,url=options.url,type=options.type,responseType="arraybuffer";options.data||null}if(xhr.addEventListener("load",function(){var data={};data[options.dataType]=xhr.response,callback(xhr.status,xhr.statusText,data,xhr.getAllResponseHeaders())}),xhr.open(type,url),xhr.responseType=responseType,options.headers)for(var prop in options.headers)options.headers.hasOwnProperty(prop)&&xhr.setRequestHeader(prop,options.headers[prop])},abort:function(){jqXHR.abort()}}})},igv}(igv||{}),igv=function(igv){function createStandardControls(browser,options){var contentKaryo,navigation,search,searchButton,zoom,zoomInButton,zoomOutButton,controlDiv=$('<div id="igvControlDiv" class="igv-control-div">')[0],fileInput=document.getElementById("fileInput");return fileInput&&fileInput.addEventListener("change",function(e){var featureFileReader,localFile=fileInput.files[0];featureFileReader=new igv.FeatureFileReader({localFile:localFile}),featureFileReader.readFeatures(function(){console.log("success reading "+localFile.name)})}),options.showNavigation&&(navigation=$('<div class="igvNavigation">'),$(controlDiv).append(navigation[0]),search=$('<div class="igvNavigationSearch">'),navigation.append(search[0]),browser.searchInput=$('<input class="igvNavigationSearchInput" type="text" placeholder="Locus Search">'),search.append(browser.searchInput[0]),searchButton=$('<i class="igv-app-icon fa fa-search fa-24px igvNavigationMarginLeft12">'),search.append(searchButton[0]),browser.searchInput.change(function(){browser.search($(this).val())}),searchButton.click(function(){browser.search(browser.searchInput.val())}),zoom=$('<div class="igvNavigationZoom">'),navigation.append(zoom[0]),zoomOutButton=$('<i class="igv-app-icon fa fa-minus-square-o fa-24px" style="padding-right: 4px;">'),zoom.append(zoomOutButton[0]),zoomInButton=$('<i class="igv-app-icon fa fa-plus-square-o fa-24px">'),zoom.append(zoomInButton[0]),zoomInButton.click(function(){igv.browser.zoomIn()}),zoomOutButton.click(function(){igv.browser.zoomOut()})),options.showKaryo&&(contentKaryo=$("#igvKaryoDiv")[0],contentKaryo||(contentKaryo=$('<div id="igvKaryoDiv" class="igv-karyo-div">')[0],$(controlDiv).append(contentKaryo)),browser.karyoPanel=new igv.KaryoPanel(contentKaryo)),controlDiv}function mergeGenome(options){options.genome&&"hg19"===options.genome&&(options.fastaURL="//dn7ywbm9isq8j.cloudfront.net/genomes/seq/hg19/hg19.fasta",options.cytobandURL="//dn7ywbm9isq8j.cloudfront.net/genomes/seq/hg19/cytoBand.txt",options.tracks||(options.tracks=[]),options.tracks.push({type:"sequence",order:9999}),options.tracks.push({url:"//dn7ywbm9isq8j.cloudfront.net/annotations/hg19/genes/gencode.v18.collapsed.bed.gz",indexed:!1,label:"Genes",order:1e4}))}function isT2D(options){if(options.tracks&&options.tracks.length>0){var t=options.tracks[0],b=t instanceof igv.T2dTrack;return b}return!1}return igv.createBrowser=function(parentDiv,options){var contentDiv,headerDiv,trackContainerDiv,browser,rootDiv,controlDiv;return igv.browser?(console.log("Attempt to create 2 browsers."),igv.browser):(options||(options={}),options.type||(options.type="IGV"),options.oauthToken&&(oauth.google.access_token=options.oauthToken),!options.flanking&&isT2D(options)&&(options.flanking=1e5),options.genome&&mergeGenome(options),trackContainerDiv=$('<div id="igvTrackContainerDiv" class="igv-track-container-div">')[0],browser=new igv.Browser(options,trackContainerDiv),rootDiv=browser.div,parentDiv.appendChild(rootDiv),controlDiv=options.createControls?options.createControls(browser,options):createStandardControls(browser,options),$(rootDiv).append($(controlDiv)),contentDiv=$('<div id="igvContentDiv" class="igv-content-div">')[0],$(rootDiv).append(contentDiv),headerDiv=$('<div id="igvHeaderDiv" class="igv-header-div">')[0],$(contentDiv).append(headerDiv),$(contentDiv).append(trackContainerDiv),browser.userFeedback=new igv.UserFeedback($(contentDiv)),browser.userFeedback.hide(),igv.popover=new igv.Popover(contentDiv),$.extend($.ui.dialog.prototype.options,{create:function(){var $this=$(this);$this.parent().find(".ui-dialog-buttonpane button:first").focus(),$this.keypress(function(e){return e.keyCode==$.ui.keyCode.ENTER?($this.parent().find(".ui-dialog-buttonpane button:first").click(),!1):void 0})}}),browser.ideoPanel=new igv.IdeoPanel(rootDiv),$(headerDiv).append(browser.ideoPanel.div),browser.ideoPanel.resize(),options.trackDefaults&&void 0!==options.trackDefaults.bam&&(void 0!==options.trackDefaults.bam.coverageThreshold&&(igv.CoverageMap.threshold=options.trackDefaults.bam.coverageThreshold),void 0!==options.trackDefaults.bam.coverageQualityWeight&&(igv.CoverageMap.qualityWeight=options.trackDefaults.bam.coverageQualityWeight)),igv.loadGenome(options.fastaURL,options.cytobandURL,function(genome){browser.genome=genome,browser.addTrack(new igv.RulerTrack);var firstChrName=browser.genome.chromosomeNames[0],firstChr=browser.genome.chromosomes[firstChrName];browser.referenceFrame=new igv.ReferenceFrame(firstChrName,0,firstChr.bpLength/browser.trackViewportWidth()),browser.controlPanelWidth=50,browser.updateLocusSearch(browser.referenceFrame),browser.ideoPanel&&browser.ideoPanel.repaint(),browser.karyoPanel&&browser.karyoPanel.repaint(),options.locus?browser.search(options.locus,function(){var refFrame=igv.browser.referenceFrame,start=refFrame.start,end=start+igv.browser.trackViewportWidth()*refFrame.bpPerPixel,range=start-end;options.tracks&&(1e5>range?genome.sequence.getSequence(refFrame.chr,start,end,function(refSeq){options.tracks.forEach(function(track){browser.loadTrack(track)})}):options.tracks.forEach(function(track){browser.loadTrack(track)}))}):options.tracks&&options.tracks.forEach(function(track){browser.loadTrack(track)})}),browser)},igv}(igv||{}),igvxhr=function(igvxhr){function isCrossDomain(url){var origin=window.location.origin;return!url.startsWith(origin)}const NONE=0,GZIP=1,BGZF=2;return igvxhr.isReachable=function(url,continuation){var request=new XMLHttpRequest;request.open("HEAD",url,!0),request.onload=function(event){0===request.status?continuation(!1,request.status):request.status>=200&&request.status<=300?continuation(!0,request.status):continuation(!1,request.status)},request.onerror=function(event){continuation(!1,request.status)},request.ontimeout=function(event){continuation(!1,request.status)},request.onabort=function(event){continuation(!1,request.status)},request.send(null)},igvxhr.loadArrayBuffer=function(url,options){options.responseType="arraybuffer",igvxhr.load(url,options)},igvxhr.loadJson=function(url,options){var success=options.success;options.contentType="application/json",options.success=function(result){success(result?JSON.parse(result):null)},igvxhr.load(url,options)},igvxhr.loadString=function(url,options){var compression,success=options.success;compression=options.bgz?BGZF:url.endsWith(".gz")?GZIP:NONE,compression===NONE?(options.mimeType="text/plain; charset=x-user-defined",igvxhr.load(url,options)):(options.responseType="arraybuffer",options.success=function(data){var result=igv.arrayBufferToString(data,compression);success(result)},igvxhr.load(url,options))},igvxhr.load=function(url,options){var header_keys,key,value,i,xhr=new XMLHttpRequest,sendData=options.sendData,method=options.method||(sendData?"POST":"GET"),success=options.success,error=options.error||success,abort=options.abort||error,timeout=options.timeout||error,task=options.task,range=options.range,responseType=options.responseType,contentType=options.contentType,mimeType=options.mimeType,headers=options.headers,isSafari=0==navigator.vendor.indexOf("Apple")&&/\sSafari\//.test(navigator.userAgent);if(task&&(task.xhrRequest=xhr),range&&isSafari&&(console.log(isSafari),url+=url.contains("?")?"&":"?",url+="someRandomSeed="+Math.random().toString(36)),xhr.open(method,url),range){var rangeEnd=range.size?range.start+range.size-1:"";xhr.setRequestHeader("Range","bytes="+range.start+"-"+rangeEnd)}if(contentType&&xhr.setRequestHeader("Content-Type",contentType),mimeType&&xhr.overrideMimeType(mimeType),responseType&&(xhr.responseType=responseType),headers)for(header_keys=Object.keys(headers),i=0;i<header_keys.length;i++)key=header_keys[i],value=headers[key],console.log("Adding to header: "+key+"="+value),xhr.setRequestHeader(key,value);xhr.onload=function(event){0==xhr.status||xhr.status>=200&&xhr.status<=300?success(xhr.response,xhr):error(null,xhr)},xhr.onerror=function(event){return isCrossDomain(url)&&url&&igv.browser.crossDomainProxy&&url!=igv.browser.crossDomainProxy&&!options.crossDomainRetried?(options.sendData="url="+url,options.crossDomainRetried=!0,void igvxhr.load(igv.browser.crossDomainProxy,options)):416===xhr.status&&options.range&&!options.rangeRetried?(options.range.size=void 0,options.rangeRetried=!0,void igv.xhr.load(url,options)):void error(null,xhr)},xhr.ontimeout=function(event){console.log("Aborted"),timeout(null,xhr)},xhr.onabort=function(event){console.log("Aborted"),abort(null,xhr)},xhr.send(sendData)},igvxhr.loadHeader=function(url,options){function parseResponseHeaders(headerStr){var headers={};if(!headerStr)return headers;for(var headerPairs=headerStr.split("\r\n"),i=0,len=headerPairs.length;len>i;i++){var headerPair=headerPairs[i],index=headerPair.indexOf(": ");if(index>0){var key=headerPair.substring(0,index).toLowerCase(),val=headerPair.substring(index+2);headers[key]=val}}return headers}var header_keys,key,value,i,xhr=new XMLHttpRequest,method="HEAD",success=options.success,error=options.error||success,timeout=options.timeout||error,headers=options.headers;if(xhr.open(method,url),headers)for(header_keys=Object.keys(headers),i=0;i<header_keys.length;i++)key=header_keys[i],value=headers[key],console&&console.log&&console.log("Adding to header: "+key+"="+value),xhr.setRequestHeader(key,value);xhr.onload=function(event){var headerStr=xhr.getAllResponseHeaders(),headerDictionary=parseResponseHeaders(headerStr);success(headerDictionary)},xhr.onerror=function(event){error(null,xhr)},xhr.ontimeout=function(event){timeout(null)},xhr.send()},igvxhr.getContentLength=function(url,options){var continuation=options.success;options.error||(options.error=function(){continuation(-1)}),options.success=function(header){var contentLengthString=header?header["content-length"]:null;continuation(contentLengthString?parseInt(contentLengthString):-1)},igvxhr.loadHeader(url,options)},igvxhr.loadStringFromFile=function(localfile,options){{var fileReader=new FileReader,success=options.success,error=options.error||options.success;options.abort||options.error,options.timeout||options.error,options.range}fileReader.onload=function(e){var compression,result;compression=options.bgz?BGZF:localfile.name.endsWith(".gz")?GZIP:NONE,result=igv.arrayBufferToString(fileReader.result,compression),success(result,localfile)},fileReader.onerror=function(e){console.log("error uploading local file "+localfile.name),error(null,fileReader)},fileReader.readAsArrayBuffer(localfile)},igv.arrayBufferToString=function(arraybuffer,compression){var plain,inflate;compression===GZIP?(inflate=new Zlib.Gunzip(new Uint8Array(arraybuffer)),plain=inflate.decompress()):plain=new Uint8Array(compression===BGZF?igv.unbgzf(arraybuffer):arraybuffer);for(var result="",i=0,len=plain.length;len>i;i++)result+=String.fromCharCode(plain[i]);return result},igvxhr}(igvxhr||{}),igv=function(igv){function searchAll(interval,node,results){return node.interval.overlaps(interval)&&results.push(node.interval),node.left!=NIL&&node.left.max>=interval.low&&searchAll.call(this,interval,node.left,results),node.right!=NIL&&node.right.min<=interval.high&&searchAll.call(this,interval,node.right,results),results}function leftRotate(x){var y=x.right;x.right=y.left,y.left!=NIL&&(y.left.parent=x),y.parent=x.parent,x.parent==NIL?this.root=y:x.parent.left==x?x.parent.left=y:x.parent.right=y,y.left=x,x.parent=y,applyUpdate.call(this,x)}function rightRotate(x){var y=x.left;x.left=y.right,y.right!=NIL&&(y.right.parent=x),y.parent=x.parent,x.parent==NIL?this.root=y:x.parent.right==x?x.parent.right=y:x.parent.left=y,y.right=x,x.parent=y,applyUpdate.call(this,x)}function applyUpdate(node){for(;node!=NIL;){var nodeMax=node.left.max>node.right.max?node.left.max:node.right.max,intervalHigh=node.interval.high;node.max=nodeMax>intervalHigh?nodeMax:intervalHigh;var nodeMin=node.left.min<node.right.min?node.left.min:node.right.min,intervalLow=node.interval.low;node.min=intervalLow>nodeMin?nodeMin:intervalLow,node=node.parent}}function Interval(low,high,value){
|
8
|
+
this.low=low,this.high=high,this.value=value}function Node(interval){this.parent=NIL,this.left=NIL,this.right=NIL,this.interval=interval,this.color=RED}var BLACK=1,RED=2,NIL={};return NIL.color=BLACK,NIL.parent=NIL,NIL.left=NIL,NIL.right=NIL,igv.IntervalTree=function(){this.root=NIL},igv.IntervalTree.prototype.insert=function(start,end,value){var interval=new Interval(start,end,value),x=new Node(interval);for(this.treeInsert(x),x.color=RED;x!=this.root&&x.parent.color==RED;)if(x.parent==x.parent.parent.left){var y=x.parent.parent.right;y.color==RED?(x.parent.color=BLACK,y.color=BLACK,x.parent.parent.color=RED,x=x.parent.parent):(x==x.parent.right&&(x=x.parent,leftRotate.call(this,x)),x.parent.color=BLACK,x.parent.parent.color=RED,rightRotate.call(this,x.parent.parent))}else{var y=x.parent.parent.left;y.color==RED?(x.parent.color=BLACK,y.color=BLACK,x.parent.parent.color=RED,x=x.parent.parent):(x==x.parent.left&&(x=x.parent,rightRotate.call(this,x)),x.parent.color=BLACK,x.parent.parent.color=RED,leftRotate.call(this,x.parent.parent))}this.root.color=BLACK},igv.IntervalTree.prototype.findOverlapping=function(start,end){var searchInterval=new Interval(start,end,0);if(this.root===NIL)return[];var intervals=searchAll.call(this,searchInterval,this.root,[]);return intervals.length>1&&intervals.sort(function(i1,i2){return i1.low-i2.low}),intervals},igv.IntervalTree.prototype.logIntervals=function(){function logNode(node,indent){for(var space="",i=0;indent>i;i++)space+=" ";console.log(space+node.interval.low+" "+node.interval.high),indent+=5,node.left!=NIL&&logNode(node.left,indent),node.right!=NIL&&logNode(node.right,indent)}logNode(this.root,0)},igv.IntervalTree.prototype.mapIntervals=function(func){function applyInterval(node){func(node.interval),node.left!=NIL&&applyInterval(node.left),node.right!=NIL&&applyInterval(node.right)}applyInterval(this.root)},igv.IntervalTree.prototype.treeInsert=function(x){for(var node=this.root,y=NIL;node!=NIL;)y=node,node=x.interval.low<=node.interval.low?node.left:node.right;x.parent=y,y==NIL?(this.root=x,x.left=x.right=NIL):x.interval.low<=y.interval.low?y.left=x:y.right=x,applyUpdate.call(this,x)},Interval.prototype.equals=function(other){return other?this==other?!0:this.low==otherInterval.low&&this.high==otherInterval.high:!1},Interval.prototype.compareTo=function(other){return this.low<other.low?-1:this.low>other.low?1:this.high<other.high?-1:this.high>other.high?1:0},Interval.prototype.overlaps=function(other){try{return this.low<=other.high&&other.low<=this.high}catch(e){alert(e)}},igv}(igv||{}),igv=function(igv){var log=function(txt){};return igv.KaryoPanel=function(parentElement){this.ideograms=null,igv.guichromosomes=[],this.div=$('<div class="igv-karyo-div"></div>')[0],$(parentElement).append(this.div);var contentDiv=$('<div class="igv-karyo-content-div"></div>')[0];$(this.div).append(contentDiv);var canvas=$('<canvas class="igv-karyo-canvas"></canvas>')[0];$(contentDiv).append(canvas),canvas.setAttribute("width",contentDiv.offsetWidth),canvas.setAttribute("height",contentDiv.offsetHeight),this.canvas=canvas,this.ctx=canvas.getContext("2d");var tipCanvas=document.createElement("canvas");tipCanvas.style.position="absolute",tipCanvas.style.width="100px",tipCanvas.style.height="20px",tipCanvas.style.left="-2000px",tipCanvas.setAttribute("width","100px"),tipCanvas.setAttribute("height","20px");var tipCtx=tipCanvas.getContext("2d");contentDiv.appendChild(tipCanvas),this.canvas.onmousemove=function(e){for(var mouseCoords=igv.translateMouseCoordinates(e,canvas),mouseX=mouseCoords.x,mouseY=mouseCoords.y,hit=!1,i=0;i<igv.guichromosomes.length;i++){var g=igv.guichromosomes[i];if(g.x<mouseX&&g.right>mouseX&&g.y<mouseY&&g.bottom>mouseY){var dy=mouseY-g.y,bp=Math.round(g.size*dy/g.h);tipCanvas.style.left=Math.round(mouseX+20)+"px",tipCanvas.style.top=Math.round(mouseY-5)+"px",tipCtx.clearRect(0,0,tipCanvas.width,tipCanvas.height),tipCtx.fillStyle="rgb(255,255,220)",tipCtx.fillRect(0,0,tipCanvas.width,tipCanvas.height),tipCtx.fillStyle="rgb(0,0,0)";var mb=Math.round(bp/1e6);tipCtx.fillText(g.name+" @ "+mb+" MB",3,12),hit=!0;break}}hit||(tipCanvas.style.left="-2000px")},this.canvas.onclick=function(e){var mouseCoords=igv.translateMouseCoordinates(e,canvas),mouseX=mouseCoords.x,mouseY=mouseCoords.y;igv.navigateKaryo(mouseX,mouseY)}},igv.navigateKaryo=function(mouseX,mouseY){for(var i=0;i<igv.guichromosomes.length;i++){var g=igv.guichromosomes[i];if(g.x<mouseX&&g.right>mouseX&&g.y<mouseY&&g.bottom>mouseY){var dy=mouseY-g.y,bp=Math.round(g.size*dy/g.h);log("Going to position "+bp),igv.browser["goto"](g.name,bp);break}}igv.browser.update()},igv.KaryoPanel.prototype.resize=function(){var canvas=this.canvas;canvas.setAttribute("width",canvas.clientWidth),canvas.setAttribute("height",canvas.clientHeight),log("Resize called: width="+canvas.clientWidth+"/"+canvas.clientHeight),this.ideograms=void 0,this.repaint()},igv.KaryoPanel.prototype.repaint=function(){function drawImage(){image=document.createElement("canvas"),image.width=w,image.height=h;var bufferCtx=image.getContext("2d"),nr=0,col=0,row=1,y=top;igv.guichromosomes=[];for(chr in chromosomes){if(nr>nrchr)break;1==row&&2==nrrows&&nr+1>nrchr/2&&(row=2,col=0,y=y+chrheight+top),nr++,col++;var chromosome=genome.getChromosome(chr);"chrM"!=chr||chromosome.bpLength||(chromosome.bpLength=16e3),chromosome.x=col*totalchrwidth,chromosome.y=y;var guichrom=new Object;guichrom.name=chr,igv.guichromosomes.push(guichrom),drawIdeogram(guichrom,chromosome.x,chromosome.y,chromosome,bufferCtx,chrwidth,chrheight,maxLen)}this.ideograms=image,log("============= PROCESSING "+igv.browser.trackViews.length+" TRACKS");for(var tracknr=0,i=0;i<igv.browser.trackViews.length;i++){var trackPanel=igv.browser.trackViews[i],track=trackPanel.track;if(track.getSummary&&track.loadSummary){log("Found track with summary: "+track.label);var source=track;window.source=track,source.loadSummary("chr1",0,1e6,function(featureList){if(featureList){nr=0;for(chr in chromosomes){var guichrom=igv.guichromosomes[nr];nr++,guichrom&&guichrom.size&&loadfeatures(source,chr,0,guichrom.size,guichrom,bufferCtx,tracknr)}}}),tracknr++}}}function drawFeatures(source,featurelist,guichrom,ideogramLeft,top,bufferCtx,ideogramWidth,ideogramHeight,longestChr,tracknr){if(genome&&guichrom&&featurelist){var len=featurelist.length;if(0!=len)for(var scale=ideogramHeight/longestChr,dx=1,i=0;i<featurelist.length;i++){var feature=featurelist[i],color="rgb(0,0,150)",value=feature.score;source.getColor&&(color=source.getColor(value));var starty=scale*feature.start+top,endy=scale*feature.end+top,dy=Math.max(.01,endy-starty);bufferCtx.fillStyle=color,bufferCtx.fillRect(ideogramLeft+ideogramWidth+2*tracknr+1,starty,dx,dy)}}}function drawIdeogram(guichrom,ideogramLeft,top,chromosome,bufferCtx,ideogramWidth,ideogramHeight,longestChr){if(genome&&chromosome){var cytobands=chromosome.cytobands,centerx=ideogramLeft+ideogramWidth/2,xC=[],yC=[],len=cytobands.length,scale=ideogramHeight/longestChr;guichrom.x=ideogramLeft,guichrom.y=top,guichrom.w=ideogramWidth,guichrom.right=ideogramLeft+ideogramWidth;var last=0,lastPY=-1;if(len>0)last=cytobands[len-1].end,guichrom.h=scale*last,guichrom.size=last;else{var MINH=5;lastPY=top+MINH,guichrom.h=MINH,guichrom.size=MINH/scale}if(guichrom.longest=longestChr,guichrom.bottom=top+guichrom.h,len>0)for(var i=0;i<cytobands.length;i++){var cytoband=cytobands[i],starty=scale*cytoband.start+top,endy=scale*cytoband.end+top;if(endy>lastPY)if("c"==cytoband.type)"p"==cytoband.label.charAt(0)?(yC[0]=starty,xC[0]=ideogramWidth+ideogramLeft,yC[1]=starty,xC[1]=ideogramLeft,yC[2]=endy,xC[2]=centerx):(yC[0]=endy,xC[0]=ideogramWidth+ideogramLeft,yC[1]=endy,xC[1]=ideogramLeft,yC[2]=starty,xC[2]=centerx),bufferCtx.fillStyle="rgb(220, 150, 100)",bufferCtx.strokeStyle="rgb(150, 0, 0)",bufferCtx.polygon(xC,yC,1,0);else{var dy=endy-starty;bufferCtx.fillStyle=getCytobandColor(cytoband),bufferCtx.fillRect(ideogramLeft,starty,ideogramWidth,dy)}lastPY=endy}bufferCtx.fillStyle=null,bufferCtx.lineWidth=1,bufferCtx.strokeStyle="darkgray";var r=ideogramWidth/2;bufferCtx.roundRect(ideogramLeft,top-r/2,ideogramWidth,lastPY-top+r,ideogramWidth/2,0,1),bufferCtx.font="bold 10px Arial",bufferCtx.fillStyle="rgb(0, 0, 0)";var name=chromosome.name;name.length>3&&(name=name.substring(3)),bufferCtx.fillText(name,ideogramLeft+ideogramWidth/2-3*name.length,top-10)}}function getCytobandColor(data){if("c"==data.type)return"rgb(150, 10, 10)";var stain=data.stain,shade=230;"p"==data.type&&(shade=Math.floor(230-stain/100*230));var c=stainColors[shade];return null==c&&(c="rgb("+shade+","+shade+","+shade+")",stainColors[shade]=c),c}function loadfeatures(source,chr,start,end,guichrom,bufferCtx,tracknr){source.getSummary(chr,start,end,function(featureList){featureList&&(len=featureList.length,drawFeatures(source,featureList,guichrom,guichrom.x,guichrom.y,bufferCtx,chrwidth,chrheight,maxLen,tracknr),me.repaint())})}var genome=igv.browser.genome,referenceFrame=igv.browser.referenceFrame,stainColors=[],w=this.canvas.width,h=this.canvas.height;if(this.ctx.clearRect(0,0,w,h),genome&&referenceFrame&&genome.chromosomes&&referenceFrame.chr){var chromosomes=genome.getChromosomes(),image=this.ideograms;if(chromosomes.length<1)return void log("No chromosomes yet, returning");var nrchr=24,nrrows=1;300>w&&(nrrows=2);var totalchrwidth=Math.min(50,(w-20)/(nrchr+2)*nrrows),chrwidth=Math.min(20,totalchrwidth/2),top=25,chrheight=h/nrrows-top,longestChr=genome.getChromosome("chr1"),cytobands=longestChr.cytobands,me=this,maxLen=cytobands[cytobands.length-1].end;image&&null!=image||drawImage.call(this),this.ctx.drawImage(image,0,0),this.ctx.save();var chr=referenceFrame.chr;this.genome&&(chr=this.genome.getChromosomeName(chr));var chromosome=igv.browser.genome.getChromosome(chr);if(chromosome){var ideoScale=longestChr.bpLength/chrheight,boxHeight=Math.max(3,igv.browser.trackViewportWidth()*referenceFrame.bpPerPixel/ideoScale);this.ctx.strokeStyle="rgb(150, 0, 0)",this.ctx.lineWidth=2,this.ctx.strokeRect(chromosome.x-3,chromosome.y-3,chrwidth+6,boxHeight+6),this.ctx.restore()}else log("Could not find chromosome "+chr)}},igv}(igv||{}),oauth=function(oauth){if(!oauth.google){var tokenType,expiresIn,user,OAUTHURL="https://accounts.google.com/o/oauth2/auth?",VALIDURL="https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=",REDIRECT="http://localhost/igv-web/emptyPage.html",_url=OAUTHURL+"scope=https://www.googleapis.com/auth/genomics https://www.googleapis.com/auth/userinfo.profile&state=%2Fprofile&redirect_uri=http%3A%2F%2Flocalhost%2Figv-web%2FemptyPage.html&response_type=token&client_id=661332306814-8nt29308rppg325bkq372vli8nm3na14.apps.googleusercontent.com",loggedIn=!1;oauth.google={login:function(){var win=window.open(_url,"windowname1","width=800, height=600"),pollTimer=window.setInterval(function(){try{if(console.log(win.document.URL),-1!=win.document.URL.indexOf(REDIRECT)){window.clearInterval(pollTimer);var url=win.document.URL;oauth.google.access_token=oauth.google.gup(url,"access_token"),tokenType=oauth.google.gup(url,"token_type"),expiresIn=oauth.google.gup(url,"expires_in"),win.close(),oauth.google.validateToken(oauth.google.access_token)}}catch(e){}},500)},validateToken:function(token){$.ajax({url:VALIDURL+token,data:null,success:function(responseText){oauth.google.getUserInfo(),loggedIn=!0},dataType:"jsonp"})},getUserInfo:function(){$.ajax({url:"https://www.googleapis.com/oauth2/v1/userinfo?access_token="+oauth.google.access_token,data:null,success:function(resp){user=resp,console.log(user)},dataType:"jsonp"})},gup:function(url,name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regexS="[\\#&]"+name+"=([^&#]*)",regex=new RegExp(regexS),results=regex.exec(url);return null==results?"":results[1]},startLogoutPolling:function(){$("#loginText").show(),$("#logoutText").hide(),loggedIn=!1,$("#uName").text("Welcome "),$("#imgHolder").attr("src","none.jpg")}}}return oauth}(oauth||{}),igv=function(igv){return igv.isBlank=function(line){var meh=line.match(/\S+/g);return!meh},igv.isComment=function(line){var index=line.indexOf("#");return 0==index},igv.getQueryValue=function(name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regexS="[\\?&]"+name+"=([^&#]*)",regex=new RegExp(regexS),results=regex.exec(window.location.href);return null==results?void 0:results[1]},igv.inferFileType=function(path){var fn=path.toLowerCase();return fn.endsWith(".gz")?fn=fn.substr(0,fn.length-3):(fn.endsWith(".txt")||fn.endsWith(".tab"))&&(fn=fn.substr(0,fn.length-4)),fn.endsWith(".vcf")||fn.endsWith(".vcf.gz")?"vcf":fn.endsWith(".narrowpeak")?"narrowPeak":fn.endsWith(".broadpeak")?"broadPeak":fn.endsWith(".bedgraph")?"bedgraph":fn.endsWith(".wig")?"wig":fn.endsWith(".bed")?"bed":fn.endsWith(".seg")?"seg":fn.endsWith(".bam")?"bam":fn.endsWith(".bw")||fn.endsWith(".bigwig")?"bigwig":fn.endsWith(".bb")||fn.endsWith(".bigbed")?"bigwig":null},igv}(igv||{}),igv=function(igv){function popoverPosition(pageX,pageY,popoverWidget){var left,popupRect,containerCoordinates={x:pageX,y:pageY},containerRect={x:0,y:0,width:$(window).width(),height:$(window).height()},popupX=pageX,popupY=pageY;return popupX-=$(popoverWidget.parentDiv).offset().left,popupY-=$(popoverWidget.parentDiv).offset().top,popupRect={x:popupX,y:popupY,width:popoverWidget.popover.outerWidth(),height:popoverWidget.popover.outerHeight()},left=popupX,containerCoordinates.x+popupRect.width>containerRect.width&&(left=popupX-popupRect.width),{left:left+"px",top:popupY+"px"}}return igv.Popover=function(parentDiv){this.markupWithParentDiv(parentDiv)},igv.Popover.prototype.markupWithParentDiv=function(parentDiv){var popoverHeader,popoverClose,popoverCloseFontAwesome,myself=this;this.parentDiv||(this.parentDiv=parentDiv,this.popover=$('<div class="igv-popover">'),$(this.parentDiv).append(this.popover[0]),popoverHeader=$('<div class="igv-popoverHeader">'),this.popover.append(popoverHeader[0]),popoverClose=$('<div class="igv-popoverClose">'),popoverHeader.append(popoverClose[0]),popoverCloseFontAwesome=$('<i class="fa fa-times igv-popoverCloseFontAwesome">'),popoverClose.append(popoverCloseFontAwesome[0]),popoverCloseFontAwesome.hover(function(){popoverCloseFontAwesome.removeClass("fa-times"),popoverCloseFontAwesome.addClass("fa-times-circle"),popoverCloseFontAwesome.css({color:"#222"})},function(){popoverCloseFontAwesome.removeClass("fa-times-circle"),popoverCloseFontAwesome.addClass("fa-times"),popoverCloseFontAwesome.css({color:"#444"})}),popoverCloseFontAwesome.click(function(){myself.hide()}),this.popoverContent=$("<div>"),this.popover.append(this.popoverContent[0]))},igv.Popover.prototype.testData=function(rows){var i,name,nameValues=[];for(i=0;rows>i;i++)name="name "+i,nameValues.push({name:name,value:"verbsgohuman"});return nameValues},igv.Popover.prototype.hide=function(){this.popover.hide()},igv.Popover.prototype.presentTrackMenu=function(pageX,pageY,trackView){var container=$('<div class="igv-track-menu-container">'),trackMenuItems=igv.trackMenuItems(this,trackView);trackMenuItems.forEach(function(trackMenuItem,index,tmi){if(trackMenuItem.object){var ob=trackMenuItem.object;container.append(ob[0])}else container.append(trackMenuItem)}),this.popoverContent.empty(),this.popoverContent.removeClass("igv-popoverTrackPopupContent"),this.popoverContent.append(container[0]),trackMenuItems.forEach(function(trackMenuItem){var ob=trackMenuItem.object,cl=trackMenuItem.click,init=trackMenuItem.init;cl&&ob.click(cl),init&&init()}),this.popover.css(popoverPosition(pageX,pageY,this)).show()},igv.Popover.prototype.presentTrackPopup=function(pageX,pageY,content){content&&(this.popoverContent.addClass("igv-popoverTrackPopupContent"),this.popoverContent.html(content),this.popover.css(popoverPosition(pageX,pageY,this)).show())},igv}(igv||{}),igv=function(igv){return igv.ReferenceFrame=function(chr,start,bpPerPixel){this.chr=chr,this.start=start,this.bpPerPixel=bpPerPixel},igv.ReferenceFrame.prototype.toPixels=function(bp){return bp/this.bpPerPixel},igv.ReferenceFrame.prototype.toBP=function(pixels){return this.bpPerPixel*pixels},igv.ReferenceFrame.prototype.shiftPixels=function(pixels){this.start+=pixels*this.bpPerPixel},igv.ReferenceFrame.prototype.description=function(){return"ReferenceFrame "+this.chr+" "+igv.numberFormatter(Math.floor(this.start))+" bpp "+this.bpPerPixel},igv}(igv||{}),igv=function(igv){function TickSpacing(majorTick,majorUnit,unitMultiplier){this.majorTick=majorTick,this.majorUnit=majorUnit,this.unitMultiplier=unitMultiplier}function findSpacing(maxValue){function log10(x){var dn=Math.log(10);return Math.log(x)/dn}if(10>maxValue)return new TickSpacing(1,"",1);var nZeroes=Math.floor(log10(maxValue)),majorUnit="",unitMultiplier=1;nZeroes>9&&(majorUnit="gb",unitMultiplier=1e9),nZeroes>6?(majorUnit="mb",unitMultiplier=1e6):nZeroes>3&&(majorUnit="kb",unitMultiplier=1e3);var nMajorTicks=maxValue/Math.pow(10,nZeroes-1);return 25>nMajorTicks?new TickSpacing(Math.pow(10,nZeroes-1),majorUnit,unitMultiplier):new TickSpacing(Math.pow(10,nZeroes)/2,majorUnit,unitMultiplier)}return igv.RulerTrack=function(){this.height=50,this.label="",this.id="ruler",this.disableButtons=!0,this.ignoreTrackMenu=!0},igv.RulerTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,success,task){success([])},igv.RulerTrack.prototype.draw=function(options){function formatNumber(anynum,decimal){var divider=10;switch(decimal){case 0:divider=1;break;case 1:divider=10;break;case 2:divider=100;break;default:divider=1e3}var workNum=Math.abs(Math.round(anynum*divider)/divider),workStr=""+workNum;-1==workStr.indexOf(".")&&(workStr+=".");for(var dStr=workStr.substr(0,workStr.indexOf(".")),dNum=dStr-0,pStr=workStr.substr(workStr.indexOf("."));pStr.length-1<decimal;)pStr+="0";if("."==pStr&&(pStr=""),dNum>=1e3){var dLen=dStr.length;dStr=parseInt(""+dNum/1e3)+","+dStr.substring(dLen-3,dLen)}dNum>=1e6&&(dLen=dStr.length,dStr=parseInt(""+dNum/1e6)+","+dStr.substring(dLen-7,dLen));var retval=dStr+pStr;return 0>anynum&&(retval="("+retval+")"),retval}var fontStyle,range,ts,spacing,nTick,x,ctx=options.context;for(fontStyle={textAlign:"center",font:"10px PT Sans",fillStyle:"rgba(64, 64, 64, 1)",strokeStyle:"rgba(64, 64, 64, 1)"},range=Math.floor(1100*options.bpPerPixel),ts=findSpacing(range),spacing=ts.majorTick,nTick=Math.floor(options.bpStart/spacing)-1,x=0,igv.Canvas.setProperties.call(ctx,fontStyle);x<options.pixelWidth;){var l=Math.floor(nTick*spacing);x=Math.round((l-1-options.bpStart+.5)/options.bpPerPixel);var chrPosition=formatNumber(l/ts.unitMultiplier,0)+" "+ts.majorUnit;nTick%1==0&&igv.Canvas.fillText.call(ctx,chrPosition,x,this.height-15),igv.Canvas.strokeLine.call(ctx,x,this.height-10,x,this.height-2),nTick++}igv.Canvas.strokeLine.call(ctx,0,this.height-1,options.pixelWidth,this.height-1)},igv}(igv||{}),igv=function(igv){return igv.SequenceTrack=function(config){this.label="",this.id="sequence",this.type=config.type,this.height=15,this.disableButtons=!0,this.order=config.order||9999,this.ignoreTrackMenu=!0},igv.SequenceTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){igv.browser.referenceFrame.bpPerPixel>1?continuation(null):igv.browser.genome.sequence.getSequence(chr,bpStart,bpEnd,continuation,task)},igv.SequenceTrack.prototype.draw=function(options){var sequence=options.features,ctx=options.context,bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,pixelWidth=options.pixelWidth,bpEnd=bpStart+pixelWidth*bpPerPixel+1;if(sequence)for(var len=sequence.length,w=1/bpPerPixel,y=this.height/2,pos=bpStart;bpEnd>=pos;pos++){var offset=pos-bpStart;if(len>offset){var b=sequence[offset],p0=Math.floor(offset*w),p1=Math.floor((offset+1)*w),pc=Math.round((p0+p1)/2),c=igv.nucleotideColors[b];c||(c="gray"),bpPerPixel>.1?igv.Canvas.fillRect.call(ctx,p0,0,p1-p0,10,{fillStyle:c}):igv.Canvas.strokeText.call(ctx,b,pc,y,{strokeStyle:c,font:"normal 10px Arial",textAlign:"center"})}}},igv}(igv||{});Array.isArray||(Array.isArray=function(vArg){return"[object Array]"===Object.prototype.toString.call(vArg)}),Set?Set.prototype.isEmpty=function(){return 0===this.size}:(Set=function(){this.data={},this.add.apply(this,arguments)},Set.prototype={add:function(){for(var key,i=0;i<arguments.length;i++)if(key=arguments[i],Array.isArray(key)||this._isPseudoArray(key))for(var j=0;j<key.length;j++)this._add(key[j]);else if(key instanceof Set){var self=this;key.each(function(val,key){self._add(key,val)})}else this._add(key);return this},_add:function(key,val){return"undefined"==typeof val&&(val=key),this.data[this._makeKey(key)]=val,this},_getKey:function(arg){return arg},_makeKey:function(arg){return arg},_removeItem:function(key){delete this.data[this._getKey(key)]},_isPseudoArray:function(item){return!1},"delete":function(key){for(var item,j=0;j<arguments.length;j++)if(item=arguments[j],Array.isArray(item)||this._isPseudoArray(item))for(var i=0;i<item.length;i++)this._removeItem(item[i]);else this._removeItem(item);return this},has:function(key){return key=this._makeKey(key),Object.prototype.hasOwnProperty.call(this.data,key)},hasAll:function(args){var testSet=this.makeNew.apply(this,arguments),self=this;return testSet.every(function(data,key){return self.has(key)})},makeSet:function(args){return args instanceof Set?args:this.makeNew.apply(this,arguments)},equals:function(otherSet){return otherSet=this.makeSet(otherSet),this.isSubset(otherSet)&&this.isSuperset(otherSet)},isEmpty:function(){for(var key in this.data)if(this.has(key))return!1;return!0},size:function(){var size=0;for(var key in this.data)this.has(key)&&size++;return size},keys:function(){var results=[];return this.each(function(data){results.push(data)}),results},clear:function(){return this.data={},this},makeNew:function(){var newSet=new this.constructor;return arguments.length&&newSet.add.apply(newSet,arguments),newSet},union:function(otherSet){otherSet=this.makeSet(otherSet);var newSet=this.makeNew(this);return newSet.add(otherSet),newSet},intersection:function(otherSet){otherSet=this.makeSet(otherSet);var newSet=this.makeNew();return this.each(function(data,key){otherSet.has(key)&&newSet._add(key,data)}),newSet},difference:function(otherSet){otherSet=this.makeSet(otherSet);var newSet=this.makeNew();return this.each(function(data,key){otherSet.has(key)||newSet._add(key,data)}),newSet},notInBoth:function(otherSet){otherSet=this.makeSet(otherSet);var newSet=this.difference(otherSet);return newSet.add(otherSet.difference(this))},isSubset:function(otherSet){return otherSet=this.makeSet(otherSet),this.eachReturn(function(data,key){return otherSet.has(key)?void 0:!1})},isSuperset:function(otherSet){otherSet=this.makeSet(otherSet);var self=this;return otherSet.eachReturn(function(data,key){return self.has(key)?void 0:!1})},each:function(fn){return this.eachReturn(fn),this},eachReturn:function(fn){for(var key in this.data)if(this.has(key)&&fn.call(this,this.data[key],key)===!1)return!1;return!0},filter:function(fn){var newSet=this.makeNew();return this.each(function(data,key){fn.call(this,key)===!0&&newSet._add(key,data)}),newSet},map:function(fn){var newSet=this.makeNew();return this.each(function(data,key){var ret=fn.call(this,key);"undefined"!=typeof ret&&newSet._add(key,data)}),newSet},some:function(fn){var found=!1;return this.eachReturn(function(key){return fn.call(this,key)===!0?(found=!0,!1):void 0}),found},every:function(fn){return this.eachReturn(fn)}},Set.prototype.constructor=Set);var igv=function(igv){var transformations;return igv.SVG=function(){this.svg="",this.contents=[],transformations=[]},igv.SVG.prototype.setProperties=function(properties){var str="";for(var key in properties)if(properties.hasOwnProperty(key)){var value=properties[key];"font-family"===key?str+="font-family:"+value+";":"font-size"===key?str+="font-size:"+value+";":"fillStyle"==key?str+="fill:"+value+";":"fill"===key?str+="fill:"+value+";":"strokeStyle"==key?str+="stroke:"+value+";":"stroke"===key?str+="stroke:"+value+";":"stroke-width"===key?str+="stroke-width:"+value+";":console.log("Unknown property: "+key)}return str},igv.SVG.prototype.setTransforms=function(transforms,x,y){var str="";for(var key in transforms){if(transforms.hasOwnProperty(key)){var value=transforms[key];"rotate"===key?(str+="rotate("+value.angle,str+=","+x,str+=","+y,str+=")"):"translate"===key?(str+="translate("+value[x],"y"in value&&(str+=","+value.y),str+=")"):console.log("Unknown transform: "+key)}str+=" "}return str},igv.SVG.prototype.clearRect=function(x,y,w,h){},igv.SVG.prototype.strokeLine=function(x1,y1,x2,y2,properties,transforms){var str="";str+='<line x1="'+x1+'" y1="'+y1+'" x2="'+x2+'" y2="'+y2+'"',properties&&(str+=' style="'+this.setProperties(properties)+'"'),transforms&&(str+=' transform="'+this.setTransforms(transforms,x1,y1)+'"'),str+="/>",this.contents.push(str)},igv.SVG.prototype.fillRect=function(x,y,w,h,properties,transforms){var str="";str+='<rect x="'+x+'" y="'+y,str+='" width="'+w+'" height="'+h+'"',properties&&(str+=' style="'+this.setProperties(properties)+'"'),transforms&&(str+=' transform="'+this.setTransforms(transforms,x,y)+'"'),str+="/>",this.contents.push(str)},igv.SVG.prototype.fillRectWithCenter=function(centerX,centerY,width,height,properties,transforms){var str="";str+='<rect x="'+(centerX-width/2)+'" y="'+(centerY-height/2),str+='" width="'+width+'" height="'+height+'"',properties&&(str+=' style="'+this.setProperties(properties)+'"'),transforms&&(str+=' transform="'+this.setTransforms(transforms,centerX,centerY)+'"'),str+="/>",this.contents.push(str)},igv.SVG.prototype.fillPolygon=function(x,y,properties,transforms){var str="";str+='<polygon points="';for(var index=0;index<x.length;index++)str+=" "+x[index]+","+y[index];str+='"',properties&&(str+=' style="'+this.setProperties(properties)+'"'),transforms&&(str+=' transform="'+this.setTransforms(transforms,x,y)+'"'),str+="/>",this.contents.push(str)},igv.SVG.prototype.fillText=function(text,x,y,properties,transforms){var str="";str+='<text x="'+x+'" y="'+y+'"',properties&&(str+=' style="'+this.setProperties(properties)+'"'),transforms&&(str+=' transform="'+this.setTransforms(transforms,x,y)+'"'),str+=">",str+=text,str+="</text>",this.contents.push(str)},igv.SVG.prototype.strokeText=function(text,x,y,properties,transforms){var str="";str+='<text x="'+x+'" y="'+y+'"',properties&&(str+=' style="'+this.setProperties(properties)+'"'),transforms&&(str+=' transform="'+this.setTransforms(transforms,x,y)+'"'),str+=">",str+=text,str+="</text>",this.contents.push(str)},igv.SVG.prototype.strokeCircle=function(x,y,radius,properties,transforms){var str="";str+='<circle cx="'+x+'" cy="'+y+'" r="'+radius+'" stroke="black" fill-opacity="0.0"/>',this.contents.push(str)},igv.SVG.prototype.string=function(){var string="";string+='<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">';for(var index=0;index<this.contents.length;index++)string+="\n"+this.contents[index];return string+="</svg>"},igv.SVG.prototype.innerString=function(){for(var string="",index=0;index<this.contents.length;index++)string+="\n"+this.contents[index];return string},igv}(igv||{}),igv=function(igv){return igv.loadTabixIndex=function(tabixURL,config,continuation){},igv}(igv||{}),igv=function(igv){return igv.configTrack=function(track,config){config.type||(config.type=igv.inferFileType(this.filename)),track.config=config,track.url=config.url,track.label=config.label||"",track.id=config.id||config.label,track.order=config.order,track.color=config.color||"rgb(150,150,150)",track.type=config.type,track.height=config.height||("bed"===config.type?100:50),track.autoHeight=void 0===config.height,track.minHeight=config.minHeight||Math.min(25,this.height),track.maxHeight=config.maxHeight||Math.max(1e3,this.height),config.visibilityWindow&&(track.visibilityWindow=config.visibilityWindow)},igv.setTrackLabel=function(track,label){track.label=label,track.description?track.labelButton.innerHTML=track.label:track.labelSpan.innerHTML=track.label,track.trackView&&track.trackView.repaint()},igv.setTrackColor=function(track,color){track.color=color,track.trackView&&track.trackView.repaint()},igv}(igv||{}),igv;igv=function(igv){return igv.TrackFilter=function(trackPanel){this.trackPanel=trackPanel,this.guid=igv.guid(),this.isFilterActive=!1,this.previousRadioButton=void 0,this.radioButton=void 0},igv.TrackFilter.prototype.setWithJSON=function(json){function radioButtonWithID(radioButtonID){var chosen=void 0,radioButtonGroupContainer=$("#modalBody_"+myself.guid).find(".radio");return radioButtonGroupContainer.each(function(){var radio=$(this).find("input");radioButtonID===radio[0].id&&(chosen=radio,chosen.prop("checked",!0))}),chosen}var myself=this,modalPresentationButton=$("#modalPresentationButton_"+this.guid),minimumElement=$("#minimumScoreFilterID_"+this.guid),maximumElement=$("#maximumScoreFilterID_"+this.guid);this.isFilterActive=json.isFilterActive,this.radioButton=void 0===json.radioButtonIDPrefix?void 0:radioButtonWithID(json.radioButtonIDPrefix+this.guid),"minMaxRadio_"+this.guid===this.radioButton[0].id?(minimumElement.val(json.minimum),maximumElement.val(json.maximum),this.minimum=json.minimum,this.maximum=json.maximum,(void 0!==json.minimum||void 0!==json.maximum)&&modalPresentationButton.addClass("igv-trackfilter-fa-selected")):this.isFilterActive&&modalPresentationButton.addClass("igv-trackfilter-fa-selected")},igv.TrackFilter.prototype.jsonRepresentation=function(){var json,re=new RegExp(this.guid,"g");return json={isFilterActive:this.isFilterActive,radioButtonIDPrefix:void 0==this.radioButton[0]?void 0:this.radioButton[0].id.replace(re,""),minimum:void 0===this.minimum?void 0:this.minimum,maximum:void 0===this.maximum?void 0:this.maximum}},igv.TrackFilter.prototype.makeTrackFilterOverlayRenderer=function(cursorHistogramRenderMinimumOverlay,cursorHistogramRenderMaximumOverlay){var myself=this,trackFilterOverlayRenderer=function(){};return"minMaxRadio_"+this.guid===this.radioButton[0].id&&(trackFilterOverlayRenderer=function(){myself.minimum&&cursorHistogramRenderMinimumOverlay(myself.minimum),myself.maximum&&cursorHistogramRenderMaximumOverlay(myself.maximum)}),trackFilterOverlayRenderer},igv.TrackFilter.prototype.doEvaluateFilter=function(){var modalPresentationButton=$("#modalPresentationButton_"+this.guid),minimumElement=$("#minimumScoreFilterID_"+this.guid),maximumElement=$("#maximumScoreFilterID_"+this.guid);return this.isFilterActive?(modalPresentationButton.addClass("igv-trackfilter-fa-selected"),"minMaxRadio_"+this.guid===this.radioButton[0].id&&(this.minimum=igv.isNumber(minimumElement.val())?parseFloat(minimumElement.val(),10):void 0,this.maximum=igv.isNumber(maximumElement.val())?parseFloat(maximumElement.val(),10):void 0,void 0===this.minimum&&void 0===this.maximum&&modalPresentationButton.removeClass("igv-trackfilter-fa-selected")),void this.trackPanel.browser.cursorModel.filterRegions()):(modalPresentationButton.removeClass("igv-trackfilter-fa-selected"),void this.trackPanel.browser.cursorModel.filterRegions())},igv.TrackFilter.prototype.evaluate=function(featureCache,region,regionWidth){var score=region.getScore(featureCache,regionWidth);return"minMaxRadio_"+this.guid===this.radioButton[0].id?this.isIncluded(score):"regionContainsFeatureRadio_"+this.guid===this.radioButton[0].id?-1!==score:"regionLacksFeatureRadio_"+this.guid===this.radioButton[0].id?-1===score:void 0},igv.TrackFilter.prototype.isIncluded=function(score){var includeMinimum,includeMaximum;return includeMinimum=void 0===this.minimum?!0:score>=this.minimum,includeMaximum=void 0===this.maximum?!0:score<=this.maximum,includeMinimum&&includeMaximum},igv.TrackFilter.prototype.createTrackFilterWidgetWithParentElement=function(parentDiv){function chosenRadioButton(radioButtonGroupContainer){var chosen=void 0;return radioButtonGroupContainer.each(function(){var radio=$(this).find("input");radio[0].checked&&(chosen=radio)}),chosen}var modalPresentationButton,modalDialogDataTarget,closeTrackFilterModal,applyTrackFilterModal,radioButtonGroupContainer,modalDialogCallback,myself=this;
|
9
|
+
|
10
|
+
parentDiv.innerHTML=this.createFilterModalMarkupWithGUID(this.guid),modalDialogDataTarget=$("#modalDialogDataTarget_"+this.guid),modalDialogDataTarget.on("shown.bs.modal",function(e){myself.previousRadioButton=myself.radioButton,modalDialogCallback=function(){myself.radioButton=myself.previousRadioButton,myself.radioButton.prop("checked",!0)}}),modalDialogDataTarget.on("hidden.bs.modal",function(e){modalDialogCallback()}),radioButtonGroupContainer=$("#modalBody_"+this.guid).find(".radio"),myself.radioButton=chosenRadioButton(radioButtonGroupContainer),modalPresentationButton=$("#modalPresentationButton_"+this.guid),radioButtonGroupContainer.click(function(){myself.previousRadioButton=myself.radioButton,myself.radioButton=$(this).find("input")}),closeTrackFilterModal=$("#closeTrackFilterModal_"+this.guid),closeTrackFilterModal.on("click",function(e){}),applyTrackFilterModal=$("#applyTrackFilterModal_"+this.guid),applyTrackFilterModal.on("click",function(e){modalDialogCallback=function(){myself.isFilterActive=!(myself.radioButton[0].id==="inActiveFilterRadio_"+myself.guid),myself.doEvaluateFilter()}})},igv.TrackFilter.prototype.createFilterModalMarkupWithGUID=function(guid){var filterModalPresentationButtonMarkup,filterModalMarkup,re=new RegExp("GUID","g");return filterModalPresentationButtonMarkup=this.createFilterModalPresentationButtonMarkupWithGUID(guid),filterModalMarkup='<!-- modal dialog --> <div id="modalDialogDataTarget_GUID" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <div class="spacer20"></div> <h4> Display only regions that meet the criteria: </h4> <div class="spacer20"></div> </div><!-- /.modal-header --> <div id="modalBody_GUID" class="modal-body"> <div class="radio"> <div class="spacer5"></div> <label> <input id="inActiveFilterRadio_GUID" type="radio" name="trackFilterRadioButtonGroup_GUID" value="option4"> All regions </label> <div class="spacer5"></div> </div><!-- radio - all regions --> <hr> <div class="radio"> <div> <label> <input id="minMaxRadio_GUID" type="radio" name="trackFilterRadioButtonGroup_GUID" value="option1" checked> Regions that contain features whose scores are bounded by min and max </label> </div> <div class="spacer20"></div> <div class="container"> <div class="row"><!-- row --> <div class="col-md-3"><!-- column --> <div class="input-group input-group-md"><!-- maximumScore input group --> <span class="input-group-addon">Maximum</span> <input id="maximumScoreFilterID_GUID" type="text" class="form-control" placeholder=""> </div><!-- maximumScore input group --> </div><!-- column --> </div><!-- maximum row --> <div class="spacer20"></div> <div class="row"><!-- row --> <div class="col-md-3"><!-- column --> <div class="input-group input-group-md"><!-- minimumScore input group --> <span class="input-group-addon">Minimum</span> <input id="minimumScoreFilterID_GUID" type="text" class="form-control" placeholder=""> </div><!-- minimumScore input group --> </div><!-- column --> </div><!-- minimum row --> </div><!-- min/max container --> </div><!-- radio - regions are bounded by min/max --> <hr> <div class="radio"> <div class="spacer5"></div> <label> <input id="regionContainsFeatureRadio_GUID" type="radio" name="trackFilterRadioButtonGroup_GUID" value="option2"> Regions that contain features </label> <div class="spacer5"></div> </div><!-- radio - regions that contain features --> <hr> <div class="radio"> <div class="spacer5"></div> <label> <input id="regionLacksFeatureRadio_GUID" type="radio" name="trackFilterRadioButtonGroup_GUID" value="option3"> Regions that do not contain features </label> <div class="spacer5"></div> </div><!-- radio - regions that do not contain features --> </div><!-- /.modal-body --> <div class="modal-footer"> <button id="closeTrackFilterModal_GUID" type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <button id="applyTrackFilterModal_GUID" type="button" class="btn btn-primary" data-dismiss="modal">Apply</button> </div><!-- /.modal-footer --> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div>',filterModalMarkup=filterModalMarkup.replace(re,guid),filterModalPresentationButtonMarkup+filterModalMarkup},igv.TrackFilter.prototype.createFilterModalPresentationButtonMarkupWithGUID=function(guid){var presentationButton,re=new RegExp("GUID","g");return presentationButton='<i id="modalPresentationButton_GUID" class="glyphicon glyphicon-filter igv-trackfilter-fa" data-toggle="modal" data-target="#modalDialogDataTarget_GUID"></i>',presentationButton=presentationButton.replace(re,guid)},igv}(igv||{});var igv=function(igv){return igv.TrackMenuPopupDialog=function(trackMenu,dialogLabel,inputValue,ok,width,height){var dialogLabelRE,inputValueRE,htmlString,myself=this;htmlString='<div id="dialog-form" title="DIALOG_LABEL"><p class="validateTips"></p><form><fieldset><input type="text" name="name" id="name" value="INPUT_VALUE"></fieldset></form></div>',dialogLabelRE=new RegExp("DIALOG_LABEL","g"),htmlString=htmlString.replace(dialogLabelRE,dialogLabel),inputValueRE=new RegExp("INPUT_VALUE","g"),htmlString=htmlString.replace(inputValueRE,inputValue),$("body").append($.parseHTML(htmlString)),this.dialogForm=$("#dialog-form"),this.form=this.dialogForm.find("form"),this.name=$("#name"),this.tips=$(".validateTips"),this.dialogForm.dialog({autoOpen:!1,width:width||320,height:height||256,modal:!0,buttons:{ok:ok,cancel:function(){myself.dialogForm.dialog("close")}},close:function(){myself.form[0].reset(),myself.dialogForm.remove(),myself.dialogForm=void 0,trackMenu&&trackMenu.hide()}}),this.form.on("submit",function(event){event.preventDefault(),$("#users").find(" tbody").append("<tr><td>"+myself.name.val()+"</td></tr>"),myself.dialogForm.dialog("close")})},igv.TrackMenuPopupDialog.prototype.updateTips=function(t){var myself=this;this.tips.text(t).addClass("ui-state-highlight"),setTimeout(function(){myself.tips.removeClass("ui-state-highlight",1500)},500)},igv}(igv||{}),igv=function(igv){function setTrackHeight_(newHeight,update){var trackHeightStr;trackHeightStr=newHeight+"px",this.track.height=newHeight,this.trackDiv.style.height=trackHeightStr,this.track.paintControl&&(this.controlCanvas.style.height=trackHeightStr,this.controlCanvas.setAttribute("height",newHeight)),this.viewportDiv.style.height=trackHeightStr,this.canvas.setAttribute("height",this.canvas.clientHeight),"CURSOR"===this.browser.type&&this.track.cursorHistogram.updateHeightAndInitializeHistogramWithTrack(this.track),(void 0===update||update===!0)&&this.update()}function Tile(chr,tileStart,tileEnd,scale,image){this.chr=chr,this.startBP=tileStart,this.endBP=tileEnd,this.scale=scale,this.image=image}function addRulerTrackHandlers(trackView){function sweepWidthThresholdUnmet(sweepWidth){return rulerWidth/(igv.browser.referenceFrame.bpPerPixel*sweepWidth)>igv.browser.pixelPerBasepairThreshold()?!0:!1}var left,rulerSweepWidth,dx,isMouseDown=void 0,isMouseIn=void 0,mouseDownXY=void 0,mouseMoveXY=void 0,rulerWidth=$(trackView.contentDiv).width();$(document).mousedown(function(e){mouseDownXY=igv.translateMouseCoordinates(e,trackView.contentDiv),left=mouseDownXY.x,rulerSweepWidth=0,trackView.rulerSweeper.css({display:"inline",left:left+"px",width:rulerSweepWidth+"px"}),isMouseIn=!0}),$(trackView.contentDiv).mousedown(function(e){isMouseDown=!0}),$(document).mousemove(function(e){isMouseDown&&isMouseIn&&(mouseMoveXY=igv.translateMouseCoordinates(e,trackView.contentDiv),dx=mouseMoveXY.x-mouseDownXY.x,rulerSweepWidth=Math.abs(dx),trackView.rulerSweeper.css({width:rulerSweepWidth+"px"}),0>dx&&(left=mouseDownXY.x+dx,trackView.rulerSweeper.css({left:left+"px"})),trackView.rulerSweeper.css({backgroundColor:"rgba(68, 134, 247, 0.75)"}))}),$(document).mouseup(function(e){var locus,ss,ee,trackHalfWidthBP,trackWidthBP,centroidZoom,chromosome,chromosomeLength;isMouseDown&&(isMouseDown=!1,isMouseIn=!1,trackView.rulerSweeper.css({display:"none",left:"0px",width:"0px"}),ss=igv.browser.referenceFrame.start+left*igv.browser.referenceFrame.bpPerPixel,ee=ss+rulerSweepWidth*igv.browser.referenceFrame.bpPerPixel,sweepWidthThresholdUnmet(rulerSweepWidth)&&(chromosome=igv.browser.genome.getChromosome(igv.browser.referenceFrame.chr),chromosomeLength=chromosome.bpLength,trackWidthBP=igv.browser.trackViewportWidth()/igv.browser.pixelPerBasepairThreshold(),trackHalfWidthBP=.5*trackWidthBP,centroidZoom=(ee+ss)/2,0>centroidZoom-trackHalfWidthBP?(ss=1,ee=trackWidthBP):centroidZoom+trackHalfWidthBP>chromosomeLength?(ee=chromosomeLength,ss=1+ee-trackWidthBP):(ss=1+centroidZoom-trackHalfWidthBP,ee=centroidZoom+trackHalfWidthBP)),locus=igv.browser.referenceFrame.chr+":"+igv.numberFormatter(Math.floor(ss))+"-"+igv.numberFormatter(Math.floor(ee)),igv.browser.search(locus,void 0))})}function addTrackHandlers(trackView){var popupTimer,isMouseDown=!1,lastMouseX=void 0,mouseDownX=void 0;$(trackView.canvas).mousedown(function(e){var canvasCoords=igv.translateMouseCoordinates(e,trackView.canvas);igv.popover&&igv.popover.hide(),isMouseDown=!0,lastMouseX=canvasCoords.x,mouseDownX=lastMouseX}),$(trackView.canvas).mouseup(function(e){e=$.event.fix(e);var canvasCoords=igv.translateMouseCoordinates(e,trackView.canvas),referenceFrame=trackView.browser.referenceFrame,genomicLocation=Math.floor(referenceFrame.start+referenceFrame.toBP(canvasCoords.x));if(referenceFrame){if(popupTimer)console.log("Cancel timer"),window.clearTimeout(popupTimer),popupTimer=void 0;else if(e.shiftKey)trackView.track.shiftClick&&trackView.tile&&trackView.track.shiftClick(genomicLocation,e);else if(e.altKey)trackView.track.altClick&&trackView.tile&&trackView.track.altClick(genomicLocation,e);else if(Math.abs(canvasCoords.x-mouseDownX)<=igv.constants.dragThreshold&&trackView.track.popupData){const doubleClickDelay=300;popupTimer=window.setTimeout(function(){var popupData,xOrigin;void 0!==genomicLocation&&null!==trackView.tile&&(xOrigin=Math.round(referenceFrame.toPixels(trackView.tile.startBP-referenceFrame.start)),popupData=trackView.track.popupData(genomicLocation,canvasCoords.x-xOrigin,canvasCoords.y),popupData&&popupData.length>0&&igv.popover.presentTrackPopup(e.pageX,e.pageY,igv.formatPopoverText(popupData)),mouseDownX=void 0,popupTimer=void 0)},doubleClickDelay)}mouseDownX=void 0,isMouseDown=!1,lastMouseX=void 0}})}return igv.TrackView=function(track,browser){this.track=track,this.browser=browser,"CURSOR"===browser.type?(this.cursorTrackContainer=$('<div class="igv-cursor-track-container">')[0],$(browser.trackContainerDiv).append(this.cursorTrackContainer),this.trackDiv=$('<div class="igv-track-div">')[0],$(this.cursorTrackContainer).append(this.trackDiv)):(this.trackDiv=$('<div class="igv-track-div">')[0],$(browser.trackContainerDiv).append(this.trackDiv)),track.height&&(this.trackDiv.style.height=track.height+"px"),"CURSOR"!==browser.type&&this.trackDiv.appendChild(igv.spinner()),this.addLeftHandGutterToParentTrackDiv(this.trackDiv),this.addViewportToParentTrackDiv(this.trackDiv),"CURSOR"===browser.type&&(this.cursorHistogramContainer=$('<div class="igv-cursor-histogram-container">')[0],$(this.trackDiv).append(this.cursorHistogramContainer),this.track.cursorHistogram=new cursor.CursorHistogram(this.cursorHistogramContainer,this.track)),this.addRightHandGutterToParentTrackDiv(this.trackDiv),this.track instanceof igv.RulerTrack?(this.trackDiv.dataset.rulerTrack="rulerTrack",this.rulerSweeper=$('<div class="igv-ruler-sweeper-div">'),$(this.contentDiv).append(this.rulerSweeper[0]),addRulerTrackHandlers(this)):addTrackHandlers(this)},igv.TrackView.prototype.addViewportToParentTrackDiv=function(trackDiv){this.viewportDiv=$('<div class="igv-viewport-div">')[0],$(trackDiv).append(this.viewportDiv),this.contentDiv=$('<div class="igv-content-div">')[0],$(this.viewportDiv).append(this.contentDiv),this.canvas=$('<canvas class = "igv-content-canvas">')[0],$(this.contentDiv).append(this.canvas),this.canvas.setAttribute("width",this.contentDiv.clientWidth),this.canvas.setAttribute("height",this.contentDiv.clientHeight),this.ctx=this.canvas.getContext("2d"),this.viewportCreationHelper(this.viewportDiv)},igv.TrackView.prototype.viewportCreationHelper=function(viewportDiv){var labelButton,trackIconContainer,myself=this;"CURSOR"!==this.browser.type&&(this.track.description?(labelButton=document.createElement("button"),viewportDiv.appendChild(labelButton),this.track.labelButton=labelButton,labelButton.className="btn btn-xs btn-cursor-deselected igv-track-label-span-base",labelButton.style.position="absolute",labelButton.style.top="10px",labelButton.style.left="10px",labelButton.innerHTML=this.track.label,labelButton.onclick=function(e){igv.popover.presentTrackPopup(e.pageX,e.pageY,myself.track.description)}):this.track.label&&(trackIconContainer=$('<div class="igv-app-icon-container">'),$(viewportDiv).append(trackIconContainer[0]),this.track.labelSpan=$('<span class="igv-track-label-span-base">')[0],this.track.labelSpan.innerHTML=this.track.label,$(trackIconContainer).append(this.track.labelSpan),$(viewportDiv).scroll(function(){trackIconContainer.css({top:$(viewportDiv).scrollTop()+"px"})})))},igv.TrackView.prototype.addLeftHandGutterToParentTrackDiv=function(trackDiv){this.leftHandGutter=$('<div class="igv-left-hand-gutter">')[0],$(trackDiv).append(this.leftHandGutter),this.leftHandGutterCreationHelper(this.leftHandGutter)},igv.TrackView.prototype.leftHandGutterCreationHelper=function(leftHandGutter){this.track.paintControl&&(this.controlCanvas=$('<canvas class ="igv-track-control-canvas">')[0],$(leftHandGutter).append(this.controlCanvas),this.controlCanvas.setAttribute("width",leftHandGutter.clientWidth),this.controlCanvas.setAttribute("height",leftHandGutter.clientHeight),this.controlCtx=this.controlCanvas.getContext("2d"))},igv.TrackView.prototype.addRightHandGutterToParentTrackDiv=function(trackDiv){var trackManipulationIconBox;this.rightHandGutter=$('<div class="igv-right-hand-gutter">')[0],$(trackDiv).append(this.rightHandGutter),trackManipulationIconBox=$('<div class="igv-track-menu-icon-box">')[0],$(this.rightHandGutter).append(trackManipulationIconBox),this.rightHandGutterCreationHelper(trackManipulationIconBox)},igv.TrackView.prototype.rightHandGutterCreationHelper=function(trackManipulationIconBox){var gearButton,myself=this;this.track.ignoreTrackMenu||(gearButton=$('<i class="fa fa-gear fa-20px igv-track-menu-gear igv-app-icon" style="padding-top: 5px">'),$(trackManipulationIconBox).append(gearButton[0]),$(gearButton).click(function(e){igv.popover.presentTrackMenu(e.pageX,e.pageY,myself)}))},igv.TrackView.prototype.resize=function(){var canvas=this.canvas,contentDiv=this.contentDiv,contentWidth=this.viewportDiv.clientWidth;contentDiv.style.width=contentWidth+"px",canvas.style.width=contentWidth+"px",canvas.setAttribute("width",contentWidth),this.update()},igv.TrackView.prototype.setTrackHeight=function(newHeight,update){setTrackHeight_.call(this,newHeight,update||!0),this.track.autoHeight=!1},igv.TrackView.prototype.setContentHeight=function(newHeight){contentHeightStr=newHeight+"px",this.contentDiv.style.height=contentHeightStr,this.track.autoHeight?setTrackHeight_.call(this,newHeight,!1):(this.canvas.setAttribute("height",this.canvas.clientHeight),this.track.paintControl&&(this.controlCanvas.style.height=contentHeightStr,this.controlCanvas.setAttribute("height",newHeight))),this.update()},igv.TrackView.prototype.update=function(){this.tile=null,this.repaint()},igv.TrackView.prototype.repaint=function(){function hasCachedImaged(chr,start,end,bpPerPixel){return this.tile&&this.tile.containsRange(chr,start,end,bpPerPixel)}function viewIsReady(){return this.track&&this.browser&&this.browser.referenceFrame}function isNotIndexed(track){return track.featureSource&&track.featureSource.indexed===!1}if(viewIsReady.call(this)){var pixelWidth,bpWidth,bpStart,bpEnd,ctx,success,self=this,referenceFrame=this.browser.referenceFrame,chr=referenceFrame.chr,refFrameStart=referenceFrame.start,refFrameEnd=refFrameStart+referenceFrame.toBP(this.canvas.width);hasCachedImaged.call(this,chr,refFrameStart,refFrameEnd,referenceFrame.bpPerPixel)||this.currentLoadTask&&(isNotIndexed(this.track)||this.currentLoadTask.end>=refFrameEnd&&this.currentLoadTask.start<=refFrameStart)||(this.currentLoadTask&&this.currentLoadTask.abort(),pixelWidth=3*this.canvas.width,bpWidth=Math.round(referenceFrame.toBP(pixelWidth)),bpStart=Math.max(0,Math.round(referenceFrame.start-bpWidth/3)),bpEnd=bpStart+bpWidth,success=function(features){if(igv.stopSpinnerAtParentElement(self.trackDiv),self.currentLoadTask=void 0,features){if(self.track.computePixelHeight){var requiredHeight=self.track.computePixelHeight(features);requiredHeight!=self.contentDiv.clientHeight&&self.setContentHeight(requiredHeight)}var buffer=document.createElement("canvas");if(buffer.width=pixelWidth,buffer.height=self.canvas.height,ctx=buffer.getContext("2d"),self.track.draw({features:features,context:ctx,bpStart:bpStart,bpPerPixel:referenceFrame.bpPerPixel,pixelWidth:buffer.width,pixelHeight:buffer.height}),self.track.paintControl){var buffer2=document.createElement("canvas");buffer2.width=self.controlCanvas.width,buffer2.height=self.controlCanvas.height;var ctx2=buffer2.getContext("2d");self.track.paintControl(ctx2,buffer2.width,buffer2.height),self.controlCtx.drawImage(buffer2,0,0)}self.tile=new Tile(referenceFrame.chr,bpStart,bpEnd,referenceFrame.bpPerPixel,buffer),self.paintImage()}},this.currentLoadTask={start:bpStart,end:bpEnd,abort:function(){this.canceled=!0,this.xhrRequest&&this.xhrRequest.abort(),self.currentLoadTask=void 0}},igv.startSpinnerAtParentElement(self.trackDiv),this.track.getFeatures(referenceFrame.chr,bpStart,bpEnd,success,self.currentLoadTask)),this.tile&&this.tile.overlapsRange(referenceFrame.chr,refFrameStart,refFrameEnd)?this.paintImage():this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}},Tile.prototype.containsRange=function(chr,start,end,scale){return this.scale===scale&&start>=this.startBP&&end<=this.endBP&&chr===this.chr},Tile.prototype.overlapsRange=function(chr,start,end){return this.chr===chr&&this.endBP>=start&&this.startBP<=end},igv.TrackView.prototype.paintImage=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.tile&&(this.xOffset=Math.round(this.browser.referenceFrame.toPixels(this.tile.startBP-this.browser.referenceFrame.start)),this.ctx.drawImage(this.tile.image,this.xOffset,0),this.ctx.save(),this.ctx.restore())},igv}(igv||{}),igv=function(igv){return igv.UserFeedback=function(parentObject){var myself=this;this.userFeedback=$('<div class="igvUserFeedback">'),parentObject.append(this.userFeedback[0]),this.userFeedbackHeader=$('<div class="igvUserFeedbackHeader">'),this.userFeedback.append(this.userFeedbackHeader[0]),this.userFeedbackAlert=$('<i class="fa fa-exclamation-triangle fa-20px igvUserFeedbackAlert">'),this.userFeedbackHeader.append(this.userFeedbackAlert[0]),this.userFeedbackDismiss=$('<i class="fa fa-times-circle fa-20px igvUserFeedbackDismiss">'),this.userFeedbackHeader.append(this.userFeedbackDismiss[0]),this.userFeedbackDismiss.click(function(){myself.userFeedbackBodyCopy.html(""),myself.userFeedback.hide()}),this.userFeedbackBodyCopy=$('<div class="igvUserFeedbackBodyCopy">'),this.userFeedback.append(this.userFeedbackBodyCopy[0])},igv.UserFeedback.prototype.show=function(){this.userFeedback.show()},igv.UserFeedback.prototype.hide=function(){this.userFeedback.hide()},igv.UserFeedback.prototype.bodyCopy=function(htmlString){this.userFeedbackBodyCopy.html(htmlString)},igv}(igv||{}),igv=function(igv){function computeStart(variant){altTokens=variant.alt.split(","),altTokens.length>0?(variant.alleles=[],variant.start=Number.MAX_VALUE,variant.end=0,altTokens.forEach(function(alt){var s,e,diff;alt.length>0&&(diff=variant.ref.length-alt.length,diff>0?(s=variant.pos+alt.length,e=s+diff):0>diff?(s=variant.pos+variant.ref.length,e=s+1):(s=variant.pos,e=s+alt.length),variant.start=Math.min(variant.start,s),variant.end=Math.max(variant.end,e))})):(variant.start=variant.pos-1,variant.end=variant.pos)}return igv.createVCFVariant=function(tokens){var variant=new igv.Variant;return variant.chr=tokens[0],variant.pos=parseInt(tokens[1])-1,variant.names=tokens[2],variant.ref=tokens[3],variant.alt=tokens[4],variant.qual=parseInt(tokens[5]),variant.filter=tokens[6],variant.info=tokens[7],computeStart(variant),variant},igv.createGAVariant=function(json){function arrayToCommaString(array){if(array){var i,str="";for(array.length>0&&(str=array[0]),i=1;i<array.length;i++)str+=", "+array[1];return str}}var variant=new igv.Variant;return variant.chr=json.referenceName,variant.pos=parseInt(json.start),variant.names=arrayToCommaString(json.names),variant.ref=json.referenceBases+"",variant.alt=json.alternateBases+"",variant.qual=json.quality,variant.filter=arrayToCommaString(json.filter),variant.info=json.info,variant.calls=json.calls,computeStart(variant),variant},igv.Variant=function(){},igv.Variant.prototype.popupData=function(genomicLocation){var fields,infoFields;return fields=[{name:"Names",value:this.names},{name:"Ref",value:this.ref},{name:"Alt",value:this.alt},{name:"Qual",value:this.qual},{name:"Filter",value:this.filter},"<hr>"],infoFields=this.info.split(";"),infoFields.forEach(function(f){var tokens=f.split("=");tokens.length>1&&fields.push({name:tokens[0],value:tokens[1]})}),fields},igv}(igv||{}),igv=function(igv){function Variant(tokens){var altTokens,self=this;this.chr=tokens[0],this.pos=parseInt(tokens[1]),this.names=tokens[2],this.ref=tokens[3],this.alt=tokens[4],this.qual=parseInt(tokens[5]),this.filter=tokens[6],this.info=tokens[7],altTokens=this.alt.split(","),altTokens.length>0?(this.alleles=[],this.start=Number.MAX_VALUE,this.end=0,altTokens.forEach(function(alt){var s,e,diff;alt.length>0&&(diff=self.ref.length-alt.length,diff>0?(s=self.pos-1+alt.length,e=s+diff):0>diff?(s=self.pos-1+self.ref.length,e=s+1):(s=self.pos-1,e=s+alt.length),self.alleles.push({allele:alt,start:s,end:e}),self.start=Math.min(self.start,s),self.end=Math.max(self.end,e))})):(this.start=this.pos-1,this.end=this.pos)}return igv.VcfParser=function(){},igv.VcfParser.prototype.parseHeader=function(data){var line,i,tokens,id,values,ltIdx,gtIdx,type,lines=data.splitLines(),len=lines.length,header={};if(this.header=header,!lines[0].startsWith("##fileformat"))throw new Error("Invalid VCF file: missing fileformat line");for(header.version=lines[0].substr(13),i=1;len>i&&(line=lines[i].trim(),line.startsWith("#"));i++)if(id=null,values={},line.startsWith("##")){if(line.startsWith("##INFO")||line.startsWith("##FILTER")||line.startsWith("##FORMAT")){if(ltIdx=line.indexOf("<"),gtIdx=line.lastIndexOf(">"),!(ltIdx>2&>Idx>0)){console.log("Malformed VCF header line: "+line);continue}type=line.substring(2,ltIdx-1),header[type]||(header[type]={}),tokens=igv.splitStringRespectingQuotes(line.substring(ltIdx+1,gtIdx-1),","),tokens.forEach(function(token){var kv=token.split("=");kv.length>1&&("ID"===kv[0]?id=kv[1]:values[kv[0]]=kv[1])}),id&&(header[type][id]=values)}}else line.startsWith("#CHROM");return header},igv.VcfParser.prototype.parseFeatures=function(data){function decode(tokens){return tokens.length<8?null:new Variant(tokens)}var tokens,allFeatures,line,i,variant,lines=data.split("\n"),len=lines.length;for(allFeatures=[],i=0;len>i;i++)line=lines[i],line.startsWith("#")||(tokens=lines[i].split(" "),variant=decode(tokens),null!=variant&&(variant.header=this.header,allFeatures.push(variant)));return allFeatures},Variant.prototype.popupData=function(genomicLocation){var fields,infoFields;return fields=[{name:"Names",value:this.names},{name:"Ref",value:this.ref},{name:"Alt",value:this.alt},{name:"Qual",value:this.qual},{name:"Filter",value:this.filter},"<hr>"],infoFields=this.info.split(";"),infoFields.forEach(function(f){var tokens=f.split("=");tokens.length>1&&fields.push({name:tokens[0],value:tokens[1]})}),fields},igv}(igv||{}),igv=function(igv){function autoscale(features){var min=Number.MAX_VALUE,max=-Number.MAX_VALUE;return features.forEach(function(f){min=Math.min(min,f.value),max=Math.max(max,f.value)}),{min:min,max:max}}function signsDiffer(a,b){return a>0&&0>b||0>a&&b>0}return igv.WIGTrack=function(config){this.config=config,this.url=config.url,config.type||(config.type=igv.inferFileType(config.url||config.localFile.name)),this.featureSource="bigwig"===config.type?new igv.BWSource(config):new igv.FeatureSource(config),this.label=config.label,this.id=config.id||this.label,this.color=config.color||"rgb(150,150,150)",this.height=100,this.order=config.order,this.min=config.min,this.max=config.max},igv.WIGTrack.prototype.getFeatures=function(chr,bpStart,bpEnd,continuation,task){this.featureSource.getFeatures(chr,bpStart,bpEnd,continuation,task)},igv.WIGTrack.prototype.draw=function(options){function renderFeature(feature,index,featureList){var yUnitless,heightUnitLess,x,width,rectEnd;feature.end<bpStart||feature.start>bpEnd||(x=(feature.start-bpStart)/bpPerPixel,rectEnd=(feature.end-bpStart)/bpPerPixel,width=Math.max(1,rectEnd-x),signsDiffer(featureValueMinimum,featureValueMaximum)?feature.value<0?(yUnitless=featureValueMaximum/featureValueRange,heightUnitLess=-feature.value/featureValueRange):(yUnitless=(featureValueMaximum-feature.value)/featureValueRange,heightUnitLess=feature.value/featureValueRange):0>featureValueMaximum?(yUnitless=0,heightUnitLess=-feature.value/featureValueRange):(yUnitless=1-feature.value/featureValueRange,heightUnitLess=feature.value/featureValueRange),igv.Canvas.fillRect.call(ctx,x,yUnitless*pixelHeight,width,heightUnitLess*pixelHeight,{fillStyle:track.color}))}var featureValueMinimum,featureValueMaximum,featureValueRange,track=this,features=options.features,ctx=options.context,bpPerPixel=options.bpPerPixel,bpStart=options.bpStart,pixelWidth=options.pixelWidth,pixelHeight=options.pixelHeight,bpEnd=bpStart+pixelWidth*bpPerPixel+1;if(features&&features.length>0){if(featureValueMinimum=track.min?track.min:0,featureValueMaximum=track.max,void 0===featureValueMaximum){var s=autoscale(features);featureValueMinimum=s.min,featureValueMaximum=s.max}featureValueRange=featureValueMaximum-featureValueMinimum,features.forEach(renderFeature)}},igv}(igv||{}),MAX_WBITS=15,DEF_WBITS=MAX_WBITS,MAX_MEM_LEVEL=9,MANY=1440,BMAX=15,PRESET_DICT=32,Z_NO_FLUSH=0,Z_PARTIAL_FLUSH=1,Z_SYNC_FLUSH=2,Z_FULL_FLUSH=3,Z_FINISH=4,Z_DEFLATED=8,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_ERRNO=-1,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR=-5,Z_VERSION_ERROR=-6,METHOD=0,FLAG=1,DICT4=2,DICT3=3,DICT2=4,DICT1=5,DICT0=6,BLOCKS=7,CHECK4=8,CHECK3=9,CHECK2=10,CHECK1=11,DONE=12,BAD=13,inflate_mask=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],IB_TYPE=0,IB_LENS=1,IB_STORED=2,IB_TABLE=3,IB_BTREE=4,IB_DTREE=5,IB_CODES=6,IB_DRY=7,IB_DONE=8,IB_BAD=9,fixed_bl=9,fixed_bd=5,fixed_tl=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],fixed_td=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,112,112],cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];ZStream.prototype.inflateInit=function(w,nowrap){return w||(w=DEF_WBITS),nowrap&&(nowrap=!1),this.istate=new Inflate,this.istate.inflateInit(this,nowrap?-w:w)},ZStream.prototype.inflate=function(f){return null==this.istate?Z_STREAM_ERROR:this.istate.inflate(this,f)},ZStream.prototype.inflateEnd=function(){if(null==this.istate)return Z_STREAM_ERROR;var ret=istate.inflateEnd(this);return this.istate=null,ret},ZStream.prototype.inflateSync=function(){return istate.inflateSync(this)},ZStream.prototype.inflateSetDictionary=function(dictionary,dictLength){
|
11
|
+
return istate.inflateSetDictionary(this,dictionary,dictLength)},Inflate.prototype.inflateReset=function(z){return null==z||null==z.istate?Z_STREAM_ERROR:(z.total_in=z.total_out=0,z.msg=null,z.istate.mode=0!=z.istate.nowrap?BLOCKS:METHOD,z.istate.blocks.reset(z,null),Z_OK)},Inflate.prototype.inflateEnd=function(z){return null!=this.blocks&&this.blocks.free(z),this.blocks=null,Z_OK},Inflate.prototype.inflateInit=function(z,w){return z.msg=null,this.blocks=null,nowrap=0,0>w&&(w=-w,nowrap=1),8>w||w>15?(this.inflateEnd(z),Z_STREAM_ERROR):(this.wbits=w,z.istate.blocks=new InfBlocks(z,0!=z.istate.nowrap?null:this,1<<w),this.inflateReset(z),Z_OK)},Inflate.prototype.inflate=function(z,f){var r,b;if(null==z||null==z.istate||null==z.next_in)return Z_STREAM_ERROR;for(f=f==Z_FINISH?Z_BUF_ERROR:Z_OK,r=Z_BUF_ERROR;;)switch(z.istate.mode){case METHOD:if(0==z.avail_in)return r;if(r=f,z.avail_in--,z.total_in++,(15&(z.istate.method=z.next_in[z.next_in_index++]))!=Z_DEFLATED){z.istate.mode=BAD,z.msg="unknown compression method",z.istate.marker=5;break}if((z.istate.method>>4)+8>z.istate.wbits){z.istate.mode=BAD,z.msg="invalid window size",z.istate.marker=5;break}z.istate.mode=FLAG;case FLAG:if(0==z.avail_in)return r;if(r=f,z.avail_in--,z.total_in++,b=255&z.next_in[z.next_in_index++],((z.istate.method<<8)+b)%31!=0){z.istate.mode=BAD,z.msg="incorrect header check",z.istate.marker=5;break}if(0==(b&PRESET_DICT)){z.istate.mode=BLOCKS;break}z.istate.mode=DICT4;case DICT4:if(0==z.avail_in)return r;r=f,z.avail_in--,z.total_in++,z.istate.need=(255&z.next_in[z.next_in_index++])<<24&4278190080,z.istate.mode=DICT3;case DICT3:if(0==z.avail_in)return r;r=f,z.avail_in--,z.total_in++,z.istate.need+=(255&z.next_in[z.next_in_index++])<<16&16711680,z.istate.mode=DICT2;case DICT2:if(0==z.avail_in)return r;r=f,z.avail_in--,z.total_in++,z.istate.need+=(255&z.next_in[z.next_in_index++])<<8&65280,z.istate.mode=DICT1;case DICT1:return 0==z.avail_in?r:(r=f,z.avail_in--,z.total_in++,z.istate.need+=255&z.next_in[z.next_in_index++],z.adler=z.istate.need,z.istate.mode=DICT0,Z_NEED_DICT);case DICT0:return z.istate.mode=BAD,z.msg="need dictionary",z.istate.marker=0,Z_STREAM_ERROR;case BLOCKS:if(r=z.istate.blocks.proc(z,r),r==Z_DATA_ERROR){z.istate.mode=BAD,z.istate.marker=0;break}if(r==Z_OK&&(r=f),r!=Z_STREAM_END)return r;if(r=f,z.istate.blocks.reset(z,z.istate.was),0!=z.istate.nowrap){z.istate.mode=DONE;break}z.istate.mode=CHECK4;case CHECK4:if(0==z.avail_in)return r;r=f,z.avail_in--,z.total_in++,z.istate.need=(255&z.next_in[z.next_in_index++])<<24&4278190080,z.istate.mode=CHECK3;case CHECK3:if(0==z.avail_in)return r;r=f,z.avail_in--,z.total_in++,z.istate.need+=(255&z.next_in[z.next_in_index++])<<16&16711680,z.istate.mode=CHECK2;case CHECK2:if(0==z.avail_in)return r;r=f,z.avail_in--,z.total_in++,z.istate.need+=(255&z.next_in[z.next_in_index++])<<8&65280,z.istate.mode=CHECK1;case CHECK1:if(0==z.avail_in)return r;if(r=f,z.avail_in--,z.total_in++,z.istate.need+=255&z.next_in[z.next_in_index++],z.istate.was[0]!=z.istate.need){z.istate.mode=BAD,z.msg="incorrect data check",z.istate.marker=5;break}z.istate.mode=DONE;case DONE:return Z_STREAM_END;case BAD:return Z_DATA_ERROR;default:return Z_STREAM_ERROR}},Inflate.prototype.inflateSetDictionary=function(z,dictionary,dictLength){var index=0,length=dictLength;return null==z||null==z.istate||z.istate.mode!=DICT0?Z_STREAM_ERROR:z._adler.adler32(1,dictionary,0,dictLength)!=z.adler?Z_DATA_ERROR:(z.adler=z._adler.adler32(0,null,0,0),length>=1<<z.istate.wbits&&(length=(1<<z.istate.wbits)-1,index=dictLength-length),z.istate.blocks.set_dictionary(dictionary,index,length),z.istate.mode=BLOCKS,Z_OK)};var mark=[0,0,255,255];Inflate.prototype.inflateSync=function(z){var n,p,m,r,w;if(null==z||null==z.istate)return Z_STREAM_ERROR;if(z.istate.mode!=BAD&&(z.istate.mode=BAD,z.istate.marker=0),0==(n=z.avail_in))return Z_BUF_ERROR;for(p=z.next_in_index,m=z.istate.marker;0!=n&&4>m;)z.next_in[p]==mark[m]?m++:m=0!=z.next_in[p]?0:4-m,p++,n--;return z.total_in+=p-z.next_in_index,z.next_in_index=p,z.avail_in=n,z.istate.marker=m,4!=m?Z_DATA_ERROR:(r=z.total_in,w=z.total_out,this.inflateReset(z),z.total_in=r,z.total_out=w,z.istate.mode=BLOCKS,Z_OK)},Inflate.prototype.inflateSyncPoint=function(z){return null==z||null==z.istate||null==z.istate.blocks?Z_STREAM_ERROR:z.istate.blocks.sync_point()};var INFBLOCKS_BORDER=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];InfBlocks.prototype.reset=function(z,c){c&&(c[0]=this.check),this.mode==IB_CODES&&this.codes.free(z),this.mode=IB_TYPE,this.bitk=0,this.bitb=0,this.read=this.write=0,this.checkfn&&(z.adler=this.check=z._adler.adler32(0,null,0,0))},InfBlocks.prototype.proc=function(z,r){var t,b,k,p,n,q,m;for(p=z.next_in_index,n=z.avail_in,b=this.bitb,k=this.bitk,q=this.write,m=q<this.read?this.read-q-1:this.end-q;;)switch(this.mode){case IB_TYPE:for(;3>k;){if(0==n)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}switch(t=7&b,this.last=1&t,t>>>1){case 0:b>>>=3,k-=3,t=7&k,b>>>=t,k-=t,this.mode=IB_LENS;break;case 1:var bl=new Int32Array(1),bd=new Int32Array(1),tl=[],td=[];inflate_trees_fixed(bl,bd,tl,td,z),this.codes.init(bl[0],bd[0],tl[0],0,td[0],0,z),b>>>=3,k-=3,this.mode=IB_CODES;break;case 2:b>>>=3,k-=3,this.mode=IB_TABLE;break;case 3:return b>>>=3,k-=3,this.mode=BAD,z.msg="invalid block type",r=Z_DATA_ERROR,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r)}break;case IB_LENS:for(;32>k;){if(0==n)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}if((~b>>>16&65535)!=(65535&b))return this.mode=BAD,z.msg="invalid stored block lengths",r=Z_DATA_ERROR,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);this.left=65535&b,b=k=0,this.mode=0!=left?IB_STORED:0!=this.last?IB_DRY:IB_TYPE;break;case IB_STORED:if(0==n)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,write=q,this.inflate_flush(z,r);if(0==m&&(q==end&&0!=read&&(q=0,m=q<this.read?this.read-q-1:this.end-q),0==m&&(this.write=q,r=this.inflate_flush(z,r),q=this.write,m=q<this.read?this.read-q-1:this.end-q,q==this.end&&0!=this.read&&(q=0,m=q<this.read?this.read-q-1:this.end-q),0==m)))return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);if(r=Z_OK,t=this.left,t>n&&(t=n),t>m&&(t=m),arrayCopy(z.next_in,p,window,q,t),p+=t,n-=t,q+=t,m-=t,0!=(this.left-=t))break;this.mode=0!=this.last?IB_DRY:IB_TYPE;break;case IB_TABLE:for(;14>k;){if(0==n)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}if(this.table=t=16383&b,(31&t)>29||(t>>5&31)>29)return this.mode=IB_BAD,z.msg="too many length or distance symbols",r=Z_DATA_ERROR,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);if(t=258+(31&t)+(t>>5&31),null==this.blens||this.blens.length<t)this.blens=new Int32Array(t);else for(var i=0;t>i;i++)this.blens[i]=0;b>>>=14,k-=14,this.index=0,mode=IB_BTREE;case IB_BTREE:for(;this.index<4+(this.table>>>10);){for(;3>k;){if(0==n)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}this.blens[INFBLOCKS_BORDER[this.index++]]=7&b,b>>>=3,k-=3}for(;this.index<19;)this.blens[INFBLOCKS_BORDER[this.index++]]=0;if(this.bb[0]=7,t=this.inftree.inflate_trees_bits(this.blens,this.bb,this.tb,this.hufts,z),t!=Z_OK)return r=t,r==Z_DATA_ERROR&&(this.blens=null,this.mode=IB_BAD),this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,write=q,this.inflate_flush(z,r);this.index=0,this.mode=IB_DTREE;case IB_DTREE:for(;;){if(t=this.table,!(this.index<258+(31&t)+(t>>5&31)))break;var i,j,c;for(t=this.bb[0];t>k;){if(0==n)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}if(t=this.hufts[3*(this.tb[0]+(b&inflate_mask[t]))+1],c=this.hufts[3*(this.tb[0]+(b&inflate_mask[t]))+2],16>c)b>>>=t,k-=t,this.blens[this.index++]=c;else{for(i=18==c?7:c-14,j=18==c?11:3;t+i>k;){if(0==n)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}if(b>>>=t,k-=t,j+=b&inflate_mask[i],b>>>=i,k-=i,i=this.index,t=this.table,i+j>258+(31&t)+(t>>5&31)||16==c&&1>i)return this.blens=null,this.mode=IB_BAD,z.msg="invalid bit length repeat",r=Z_DATA_ERROR,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);c=16==c?this.blens[i-1]:0;do this.blens[i++]=c;while(0!=--j);this.index=i}}this.tb[0]=-1;var bl=new Int32Array(1),bd=new Int32Array(1),tl=new Int32Array(1),td=new Int32Array(1);if(bl[0]=9,bd[0]=6,t=this.table,t=this.inftree.inflate_trees_dynamic(257+(31&t),1+(t>>5&31),this.blens,bl,bd,tl,td,this.hufts,z),t!=Z_OK)return t==Z_DATA_ERROR&&(this.blens=null,this.mode=BAD),r=t,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);this.codes.init(bl[0],bd[0],this.hufts,tl[0],this.hufts,td[0],z),this.mode=IB_CODES;case IB_CODES:if(this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,(r=this.codes.proc(this,z,r))!=Z_STREAM_END)return this.inflate_flush(z,r);if(r=Z_OK,this.codes.free(z),p=z.next_in_index,n=z.avail_in,b=this.bitb,k=this.bitk,q=this.write,m=q<this.read?this.read-q-1:this.end-q,0==this.last){this.mode=IB_TYPE;break}this.mode=IB_DRY;case IB_DRY:if(this.write=q,r=this.inflate_flush(z,r),q=this.write,m=q<this.read?this.read-q-1:this.end-q,this.read!=this.write)return this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);mode=DONE;case IB_DONE:return r=Z_STREAM_END,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);case IB_BAD:return r=Z_DATA_ERROR,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r);default:return r=Z_STREAM_ERROR,this.bitb=b,this.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,this.write=q,this.inflate_flush(z,r)}},InfBlocks.prototype.free=function(z){this.reset(z,null),this.window=null,this.hufts=null},InfBlocks.prototype.set_dictionary=function(d,start,n){arrayCopy(d,start,window,0,n),this.read=this.write=n},InfBlocks.prototype.sync_point=function(){return this.mode==IB_LENS},InfBlocks.prototype.inflate_flush=function(z,r){var n,p,q;return p=z.next_out_index,q=this.read,n=(q<=this.write?this.write:this.end)-q,n>z.avail_out&&(n=z.avail_out),0!=n&&r==Z_BUF_ERROR&&(r=Z_OK),z.avail_out-=n,z.total_out+=n,null!=this.checkfn&&(z.adler=this.check=z._adler.adler32(this.check,this.window,q,n)),arrayCopy(this.window,q,z.next_out,p,n),p+=n,q+=n,q==this.end&&(q=0,this.write==this.end&&(this.write=0),n=this.write-q,n>z.avail_out&&(n=z.avail_out),0!=n&&r==Z_BUF_ERROR&&(r=Z_OK),z.avail_out-=n,z.total_out+=n,null!=this.checkfn&&(z.adler=this.check=z._adler.adler32(this.check,this.window,q,n)),arrayCopy(this.window,q,z.next_out,p,n),p+=n,q+=n),z.next_out_index=p,this.read=q,r};var IC_START=0,IC_LEN=1,IC_LENEXT=2,IC_DIST=3,IC_DISTEXT=4,IC_COPY=5,IC_LIT=6,IC_WASH=7,IC_END=8,IC_BADCODE=9;InfCodes.prototype.init=function(bl,bd,tl,tl_index,td,td_index,z){this.mode=IC_START,this.lbits=bl,this.dbits=bd,this.ltree=tl,this.ltree_index=tl_index,this.dtree=td,this.dtree_index=td_index,this.tree=null},InfCodes.prototype.proc=function(s,z,r){var j,tindex,e,n,q,m,f,b=0,k=0,p=0;for(p=z.next_in_index,n=z.avail_in,b=s.bitb,k=s.bitk,q=s.write,m=q<s.read?s.read-q-1:s.end-q;;)switch(this.mode){case IC_START:if(m>=258&&n>=10&&(s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,r=this.inflate_fast(this.lbits,this.dbits,this.ltree,this.ltree_index,this.dtree,this.dtree_index,s,z),p=z.next_in_index,n=z.avail_in,b=s.bitb,k=s.bitk,q=s.write,m=q<s.read?s.read-q-1:s.end-q,r!=Z_OK)){this.mode=r==Z_STREAM_END?IC_WASH:IC_BADCODE;break}this.need=this.lbits,this.tree=this.ltree,this.tree_index=this.ltree_index,this.mode=IC_LEN;case IC_LEN:for(j=this.need;j>k;){if(0==n)return s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}if(tindex=3*(this.tree_index+(b&inflate_mask[j])),b>>>=this.tree[tindex+1],k-=this.tree[tindex+1],e=this.tree[tindex],0==e){this.lit=this.tree[tindex+2],this.mode=IC_LIT;break}if(0!=(16&e)){this.get=15&e,this.len=this.tree[tindex+2],this.mode=IC_LENEXT;break}if(0==(64&e)){this.need=e,this.tree_index=tindex/3+this.tree[tindex+2];break}if(0!=(32&e)){this.mode=IC_WASH;break}return this.mode=IC_BADCODE,z.msg="invalid literal/length code",r=Z_DATA_ERROR,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);case IC_LENEXT:for(j=this.get;j>k;){if(0==n)return s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}this.len+=b&inflate_mask[j],b>>=j,k-=j,this.need=this.dbits,this.tree=this.dtree,this.tree_index=this.dtree_index,this.mode=IC_DIST;case IC_DIST:for(j=this.need;j>k;){if(0==n)return s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}if(tindex=3*(this.tree_index+(b&inflate_mask[j])),b>>=this.tree[tindex+1],k-=this.tree[tindex+1],e=this.tree[tindex],0!=(16&e)){this.get=15&e,this.dist=this.tree[tindex+2],this.mode=IC_DISTEXT;break}if(0==(64&e)){this.need=e,this.tree_index=tindex/3+this.tree[tindex+2];break}return this.mode=IC_BADCODE,z.msg="invalid distance code",r=Z_DATA_ERROR,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);case IC_DISTEXT:for(j=this.get;j>k;){if(0==n)return s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);r=Z_OK,n--,b|=(255&z.next_in[p++])<<k,k+=8}this.dist+=b&inflate_mask[j],b>>=j,k-=j,this.mode=IC_COPY;case IC_COPY:for(f=q-this.dist;0>f;)f+=s.end;for(;0!=this.len;){if(0==m&&(q==s.end&&0!=s.read&&(q=0,m=q<s.read?s.read-q-1:s.end-q),0==m&&(s.write=q,r=s.inflate_flush(z,r),q=s.write,m=q<s.read?s.read-q-1:s.end-q,q==s.end&&0!=s.read&&(q=0,m=q<s.read?s.read-q-1:s.end-q),0==m)))return s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);s.window[q++]=s.window[f++],m--,f==s.end&&(f=0),this.len--}this.mode=IC_START;break;case IC_LIT:if(0==m&&(q==s.end&&0!=s.read&&(q=0,m=q<s.read?s.read-q-1:s.end-q),0==m&&(s.write=q,r=s.inflate_flush(z,r),q=s.write,m=q<s.read?s.read-q-1:s.end-q,q==s.end&&0!=s.read&&(q=0,m=q<s.read?s.read-q-1:s.end-q),0==m)))return s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);r=Z_OK,s.window[q++]=this.lit,m--,this.mode=IC_START;break;case IC_WASH:if(k>7&&(k-=8,n++,p--),s.write=q,r=s.inflate_flush(z,r),q=s.write,m=q<s.read?s.read-q-1:s.end-q,s.read!=s.write)return s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);this.mode=IC_END;case IC_END:return r=Z_STREAM_END,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);case IC_BADCODE:return r=Z_DATA_ERROR,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r);default:return r=Z_STREAM_ERROR,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,s.inflate_flush(z,r)}},InfCodes.prototype.free=function(z){},InfCodes.prototype.inflate_fast=function(bl,bd,tl,tl_index,td,td_index,s,z){var t,tp,tp_index,e,b,k,p,n,q,m,ml,md,c,d,r,tp_index_t_3;p=z.next_in_index,n=z.avail_in,b=s.bitb,k=s.bitk,q=s.write,m=q<s.read?s.read-q-1:s.end-q,ml=inflate_mask[bl],md=inflate_mask[bd];do{for(;20>k;)n--,b|=(255&z.next_in[p++])<<k,k+=8;if(t=b&ml,tp=tl,tp_index=tl_index,tp_index_t_3=3*(tp_index+t),0!=(e=tp[tp_index_t_3]))for(;;){if(b>>=tp[tp_index_t_3+1],k-=tp[tp_index_t_3+1],0!=(16&e)){for(e&=15,c=tp[tp_index_t_3+2]+(b&inflate_mask[e]),b>>=e,k-=e;15>k;)n--,b|=(255&z.next_in[p++])<<k,k+=8;for(t=b&md,tp=td,tp_index=td_index,tp_index_t_3=3*(tp_index+t),e=tp[tp_index_t_3];;){if(b>>=tp[tp_index_t_3+1],k-=tp[tp_index_t_3+1],0!=(16&e)){for(e&=15;e>k;)n--,b|=(255&z.next_in[p++])<<k,k+=8;if(d=tp[tp_index_t_3+2]+(b&inflate_mask[e]),b>>=e,k-=e,m-=c,q>=d)r=q-d,q-r>0&&2>q-r?(s.window[q++]=s.window[r++],s.window[q++]=s.window[r++],c-=2):(s.window[q++]=s.window[r++],s.window[q++]=s.window[r++],c-=2);else{r=q-d;do r+=s.end;while(0>r);if(e=s.end-r,c>e){if(c-=e,q-r>0&&e>q-r){do s.window[q++]=s.window[r++];while(0!=--e)}else arrayCopy(s.window,r,s.window,q,e),q+=e,r+=e,e=0;r=0}}do s.window[q++]=s.window[r++];while(0!=--c);break}if(0!=(64&e))return z.msg="invalid distance code",c=z.avail_in-n,c=c>k>>3?k>>3:c,n+=c,p-=c,k-=c<<3,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,Z_DATA_ERROR;t+=tp[tp_index_t_3+2],t+=b&inflate_mask[e],tp_index_t_3=3*(tp_index+t),e=tp[tp_index_t_3]}break}if(0!=(64&e))return 0!=(32&e)?(c=z.avail_in-n,c=c>k>>3?k>>3:c,n+=c,p-=c,k-=c<<3,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,Z_STREAM_END):(z.msg="invalid literal/length code",c=z.avail_in-n,c=c>k>>3?k>>3:c,n+=c,p-=c,k-=c<<3,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,Z_DATA_ERROR);if(t+=tp[tp_index_t_3+2],t+=b&inflate_mask[e],tp_index_t_3=3*(tp_index+t),0==(e=tp[tp_index_t_3])){b>>=tp[tp_index_t_3+1],k-=tp[tp_index_t_3+1],s.window[q++]=tp[tp_index_t_3+2],m--;break}}else b>>=tp[tp_index_t_3+1],k-=tp[tp_index_t_3+1],s.window[q++]=tp[tp_index_t_3+2],m--}while(m>=258&&n>=10);return c=z.avail_in-n,c=c>k>>3?k>>3:c,n+=c,p-=c,k-=c<<3,s.bitb=b,s.bitk=k,z.avail_in=n,z.total_in+=p-z.next_in_index,z.next_in_index=p,s.write=q,Z_OK},InfTree.prototype.huft_build=function(b,bindex,n,s,d,e,t,m,hp,hn,v){var a,f,g,h,i,j,k,l,mask,p,q,w,xp,y,z;p=0,i=n;do this.c[b[bindex+p]]++,p++,i--;while(0!=i);if(this.c[0]==n)return t[0]=-1,m[0]=0,Z_OK;for(l=m[0],j=1;BMAX>=j&&0==this.c[j];j++);for(k=j,j>l&&(l=j),i=BMAX;0!=i&&0==this.c[i];i--);for(g=i,l>i&&(l=i),m[0]=l,y=1<<j;i>j;j++,y<<=1)if((y-=this.c[j])<0)return Z_DATA_ERROR;if((y-=this.c[i])<0)return Z_DATA_ERROR;for(this.c[i]+=y,this.x[1]=j=0,p=1,xp=2;0!=--i;)this.x[xp]=j+=this.c[p],xp++,p++;i=0,p=0;do 0!=(j=b[bindex+p])&&(this.v[this.x[j]++]=i),p++;while(++i<n);for(n=this.x[g],this.x[0]=i=0,p=0,h=-1,w=-l,this.u[0]=0,q=0,z=0;g>=k;k++)for(a=this.c[k];0!=a--;){for(;k>w+l;){if(h++,w+=l,z=g-w,z=z>l?l:z,(f=1<<(j=k-w))>a+1&&(f-=a+1,xp=k,z>j))for(;++j<z&&!((f<<=1)<=this.c[++xp]);)f-=this.c[xp];if(z=1<<j,this.hn[0]+z>MANY)return Z_DATA_ERROR;this.u[h]=q=this.hn[0],this.hn[0]+=z,0!=h?(this.x[h]=i,this.r[0]=j,this.r[1]=l,j=i>>>w-l,this.r[2]=q-this.u[h-1]-j,arrayCopy(this.r,0,hp,3*(this.u[h-1]+j),3)):t[0]=q}for(this.r[1]=k-w,p>=n?this.r[0]=192:v[p]<s?(this.r[0]=this.v[p]<256?0:96,this.r[2]=this.v[p++]):(this.r[0]=e[this.v[p]-s]+16+64,this.r[2]=d[this.v[p++]-s]),f=1<<k-w,j=i>>>w;z>j;j+=f)arrayCopy(this.r,0,hp,3*(q+j),3);for(j=1<<k-1;0!=(i&j);j>>>=1)i^=j;for(i^=j,mask=(1<<w)-1;(i&mask)!=this.x[h];)h--,w-=l,mask=(1<<w)-1}return 0!=y&&1!=g?Z_BUF_ERROR:Z_OK},InfTree.prototype.inflate_trees_bits=function(c,bb,tb,hp,z){var result;return this.initWorkArea(19),this.hn[0]=0,result=this.huft_build(c,0,19,19,null,null,tb,bb,hp,this.hn,this.v),result==Z_DATA_ERROR?z.msg="oversubscribed dynamic bit lengths tree":(result==Z_BUF_ERROR||0==bb[0])&&(z.msg="incomplete dynamic bit lengths tree",result=Z_DATA_ERROR),result},InfTree.prototype.inflate_trees_dynamic=function(nl,nd,c,bl,bd,tl,td,hp,z){var result;return this.initWorkArea(288),this.hn[0]=0,result=this.huft_build(c,0,nl,257,cplens,cplext,tl,bl,hp,this.hn,this.v),result!=Z_OK||0==bl[0]?(result==Z_DATA_ERROR?z.msg="oversubscribed literal/length tree":result!=Z_MEM_ERROR&&(z.msg="incomplete literal/length tree",result=Z_DATA_ERROR),result):(this.initWorkArea(288),result=this.huft_build(c,nl,nd,0,cpdist,cpdext,td,bd,hp,this.hn,this.v),result!=Z_OK||0==bd[0]&&nl>257?(result==Z_DATA_ERROR?z.msg="oversubscribed distance tree":result==Z_BUF_ERROR?(z.msg="incomplete distance tree",result=Z_DATA_ERROR):result!=Z_MEM_ERROR&&(z.msg="empty distance tree with lengths",result=Z_DATA_ERROR),result):Z_OK)},InfTree.prototype.initWorkArea=function(vsize){null==this.hn&&(this.hn=new Int32Array(1),this.v=new Int32Array(vsize),this.c=new Int32Array(BMAX+1),this.r=new Int32Array(3),this.u=new Int32Array(BMAX),this.x=new Int32Array(BMAX+1)),this.v.length<vsize&&(this.v=new Int32Array(vsize));for(var i=0;vsize>i;i++)this.v[i]=0;for(var i=0;BMAX+1>i;i++)this.c[i]=0;for(var i=0;3>i;i++)this.r[i]=0;arrayCopy(this.c,0,this.u,0,BMAX),arrayCopy(this.c,0,this.x,0,BMAX+1)};var testArray=new Uint8Array(1),hasSubarray="function"==typeof testArray.subarray,hasSlice=!1,ADLER_BASE=65521,ADLER_NMAX=5552;(function(){"use strict";function q(b){throw b}function A(b,a){var c=b.split("."),d=aa;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var f;c.length&&(f=c.shift());)c.length||a===t?d=d[f]?d[f]:d[f]={}:d[f]=a}function F(b,a){this.index="number"==typeof a?a:0,this.m=0,this.buffer=b instanceof(B?Uint8Array:Array)?b:new(B?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&q(Error("invalid index")),this.buffer.length<=this.index&&this.f()}function ja(b,a,c){var d,f="number"==typeof a?a:a=0,e="number"==typeof c?c:b.length;for(d=-1,f=7&e;f--;++a)d=d>>>8^O[255&(d^b[a])];for(f=e>>3;f--;a+=8)d=d>>>8^O[255&(d^b[a])],d=d>>>8^O[255&(d^b[a+1])],d=d>>>8^O[255&(d^b[a+2])],d=d>>>8^O[255&(d^b[a+3])],d=d>>>8^O[255&(d^b[a+4])],d=d>>>8^O[255&(d^b[a+5])],d=d>>>8^O[255&(d^b[a+6])],d=d>>>8^O[255&(d^b[a+7])];return(4294967295^d)>>>0}function P(){}function la(b){this.buffer=new(B?Uint16Array:Array)(2*b),this.length=0}function ma(b){var f,e,g,k,h,l,s,n,m,a=b.length,c=0,d=Number.POSITIVE_INFINITY;for(n=0;a>n;++n)b[n]>c&&(c=b[n]),b[n]<d&&(d=b[n]);for(f=1<<c,e=new(B?Uint32Array:Array)(f),g=1,k=0,h=2;c>=g;){for(n=0;a>n;++n)if(b[n]===g){for(l=0,s=k,m=0;g>m;++m)l=l<<1|1&s,s>>=1;for(m=l;f>m;m+=h)e[m]=g<<16|n;++k}++g,k<<=1,h<<=1}return[e,c,d]}function na(b,a){this.k=qa,this.I=0,this.input=B&&b instanceof Array?new Uint8Array(b):b,this.b=0,a&&(a.lazy&&(this.I=a.lazy),"number"==typeof a.compressionType&&(this.k=a.compressionType),a.outputBuffer&&(this.a=B&&a.outputBuffer instanceof Array?new Uint8Array(a.outputBuffer):a.outputBuffer),"number"==typeof a.outputIndex&&(this.b=a.outputIndex)),this.a||(this.a=new(B?Uint8Array:Array)(32768))}function xa(b,a){this.length=b,this.P=a}function ta(b,a){function c(a,c){var f,b=a.P,d=[],e=0;f=Aa[a.length],d[e++]=65535&f,d[e++]=f>>16&255,d[e++]=f>>24;var g;switch(u){case 1===b:g=[0,b-1,0];break;case 2===b:g=[1,b-2,0];break;case 3===b:g=[2,b-3,0];break;case 4===b:g=[3,b-4,0];break;case 6>=b:g=[4,b-5,1];break;case 8>=b:g=[5,b-7,1];break;case 12>=b:g=[6,b-9,2];break;case 16>=b:g=[7,b-13,2];break;case 24>=b:g=[8,b-17,3];break;case 32>=b:g=[9,b-25,3];break;case 48>=b:g=[10,b-33,4];break;case 64>=b:g=[11,b-49,4];break;case 96>=b:g=[12,b-65,5];break;case 128>=b:g=[13,b-97,5];break;case 192>=b:g=[14,b-129,6];break;case 256>=b:g=[15,b-193,6];break;case 384>=b:g=[16,b-257,7];break;case 512>=b:g=[17,b-385,7];break;case 768>=b:g=[18,b-513,8];break;case 1024>=b:g=[19,b-769,8];break;case 1536>=b:g=[20,b-1025,9];break;case 2048>=b:g=[21,b-1537,9];break;case 3072>=b:g=[22,b-2049,10];break;case 4096>=b:g=[23,b-3073,10];break;case 6144>=b:g=[24,b-4097,11];break;case 8192>=b:g=[25,b-6145,11];break;case 12288>=b:g=[26,b-8193,12];break;case 16384>=b:g=[27,b-12289,12];break;case 24576>=b:g=[28,b-16385,13];break;case 32768>=b:g=[29,b-24577,13];break;default:q("invalid distance")}f=g,d[e++]=f[0],d[e++]=f[1],d[e++]=f[2];var h,k;for(h=0,k=d.length;k>h;++h)m[p++]=d[h];v[d[0]]++,x[d[3]]++,r=a.length+c-1,n=null}var d,f,e,g,k,l,s,n,y,h={},m=B?new Uint16Array(2*a.length):[],p=0,r=0,v=new(B?Uint32Array:Array)(286),x=new(B?Uint32Array:Array)(30),Q=b.I;if(!B){for(e=0;285>=e;)v[e++]=0;for(e=0;29>=e;)x[e++]=0}for(v[256]=1,d=0,f=a.length;f>d;++d){for(e=k=0,g=3;g>e&&d+e!==f;++e)k=k<<8|a[d+e];if(h[k]===t&&(h[k]=[]),l=h[k],!(0<r--)){for(;0<l.length&&32768<d-l[0];)l.shift();if(d+3>=f){for(n&&c(n,-1),e=0,g=f-d;g>e;++e)y=a[d+e],m[p++]=y,++v[y];break}0<l.length?(s=Ba(a,d,l),n?n.length<s.length?(y=a[d-1],m[p++]=y,++v[y],c(s,0)):c(n,-1):s.length<Q?n=s:c(s,0)):n?c(n,-1):(y=a[d],m[p++]=y,++v[y])}l.push(d)}return m[p++]=256,v[256]++,b.V=v,b.U=x,B?m.subarray(0,p):m}function Ba(b,a,c){var d,f,g,k,h,l,e=0,s=b.length;k=0,l=c.length;a:for(;l>k;k++){if(d=c[l-k-1],g=3,e>3){for(h=e;h>3;h--)if(b[d+h-1]!==b[a+h-1])continue a;g=e}for(;258>g&&s>a+g&&b[d+g]===b[a+g];)++g;if(g>e&&(f=d,e=g),258===g)break}return new xa(e,a-f)}function ua(b,a){var e,g,k,h,l,c=b.length,d=new la(572),f=new(B?Uint8Array:Array)(c);if(!B)for(h=0;c>h;h++)f[h]=0;for(h=0;c>h;++h)0<b[h]&&d.push(h,b[h]);if(e=Array(d.length/2),g=new(B?Uint32Array:Array)(d.length/2),1===e.length)return f[d.pop().index]=1,f;for(h=0,l=d.length/2;l>h;++h)e[h]=d.pop(),g[h]=e[h].value;for(k=Ca(g,g.length,a),h=0,l=e.length;l>h;++h)f[e[h].index]=k[h];return f}function Ca(b,a,c){function d(b){var c=h[b][l[b]];c===a?(d(b+1),d(b+1)):--g[c],++l[b]}var m,p,r,v,x,f=new(B?Uint16Array:Array)(c),e=new(B?Uint8Array:Array)(c),g=new(B?Uint8Array:Array)(a),k=Array(c),h=Array(c),l=Array(c),s=(1<<c)-a,n=1<<c-1;for(f[c-1]=a,p=0;c>p;++p)n>s?e[p]=0:(e[p]=1,s-=n),s<<=1,f[c-2-p]=(f[c-1-p]/2|0)+a;for(f[0]=e[0],k[0]=Array(f[0]),h[0]=Array(f[0]),p=1;c>p;++p)f[p]>2*f[p-1]+e[p]&&(f[p]=2*f[p-1]+e[p]),k[p]=Array(f[p]),h[p]=Array(f[p]);for(m=0;a>m;++m)g[m]=c;for(r=0;r<f[c-1];++r)k[c-1][r]=b[r],h[c-1][r]=r;for(m=0;c>m;++m)l[m]=0;for(1===e[c-1]&&(--g[0],++l[c-1]),p=c-2;p>=0;--p){for(v=m=0,x=l[p+1],r=0;r<f[p];r++)v=k[p+1][x]+k[p+1][x+1],v>b[m]?(k[p][r]=v,h[p][r]=a,x+=2):(k[p][r]=b[m],h[p][r]=m,++m);l[p]=0,1===e[p]&&d(p)}return g}function va(b){var e,g,k,h,a=new(B?Uint16Array:Array)(b.length),c=[],d=[],f=0;for(e=0,g=b.length;g>e;e++)c[b[e]]=(0|c[b[e]])+1;for(e=1,g=16;g>=e;e++)d[e]=f,f+=0|c[e],f<<=1;for(e=0,g=b.length;g>e;e++)for(f=d[b[e]],d[b[e]]+=1,k=a[e]=0,h=b[e];h>k;k++)a[e]=a[e]<<1|1&f,f>>>=1;return a}function Da(b,a){this.input=b,this.b=this.c=0,this.i={},a&&(a.flags&&(this.i=a.flags),"string"==typeof a.filename&&(this.filename=a.filename),"string"==typeof a.comment&&(this.A=a.comment),a.deflateOptions&&(this.l=a.deflateOptions)),this.l||(this.l={})}function T(b,a){switch(this.p=[],this.q=32768,this.e=this.j=this.c=this.u=0,this.input=B?new Uint8Array(b):b,this.w=!1,this.r=Ia,this.L=!1,(a||!(a={}))&&(a.index&&(this.c=a.index),a.bufferSize&&(this.q=a.bufferSize),a.bufferType&&(this.r=a.bufferType),a.resize&&(this.L=a.resize)),this.r){case Xa:this.b=32768,this.a=new(B?Uint8Array:Array)(32768+this.q+258);break;case Ia:this.b=0,this.a=new(B?Uint8Array:Array)(this.q),this.f=this.T,this.B=this.Q,this.s=this.S;break;default:q(Error("invalid inflate mode"))}}function U(b,a){for(var g,c=b.j,d=b.e,f=b.input,e=b.c;a>d;)g=f[e++],g===t&&q(Error("input buffer is broken")),c|=g<<d,d+=8;return g=c&(1<<a)-1,b.j=c>>>a,b.e=d-a,b.c=e,g}function rb(b,a){for(var h,l,s,c=b.j,d=b.e,f=b.input,e=b.c,g=a[0],k=a[1];k>d&&(h=f[e++],h!==t);)c|=h<<d,d+=8;return l=g[c&(1<<k)-1],s=l>>>16,b.j=c>>s,b.e=d-s,b.c=e,65535&l}function ab(b){function a(a,b,c){var d,e,f,g;for(g=0;a>g;)switch(d=rb(this,b)){case 16:for(f=3+U(this,2);f--;)c[g++]=e;break;case 17:for(f=3+U(this,3);f--;)c[g++]=0;e=0;break;case 18:for(f=11+U(this,7);f--;)c[g++]=0;e=0;break;default:e=c[g++]=d}return c}var g,k,h,l,c=U(b,5)+257,d=U(b,5)+1,f=U(b,4)+4,e=new(B?Uint8Array:Array)(cb.length);for(l=0;f>l;++l)e[cb[l]]=U(b,3);g=ma(e),k=new(B?Uint8Array:Array)(c),h=new(B?Uint8Array:Array)(d),b.s(ma(a.call(b,c,g,k)),ma(a.call(b,d,g,h)))}function sb(b){this.input=b,this.c=0,this.t=[],this.D=!1}function tb(b){if("string"==typeof b){var c,d,a=b.split("");for(c=0,d=a.length;d>c;c++)a[c]=(255&a[c].charCodeAt(0))>>>0;b=a}for(var k,f=1,e=0,g=b.length,h=0;g>0;){k=g>1024?1024:g,g-=k;do f+=b[h++],e+=f;while(--k);f%=65521,e%=65521}return(e<<16|f)>>>0}function ub(b,a){var c,d;switch(this.input=b,this.c=0,(a||!(a={}))&&(a.index&&(this.c=a.index),a.verify&&(this.Z=a.verify)),c=b[this.c++],d=b[this.c++],15&c){case vb:this.method=vb;break;default:q(Error("unsupported compression method"))}0!==((c<<8)+d)%31&&q(Error("invalid fcheck flag:"+((c<<8)+d)%31)),32&d&&q(Error("fdict flag is not supported")),this.K=new T(b,{index:this.c,bufferSize:a.bufferSize,bufferType:a.bufferType,resize:a.resize})}function wb(b,a){this.input=b,this.a=new(B?Uint8Array:Array)(32768),this.k=W.o;var d,c={};!a&&(a={})||"number"!=typeof a.compressionType||(this.k=a.compressionType);for(d in a)c[d]=a[d];c.outputBuffer=this.a,this.J=new na(this.input,c)}function xb(b,a){var c,d,f,e;if(Object.keys)c=Object.keys(a);else for(d in c=[],f=0,a)c[f++]=d;for(f=0,e=c.length;e>f;++f)d=c[f],A(b+"."+d,a[d])}var t=void 0,u=!0,aa=this,B="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;F.prototype.f=function(){var a,b=this.buffer,c=b.length,d=new(B?Uint8Array:Array)(c<<1);if(B)d.set(b);else for(a=0;c>a;++a)d[a]=b[a];return this.buffer=d},F.prototype.d=function(b,a,c){var k,d=this.buffer,f=this.index,e=this.m,g=d[f];if(c&&a>1&&(b=a>8?(H[255&b]<<24|H[b>>>8&255]<<16|H[b>>>16&255]<<8|H[b>>>24&255])>>32-a:H[b]>>8-a),8>a+e)g=g<<a|b,e+=a;else for(k=0;a>k;++k)g=g<<1|b>>a-k-1&1,8===++e&&(e=0,d[f++]=H[g],g=0,f===d.length&&(d=this.f()));d[f]=g,this.buffer=d,this.m=e,this.index=f},F.prototype.finish=function(){var c,b=this.buffer,a=this.index;return 0<this.m&&(b[a]<<=8-this.m,b[a]=H[b[a]],a++),B?c=b.subarray(0,a):(b.length=a,c=b),c};var ca,ba=new(B?Uint8Array:Array)(256);for(ca=0;256>ca;++ca){for(var K=ca,da=K,ea=7,K=K>>>1;K;K>>>=1)da<<=1,da|=1&K,--ea;ba[ca]=(da<<ea&255)>>>0}var H=ba,ka=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],O=B?new Uint32Array(ka):ka;
|
12
|
+
|
13
|
+
P.prototype.getName=function(){return this.name},P.prototype.getData=function(){return this.data},P.prototype.X=function(){return this.Y},A("Zlib.GunzipMember",P),A("Zlib.GunzipMember.prototype.getName",P.prototype.getName),A("Zlib.GunzipMember.prototype.getData",P.prototype.getData),A("Zlib.GunzipMember.prototype.getMtime",P.prototype.X),la.prototype.getParent=function(b){return 2*((b-2)/4|0)},la.prototype.push=function(b,a){var c,d,e,f=this.buffer;for(c=this.length,f[this.length++]=a,f[this.length++]=b;c>0&&(d=this.getParent(c),f[c]>f[d]);)e=f[c],f[c]=f[d],f[d]=e,e=f[c+1],f[c+1]=f[d+1],f[d+1]=e,c=d;return this.length},la.prototype.pop=function(){var b,a,d,f,e,c=this.buffer;for(a=c[0],b=c[1],this.length-=2,c[0]=c[this.length],c[1]=c[this.length+1],e=0;(f=2*e+2,!(f>=this.length))&&(f+2<this.length&&c[f+2]>c[f]&&(f+=2),c[f]>c[e]);)d=c[e],c[e]=c[f],c[f]=d,d=c[e+1],c[e+1]=c[f+1],c[f+1]=d,e=f;return{index:b,value:a,length:this.length}};var S,qa=2,ra={NONE:0,v:1,o:qa,aa:3},sa=[];for(S=0;288>S;S++)switch(u){case 143>=S:sa.push([S+48,8]);break;case 255>=S:sa.push([S-144+400,9]);break;case 279>=S:sa.push([S-256+0,7]);break;case 287>=S:sa.push([S-280+192,8]);break;default:q("invalid literal: "+S)}na.prototype.g=function(){var b,a,c,d,f=this.input;switch(this.k){case 0:for(c=0,d=f.length;d>c;){a=B?f.subarray(c,c+65535):f.slice(c,c+65535),c+=a.length;var e=a,g=c===d,k=t,h=t,l=t,s=t,n=t,m=this.a,p=this.b;if(B){for(m=new Uint8Array(this.a.buffer);m.length<=p+e.length+5;)m=new Uint8Array(m.length<<1);m.set(this.a)}if(k=g?1:0,m[p++]=0|k,h=e.length,l=~h+65536&65535,m[p++]=255&h,m[p++]=h>>>8&255,m[p++]=255&l,m[p++]=l>>>8&255,B)m.set(e,p),p+=e.length,m=m.subarray(0,p);else{for(s=0,n=e.length;n>s;++s)m[p++]=e[s];m.length=p}this.b=p,this.a=m}break;case 1:var r=new F(B?new Uint8Array(this.a.buffer):this.a,this.b);r.d(1,1,u),r.d(1,2,u);var x,Q,y,v=ta(this,f);for(x=0,Q=v.length;Q>x;x++)if(y=v[x],F.prototype.d.apply(r,sa[y]),y>256)r.d(v[++x],v[++x],u),r.d(v[++x],5),r.d(v[++x],v[++x],u);else if(256===y)break;this.a=r.finish(),this.b=this.a.length;break;case qa:var Ja,R,X,Y,Z,fa,Ka,ga,La,oa,Ma,$,pa,C,Na,E=new F(B?new Uint8Array(this.a.buffer):this.a,this.b),pb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],wa=Array(19);for(Ja=qa,E.d(1,1,u),E.d(Ja,2,u),R=ta(this,f),fa=ua(this.V,15),Ka=va(fa),ga=ua(this.U,7),La=va(ga),X=286;X>257&&0===fa[X-1];X--);for(Y=30;Y>1&&0===ga[Y-1];Y--);var w,L,z,ha,G,D,Oa=X,Pa=Y,J=new(B?Uint32Array:Array)(Oa+Pa),I=new(B?Uint32Array:Array)(316),M=new(B?Uint8Array:Array)(19);for(w=L=0;Oa>w;w++)J[L++]=fa[w];for(w=0;Pa>w;w++)J[L++]=ga[w];if(!B)for(w=0,ha=M.length;ha>w;++w)M[w]=0;for(w=G=0,ha=J.length;ha>w;w+=L){for(L=1;ha>w+L&&J[w+L]===J[w];++L);if(z=L,0===J[w])if(3>z)for(;0<z--;)I[G++]=0,M[0]++;else for(;z>0;)D=138>z?z:138,D>z-3&&z>D&&(D=z-3),10>=D?(I[G++]=17,I[G++]=D-3,M[17]++):(I[G++]=18,I[G++]=D-11,M[18]++),z-=D;else if(I[G++]=J[w],M[J[w]]++,z--,3>z)for(;0<z--;)I[G++]=J[w],M[J[w]]++;else for(;z>0;)D=6>z?z:6,D>z-3&&z>D&&(D=z-3),I[G++]=16,I[G++]=D-3,M[16]++,z-=D}for(b=B?I.subarray(0,G):I.slice(0,G),oa=ua(M,7),C=0;19>C;C++)wa[C]=oa[pb[C]];for(Z=19;Z>4&&0===wa[Z-1];Z--);for(Ma=va(oa),E.d(X-257,5,u),E.d(Y-1,5,u),E.d(Z-4,4,u),C=0;Z>C;C++)E.d(wa[C],3,u);for(C=0,Na=b.length;Na>C;C++)if($=b[C],E.d(Ma[$],oa[$],u),$>=16){switch(C++,$){case 16:pa=2;break;case 17:pa=3;break;case 18:pa=7;break;default:q("invalid code: "+$)}E.d(b[C],pa,u)}var N,Sa,ia,za,Ta,Ua,Va,Wa,Qa=[Ka,fa],Ra=[La,ga];for(Ta=Qa[0],Ua=Qa[1],Va=Ra[0],Wa=Ra[1],N=0,Sa=R.length;Sa>N;++N)if(ia=R[N],E.d(Ta[ia],Ua[ia],u),ia>256)E.d(R[++N],R[++N],u),za=R[++N],E.d(Va[za],Wa[za],u),E.d(R[++N],R[++N],u);else if(256===ia)break;this.a=E.finish(),this.b=this.a.length;break;default:q("invalid compression type")}return this.a};var ya=function(){function b(a){switch(u){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:q("invalid length: "+a)}}var c,d,a=[];for(c=3;258>=c;c++)d=b(c),a[c]=d[2]<<24|d[1]<<16|d[0];return a}(),Aa=B?new Uint32Array(ya):ya;Da.prototype.g=function(){var b,a,c,d,f,e,g,k,h=new(B?Uint8Array:Array)(32768),l=0,s=this.input,n=this.c,m=this.filename,p=this.A;if(h[l++]=31,h[l++]=139,h[l++]=8,b=0,this.i.fname&&(b|=Ea),this.i.fcomment&&(b|=Fa),this.i.fhcrc&&(b|=Ga),h[l++]=b,a=(Date.now?Date.now():+new Date)/1e3|0,h[l++]=255&a,h[l++]=a>>>8&255,h[l++]=a>>>16&255,h[l++]=a>>>24&255,h[l++]=0,h[l++]=Ha,this.i.fname!==t){for(g=0,k=m.length;k>g;++g)e=m.charCodeAt(g),e>255&&(h[l++]=e>>>8&255),h[l++]=255&e;h[l++]=0}if(this.i.comment){for(g=0,k=p.length;k>g;++g)e=p.charCodeAt(g),e>255&&(h[l++]=e>>>8&255),h[l++]=255&e;h[l++]=0}return this.i.fhcrc&&(c=65535&ja(h,0,l),h[l++]=255&c,h[l++]=c>>>8&255),this.l.outputBuffer=h,this.l.outputIndex=l,f=new na(s,this.l),h=f.g(),l=f.b,B&&(l+8>h.buffer.byteLength?(this.a=new Uint8Array(l+8),this.a.set(new Uint8Array(h.buffer)),h=this.a):h=new Uint8Array(h.buffer)),d=ja(s,t,t),h[l++]=255&d,h[l++]=d>>>8&255,h[l++]=d>>>16&255,h[l++]=d>>>24&255,k=s.length,h[l++]=255&k,h[l++]=k>>>8&255,h[l++]=k>>>16&255,h[l++]=k>>>24&255,this.c=n,B&&l<h.length&&(this.a=h=h.subarray(0,l)),h};var Ha=255,Ga=2,Ea=8,Fa=16;A("Zlib.Gzip",Da),A("Zlib.Gzip.prototype.compress",Da.prototype.g);var Xa=0,Ia=1,Ya={N:Xa,M:Ia};T.prototype.h=function(){for(;!this.w;){var b=U(this,3);switch(1&b&&(this.w=u),b>>>=1){case 0:var a=this.input,c=this.c,d=this.a,f=this.b,e=t,g=t,k=t,h=d.length,l=t;switch(this.e=this.j=0,e=a[c++],e===t&&q(Error("invalid uncompressed block header: LEN (first byte)")),g=e,e=a[c++],e===t&&q(Error("invalid uncompressed block header: LEN (second byte)")),g|=e<<8,e=a[c++],e===t&&q(Error("invalid uncompressed block header: NLEN (first byte)")),k=e,e=a[c++],e===t&&q(Error("invalid uncompressed block header: NLEN (second byte)")),k|=e<<8,g===~k&&q(Error("invalid uncompressed block header: length verify")),c+g>a.length&&q(Error("input buffer is broken")),this.r){case Xa:for(;f+g>d.length;){if(l=h-f,g-=l,B)d.set(a.subarray(c,c+l),f),f+=l,c+=l;else for(;l--;)d[f++]=a[c++];this.b=f,d=this.f(),f=this.b}break;case Ia:for(;f+g>d.length;)d=this.f({F:2});break;default:q(Error("invalid inflate mode"))}if(B)d.set(a.subarray(c,c+g),f),f+=g,c+=g;else for(;g--;)d[f++]=a[c++];this.c=c,this.b=f,this.a=d;break;case 1:this.s(Za,$a);break;case 2:ab(this);break;default:q(Error("unknown BTYPE: "+b))}}return this.B()};var V,mb,bb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],cb=B?new Uint16Array(bb):bb,db=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],eb=B?new Uint16Array(db):db,fb=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],gb=B?new Uint8Array(fb):fb,hb=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],ib=B?new Uint16Array(hb):hb,jb=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],kb=B?new Uint8Array(jb):jb,lb=new(B?Uint8Array:Array)(288);for(V=0,mb=lb.length;mb>V;++V)lb[V]=143>=V?8:255>=V?9:279>=V?7:8;var ob,qb,Za=ma(lb),nb=new(B?Uint8Array:Array)(30);for(ob=0,qb=nb.length;qb>ob;++ob)nb[ob]=5;var $a=ma(nb);T.prototype.s=function(b,a){var c=this.a,d=this.b;this.C=b;for(var e,g,k,h,f=c.length-258;256!==(e=rb(this,b));)if(256>e)d>=f&&(this.b=d,c=this.f(),d=this.b),c[d++]=e;else for(g=e-257,h=eb[g],0<gb[g]&&(h+=U(this,gb[g])),e=rb(this,a),k=ib[e],0<kb[e]&&(k+=U(this,kb[e])),d>=f&&(this.b=d,c=this.f(),d=this.b);h--;)c[d]=c[d++-k];for(;8<=this.e;)this.e-=8,this.c--;this.b=d},T.prototype.S=function(b,a){var c=this.a,d=this.b;this.C=b;for(var e,g,k,h,f=c.length;256!==(e=rb(this,b));)if(256>e)d>=f&&(c=this.f(),f=c.length),c[d++]=e;else for(g=e-257,h=eb[g],0<gb[g]&&(h+=U(this,gb[g])),e=rb(this,a),k=ib[e],0<kb[e]&&(k+=U(this,kb[e])),d+h>f&&(c=this.f(),f=c.length);h--;)c[d]=c[d++-k];for(;8<=this.e;)this.e-=8,this.c--;this.b=d},T.prototype.f=function(){var c,d,b=new(B?Uint8Array:Array)(this.b-32768),a=this.b-32768,f=this.a;if(B)b.set(f.subarray(32768,b.length));else for(c=0,d=b.length;d>c;++c)b[c]=f[c+32768];if(this.p.push(b),this.u+=b.length,B)f.set(f.subarray(a,a+32768));else for(c=0;32768>c;++c)f[c]=f[a+c];return this.b=32768,f},T.prototype.T=function(b){var a,d,f,e,c=this.input.length/this.c+1|0,g=this.input,k=this.a;return b&&("number"==typeof b.F&&(c=b.F),"number"==typeof b.O&&(c+=b.O)),2>c?(d=(g.length-this.c)/this.C[2],e=258*(d/2)|0,f=e<k.length?k.length+e:k.length<<1):f=k.length*c,B?(a=new Uint8Array(f),a.set(k)):a=k,this.a=a},T.prototype.B=function(){var d,e,g,k,h,b=0,a=this.a,c=this.p,f=new(B?Uint8Array:Array)(this.u+(this.b-32768));if(0===c.length)return B?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);for(e=0,g=c.length;g>e;++e)for(d=c[e],k=0,h=d.length;h>k;++k)f[b++]=d[k];for(e=32768,g=this.b;g>e;++e)f[b++]=a[e];return this.p=[],this.buffer=f},T.prototype.Q=function(){var b,a=this.b;return B?this.L?(b=new Uint8Array(a),b.set(this.a.subarray(0,a))):b=this.a.subarray(0,a):(this.a.length>a&&(this.a.length=a),b=this.a),this.buffer=b},sb.prototype.W=function(){return this.D||this.h(),this.t.slice()},sb.prototype.h=function(){for(var b=this.input.length;this.c<b;){var a=new P,c=t,d=t,f=t,e=t,g=t,k=t,h=t,l=t,s=t,n=this.input,m=this.c;switch(a.G=n[m++],a.H=n[m++],(31!==a.G||139!==a.H)&&q(Error("invalid file signature:"+a.G+","+a.H)),a.z=n[m++],a.z){case 8:break;default:q(Error("unknown compression method: "+a.z))}if(a.n=n[m++],l=n[m++]|n[m++]<<8|n[m++]<<16|n[m++]<<24,a.Y=new Date(1e3*l),a.ea=n[m++],a.da=n[m++],0<(4&a.n)&&(a.$=n[m++]|n[m++]<<8,m+=a.$),0<(a.n&Ea)){for(h=[],k=0;0<(g=n[m++]);)h[k++]=String.fromCharCode(g);a.name=h.join("")}if(0<(a.n&Fa)){for(h=[],k=0;0<(g=n[m++]);)h[k++]=String.fromCharCode(g);a.A=h.join("")}0<(a.n&Ga)&&(a.R=65535&ja(n,0,m),a.R!==(n[m++]|n[m++]<<8)&&q(Error("invalid header crc16"))),c=n[n.length-4]|n[n.length-3]<<8|n[n.length-2]<<16|n[n.length-1]<<24,n.length-m-4-4<512*c&&(e=c),d=new T(n,{index:m,bufferSize:e}),a.data=f=d.h(),m=d.c,a.ba=s=(n[m++]|n[m++]<<8|n[m++]<<16|n[m++]<<24)>>>0,ja(f,t,t)!==s&&q(Error("invalid CRC-32 checksum: 0x"+ja(f,t,t).toString(16)+" / 0x"+s.toString(16))),a.ca=c=(n[m++]|n[m++]<<8|n[m++]<<16|n[m++]<<24)>>>0,(4294967295&f.length)!==c&&q(Error("invalid input size: "+(4294967295&f.length)+" / "+c)),this.t.push(a),this.c=m}this.D=u;var r,v,y,p=this.t,x=0,Q=0;for(r=0,v=p.length;v>r;++r)Q+=p[r].data.length;if(B)for(y=new Uint8Array(Q),r=0;v>r;++r)y.set(p[r].data,x),x+=p[r].data.length;else{for(y=[],r=0;v>r;++r)y[r]=p[r].data;y=Array.prototype.concat.apply([],y)}return y},A("Zlib.Gunzip",sb),A("Zlib.Gunzip.prototype.decompress",sb.prototype.h),A("Zlib.Gunzip.prototype.getMembers",sb.prototype.W),ub.prototype.h=function(){var a,c,b=this.input;return a=this.K.h(),this.c=this.K.c,this.Z&&(c=(b[this.c++]<<24|b[this.c++]<<16|b[this.c++]<<8|b[this.c++])>>>0,c!==tb(a)&&q(Error("invalid adler-32 checksum"))),a};var vb=8,W=ra;wb.prototype.g=function(){var b,a,c,d,f,e,g,k=0;switch(g=this.a,b=vb){case vb:a=Math.LOG2E*Math.log(32768)-8;break;default:q(Error("invalid compression method"))}switch(c=a<<4|b,g[k++]=c,b){case vb:switch(this.k){case W.NONE:f=0;break;case W.v:f=1;break;case W.o:f=2;break;default:q(Error("unsupported compression type"))}break;default:q(Error("invalid compression method"))}return d=f<<6|0,g[k++]=d|31-(256*c+d)%31,e=tb(this.input),this.J.b=k,g=this.J.g(),k=g.length,B&&(g=new Uint8Array(g.buffer),g.length<=k+4&&(this.a=new Uint8Array(g.length+4),this.a.set(g),g=this.a),g=g.subarray(0,k+4)),g[k++]=e>>24&255,g[k++]=e>>16&255,g[k++]=e>>8&255,g[k++]=255&e,g},A("Zlib.Inflate",ub),A("Zlib.Inflate.prototype.decompress",ub.prototype.h),xb("Zlib.Inflate.BufferType",{ADAPTIVE:Ya.M,BLOCK:Ya.N}),A("Zlib.Deflate",wb),A("Zlib.Deflate.compress",function(b,a){return new wb(b,a).g()}),A("Zlib.Deflate.prototype.compress",wb.prototype.g),xb("Zlib.Deflate.CompressionType",{NONE:W.NONE,FIXED:W.v,DYNAMIC:W.o})}).call(this),function($){"use strict";var _colorpicker_index=0,_container_popup='<div class="ui-colorpicker ui-colorpicker-dialog ui-dialog ui-widget ui-widget-content ui-corner-all" style="display: none;"></div>',_container_inlineFrame='<div class="ui-colorpicker ui-colorpicker-inline ui-dialog ui-widget ui-widget-content ui-corner-all"></div>',_container_inline='<div class="ui-colorpicker ui-colorpicker-inline"></div>',_intToHex=function(dec){var result=Math.floor(dec).toString(16);return 1===result.length&&(result="0"+result),result.toLowerCase()},_parseHex=function(color){var c,m;return m=/^#?([a-fA-F0-9]{1,6})$/.exec(color),m?(c=parseInt(m[1],16),new $.colorpicker.Color((c>>16&255)/255,(c>>8&255)/255,(255&c)/255)):new $.colorpicker.Color},_layoutTable=function(layout,callback){var bitmap,x,y,width,height,columns,rows,index,cell,html,w,h,colspan,walked;for(layout.sort(function(a,b){return a.pos[1]===b.pos[1]?a.pos[0]-b.pos[0]:a.pos[1]-b.pos[1]}),width=0,height=0,$.each(layout,function(index,part){width=Math.max(width,part.pos[0]+part.pos[2]),height=Math.max(height,part.pos[1]+part.pos[3])}),bitmap=[],x=0;width>x;++x)bitmap.push([]);for(rows=[],columns=[],$.each(layout,function(index,part){for(x=0;x<part.pos[2];x+=1)columns[part.pos[0]+x]=!0;for(y=0;y<part.pos[3];y+=1)rows[part.pos[1]+y]=!0}),html="",cell=layout[index=0],y=0;height>y;++y){for(html+="<tr>",x=0;width>x;)if("undefined"!=typeof cell&&x===cell.pos[0]&&y===cell.pos[1]){for(html+=callback(cell,x,y),h=0;h<cell.pos[3];h+=1)for(w=0;w<cell.pos[2];w+=1)bitmap[x+w][y+h]=!0;x+=cell.pos[2],cell=layout[++index]}else{for(colspan=0,walked=!1;width>x&&void 0===bitmap[x][y]&&(void 0===cell||y<cell.pos[1]||y===cell.pos[1]&&x<cell.pos[0]);)columns[x]===!0&&(colspan+=1),walked=!0,x+=1;colspan>0?html+='<td colspan="'+colspan+'"></td>':walked||(x+=1)}html+="</tr>"}return'<table cellspacing="0" cellpadding="0" border="0"><tbody>'+html+"</tbody></table>"};$.colorpicker=new function(){this.regional={"":{ok:"OK",cancel:"Cancel",none:"None",button:"Color",title:"Pick a color",transparent:"Transparent",hsvH:"H",hsvS:"S",hsvV:"V",rgbR:"R",rgbG:"G",rgbB:"B",labL:"L",labA:"a",labB:"b",hslH:"H",hslS:"S",hslL:"L",cmykC:"C",cmykM:"M",cmykY:"Y",cmykK:"K",alphaA:"A"}},this.swatches={html:[{name:"black",r:0,g:0,b:0},{name:"dimgray",r:.4117647058823529,g:.4117647058823529,b:.4117647058823529},{name:"gray",r:.5019607843137255,g:.5019607843137255,b:.5019607843137255},{name:"darkgray",r:.6627450980392157,g:.6627450980392157,b:.6627450980392157},{name:"silver",r:.7529411764705882,g:.7529411764705882,b:.7529411764705882},{name:"lightgrey",r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},{name:"gainsboro",r:.8627450980392157,g:.8627450980392157,b:.8627450980392157},{name:"whitesmoke",r:.9607843137254902,g:.9607843137254902,b:.9607843137254902},{name:"white",r:1,g:1,b:1},{name:"rosybrown",r:.7372549019607844,g:.5607843137254902,b:.5607843137254902},{name:"indianred",r:.803921568627451,g:.3607843137254902,b:.3607843137254902},{name:"brown",r:.6470588235294118,g:.16470588235294117,b:.16470588235294117},{name:"firebrick",r:.6980392156862745,g:.13333333333333333,b:.13333333333333333},{name:"lightcoral",r:.9411764705882353,g:.5019607843137255,b:.5019607843137255},{name:"maroon",r:.5019607843137255,g:0,b:0},{name:"darkred",r:.5450980392156862,g:0,b:0},{name:"red",r:1,g:0,b:0},{name:"snow",r:1,g:.9803921568627451,b:.9803921568627451},{name:"salmon",r:.9803921568627451,g:.5019607843137255,b:.4470588235294118},{name:"mistyrose",r:1,g:.8941176470588236,b:.8823529411764706},{name:"tomato",r:1,g:.38823529411764707,b:.2784313725490196},{name:"darksalmon",r:.9137254901960784,g:.5882352941176471,b:.47843137254901963},{name:"orangered",r:1,g:.27058823529411763,b:0},{name:"coral",r:1,g:.4980392156862745,b:.3137254901960784},{name:"lightsalmon",r:1,g:.6274509803921569,b:.47843137254901963},{name:"sienna",r:.6274509803921569,g:.3215686274509804,b:.17647058823529413},{name:"seashell",r:1,g:.9607843137254902,b:.9333333333333333},{name:"chocolate",r:.8235294117647058,g:.4117647058823529,b:.11764705882352941},{name:"saddlebrown",r:.5450980392156862,g:.27058823529411763,b:.07450980392156863},{name:"sandybrown",r:.9568627450980393,g:.6431372549019608,b:.3764705882352941},{name:"peachpuff",r:1,g:.8549019607843137,b:.7254901960784313},{name:"peru",r:.803921568627451,g:.5215686274509804,b:.24705882352941178},{name:"linen",r:.9803921568627451,g:.9411764705882353,b:.9019607843137255},{name:"darkorange",r:1,g:.5490196078431373,b:0},{name:"bisque",r:1,g:.8941176470588236,b:.7686274509803922},{name:"burlywood",r:.8705882352941177,g:.7215686274509804,b:.5294117647058824},{name:"tan",r:.8235294117647058,g:.7058823529411765,b:.5490196078431373},{name:"antiquewhite",r:.9803921568627451,g:.9215686274509803,b:.8431372549019608},{name:"navajowhite",r:1,g:.8705882352941177,b:.6784313725490196},{name:"blanchedalmond",r:1,g:.9215686274509803,b:.803921568627451},{name:"papayawhip",r:1,g:.9372549019607843,b:.8352941176470589},{name:"orange",r:1,g:.6470588235294118,b:0},{name:"moccasin",r:1,g:.8941176470588236,b:.7098039215686275},{name:"wheat",r:.9607843137254902,g:.8705882352941177,b:.7019607843137254},{name:"oldlace",r:.9921568627450981,g:.9607843137254902,b:.9019607843137255},{name:"floralwhite",r:1,g:.9803921568627451,b:.9411764705882353},{name:"goldenrod",r:.8549019607843137,g:.6470588235294118,b:.12549019607843137},{name:"darkgoldenrod",r:.7215686274509804,g:.5254901960784314,b:.043137254901960784},{name:"cornsilk",r:1,g:.9725490196078431,b:.8627450980392157},{name:"gold",r:1,g:.8431372549019608,b:0},{name:"palegoldenrod",r:.9333333333333333,g:.9098039215686274,b:.6666666666666666},{name:"khaki",r:.9411764705882353,g:.9019607843137255,b:.5490196078431373},{name:"lemonchiffon",r:1,g:.9803921568627451,b:.803921568627451},{name:"darkkhaki",r:.7411764705882353,g:.7176470588235294,b:.4196078431372549},{name:"beige",r:.9607843137254902,g:.9607843137254902,b:.8627450980392157},{name:"lightgoldenrodyellow",r:.9803921568627451,g:.9803921568627451,b:.8235294117647058},{name:"olive",r:.5019607843137255,g:.5019607843137255,b:0},{name:"yellow",r:1,g:1,b:0},{name:"lightyellow",r:1,g:1,b:.8784313725490196},{name:"ivory",r:1,g:1,b:.9411764705882353},{name:"olivedrab",r:.4196078431372549,g:.5568627450980392,b:.13725490196078433},{name:"yellowgreen",r:.6039215686274509,g:.803921568627451,b:.19607843137254902},{name:"darkolivegreen",r:.3333333333333333,g:.4196078431372549,b:.1843137254901961},{name:"greenyellow",r:.6784313725490196,g:1,b:.1843137254901961},{name:"lawngreen",r:.48627450980392156,g:.9882352941176471,b:0},{name:"chartreuse",r:.4980392156862745,g:1,b:0},{name:"darkseagreen",r:.5607843137254902,g:.7372549019607844,b:.5607843137254902},{name:"forestgreen",r:.13333333333333333,g:.5450980392156862,b:.13333333333333333},{name:"limegreen",r:.19607843137254902,g:.803921568627451,b:.19607843137254902},{name:"lightgreen",r:.5647058823529412,g:.9333333333333333,b:.5647058823529412},{name:"palegreen",r:.596078431372549,g:.984313725490196,b:.596078431372549},{name:"darkgreen",r:0,g:.39215686274509803,b:0},{name:"green",r:0,g:.5019607843137255,b:0},{name:"lime",r:0,g:1,b:0},{name:"honeydew",r:.9411764705882353,g:1,b:.9411764705882353},{name:"mediumseagreen",r:.23529411764705882,g:.7019607843137254,b:.44313725490196076},{name:"seagreen",r:.1803921568627451,g:.5450980392156862,b:.3411764705882353},{name:"springgreen",r:0,g:1,b:.4980392156862745},{name:"mintcream",r:.9607843137254902,g:1,b:.9803921568627451},{name:"mediumspringgreen",r:0,g:.9803921568627451,b:.6039215686274509},{name:"mediumaquamarine",r:.4,g:.803921568627451,b:.6666666666666666},{name:"aquamarine",r:.4980392156862745,g:1,b:.8313725490196079},{name:"turquoise",r:.25098039215686274,g:.8784313725490196,b:.8156862745098039},{name:"lightseagreen",r:.12549019607843137,g:.6980392156862745,b:.6666666666666666},{name:"mediumturquoise",r:.2823529411764706,g:.8196078431372549,b:.8},{name:"darkslategray",r:.1843137254901961,g:.30980392156862746,b:.30980392156862746},{name:"paleturquoise",r:.6862745098039216,g:.9333333333333333,b:.9333333333333333},{name:"teal",r:0,g:.5019607843137255,b:.5019607843137255},{name:"darkcyan",r:0,g:.5450980392156862,b:.5450980392156862},{name:"darkturquoise",r:0,g:.807843137254902,b:.8196078431372549},{name:"aqua",r:0,g:1,b:1},{name:"cyan",r:0,g:1,b:1},{name:"lightcyan",r:.8784313725490196,g:1,b:1},{name:"azure",r:.9411764705882353,g:1,b:1},{name:"cadetblue",r:.37254901960784315,g:.6196078431372549,b:.6274509803921569},{name:"powderblue",r:.6901960784313725,g:.8784313725490196,b:.9019607843137255},{name:"lightblue",r:.6784313725490196,g:.8470588235294118,b:.9019607843137255},{name:"deepskyblue",r:0,g:.7490196078431373,b:1},{name:"skyblue",r:.5294117647058824,g:.807843137254902,b:.9215686274509803},{name:"lightskyblue",r:.5294117647058824,g:.807843137254902,b:.9803921568627451},{name:"steelblue",r:.27450980392156865,g:.5098039215686274,b:.7058823529411765},{name:"aliceblue",r:.9411764705882353,g:.9725490196078431,b:1},{name:"dodgerblue",r:.11764705882352941,g:.5647058823529412,b:1},{name:"slategray",r:.4392156862745098,g:.5019607843137255,b:.5647058823529412},{name:"lightslategray",r:.4666666666666667,g:.5333333333333333,b:.6},{name:"lightsteelblue",r:.6901960784313725,g:.7686274509803922,b:.8705882352941177},{name:"cornflowerblue",r:.39215686274509803,g:.5843137254901961,b:.9294117647058824},{name:"royalblue",r:.2549019607843137,g:.4117647058823529,b:.8823529411764706},{name:"midnightblue",r:.09803921568627451,g:.09803921568627451,b:.4392156862745098},{name:"lavender",r:.9019607843137255,g:.9019607843137255,b:.9803921568627451},{name:"navy",r:0,g:0,b:.5019607843137255},{name:"darkblue",r:0,g:0,b:.5450980392156862},{name:"mediumblue",r:0,g:0,b:.803921568627451},{name:"blue",r:0,g:0,b:1},{name:"ghostwhite",r:.9725490196078431,g:.9725490196078431,b:1},{name:"darkslateblue",r:.2823529411764706,g:.23921568627450981,b:.5450980392156862},{name:"slateblue",r:.41568627450980394,g:.35294117647058826,b:.803921568627451},{name:"mediumslateblue",r:.4823529411764706,g:.40784313725490196,b:.9333333333333333},{name:"mediumpurple",r:.5764705882352941,g:.4392156862745098,b:.8588235294117647},{name:"blueviolet",r:.5411764705882353,g:.16862745098039217,b:.8862745098039215},{name:"indigo",r:.29411764705882354,g:0,b:.5098039215686274},{name:"darkorchid",r:.6,g:.19607843137254902,b:.8},{name:"darkviolet",r:.5803921568627451,g:0,b:.8274509803921568},{name:"mediumorchid",r:.7294117647058823,g:.3333333333333333,b:.8274509803921568},{name:"thistle",r:.8470588235294118,g:.7490196078431373,b:.8470588235294118},{name:"plum",r:.8666666666666667,g:.6274509803921569,b:.8666666666666667},{name:"violet",r:.9333333333333333,g:.5098039215686274,b:.9333333333333333},{name:"purple",r:.5019607843137255,g:0,b:.5019607843137255},{name:"darkmagenta",r:.5450980392156862,g:0,b:.5450980392156862},{name:"magenta",r:1,g:0,b:1},{name:"fuchsia",r:1,g:0,b:1},{name:"orchid",r:.8549019607843137,g:.4392156862745098,b:.8392156862745098},{name:"mediumvioletred",r:.7803921568627451,g:.08235294117647059,b:.5215686274509804},{name:"deeppink",r:1,g:.0784313725490196,b:.5764705882352941},{name:"hotpink",r:1,g:.4117647058823529,b:.7058823529411765},{name:"palevioletred",r:.8588235294117647,g:.4392156862745098,b:.5764705882352941},{name:"lavenderblush",r:1,g:.9411764705882353,b:.9607843137254902},{name:"crimson",r:.8627450980392157,g:.0784313725490196,b:.23529411764705882},{name:"pink",r:1,g:.7529411764705882,b:.796078431372549},{name:"lightpink",r:1,g:.7137254901960784,b:.7568627450980392}]},this.writers={"#HEX":function(color,that){return that._formatColor("#rxgxbx",color)},"#HEX3":function(color,that){var hex3=$.colorpicker.writers.HEX3(color);return hex3===!1?!1:"#"+hex3},HEX:function(color,that){return that._formatColor("rxgxbx",color)},HEX3:function(color,that){var rgb=color.getRGB(),r=Math.floor(255*rgb.r),g=Math.floor(255*rgb.g),b=Math.floor(255*rgb.b);return r>>>4===(r&=15)&&g>>>4===(g&=15)&&b>>>4===(b&=15)?r.toString(16)+g.toString(16)+b.toString(16):!1},"#HEXA":function(color,that){return that._formatColor("#rxgxbxax",color)},"#HEXA4":function(color,that){var hexa4=$.colorpicker.writers.HEXA4(color,that);return hexa4===!1?!1:"#"+hexa4},HEXA:function(color,that){return that._formatColor("rxgxbxax",color)},HEXA4:function(color,that){var a=Math.floor(255*color.getAlpha());return a>>>4===(a&=15)?$.colorpicker.writers.HEX3(color,that)+a.toString(16):!1},RGB:function(color,that){return color.getAlpha()>=1?that._formatColor("rgb(rd,gd,bd)",color):!1},RGBA:function(color,that){return that._formatColor("rgba(rd,gd,bd,af)",color)},"RGB%":function(color,that){return color.getAlpha()>=1?that._formatColor("rgb(rp%,gp%,bp%)",color):!1},"RGBA%":function(color,that){return that._formatColor("rgba(rp%,gp%,bp%,af)",color)},HSL:function(color,that){return color.getAlpha()>=1?that._formatColor("hsl(hd,sd,vd)",color):!1},HSLA:function(color,that){return that._formatColor("hsla(hd,sd,vd,af)",color)},"HSL%":function(color,that){return color.getAlpha()>=1?that._formatColor("hsl(hp%,sp%,vp%)",color):!1},"HSLA%":function(color,that){return that._formatColor("hsla(hp%,sp%,vp%,af)",color)},NAME:function(color,that){return that._closestName(color)},EXACT:function(color,that){return that._exactName(color)}},this.parsers={"":function(color){return""===color?new $.colorpicker.Color:void 0},NAME:function(color,that){var c=that._getSwatch($.trim(color));return c?new $.colorpicker.Color(c.r,c.g,c.b):void 0},RGBA:function(color){var m=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);return m?new $.colorpicker.Color(m[1]/255,m[2]/255,m[3]/255,parseFloat(m[4])):void 0},"RGBA%":function(color){var m=/^rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);return m?new $.colorpicker.Color(m[1]/100,m[2]/100,m[3]/100,m[4]/100):void 0},HSLA:function(color){var m=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);return m?(new $.colorpicker.Color).setHSL(m[1]/255,m[2]/255,m[3]/255).setAlpha(parseFloat(m[4])):void 0},"HSLA%":function(color){var m=/^hsla?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);return m?(new $.colorpicker.Color).setHSL(m[1]/100,m[2]/100,m[3]/100).setAlpha(m[4]/100):void 0},"#HEX":function(color){var m=/^#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/.exec(color);return m?new $.colorpicker.Color(parseInt(m[1],16)/255,parseInt(m[2],16)/255,parseInt(m[3],16)/255):void 0},"#HEX3":function(color){var m=/^#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])$/.exec(color);return m?new $.colorpicker.Color(parseInt(String(m[1])+m[1],16)/255,parseInt(String(m[2])+m[2],16)/255,parseInt(String(m[3])+m[3],16)/255):void 0},HEX:function(color){var m=/^([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/.exec(color);return m?new $.colorpicker.Color(parseInt(m[1],16)/255,parseInt(m[2],16)/255,parseInt(m[3],16)/255):void 0},HEX3:function(color){var m=/^([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])$/.exec(color);return m?new $.colorpicker.Color(parseInt(String(m[1])+m[1],16)/255,parseInt(String(m[2])+m[2],16)/255,parseInt(String(m[3])+m[3],16)/255):void 0},"#HEXA":function(color){var m=/^#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/.exec(color);return m?new $.colorpicker.Color(parseInt(m[1],16)/255,parseInt(m[2],16)/255,parseInt(m[3],16)/255,parseInt(m[4],16)/255):void 0},"#HEXA4":function(color){var m=/^#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])$/.exec(color);return m?new $.colorpicker.Color(parseInt(String(m[1])+m[1],16)/255,parseInt(String(m[2])+m[2],16)/255,parseInt(String(m[3])+m[3],16)/255,parseInt(String(m[4])+m[4],16)/255):void 0},HEXA:function(color){var m=/^([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/.exec(color);return m?new $.colorpicker.Color(parseInt(m[1],16)/255,parseInt(m[2],16)/255,parseInt(m[3],16)/255,parseInt(m[4],16)/255):void 0},HEXA4:function(color){var m=/^([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])$/.exec(color);return m?new $.colorpicker.Color(parseInt(String(m[1])+m[1],16)/255,parseInt(String(m[2])+m[2],16)/255,parseInt(String(m[3])+m[3],16)/255,parseInt(String(m[4])+m[4],16)/255):void 0}},this.partslists={full:["header","map","bar","hex","hsv","rgb","alpha","lab","cmyk","preview","swatches","footer"],popup:["map","bar","hex","hsv","rgb","alpha","preview","footer"],draggable:["header","map","bar","hex","hsv","rgb","alpha","preview","footer"],inline:["map","bar","hex","hsv","rgb","alpha","preview"]},this.limits={websafe:function(color){color.limit(6)},nibble:function(color){color.limit(16)},binary:function(color){color.limit(2)},name:function(color,that){var swatch=that._getSwatch(that._closestName(color));color.setRGB(swatch.r,swatch.g,swatch.b)}},this.parts={header:function(inst){var e=null,_html=function(){var title=inst.options.title||inst._getRegional("title"),html='<span class="ui-dialog-title">'+title+"</span>";return!inst.inline&&inst.options.showCloseButton&&(html+='<a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button"><span class="ui-icon ui-icon-closethick">close</span></a>'),'<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">'+html+"</div>"};this.init=function(){e=$(_html()).prependTo(inst.dialog);var close=$(".ui-dialog-titlebar-close",e);if(inst._hoverable(close),inst._focusable(close),close.click(function(event){event.preventDefault(),inst.close(inst.options.revert)}),!inst.inline&&inst.options.draggable){var draggableOptions={handle:e};inst.options.containment&&(draggableOptions.containment=inst.options.containment),inst.dialog.draggable(draggableOptions)}}},map:function(inst){var _mousedown,_mouseup,_mousemove,_html,that=this,e=null;_mousedown=function(event){if(inst.opened){var div=$(".ui-colorpicker-map-layer-pointer",e),offset=div.offset(),width=div.width(),height=div.height(),x=event.pageX-offset.left,y=event.pageY-offset.top;x>=0&&width>x&&y>=0&&height>y&&(event.stopImmediatePropagation(),event.preventDefault(),e.unbind("mousedown",_mousedown),$(document).bind("mouseup",_mouseup),$(document).bind("mousemove",_mousemove),_mousemove(event))}},_mouseup=function(event){event.stopImmediatePropagation(),event.preventDefault(),$(document).unbind("mouseup",_mouseup),$(document).unbind("mousemove",_mousemove),e.bind("mousedown",_mousedown)},_mousemove=function(event){if(event.stopImmediatePropagation(),event.preventDefault(),event.pageX!==that.x||event.pageY!==that.y){that.x=event.pageX,that.y=event.pageY;var div=$(".ui-colorpicker-map-layer-pointer",e),offset=div.offset(),width=div.width(),height=div.height(),x=event.pageX-offset.left,y=event.pageY-offset.top;switch(x=Math.max(0,Math.min(x/width,1)),y=Math.max(0,Math.min(y/height,1)),inst.mode){case"h":inst.color.setHSV(null,x,1-y);break;case"s":case"a":inst.color.setHSV(x,null,1-y);break;case"v":inst.color.setHSV(x,1-y,null);break;case"r":inst.color.setRGB(null,1-y,x);break;case"g":inst.color.setRGB(1-y,null,x);break;case"b":inst.color.setRGB(x,1-y,null)}inst._change()}},_html=function(){var html='<div class="ui-colorpicker-map ui-colorpicker-map-'+(inst.options.part.map.size||256)+' ui-colorpicker-border"><span class="ui-colorpicker-map-layer-1"> </span><span class="ui-colorpicker-map-layer-2"> </span>'+(inst.options.alpha?'<span class="ui-colorpicker-map-layer-alpha"> </span>':"")+'<span class="ui-colorpicker-map-layer-pointer"><span class="ui-colorpicker-map-pointer"></span></span></div>';
|
14
|
+
|
15
|
+
return html},this.update=function(){var step=65*(inst.options.part.map.size||256)/64;switch(inst.mode){case"h":$(".ui-colorpicker-map-layer-1",e).css({"background-position":"0 0",opacity:""}).show(),$(".ui-colorpicker-map-layer-2",e).hide();break;case"s":case"a":$(".ui-colorpicker-map-layer-1",e).css({"background-position":"0 "+-step+"px",opacity:""}).show(),$(".ui-colorpicker-map-layer-2",e).css({"background-position":"0 "+2*-step+"px",opacity:""}).show();break;case"v":$(e).css("background-color","black"),$(".ui-colorpicker-map-layer-1",e).css({"background-position":"0 "+3*-step+"px",opacity:""}).show(),$(".ui-colorpicker-map-layer-2",e).hide();break;case"r":$(".ui-colorpicker-map-layer-1",e).css({"background-position":"0 "+4*-step+"px",opacity:""}).show(),$(".ui-colorpicker-map-layer-2",e).css({"background-position":"0 "+5*-step+"px",opacity:""}).show();break;case"g":$(".ui-colorpicker-map-layer-1",e).css({"background-position":"0 "+6*-step+"px",opacity:""}).show(),$(".ui-colorpicker-map-layer-2",e).css({"background-position":"0 "+7*-step+"px",opacity:""}).show();break;case"b":$(".ui-colorpicker-map-layer-1",e).css({"background-position":"0 "+8*-step+"px",opacity:""}).show(),$(".ui-colorpicker-map-layer-2",e).css({"background-position":"0 "+9*-step+"px",opacity:""}).show()}that.repaint()},this.repaint=function(){var div=$(".ui-colorpicker-map-layer-pointer",e),x=0,y=0;switch(inst.mode){case"h":x=inst.color.getHSV().s*div.width(),y=(1-inst.color.getHSV().v)*div.width(),$(e).css("background-color",inst.color.copy().setHSV(null,1,1).toCSS());break;case"s":case"a":x=inst.color.getHSV().h*div.width(),y=(1-inst.color.getHSV().v)*div.width(),$(".ui-colorpicker-map-layer-2",e).css("opacity",1-inst.color.getHSV().s);break;case"v":x=inst.color.getHSV().h*div.width(),y=(1-inst.color.getHSV().s)*div.width(),$(".ui-colorpicker-map-layer-1",e).css("opacity",inst.color.getHSV().v);break;case"r":x=inst.color.getRGB().b*div.width(),y=(1-inst.color.getRGB().g)*div.width(),$(".ui-colorpicker-map-layer-2",e).css("opacity",inst.color.getRGB().r);break;case"g":x=inst.color.getRGB().b*div.width(),y=(1-inst.color.getRGB().r)*div.width(),$(".ui-colorpicker-map-layer-2",e).css("opacity",inst.color.getRGB().g);break;case"b":x=inst.color.getRGB().r*div.width(),y=(1-inst.color.getRGB().g)*div.width(),$(".ui-colorpicker-map-layer-2",e).css("opacity",inst.color.getRGB().b)}inst.options.alpha&&$(".ui-colorpicker-map-layer-alpha",e).css("opacity",1-inst.color.getAlpha()),$(".ui-colorpicker-map-pointer",e).css({left:x-7,top:y-7})},this.init=function(){e=$(_html()).appendTo($(".ui-colorpicker-map-container",inst.dialog)),e.bind("mousedown",_mousedown)}},bar:function(inst){var _mousedown,_mouseup,_mousemove,_html,that=this,e=null;_mousedown=function(event){if(inst.opened){var div=$(".ui-colorpicker-bar-layer-pointer",e),offset=div.offset(),width=div.width(),height=div.height(),x=event.pageX-offset.left,y=event.pageY-offset.top;x>=0&&width>x&&y>=0&&height>y&&(event.stopImmediatePropagation(),event.preventDefault(),e.unbind("mousedown",_mousedown),$(document).bind("mouseup",_mouseup),$(document).bind("mousemove",_mousemove),_mousemove(event))}},_mouseup=function(event){event.stopImmediatePropagation(),event.preventDefault(),$(document).unbind("mouseup",_mouseup),$(document).unbind("mousemove",_mousemove),e.bind("mousedown",_mousedown)},_mousemove=function(event){if(event.stopImmediatePropagation(),event.preventDefault(),event.pageY!==that.y){that.y=event.pageY;var div=$(".ui-colorpicker-bar-layer-pointer",e),offset=div.offset(),height=div.height(),y=event.pageY-offset.top;switch(y=Math.max(0,Math.min(y/height,1)),inst.mode){case"h":inst.color.setHSV(1-y,null,null);break;case"s":inst.color.setHSV(null,1-y,null);break;case"v":inst.color.setHSV(null,null,1-y);break;case"r":inst.color.setRGB(1-y,null,null);break;case"g":inst.color.setRGB(null,1-y,null);break;case"b":inst.color.setRGB(null,null,1-y);break;case"a":inst.color.setAlpha(1-y)}inst._change()}},_html=function(){var html='<div class="ui-colorpicker-bar ui-colorpicker-bar-'+(inst.options.part.bar.size||256)+' ui-colorpicker-border"><span class="ui-colorpicker-bar-layer-1"> </span><span class="ui-colorpicker-bar-layer-2"> </span><span class="ui-colorpicker-bar-layer-3"> </span><span class="ui-colorpicker-bar-layer-4"> </span>';return inst.options.alpha&&(html+='<span class="ui-colorpicker-bar-layer-alpha"> </span><span class="ui-colorpicker-bar-layer-alphabar"> </span>'),html+='<span class="ui-colorpicker-bar-layer-pointer"><span class="ui-colorpicker-bar-pointer"></span></span></div>'},this.update=function(){var step=65*(inst.options.part.bar.size||256)/64;switch(inst.mode){case"h":case"s":case"v":case"r":case"g":case"b":$(".ui-colorpicker-bar-layer-alpha",e).show(),$(".ui-colorpicker-bar-layer-alphabar",e).hide();break;case"a":$(".ui-colorpicker-bar-layer-alpha",e).hide(),$(".ui-colorpicker-bar-layer-alphabar",e).show()}switch(inst.mode){case"h":$(".ui-colorpicker-bar-layer-1",e).css({"background-position":"0 0",opacity:""}).show(),$(".ui-colorpicker-bar-layer-2",e).hide(),$(".ui-colorpicker-bar-layer-3",e).hide(),$(".ui-colorpicker-bar-layer-4",e).hide();break;case"s":$(".ui-colorpicker-bar-layer-1",e).css({"background-position":"0 "+-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-2",e).css({"background-position":"0 "+2*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-3",e).hide(),$(".ui-colorpicker-bar-layer-4",e).hide();break;case"v":$(".ui-colorpicker-bar-layer-1",e).css({"background-position":"0 "+2*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-2",e).hide(),$(".ui-colorpicker-bar-layer-3",e).hide(),$(".ui-colorpicker-bar-layer-4",e).hide();break;case"r":$(".ui-colorpicker-bar-layer-1",e).css({"background-position":"0 "+6*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-2",e).css({"background-position":"0 "+5*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-3",e).css({"background-position":"0 "+3*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-4",e).css({"background-position":"0 "+4*-step+"px",opacity:""}).show();break;case"g":$(".ui-colorpicker-bar-layer-1",e).css({"background-position":"0 "+10*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-2",e).css({"background-position":"0 "+9*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-3",e).css({"background-position":"0 "+7*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-4",e).css({"background-position":"0 "+8*-step+"px",opacity:""}).show();break;case"b":$(".ui-colorpicker-bar-layer-1",e).css({"background-position":"0 "+14*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-2",e).css({"background-position":"0 "+13*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-3",e).css({"background-position":"0 "+11*-step+"px",opacity:""}).show(),$(".ui-colorpicker-bar-layer-4",e).css({"background-position":"0 "+12*-step+"px",opacity:""}).show();break;case"a":$(".ui-colorpicker-bar-layer-1",e).hide(),$(".ui-colorpicker-bar-layer-2",e).hide(),$(".ui-colorpicker-bar-layer-3",e).hide(),$(".ui-colorpicker-bar-layer-4",e).hide()}that.repaint()},this.repaint=function(){var div=$(".ui-colorpicker-bar-layer-pointer",e),y=0;switch(inst.mode){case"h":y=(1-inst.color.getHSV().h)*div.height();break;case"s":y=(1-inst.color.getHSV().s)*div.height(),$(".ui-colorpicker-bar-layer-2",e).css("opacity",1-inst.color.getHSV().v),$(e).css("background-color",inst.color.copy().setHSV(null,1,null).toCSS());break;case"v":y=(1-inst.color.getHSV().v)*div.height(),$(e).css("background-color",inst.color.copy().setHSV(null,null,1).toCSS());break;case"r":y=(1-inst.color.getRGB().r)*div.height(),$(".ui-colorpicker-bar-layer-2",e).css("opacity",Math.max(0,inst.color.getRGB().b-inst.color.getRGB().g)),$(".ui-colorpicker-bar-layer-3",e).css("opacity",Math.max(0,inst.color.getRGB().g-inst.color.getRGB().b)),$(".ui-colorpicker-bar-layer-4",e).css("opacity",Math.min(inst.color.getRGB().b,inst.color.getRGB().g));break;case"g":y=(1-inst.color.getRGB().g)*div.height(),$(".ui-colorpicker-bar-layer-2",e).css("opacity",Math.max(0,inst.color.getRGB().b-inst.color.getRGB().r)),$(".ui-colorpicker-bar-layer-3",e).css("opacity",Math.max(0,inst.color.getRGB().r-inst.color.getRGB().b)),$(".ui-colorpicker-bar-layer-4",e).css("opacity",Math.min(inst.color.getRGB().r,inst.color.getRGB().b));break;case"b":y=(1-inst.color.getRGB().b)*div.height(),$(".ui-colorpicker-bar-layer-2",e).css("opacity",Math.max(0,inst.color.getRGB().r-inst.color.getRGB().g)),$(".ui-colorpicker-bar-layer-3",e).css("opacity",Math.max(0,inst.color.getRGB().g-inst.color.getRGB().r)),$(".ui-colorpicker-bar-layer-4",e).css("opacity",Math.min(inst.color.getRGB().r,inst.color.getRGB().g));break;case"a":y=(1-inst.color.getAlpha())*div.height(),$(e).css("background-color",inst.color.copy().toCSS())}"a"!==inst.mode&&$(".ui-colorpicker-bar-layer-alpha",e).css("opacity",1-inst.color.getAlpha()),$(".ui-colorpicker-bar-pointer",e).css("top",y-3)},this.init=function(){e=$(_html()).appendTo($(".ui-colorpicker-bar-container",inst.dialog)),e.bind("mousedown",_mousedown)}},preview:function(inst){var _html,e=null;_html=function(){return'<div class="ui-colorpicker-preview ui-colorpicker-border"><div class="ui-colorpicker-preview-initial"><div class="ui-colorpicker-preview-initial-alpha"></div></div><div class="ui-colorpicker-preview-current"><div class="ui-colorpicker-preview-current-alpha"></div></div></div>'},this.init=function(){e=$(_html()).appendTo($(".ui-colorpicker-preview-container",inst.dialog)),$(".ui-colorpicker-preview-initial",e).click(function(){inst.color=inst.currentColor.copy(),inst._change()})},this.update=function(){inst.options.alpha?$(".ui-colorpicker-preview-initial-alpha, .ui-colorpicker-preview-current-alpha",e).show():$(".ui-colorpicker-preview-initial-alpha, .ui-colorpicker-preview-current-alpha",e).hide(),this.repaint()},this.repaint=function(){$(".ui-colorpicker-preview-initial",e).css("background-color",inst.currentColor.set?inst.currentColor.toCSS():"").attr("title",inst.currentColor.set?inst.currentColor.toCSS():""),$(".ui-colorpicker-preview-initial-alpha",e).css("opacity",1-inst.currentColor.getAlpha()),$(".ui-colorpicker-preview-current",e).css("background-color",inst.color.set?inst.color.toCSS():"").attr("title",inst.color.set?inst.color.toCSS():""),$(".ui-colorpicker-preview-current-alpha",e).css("opacity",1-inst.color.getAlpha())}},hsv:function(inst){var _html,e=null;_html=function(){var html="";return inst.options.hsv&&(html+='<div class="ui-colorpicker-hsv-h"><input class="ui-colorpicker-mode" type="radio" value="h"/><label>'+inst._getRegional("hsvH")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="360" size="10"/><span class="ui-colorpicker-unit">°</span></div><div class="ui-colorpicker-hsv-s"><input class="ui-colorpicker-mode" type="radio" value="s"/><label>'+inst._getRegional("hsvS")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100" size="10"/><span class="ui-colorpicker-unit">%</span></div><div class="ui-colorpicker-hsv-v"><input class="ui-colorpicker-mode" type="radio" value="v"/><label>'+inst._getRegional("hsvV")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100" size="10"/><span class="ui-colorpicker-unit">%</span></div>'),'<div class="ui-colorpicker-hsv">'+html+"</div>"},this.init=function(){e=$(_html()).appendTo($(".ui-colorpicker-hsv-container",inst.dialog)),$(".ui-colorpicker-mode",e).click(function(){inst.mode=$(this).val(),inst._updateAllParts()}),$(".ui-colorpicker-number",e).bind("change keyup",function(){inst.color.setHSV($(".ui-colorpicker-hsv-h .ui-colorpicker-number",e).val()/360,$(".ui-colorpicker-hsv-s .ui-colorpicker-number",e).val()/100,$(".ui-colorpicker-hsv-v .ui-colorpicker-number",e).val()/100),inst._change()})},this.repaint=function(){var hsv=inst.color.getHSV();hsv.h*=360,hsv.s*=100,hsv.v*=100,$.each(hsv,function(index,value){var input=$(".ui-colorpicker-hsv-"+index+" .ui-colorpicker-number",e);value=Math.round(value),parseInt(input.val(),10)!==value&&input.val(value)})},this.update=function(){$(".ui-colorpicker-mode",e).each(function(){$(this).attr("checked",$(this).val()===inst.mode)}),this.repaint()}},rgb:function(inst){var _html,e=null;_html=function(){var html="";return inst.options.rgb&&(html+='<div class="ui-colorpicker-rgb-r"><input class="ui-colorpicker-mode" type="radio" value="r"/><label>'+inst._getRegional("rgbR")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="255"/></div><div class="ui-colorpicker-rgb-g"><input class="ui-colorpicker-mode" type="radio" value="g"/><label>'+inst._getRegional("rgbG")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="255"/></div><div class="ui-colorpicker-rgb-b"><input class="ui-colorpicker-mode" type="radio" value="b"/><label>'+inst._getRegional("rgbB")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="255"/></div>'),'<div class="ui-colorpicker-rgb">'+html+"</div>"},this.init=function(){e=$(_html()).appendTo($(".ui-colorpicker-rgb-container",inst.dialog)),$(".ui-colorpicker-mode",e).click(function(){inst.mode=$(this).val(),inst._updateAllParts()}),$(".ui-colorpicker-number",e).bind("change keyup",function(){$(".ui-colorpicker-rgb-r .ui-colorpicker-number",e).val();inst.color.setRGB($(".ui-colorpicker-rgb-r .ui-colorpicker-number",e).val()/255,$(".ui-colorpicker-rgb-g .ui-colorpicker-number",e).val()/255,$(".ui-colorpicker-rgb-b .ui-colorpicker-number",e).val()/255),inst._change()})},this.repaint=function(){$.each(inst.color.getRGB(),function(index,value){var input=$(".ui-colorpicker-rgb-"+index+" .ui-colorpicker-number",e);value=Math.floor(255*value),parseInt(input.val(),10)!==value&&input.val(value)})},this.update=function(){$(".ui-colorpicker-mode",e).each(function(){$(this).attr("checked",$(this).val()===inst.mode)}),this.repaint()}},lab:function(inst){var part=null,html=function(){var html="";return inst.options.hsv&&(html+='<div class="ui-colorpicker-lab-l"><label>'+inst._getRegional("labL")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/></div><div class="ui-colorpicker-lab-a"><label>'+inst._getRegional("labA")+'</label><input class="ui-colorpicker-number" type="number" min="-128" max="127"/></div><div class="ui-colorpicker-lab-b"><label>'+inst._getRegional("labB")+'</label><input class="ui-colorpicker-number" type="number" min="-128" max="127"/></div>'),'<div class="ui-colorpicker-lab">'+html+"</div>"};this.init=function(){part=$(html()).appendTo($(".ui-colorpicker-lab-container",inst.dialog)),$(".ui-colorpicker-number",part).bind("change keyup",function(event){inst.color.setLAB(parseInt($(".ui-colorpicker-lab-l .ui-colorpicker-number",part).val(),10)/100,(parseInt($(".ui-colorpicker-lab-a .ui-colorpicker-number",part).val(),10)+128)/255,(parseInt($(".ui-colorpicker-lab-b .ui-colorpicker-number",part).val(),10)+128)/255),inst._change()})},this.repaint=function(){var lab=inst.color.getLAB();lab.l*=100,lab.a=255*lab.a-128,lab.b=255*lab.b-128,$.each(lab,function(index,value){var input=$(".ui-colorpicker-lab-"+index+" .ui-colorpicker-number",part);value=Math.round(value),parseInt(input.val(),10)!==value&&input.val(value)})},this.update=function(){this.repaint()}},cmyk:function(inst){var part=null,html=function(){var html="";return inst.options.hsv&&(html+='<div class="ui-colorpicker-cmyk-c"><label>'+inst._getRegional("cmykC")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div><div class="ui-colorpicker-cmyk-m"><label>'+inst._getRegional("cmykM")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div><div class="ui-colorpicker-cmyk-y"><label>'+inst._getRegional("cmykY")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div><div class="ui-colorpicker-cmyk-k"><label>'+inst._getRegional("cmykK")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div>'),'<div class="ui-colorpicker-cmyk">'+html+"</div>"};this.init=function(){part=$(html()).appendTo($(".ui-colorpicker-cmyk-container",inst.dialog)),$(".ui-colorpicker-number",part).bind("change keyup",function(event){inst.color.setCMYK(parseInt($(".ui-colorpicker-cmyk-c .ui-colorpicker-number",part).val(),10)/100,parseInt($(".ui-colorpicker-cmyk-m .ui-colorpicker-number",part).val(),10)/100,parseInt($(".ui-colorpicker-cmyk-y .ui-colorpicker-number",part).val(),10)/100,parseInt($(".ui-colorpicker-cmyk-k .ui-colorpicker-number",part).val(),10)/100),inst._change()})},this.repaint=function(){$.each(inst.color.getCMYK(),function(index,value){var input=$(".ui-colorpicker-cmyk-"+index+" .ui-colorpicker-number",part);value=Math.round(100*value),parseInt(input.val(),10,10)!==value&&input.val(value)})},this.update=function(){this.repaint()}},alpha:function(inst){var _html,e=null;_html=function(){var html="";return inst.options.alpha&&(html+='<div class="ui-colorpicker-a"><input class="ui-colorpicker-mode" name="mode" type="radio" value="a"/><label>'+inst._getRegional("alphaA")+'</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div>'),'<div class="ui-colorpicker-alpha">'+html+"</div>"},this.init=function(){e=$(_html()).appendTo($(".ui-colorpicker-alpha-container",inst.dialog)),$(".ui-colorpicker-mode",e).click(function(){inst.mode=$(this).val(),inst._updateAllParts()}),$(".ui-colorpicker-number",e).bind("change keyup",function(){inst.color.setAlpha($(".ui-colorpicker-a .ui-colorpicker-number",e).val()/100),inst._change()})},this.update=function(){$(".ui-colorpicker-mode",e).each(function(){$(this).attr("checked",$(this).val()===inst.mode)}),this.repaint()},this.repaint=function(){var input=$(".ui-colorpicker-a .ui-colorpicker-number",e),value=Math.round(100*inst.color.getAlpha());parseInt(input.val(),10)!==value&&input.val(value)}},hex:function(inst){var _html,e=null;_html=function(){var html="";return inst.options.alpha&&(html+='<input class="ui-colorpicker-hex-alpha" type="text" maxlength="2" size="2"/>'),html+='<input class="ui-colorpicker-hex-input" type="text" maxlength="6" size="6"/>','<div class="ui-colorpicker-hex"><label>#</label>'+html+"</div>"},this.init=function(){e=$(_html()).appendTo($(".ui-colorpicker-hex-container",inst.dialog)),$(".ui-colorpicker-hex-input",e).bind("change keydown keyup",function(a,b,c){/[^a-fA-F0-9]/.test($(this).val())&&$(this).val($(this).val().replace(/[^a-fA-F0-9]/,""))}),$(".ui-colorpicker-hex-input",e).bind("change keyup",function(){inst.color=_parseHex($(this).val()).setAlpha(inst.color.getAlpha()),inst._change()}),$(".ui-colorpicker-hex-alpha",e).bind("change keydown keyup",function(){/[^a-fA-F0-9]/.test($(this).val())&&$(this).val($(this).val().replace(/[^a-fA-F0-9]/,""))}),$(".ui-colorpicker-hex-alpha",e).bind("change keyup",function(){inst.color.setAlpha(parseInt($(".ui-colorpicker-hex-alpha",e).val(),16)/255),inst._change()})},this.update=function(){this.repaint()},this.repaint=function(){$(".ui-colorpicker-hex-input",e).is(":focus")||$(".ui-colorpicker-hex-input",e).val(inst.color.toHex(!0)),$(".ui-colorpicker-hex-alpha",e).is(":focus")||$(".ui-colorpicker-hex-alpha",e).val(_intToHex(255*inst.color.getAlpha()))}},swatches:function(inst){var part=null,html=function(){var html="";return inst._eachSwatch(function(name,color){var c=new $.colorpicker.Color(color.r,color.g,color.b),css=c.toCSS();html+='<div class="ui-colorpicker-swatch" style="background-color:'+css+'" title="'+name+'"></div>'}),'<div class="ui-colorpicker-swatches ui-colorpicker-border" style="width:'+inst.options.swatchesWidth+'px">'+html+"</div>"};this.init=function(){part=$(html()).appendTo($(".ui-colorpicker-swatches-container",inst.dialog)),$(".ui-colorpicker-swatch",part).click(function(){inst.color=inst._parseColor($(this).css("background-color"))||new $.colorpicker.Color,inst._change()})}},footer:function(inst){var part=null,id_transparent="ui-colorpicker-special-transparent-"+_colorpicker_index,id_none="ui-colorpicker-special-none-"+_colorpicker_index,html=function(){var html="";return(inst.options.alpha||!inst.inline&&inst.options.showNoneButton)&&(html+='<div class="ui-colorpicker-buttonset">',inst.options.alpha&&(html+='<input type="radio" name="ui-colorpicker-special" id="'+id_transparent+'" class="ui-colorpicker-special-transparent"/><label for="'+id_transparent+'">'+inst._getRegional("transparent")+"</label>"),!inst.inline&&inst.options.showNoneButton&&(html+='<input type="radio" name="ui-colorpicker-special" id="'+id_none+'" class="ui-colorpicker-special-none"><label for="'+id_none+'">'+inst._getRegional("none")+"</label>"),html+="</div>"),inst.inline||(html+='<div class="ui-dialog-buttonset">',html+='<button class="ui-colorpicker-ok">ok</button>',inst.options.showCancelButton&&(html+='<button class="ui-colorpicker-cancel">cancel</button>'),html+="</div>"),'<div class="ui-dialog-buttonpane ui-widget-content">'+html+"</div>"};this.init=function(){part=$(html()).appendTo(inst.dialog),$(".ui-colorpicker-ok",part).button().click(function(){inst.close()}),$(".ui-colorpicker-cancel",part).button().click(function(){inst.close(!0)}),$(".ui-colorpicker-buttonset",part).buttonset(),$(".ui-colorpicker-special-color",part).click(function(){inst._change()}),$("#"+id_none,part).click(function(){inst.color.set=!1,inst._change()}),$("#"+id_transparent,part).click(function(){inst.color.setAlpha(0),inst._change()})},this.repaint=function(){inst.color.set?0===inst.color.getAlpha()?$(".ui-colorpicker-special-transparent",part).attr("checked",!0).button("refresh"):$("input",part).attr("checked",!1).button("refresh"):$(".ui-colorpicker-special-none",part).attr("checked",!0).button("refresh"),$(".ui-colorpicker-cancel",part).button("enable")},this.update=function(){}}},this.Color=function(){var spaces={rgb:{r:0,g:0,b:0},hsv:{h:0,s:0,v:0},hsl:{h:0,s:0,l:0},lab:{l:0,a:0,b:0},cmyk:{c:0,m:0,y:0,k:1}},a=1,illuminant=[.9504285,1,1.0889],args=arguments,_clip=function(v){return isNaN(v)||null===v?0:("string"==typeof v&&(v=parseInt(v,10)),Math.max(0,Math.min(v,1)))},_hexify=function(number){var number=Math.round(number),digits="0123456789abcdef",lsd=number%16,msd=(number-lsd)/16,hexified=digits.charAt(msd)+digits.charAt(lsd);return hexified},_rgb_to_xyz=function(rgb){var r=rgb.r>.04045?Math.pow((rgb.r+.055)/1.055,2.4):rgb.r/12.92,g=rgb.g>.04045?Math.pow((rgb.g+.055)/1.055,2.4):rgb.g/12.92,b=rgb.b>.04045?Math.pow((rgb.b+.055)/1.055,2.4):rgb.b/12.92;return{x:.4124*r+.3576*g+.1805*b,y:.2126*r+.7152*g+.0722*b,z:.0193*r+.1192*g+.9505*b}},_xyz_to_rgb=function(xyz){var rgb={r:3.2406*xyz.x+-1.5372*xyz.y+xyz.z*-.4986,g:xyz.x*-.9689+1.8758*xyz.y+.0415*xyz.z,b:.0557*xyz.x+xyz.y*-.204+1.057*xyz.z};return rgb.r=rgb.r>.0031308?1.055*Math.pow(rgb.r,1/2.4)-.055:12.92*rgb.r,rgb.g=rgb.g>.0031308?1.055*Math.pow(rgb.g,1/2.4)-.055:12.92*rgb.g,rgb.b=rgb.b>.0031308?1.055*Math.pow(rgb.b,1/2.4)-.055:12.92*rgb.b,rgb},_rgb_to_hsv=function(rgb){var del_R,del_G,del_B,minVal=Math.min(rgb.r,rgb.g,rgb.b),maxVal=Math.max(rgb.r,rgb.g,rgb.b),delta=maxVal-minVal,hsv={h:0,s:0,v:maxVal};return 0===delta?(hsv.h=0,hsv.s=0):(hsv.s=delta/maxVal,del_R=((maxVal-rgb.r)/6+delta/2)/delta,del_G=((maxVal-rgb.g)/6+delta/2)/delta,del_B=((maxVal-rgb.b)/6+delta/2)/delta,rgb.r===maxVal?hsv.h=del_B-del_G:rgb.g===maxVal?hsv.h=1/3+del_R-del_B:rgb.b===maxVal&&(hsv.h=2/3+del_G-del_R),hsv.h<0?hsv.h+=1:hsv.h>1&&(hsv.h-=1)),hsv},_hsv_to_rgb=function(hsv){var var_h,var_i,var_1,var_2,var_3,rgb={r:0,g:0,b:0};return 0===hsv.s?rgb.r=rgb.g=rgb.b=hsv.v:(var_h=1===hsv.h?0:6*hsv.h,var_i=Math.floor(var_h),var_1=hsv.v*(1-hsv.s),var_2=hsv.v*(1-hsv.s*(var_h-var_i)),var_3=hsv.v*(1-hsv.s*(1-(var_h-var_i))),0===var_i?(rgb.r=hsv.v,rgb.g=var_3,rgb.b=var_1):1===var_i?(rgb.r=var_2,rgb.g=hsv.v,rgb.b=var_1):2===var_i?(rgb.r=var_1,rgb.g=hsv.v,rgb.b=var_3):3===var_i?(rgb.r=var_1,rgb.g=var_2,rgb.b=hsv.v):4===var_i?(rgb.r=var_3,rgb.g=var_1,rgb.b=hsv.v):(rgb.r=hsv.v,rgb.g=var_1,rgb.b=var_2)),rgb},_rgb_to_hsl=function(rgb){var del_R,del_G,del_B,minVal=Math.min(rgb.r,rgb.g,rgb.b),maxVal=Math.max(rgb.r,rgb.g,rgb.b),delta=maxVal-minVal,hsl={h:0,s:0,l:(maxVal+minVal)/2};return 0===delta?(hsl.h=0,hsl.s=0):(hsl.s=hsl.l<.5?delta/(maxVal+minVal):delta/(2-maxVal-minVal),del_R=((maxVal-rgb.r)/6+delta/2)/delta,del_G=((maxVal-rgb.g)/6+delta/2)/delta,del_B=((maxVal-rgb.b)/6+delta/2)/delta,rgb.r===maxVal?hsl.h=del_B-del_G:rgb.g===maxVal?hsl.h=1/3+del_R-del_B:rgb.b===maxVal&&(hsl.h=2/3+del_G-del_R),hsl.h<0?hsl.h+=1:hsl.h>1&&(hsl.h-=1)),hsl},_hsl_to_rgb=function(hsl){var var_1,var_2,hue_to_rgb=function(v1,v2,vH){return 0>vH&&(vH+=1),vH>1&&(vH-=1),1>6*vH?v1+6*(v2-v1)*vH:1>2*vH?v2:2>3*vH?v1+(v2-v1)*(2/3-vH)*6:v1};return 0===hsl.s?{r:hsl.l,g:hsl.l,b:hsl.l}:(var_2=hsl.l<.5?hsl.l*(1+hsl.s):hsl.l+hsl.s-hsl.s*hsl.l,var_1=2*hsl.l-var_2,{r:hue_to_rgb(var_1,var_2,hsl.h+1/3),g:hue_to_rgb(var_1,var_2,hsl.h),b:hue_to_rgb(var_1,var_2,hsl.h-1/3)})},_xyz_to_lab=function(xyz){var x=xyz.x/illuminant[0],y=xyz.y/illuminant[1],z=xyz.z/illuminant[2];return x=x>.008856?Math.pow(x,1/3):7.787*x+16/116,y=y>.008856?Math.pow(y,1/3):7.787*y+16/116,z=z>.008856?Math.pow(z,1/3):7.787*z+16/116,{l:(116*y-16)/100,a:(500*(x-y)+128)/255,b:(200*(y-z)+128)/255}},_lab_to_xyz=function(lab){var lab2={l:100*lab.l,a:255*lab.a-128,b:255*lab.b-128},xyz={x:0,y:(lab2.l+16)/116,z:0};return xyz.x=lab2.a/500+xyz.y,xyz.z=xyz.y-lab2.b/200,xyz.x=Math.pow(xyz.x,3)>.008856?Math.pow(xyz.x,3):(xyz.x-16/116)/7.787,xyz.y=Math.pow(xyz.y,3)>.008856?Math.pow(xyz.y,3):(xyz.y-16/116)/7.787,xyz.z=Math.pow(xyz.z,3)>.008856?Math.pow(xyz.z,3):(xyz.z-16/116)/7.787,xyz.x*=illuminant[0],xyz.y*=illuminant[1],xyz.z*=illuminant[2],xyz},_rgb_to_cmy=function(rgb){return{c:1-rgb.r,m:1-rgb.g,y:1-rgb.b}},_cmy_to_rgb=function(cmy){return{r:1-cmy.c,g:1-cmy.m,b:1-cmy.y}},_cmy_to_cmyk=function(cmy){var K=1;return cmy.c<K&&(K=cmy.c),cmy.m<K&&(K=cmy.m),cmy.y<K&&(K=cmy.y),1===K?{c:0,m:0,y:0,k:1}:{c:(cmy.c-K)/(1-K),m:(cmy.m-K)/(1-K),y:(cmy.y-K)/(1-K),k:K}},_cmyk_to_cmy=function(cmyk){return{c:cmyk.c*(1-cmyk.k)+cmyk.k,m:cmyk.m*(1-cmyk.k)+cmyk.k,y:cmyk.y*(1-cmyk.k)+cmyk.k}};this.set=!1,this.setAlpha=function(_a){return null!==_a&&(a=_clip(_a)),this.set=!0,this},this.getAlpha=function(){return a},this.setRGB=function(r,g,b){return spaces={rgb:this.getRGB()},null!==r&&(spaces.rgb.r=_clip(r)),null!==g&&(spaces.rgb.g=_clip(g)),null!==b&&(spaces.rgb.b=_clip(b)),this.set=!0,this},this.setHSV=function(h,s,v){return spaces={hsv:this.getHSV()},null!==h&&(spaces.hsv.h=_clip(h)),null!==s&&(spaces.hsv.s=_clip(s)),null!==v&&(spaces.hsv.v=_clip(v)),this.set=!0,this},this.setHSL=function(h,s,l){return spaces={hsl:this.getHSL()},null!==h&&(spaces.hsl.h=_clip(h)),null!==s&&(spaces.hsl.s=_clip(s)),null!==l&&(spaces.hsl.l=_clip(l)),this.set=!0,this},this.setLAB=function(l,a,b){return spaces={lab:this.getLAB()},null!==l&&(spaces.lab.l=_clip(l)),null!==a&&(spaces.lab.a=_clip(a)),null!==b&&(spaces.lab.b=_clip(b)),this.set=!0,this},this.setCMYK=function(c,m,y,k){return spaces={cmyk:this.getCMYK()},null!==c&&(spaces.cmyk.c=_clip(c)),null!==m&&(spaces.cmyk.m=_clip(m)),null!==y&&(spaces.cmyk.y=_clip(y)),null!==k&&(spaces.cmyk.k=_clip(k)),this.set=!0,this},this.getRGB=function(){return spaces.rgb||(spaces.rgb=spaces.lab?_xyz_to_rgb(_lab_to_xyz(spaces.lab)):spaces.hsv?_hsv_to_rgb(spaces.hsv):spaces.hsl?_hsl_to_rgb(spaces.hsl):spaces.cmyk?_cmy_to_rgb(_cmyk_to_cmy(spaces.cmyk)):{r:0,g:0,b:0},spaces.rgb.r=_clip(spaces.rgb.r),spaces.rgb.g=_clip(spaces.rgb.g),spaces.rgb.b=_clip(spaces.rgb.b)),$.extend({},spaces.rgb)},this.getHSV=function(){return spaces.hsv||(spaces.hsv=spaces.lab?_rgb_to_hsv(this.getRGB()):spaces.rgb?_rgb_to_hsv(spaces.rgb):spaces.hsl?_rgb_to_hsv(this.getRGB()):spaces.cmyk?_rgb_to_hsv(this.getRGB()):{h:0,s:0,v:0},spaces.hsv.h=_clip(spaces.hsv.h),spaces.hsv.s=_clip(spaces.hsv.s),spaces.hsv.v=_clip(spaces.hsv.v)),$.extend({},spaces.hsv)},this.getHSL=function(){return spaces.hsl||(spaces.hsl=spaces.rgb?_rgb_to_hsl(spaces.rgb):spaces.hsv?_rgb_to_hsl(this.getRGB()):spaces.cmyk?_rgb_to_hsl(this.getRGB()):spaces.hsv?_rgb_to_hsl(this.getRGB()):{h:0,s:0,l:0},spaces.hsl.h=_clip(spaces.hsl.h),spaces.hsl.s=_clip(spaces.hsl.s),spaces.hsl.l=_clip(spaces.hsl.l)),$.extend({},spaces.hsl)},this.getCMYK=function(){return spaces.cmyk||(spaces.cmyk=spaces.rgb?_cmy_to_cmyk(_rgb_to_cmy(spaces.rgb)):spaces.hsv?_cmy_to_cmyk(_rgb_to_cmy(this.getRGB())):spaces.hsl?_cmy_to_cmyk(_rgb_to_cmy(this.getRGB())):spaces.lab?_cmy_to_cmyk(_rgb_to_cmy(this.getRGB())):{c:0,m:0,y:0,k:1},spaces.cmyk.c=_clip(spaces.cmyk.c),spaces.cmyk.m=_clip(spaces.cmyk.m),spaces.cmyk.y=_clip(spaces.cmyk.y),spaces.cmyk.k=_clip(spaces.cmyk.k)),$.extend({},spaces.cmyk)},this.getLAB=function(){return spaces.lab||(spaces.lab=spaces.rgb?_xyz_to_lab(_rgb_to_xyz(spaces.rgb)):spaces.hsv?_xyz_to_lab(_rgb_to_xyz(this.getRGB())):spaces.hsl?_xyz_to_lab(_rgb_to_xyz(this.getRGB())):spaces.cmyk?_xyz_to_lab(_rgb_to_xyz(this.getRGB())):{l:0,a:0,b:0},spaces.lab.l=_clip(spaces.lab.l),spaces.lab.a=_clip(spaces.lab.a),spaces.lab.b=_clip(spaces.lab.b)),$.extend({},spaces.lab)},this.getChannels=function(){return{r:this.getRGB().r,g:this.getRGB().g,b:this.getRGB().b,a:this.getAlpha(),h:this.getHSV().h,s:this.getHSV().s,v:this.getHSV().v,c:this.getCMYK().c,m:this.getCMYK().m,y:this.getCMYK().y,k:this.getCMYK().k,L:this.getLAB().l,A:this.getLAB().a,B:this.getLAB().b}},this.getSpaces=function(){return $.extend(!0,{},spaces)},this.distance=function(color){var channel,space="lab",getter="get"+space.toUpperCase(),a=this[getter](),b=color[getter](),distance=0;for(channel in a)distance+=Math.pow(a[channel]-b[channel],2);return distance},this.equals=function(color){if(color){var a=this.getRGB(),b=color.getRGB();return this.getAlpha()===color.getAlpha()&&a.r===b.r&&a.g===b.g&&a.b===b.b}return!1},this.limit=function(steps){steps-=1;var rgb=this.getRGB();this.setRGB(Math.round(rgb.r*steps)/steps,Math.round(rgb.g*steps)/steps,Math.round(rgb.b*steps)/steps)},this.toHex=function(){var rgb=this.getRGB();return _hexify(255*rgb.r)+_hexify(255*rgb.g)+_hexify(255*rgb.b)},this.toCSS=function(){return"#"+this.toHex()},this.copy=function(){var color=new $.colorpicker.Color(this.getSpaces(),this.getAlpha());return color.set=this.set,color},2===args.length&&(spaces=args[0],this.setAlpha(0===args[1]?0:args[1]||1),this.set=!0),args.length>2&&(this.setRGB(args[0],args[1],args[2]),this.setAlpha(0===args[3]?0:args[3]||1),this.set=!0)}},$.widget("vanderlee.colorpicker",{options:{alpha:!1,altAlpha:!0,altField:"",altOnChange:!0,altProperties:"background-color",autoOpen:!1,buttonClass:null,buttonColorize:!1,buttonImage:"images/ui-colorpicker.png",buttonImageOnly:!1,buttonText:null,closeOnEscape:!0,closeOnOutside:!0,color:"#00FF00",colorFormat:"HEX",draggable:!0,containment:null,duration:"fast",hsv:!0,inline:!0,inlineFrame:!0,layout:{map:[0,0,1,5],bar:[1,0,1,5],preview:[2,0,1,1],hsv:[2,1,1,1],rgb:[2,2,1,1],alpha:[2,3,1,1],hex:[2,4,1,1],lab:[3,1,1,1],cmyk:[3,2,1,2],swatches:[4,0,1,5]},limit:"",modal:!1,mode:"h",okOnEnter:!1,parts:"",part:{map:{size:256},bar:{size:256}},position:null,regional:"",revert:!1,rgb:!0,showAnim:"fadeIn",showCancelButton:!0,showNoneButton:!1,showCloseButton:!0,showOn:"focus click alt",showOptions:{},swatches:null,swatchesWidth:84,title:null,cancel:null,close:null,init:null,ok:null,open:null,select:null},_create:function(){var text,that=this;return++_colorpicker_index,that.widgetEventPrefix="colorpicker",that.opened=!1,that.generated=!1,that.inline=!1,that.changed=!1,that.dialog=null,that.button=null,that.image=null,that.overlay=null,that.events={window_resize:null,document_keydown:null,document_click_html:null},that.mode=that.options.mode,that.element.is("input")||that.options.inline===!1?(that._setColor(that.element.is("input")?that.element.val():that.options.color),
|
16
|
+
that._callback("init"),/\bfocus|both\b/.test(that.options.showOn)&&that.element.bind("focus",function(){that.open()}),/\bclick|both\b/.test(that.options.showOn)&&that.element.bind("click",function(){that.open()}),/\bbutton|both\b/.test(that.options.showOn)&&(""!==that.options.buttonImage&&(text=that.options.buttonText||that._getRegional("button"),that.image=$("<img/>").attr({src:that.options.buttonImage,alt:text,title:text}),that.options.buttonClass&&that.image.attr("class",that.options.buttonClass),that._setImageBackground()),that.options.buttonImageOnly&&that.image?that.button=that.image:(that.button=$('<button type="button"></button>').html(that.image||that.options.buttonText).button(),that.image=that.image?$("img",that.button).first():null),that.button.insertAfter(that.element).click(function(){that[that.opened?"close":"open"]()})),/\balt|both\b/.test(that.options.showOn)&&$(that.options.altField).bind("click",function(){that.open()}),that.options.autoOpen&&that.open()):(that.inline=!0,that._generate(),that.opened=!0),this},_setOption:function(key,value){var that=this;switch(key){case"disabled":value?that.dialog.addClass("ui-colorpicker-disabled"):that.dialog.removeClass("ui-colorpicker-disabled")}$.Widget.prototype._setOption.apply(that,arguments)},_setImageBackground:function(){this.image&&this.options.buttonColorize&&this.image.css("background-color",this.color.set?this._formatColor("RGBA",this.color):"")},_setAltField:function(){if(this.options.altOnChange&&this.options.altField&&this.options.altProperties){var index,property,properties=this.options.altProperties.split(",");for(index=0;index<=properties.length;++index)switch(property=$.trim(properties[index])){case"color":case"fill":case"stroke":case"background-color":case"backgroundColor":case"outline-color":case"border-color":$(this.options.altField).css(property,this.color.set?this.color.toCSS():"")}this.options.altAlpha&&$(this.options.altField).css("opacity",this.color.set?this.color.getAlpha():"")}},_setColor:function(text){this.color=this._parseColor(text)||new $.colorpicker.Color,this.currentColor=this.color.copy(),this._setImageBackground(),this._setAltField()},setColor:function(text){this._setColor(text),this._change()},getColor:function(format){return this._formatColor(format||this.options.colorFormat,this.color)},_generateInline:function(){var that=this;$(that.element).html(that.options.inlineFrame?_container_inlineFrame:_container_inline),that.dialog=$(".ui-colorpicker",that.element)},_generatePopup:function(){var that=this;that.dialog=$(_container_popup).appendTo("body"),null===that.events.document_click_html&&$(document).delegate("html","touchstart click",that.events.document_click_html=function(event){if(that.opened&&event.target!==that.element[0]&&!that.overlay){if(that.dialog.is(event.target)||that.dialog.has(event.target).length>0)return void that.element.blur();var p,parents=$(event.target).parents();for(parents.push(event.target),p=0;p<=parents.length;++p){if(null!==that.button&&parents[p]===that.button[0])return;if(/\balt|both\b/.test(that.options.showOn)&&$(that.options.altField).is(parents[p]))return}that.options.closeOnOutside&&that.close(that.options.revert)}}),null===that.events.document_keydown&&$(document).bind("keydown",that.events.document_keydown=function(event){that.opened&&27===event.keyCode&&that.options.closeOnEscape&&that.close(that.options.revert),that.opened&&13===event.keyCode&&that.options.okOnEnter&&that.close()}),that.element.keydown(function(event){9===event.keyCode&&that.close()}).keyup(function(event){var color=that._parseColor(that.element.val());color&&!that.color.equals(color)&&(that.color=color,that._change())})},_generate:function(){var parts_list,layout_parts,table,classes,that=this;that._setColor(that.inline||!that.element.is("input")?that.options.color:that.element.val()),that[that.inline?"_generateInline":"_generatePopup"](),parts_list="string"==typeof that.options.parts?$.colorpicker.partslists[that.options.parts]?$.colorpicker.partslists[that.options.parts]:$.colorpicker.partslists[that.inline?"inline":"popup"]:that.options.parts,that.parts={},$.each(parts_list,function(index,part){$.colorpicker.parts[part]&&(that.parts[part]=new $.colorpicker.parts[part](that))}),that.generated||(layout_parts=[],$.each(that.options.layout,function(part,pos){that.parts[part]&&layout_parts.push({part:part,pos:pos})}),table=$(_layoutTable(layout_parts,function(cell,x,y){return classes=["ui-colorpicker-"+cell.part+"-container"],x>0&&classes.push("ui-colorpicker-padding-left"),y>0&&classes.push("ui-colorpicker-padding-top"),'<td class="'+classes.join(" ")+'"'+(cell.pos[2]>1?' colspan="'+cell.pos[2]+'"':"")+(cell.pos[3]>1?' rowspan="'+cell.pos[3]+'"':"")+' valign="top"></td>'})).appendTo(that.dialog),that.options.inlineFrame&&table.addClass("ui-dialog-content ui-widget-content"),that._initAllParts(),that._updateAllParts(),that.generated=!0)},_effectGeneric:function(element,show,slide,fade,callback){var that=this;$.effects&&$.effects[that.options.showAnim]?element[show](that.options.showAnim,that.options.showOptions,that.options.duration,callback):(element["slideDown"===that.options.showAnim?slide:"fadeIn"===that.options.showAnim?fade:show](that.options.showAnim?that.options.duration:null,callback),that.options.showAnim&&that.options.duration||callback())},_effectShow:function(element,callback){this._effectGeneric(element,"show","slideDown","fadeIn",callback)},_effectHide:function(element,callback){this._effectGeneric(element,"hide","slideUp","fadeOut",callback)},open:function(){var zIndex,element,position,that=this;that.opened||(that._generate(),element=that.element.is(":hidden")?$("<div/>").insertBefore(that.element):that.element,that.options.position?(position=$.extend({},that.options.position),"element"===position.of&&(position.of=element)):position={my:"left top",at:"left bottom",of:element,collision:"flip"},that.dialog.position(position),that.element.is(":hidden")&&element.remove(),zIndex=0,$(that.element[0]).parents().each(function(){var z=$(this).css("z-index");if("number"!=typeof z&&"string"!=typeof z||""===z||isNaN(z))$(this).siblings().each(function(){var z=$(this).css("z-index");"number"!=typeof z&&"string"!=typeof z||""===z||isNaN(z)||z>zIndex&&(zIndex=parseInt(z,10))});else if(z>zIndex)return zIndex=parseInt(z,10),!1}),zIndex+=2,that.dialog.css("z-index",zIndex),that.options.modal&&(that.overlay=$('<div class="ui-widget-overlay"></div>').appendTo("body").css("z-index",zIndex-1),null!==that.events.window_resize&&$(window).unbind("resize",that.events.window_resize),that.events.window_resize=function(){that.overlay&&(that.overlay.width($(document).width()),that.overlay.height($(document).height()))},$(window).bind("resize",that.events.window_resize),that.events.window_resize()),that._effectShow(this.dialog),that.opened=!0,that._callback("open",!0),$(function(){that._repaintAllParts()}))},close:function(cancel){var that=this;cancel?(that.color=that.currentColor.copy(),that._change(),that._callback("cancel",!0)):(that.currentColor=that.color.copy(),that._callback("ok",!0)),that.changed=!1,that.overlay&&($(window).unbind("resize",that.events.window_resize),that.overlay.remove()),that._effectHide(that.dialog,function(){that.dialog.remove(),that.dialog=null,that.generated=!1,that.opened=!1,that._callback("close",!0)})},destroy:function(){null!==that.events.document_click_html&&$(document).undelegate("html","touchstart click",that.events.document_click_html),null!==that.events.document_keydown&&$(document).unbind("keydown",that.events.document_keydown),null!==that.events.resizeOverlay&&$(window).unbind("resize",that.events.resizeOverlay),this.element.unbind(),this.overlay&&this.overlay.remove(),null!==this.dialog&&this.dialog.remove(),null!==this.image&&this.image.remove(),null!==this.button&&this.button.remove()},_callback:function(callback,spaces){var data,lab,that=this;return that.color.set?(data={formatted:that._formatColor(that.options.colorFormat,that.color),colorPicker:that},lab=that.color.getLAB(),lab.a=2*lab.a-1,lab.b=2*lab.b-1,spaces===!0&&(data.a=that.color.getAlpha(),data.rgb=that.color.getRGB(),data.hsv=that.color.getHSV(),data.cmyk=that.color.getCMYK(),data.hsl=that.color.getHSL(),data.lab=lab),that._trigger(callback,null,data)):that._trigger(callback,null,{formatted:"",colorPicker:that})},_initAllParts:function(){$.each(this.parts,function(index,part){part.init&&part.init()})},_updateAllParts:function(){$.each(this.parts,function(index,part){part.update&&part.update()})},_repaintAllParts:function(){$.each(this.parts,function(index,part){part.repaint&&part.repaint()})},_change:function(){this.changed=!0,this.options.limit&&$.colorpicker.limits[this.options.limit]&&$.colorpicker.limits[this.options.limit](this.color,this),this.inline||(this.color.set?this.color.equals(this._parseColor(this.element.val()))||this.element.val(this._formatColor(this.options.colorFormat,this.color)):this.element.val(""),this._setImageBackground(),this._setAltField()),this.options.color=this.color.set?this.color.toCSS():"",this.opened&&this._repaintAllParts(),this._callback("select")},_hoverable:function(e){e.hover(function(){e.addClass("ui-state-hover")},function(){e.removeClass("ui-state-hover")})},_focusable:function(e){e.focus(function(){e.addClass("ui-state-focus")}).blur(function(){e.removeClass("ui-state-focus")})},_getRegional:function(name){return void 0!==$.colorpicker.regional[this.options.regional][name]?$.colorpicker.regional[this.options.regional][name]:$.colorpicker.regional[""][name]},_getSwatches:function(){return"string"==typeof this.options.swatches?$.colorpicker.swatches[this.options.swatches]:$.isPlainObject(this.options.swatches)?this.colorpicker.swatches:$.colorpicker.swatches.html},_eachSwatch:function(callback){var name,currentSwatches=this._getSwatches();$.each(currentSwatches,function(nameOrIndex,swatch){return name=$.isArray(currentSwatches)?swatch.name:nameOrIndex,callback(name,swatch)})},_getSwatch:function(name){var swatch=!1;return this._eachSwatch(function(swatchName,current){return swatchName.toLowerCase()==name.toLowerCase()?(swatch=current,!1):void 0}),swatch},_parseFormat:function(format,text){var color,pattern,typeRegexps={x:function(){return"([0-9a-fA-F]{2})"},d:function(){return"([12]?[0-9]{1,2})"},f:function(){return"([0-9]*\\.?[0-9]*)"},p:function(){return"([0-9]*\\.?[0-9]*)"}},typeConverters={x:function(v){return parseInt(v,16)},d:function(v){return v/255},f:function(v){return v},p:function(v){return.01*v}},setters={r:"setRGB",g:"setRGB",b:"setRGB",h:"setHSV",s:"setHSV",v:"setHSV",c:"setCMYK",m:"setCMYK",y:"setCMYK",k:"setCMYK",L:"setLAB",A:"setLAB",B:"setLAB"},setterChannels={setRGB:["r","g","b"],setHSV:["h","s","v"],setCMYK:["c","m","y","k"],setLAB:["L","A","B"]},channels=[],converters=[],setter=null;if(pattern=format.replace(/[()\\^$.|?*+[\]]/g,function(m){return"\\"+m}),pattern=pattern.replace(/\\?[argbhsvcmykLAB][xdfp]/g,function(variable){if(variable.match(/^\\/))return variable.slice(1);var channel=variable.charAt(0),type=variable.charAt(1);return channels.push(channel),converters.push(typeConverters[type]),setters[channel]&&(setter=setters[channel]),typeRegexps[type]()}),setter){var values=text.match(new RegExp(pattern));if(values){var channelIndex,args=[];values.shift(),$.each(setterChannels[setter],function(index,channel){channelIndex=$.inArray(channel,channels),args[index]=converters[channelIndex](values[channelIndex])}),color=new $.colorpicker.Color,color[setter].apply(color,args)}}return color},_parseColor:function(text){var color,that=this,formats=$.isArray(that.options.colorFormat)?that.options.colorFormat:[that.options.colorFormat];return $.each(formats,function(index,format){return color=$.colorpicker.parsers[format]?$.colorpicker.parsers[format](text,that):that._parseFormat(format,text),color?!1:void 0}),color||$.each($.colorpicker.parsers,function(name,parser){return color=parser(text,that),color?!1:void 0}),color?color:!1},_exactName:function(color){var name=!1;return this._eachSwatch(function(n,swatch){return color.equals(new $.colorpicker.Color(swatch.r,swatch.g,swatch.b))?(name=n,!1):void 0}),name},_closestName:function(color){var d,distance=(color.getRGB(),null),name=!1;return this._eachSwatch(function(n,swatch){if(d=color.distance(new $.colorpicker.Color(swatch.r,swatch.g,swatch.b)),distance>d||null===distance){if(name=n,1e-20>=d)return!1;distance=d}}),name},_formatColor:function(formats,color){var that=this,text=null,types={x:function(v){return _intToHex(255*v)},d:function(v){return Math.floor(255*v)},f:function(v){return v},p:function(v){return 100*v}},channels=color.getChannels();return $.isArray(formats)||(formats=[formats]),$.each(formats,function(index,format){return $.colorpicker.writers[format]?(text=$.colorpicker.writers[format](color,that),text===!1):(text=format.replace(/\\?[argbhsvcmykLAB][xdfp]/g,function(m){return m.match(/^\\/)?m.slice(1):types[m.charAt(1)](channels[m.charAt(0)])}),!1)}),text}})}(jQuery),jQuery(function($){$.colorpicker.regional.nl={ok:"OK",cancel:"Annuleren",none:"Geen",button:"Kleur",title:"Kies een kleur",transparent:"Transparant",hsvH:"H",hsvS:"S",hsvV:"V",rgbR:"R",rgbG:"G",rgbB:"B",labL:"L",labA:"a",labB:"b",hslH:"H",hslS:"S",hslL:"L",cmykC:"C",cmykM:"M",cmykY:"Y",cmykK:"K",alphaA:"A"}}),jQuery(function($){$.colorpicker.swatches.pantone=[{name:"100",r:.956862745098039,g:.929411764705882,b:.486274509803922},{name:"101",r:.956862745098039,g:.929411764705882,b:.27843137254902},{name:"102",r:.976470588235294,g:.909803921568627,b:.0784313725490196},{name:"103",r:.776470588235294,g:.67843137254902,b:.0588235294117647},{name:"104",r:.67843137254902,g:.607843137254902,b:.0470588235294118},{name:"105",r:.509803921568627,g:.458823529411765,b:.0588235294117647},{name:"106",r:.968627450980392,g:.909803921568627,b:.349019607843137},{name:"107",r:.976470588235294,g:.898039215686275,b:.149019607843137},{name:"108",r:.976470588235294,g:.866666666666667,b:.0862745098039216},{name:"109",r:.976470588235294,g:.83921568627451,b:.0862745098039216},{name:"110",r:.847058823529412,g:.709803921568627,b:.0666666666666667},{name:"111",r:.666666666666667,g:.576470588235294,b:.0392156862745098},{name:"112",r:.6,g:.517647058823529,b:.0392156862745098},{name:"113",r:.976470588235294,g:.898039215686275,b:.356862745098039},{name:"114",r:.976470588235294,g:.886274509803922,b:.298039215686275},{name:"115",r:.976470588235294,g:.87843137254902,b:.298039215686275},{name:"116",r:.988235294117647,g:.819607843137255,b:.0862745098039216},{name:"116 2X",r:.968627450980392,g:.709803921568627,b:.0470588235294118},{name:"117",r:.776470588235294,g:.627450980392157,b:.0470588235294118},{name:"118",r:.666666666666667,g:.556862745098039,b:.0392156862745098},{name:"119",r:.537254901960784,g:.466666666666667,b:.0980392156862745},{name:"120",r:.976470588235294,g:.886274509803922,b:.498039215686275},{name:"1205",r:.968627450980392,g:.909803921568627,b:.666666666666667},{name:"121",r:.976470588235294,g:.87843137254902,b:.43921568627451},{name:"1215",r:.976470588235294,g:.87843137254902,b:.549019607843137},{name:"122",r:.988235294117647,g:.847058823529412,b:.337254901960784},{name:"1225",r:1,g:.8,b:.286274509803922},{name:"123",r:1,g:.776470588235294,b:.117647058823529},{name:"1235",r:.988235294117647,g:.709803921568627,b:.0784313725490196},{name:"124",r:.87843137254902,g:.666666666666667,b:.0588235294117647},{name:"1245",r:.749019607843137,g:.568627450980392,b:.0470588235294118},{name:"125",r:.709803921568627,g:.549019607843137,b:.0392156862745098},{name:"1255",r:.63921568627451,g:.498039215686275,b:.0784313725490196},{name:"126",r:.63921568627451,g:.509803921568627,b:.0196078431372549},{name:"1265",r:.486274509803922,g:.388235294117647,b:.0862745098039216},{name:"127",r:.956862745098039,g:.886274509803922,b:.529411764705882},{name:"128",r:.956862745098039,g:.858823529411765,b:.376470588235294},{name:"129",r:.949019607843137,g:.819607843137255,b:.23921568627451},{name:"130",r:.917647058823529,g:.686274509803922,b:.0588235294117647},{name:"130 2X",r:.886274509803922,g:.568627450980392,b:0},{name:"131",r:.776470588235294,g:.576470588235294,b:.0392156862745098},{name:"132",r:.619607843137255,g:.486274509803922,b:.0392156862745098},{name:"133",r:.43921568627451,g:.356862745098039,b:.0392156862745098},{name:"134",r:1,g:.847058823529412,b:.498039215686275},{name:"1345",r:1,g:.83921568627451,b:.568627450980392},{name:"135",r:.988235294117647,g:.788235294117647,b:.388235294117647},{name:"1355",r:.988235294117647,g:.807843137254902,b:.529411764705882},{name:"136",r:.988235294117647,g:.749019607843137,b:.286274509803922},{name:"1365",r:.988235294117647,g:.729411764705882,b:.368627450980392},{name:"137",r:.988235294117647,g:.63921568627451,b:.0666666666666667},{name:"1375",r:.976470588235294,g:.607843137254902,b:.0470588235294118},{name:"138",r:.847058823529412,g:.549019607843137,b:.00784313725490196},{name:"1385",r:.8,g:.47843137254902,b:.00784313725490196},{name:"139",r:.686274509803922,g:.458823529411765,b:.0196078431372549},{name:"1395",r:.6,g:.376470588235294,b:.0274509803921569},{name:"140",r:.47843137254902,g:.356862745098039,b:.0666666666666667},{name:"1405",r:.419607843137255,g:.27843137254902,b:.0784313725490196},{name:"141",r:.949019607843137,g:.807843137254902,b:.407843137254902},{name:"142",r:.949019607843137,g:.749019607843137,b:.286274509803922},{name:"143",r:.937254901960784,g:.698039215686274,b:.176470588235294},{name:"144",r:.886274509803922,g:.549019607843137,b:.0196078431372549},{name:"145",r:.776470588235294,g:.498039215686275,b:.0274509803921569},{name:"146",r:.619607843137255,g:.419607843137255,b:.0196078431372549},{name:"147",r:.447058823529412,g:.368627450980392,b:.149019607843137},{name:"148",r:1,g:.83921568627451,b:.607843137254902},{name:"1485",r:1,g:.717647058823529,b:.466666666666667},{name:"149",r:.988235294117647,g:.8,b:.576470588235294},{name:"1495",r:1,g:.6,b:.247058823529412},{name:"150",r:.988235294117647,g:.67843137254902,b:.337254901960784},{name:"1505",r:.956862745098039,g:.486274509803922,b:0},{name:"151",r:.968627450980392,g:.498039215686275,b:0},{name:"152",r:.866666666666667,g:.458823529411765,b:0},{name:"1525",r:.709803921568627,g:.329411764705882,b:0},{name:"153",r:.737254901960784,g:.427450980392157,b:.0392156862745098},{name:"1535",r:.549019607843137,g:.266666666666667,b:0},{name:"154",r:.6,g:.349019607843137,b:.0196078431372549},{name:"1545",r:.27843137254902,g:.133333333333333,b:0},{name:"155",r:.956862745098039,g:.858823529411765,b:.666666666666667},{name:"1555",r:.976470588235294,g:.749019607843137,b:.619607843137255},{name:"156",r:.949019607843137,g:.776470588235294,b:.549019607843137},{name:"1565",r:.988235294117647,g:.647058823529412,b:.466666666666667},{name:"157",r:.929411764705882,g:.627450980392157,b:.309803921568627},{name:"1575",r:.988235294117647,g:.529411764705882,b:.266666666666667},{name:"158",r:.909803921568627,g:.458823529411765,b:.0666666666666667},{name:"1585",r:.976470588235294,g:.419607843137255,b:.0274509803921569},{name:"159",r:.776470588235294,g:.376470588235294,b:.0196078431372549},{name:"1595",r:.819607843137255,g:.356862745098039,b:.0196078431372549},{name:"160",r:.619607843137255,g:.329411764705882,b:.0392156862745098},{name:"1605",r:.627450980392157,g:.309803921568627,b:.0666666666666667},{name:"161",r:.388235294117647,g:.227450980392157,b:.0666666666666667},{name:"1615",r:.517647058823529,g:.247058823529412,b:.0588235294117647},{name:"162",r:.976470588235294,g:.776470588235294,b:.666666666666667},{name:"1625",r:.976470588235294,g:.647058823529412,b:.549019607843137},{name:"163",r:.988235294117647,g:.619607843137255,b:.43921568627451},{name:"1635",r:.976470588235294,g:.556862745098039,b:.427450980392157},{name:"164",r:.988235294117647,g:.498039215686275,b:.247058823529412},{name:"1645",r:.976470588235294,g:.447058823529412,b:.258823529411765},{name:"165",r:.976470588235294,g:.388235294117647,b:.00784313725490196},{name:"165 2X",r:.917647058823529,g:.309803921568627,b:0},{name:"1655",r:.976470588235294,g:.337254901960784,b:.00784313725490196},{name:"166",r:.866666666666667,g:.349019607843137,b:0},{name:"1665",r:.866666666666667,g:.309803921568627,b:.0196078431372549},{name:"167",r:.737254901960784,g:.309803921568627,b:.0274509803921569},{name:"1675",r:.647058823529412,g:.247058823529412,b:.0588235294117647},{name:"168",r:.427450980392157,g:.188235294117647,b:.0666666666666667},{name:"1685",r:.517647058823529,g:.207843137254902,b:.0666666666666667},{name:"169",r:.976470588235294,g:.729411764705882,b:.666666666666667},{name:"170",r:.976470588235294,g:.537254901960784,b:.447058823529412},{name:"171",r:.976470588235294,g:.376470588235294,b:.227450980392157},{name:"172",r:.968627450980392,g:.286274509803922,b:.00784313725490196},{name:"173",r:.819607843137255,g:.266666666666667,b:.0784313725490196},{name:"174",r:.576470588235294,g:.2,b:.0666666666666667},{name:"175",r:.427450980392157,g:.2,b:.129411764705882},{name:"176",r:.976470588235294,g:.686274509803922,b:.67843137254902},{name:"1765",r:.976470588235294,g:.619607843137255,b:.63921568627451},{name:"1767",r:.976470588235294,g:.698039215686274,b:.717647058823529},{name:"177",r:.976470588235294,g:.509803921568627,b:.498039215686275},{name:"1775",r:.976470588235294,g:.517647058823529,b:.556862745098039},{name:"1777",r:.988235294117647,g:.4,b:.458823529411765},{name:"178",r:.976470588235294,g:.368627450980392,b:.349019607843137},{name:"1785",r:.988235294117647,g:.309803921568627,b:.349019607843137},{name:"1787",r:.956862745098039,g:.247058823529412,b:.309803921568627},{name:"1788",r:.937254901960784,g:.168627450980392,b:.176470588235294},{name:"1788 2X",r:.83921568627451,g:.129411764705882,b:0},{name:"179",r:.886274509803922,g:.23921568627451,b:.156862745098039},{name:"1795",r:.83921568627451,g:.156862745098039,b:.156862745098039},{name:"1797",r:.8,g:.176470588235294,b:.188235294117647},{name:"180",r:.756862745098039,g:.219607843137255,b:.156862745098039},{name:"1805",r:.686274509803922,g:.149019607843137,b:.149019607843137},{name:"1807",r:.627450980392157,g:.188235294117647,b:.2},{name:"181",r:.486274509803922,g:.176470588235294,b:.137254901960784},{name:"1810",r:.486274509803922,g:.129411764705882,b:.117647058823529},{name:"1817",r:.356862745098039,g:.176470588235294,b:.156862745098039},{name:"182",r:.976470588235294,g:.749019607843137,b:.756862745098039},{name:"183",r:.988235294117647,g:.549019607843137,b:.6},{name:"184",r:.988235294117647,g:.368627450980392,b:.447058823529412},{name:"185",r:.909803921568627,g:.0666666666666667,b:.176470588235294},{name:"185 2X",r:.819607843137255,g:.0862745098039216,b:0},{name:"186",r:.807843137254902,g:.0666666666666667,b:.149019607843137},{name:"187",r:.686274509803922,g:.117647058823529,b:.176470588235294},{name:"188",r:.486274509803922,g:.129411764705882,b:.156862745098039},{name:"189",r:1,g:.63921568627451,b:.698039215686274},{name:"1895",r:.988235294117647,g:.749019607843137,b:.788235294117647},{name:"190",r:.988235294117647,g:.458823529411765,b:.556862745098039},{name:"1905",r:.988235294117647,g:.607843137254902,b:.698039215686274},{name:"191",r:.956862745098039,g:.27843137254902,b:.419607843137255},{name:"1915",r:.956862745098039,g:.329411764705882,b:.486274509803922},{name:"192",r:.898039215686275,g:.0196078431372549,b:.227450980392157},{name:"1925",r:.87843137254902,g:.0274509803921569,b:.27843137254902},{name:"193",r:.768627450980392,g:0,b:.262745098039216},{name:"1935",r:.756862745098039,g:.0196078431372549,b:.219607843137255},{name:"194",r:.6,g:.129411764705882,b:.207843137254902},{name:"1945",r:.658823529411765,g:.0470588235294118,b:.207843137254902},{name:"1955",r:.576470588235294,g:.0862745098039216,b:.219607843137255},{name:"196",r:.980392156862745,g:.835294117647059,b:.882352941176471},{name:"197",r:.964705882352941,g:.647058823529412,b:.745098039215686},{name:"198",r:.937254901960784,g:.356862745098039,b:.517647058823529},{name:"199",r:.627450980392157,g:.152941176470588,b:.294117647058824},{name:"200",r:.768627450980392,g:.117647058823529,b:.227450980392157},{name:"201",r:.63921568627451,g:.149019607843137,b:.219607843137255},{name:"202",r:.549019607843137,g:.149019607843137,b:.2},{name:"203",r:.949019607843137,g:.686274509803922,b:.756862745098039},{name:"204",r:.929411764705882,g:.47843137254902,b:.619607843137255},{name:"205",r:.898039215686275,g:.298039215686275,b:.486274509803922},{name:"206",r:.827450980392157,g:.0196078431372549,b:.27843137254902},{name:"207",r:.752941176470588,g:0,b:.305882352941176},{name:"208",r:.556862745098039,g:.137254901960784,b:.266666666666667},{name:"209",r:.458823529411765,g:.149019607843137,b:.23921568627451},{name:"210",r:1,g:.627450980392157,b:.749019607843137},{name:"211",r:1,g:.466666666666667,b:.658823529411765},{name:"212",r:.976470588235294,g:.309803921568627,b:.556862745098039},{name:"213",r:.917647058823529,g:.0588235294117647,b:.419607843137255},{name:"214",r:.8,g:.00784313725490196,b:.337254901960784},{name:"215",r:.647058823529412,g:.0196078431372549,b:.266666666666667},{name:"216",r:.486274509803922,g:.117647058823529,b:.247058823529412},{name:"217",r:.956862745098039,g:.749019607843137,b:.819607843137255},{name:"218",r:.929411764705882,g:.447058823529412,b:.666666666666667},{name:"219",r:.886274509803922,g:.156862745098039,b:.509803921568627},{name:"220",r:.666666666666667,g:0,b:.309803921568627},{name:"221",r:.576470588235294,g:0,b:.258823529411765},{name:"222",r:.43921568627451,g:.0980392156862745,b:.23921568627451},{name:"223",r:.976470588235294,g:.576470588235294,b:.768627450980392},{name:"224",r:.956862745098039,g:.419607843137255,b:.686274509803922},{name:"225",r:.929411764705882,g:.156862745098039,b:.576470588235294},{name:"226",r:.83921568627451,g:.00784313725490196,b:.43921568627451},{name:"227",r:.67843137254902,g:0,b:.356862745098039},{name:"228",r:.549019607843137,g:0,b:.298039215686275},{name:"229",r:.427450980392157,g:.129411764705882,b:.247058823529412},{name:"230",r:1,g:.627450980392157,b:.8},{name:"231",r:.988235294117647,g:.43921568627451,b:.729411764705882},{name:"232",r:.956862745098039,g:.247058823529412,b:.647058823529412},{name:"233",r:.807843137254902,g:0,b:.486274509803922},{name:"234",r:.666666666666667,g:0,b:.4},{name:"235",r:.556862745098039,g:.0196078431372549,b:.329411764705882},{name:"236",r:.976470588235294,g:.686274509803922,b:.827450980392157},{name:"2365",r:.968627450980392,g:.768627450980392,b:.847058823529412},{name:"237",r:.956862745098039,g:.517647058823529,b:.768627450980392},{name:"2375",r:.917647058823529,g:.419607843137255,b:.749019607843137},{name:"238",r:.929411764705882,g:.309803921568627,b:.686274509803922},{name:"2385",r:.858823529411765,g:.156862745098039,b:.647058823529412},{name:"239",r:.87843137254902,g:.129411764705882,b:.619607843137255},{name:"2395",r:.768627450980392,g:0,b:.549019607843137},{name:"240",r:.768627450980392,g:.0588235294117647,b:.537254901960784},{name:"2405",r:.658823529411765,g:0,b:.47843137254902},{name:"241",r:.67843137254902,g:0,b:.458823529411765},{name:"2415",r:.607843137254902,g:0,b:.43921568627451},{name:"242",r:.486274509803922,g:.109803921568627,b:.317647058823529},{name:"2425",r:.529411764705882,g:0,b:.356862745098039},{name:"243",r:.949019607843137,g:.729411764705882,b:.847058823529412},{name:"244",r:.929411764705882,g:.627450980392157,b:.827450980392157},{name:"245",r:.909803921568627,g:.498039215686275,b:.788235294117647},{name:"246",r:.8,g:0,b:.627450980392157},{name:"247",r:.717647058823529,g:0,b:.556862745098039},{name:"248",r:.63921568627451,g:.0196078431372549,b:.498039215686275},{name:"249",r:.498039215686275,g:.156862745098039,b:.376470588235294},{name:"250",r:.929411764705882,g:.768627450980392,b:.866666666666667},{name:"251",r:.886274509803922,g:.619607843137255,b:.83921568627451},{name:"252",r:.827450980392157,g:.419607843137255,b:.776470588235294},{name:"253",r:.686274509803922,g:.137254901960784,b:.647058823529412},{name:"254",r:.627450980392157,g:.176470588235294,b:.588235294117647},{name:"255",r:.466666666666667,g:.176470588235294,b:.419607843137255},{name:"256",r:.898039215686275,g:.768627450980392,b:.83921568627451},{name:"2562",r:.847058823529412,g:.658823529411765,b:.847058823529412},{name:"2563",r:.819607843137255,g:.627450980392157,b:.8},{name:"2567",r:.749019607843137,g:.576470588235294,b:.8},{name:"257",r:.827450980392157,g:.647058823529412,b:.788235294117647},{name:"2572",r:.776470588235294,g:.529411764705882,b:.819607843137255},{name:"2573",r:.729411764705882,g:.486274509803922,b:.737254901960784},{name:"2577",r:.666666666666667,g:.447058823529412,b:.749019607843137},{name:"258",r:.607843137254902,g:.309803921568627,b:.588235294117647},{name:"2582",r:.666666666666667,g:.27843137254902,b:.729411764705882},{name:"2583",r:.619607843137255,g:.309803921568627,b:.647058823529412},{name:"2587",r:.556862745098039,g:.27843137254902,b:.67843137254902},{name:"259",r:.447058823529412,g:.0862745098039216,b:.419607843137255},{name:"2592",r:.576470588235294,g:.0588235294117647,b:.647058823529412},{name:"2593",r:.529411764705882,g:.168627450980392,b:.576470588235294},{name:"2597",r:.4,g:0,b:.549019607843137},{name:"260",r:.407843137254902,g:.117647058823529,b:.356862745098039},{name:"2602",r:.509803921568627,g:.0470588235294118,b:.556862745098039},{name:"2603",r:.43921568627451,g:.0784313725490196,b:.47843137254902},{name:"2607",r:.356862745098039,g:.00784313725490196,b:.47843137254902},{name:"261",r:.368627450980392,g:.129411764705882,b:.329411764705882},{name:"2612",r:.43921568627451,g:.117647058823529,b:.447058823529412},{name:"2613",r:.4,g:.0666666666666667,b:.427450980392157},{name:"2617",r:.337254901960784,g:.0470588235294118,b:.43921568627451},{name:"262",r:.329411764705882,g:.137254901960784,b:.266666666666667},{name:"2622",r:.376470588235294,g:.176470588235294,b:.349019607843137},{name:"2623",r:.356862745098039,g:.0980392156862745,b:.368627450980392},{name:"2627",r:.298039215686275,g:.0784313725490196,b:.368627450980392},{name:"263",r:.87843137254902,g:.807843137254902,b:.87843137254902},{name:"2635",r:.788235294117647,g:.67843137254902,b:.847058823529412},{name:"264",r:.776470588235294,g:.666666666666667,b:.858823529411765},{name:"2645",r:.709803921568627,g:.568627450980392,b:.819607843137255},{name:"265",r:.588235294117647,g:.388235294117647,b:.768627450980392},{name:"2655",r:.607843137254902,g:.427450980392157,b:.776470588235294},{name:"266",r:.427450980392157,g:.156862745098039,b:.666666666666667},{name:"2665",r:.537254901960784,g:.309803921568627,b:.749019607843137},{name:"267",r:.349019607843137,g:.0666666666666667,b:.556862745098039},{name:"268",r:.309803921568627,g:.129411764705882,b:.43921568627451},{name:"2685",r:.337254901960784,g:0,b:.549019607843137},{name:"269",r:.266666666666667,g:.137254901960784,b:.349019607843137},{name:"2695",r:.266666666666667,g:.137254901960784,b:.368627450980392},{name:"270",r:.729411764705882,g:.686274509803922,b:.827450980392157},{name:"2705",r:.67843137254902,g:.619607843137255,b:.827450980392157},{name:"2706",r:.819607843137255,g:.807843137254902,b:.866666666666667},{name:"2707",r:.749019607843137,g:.819607843137255,b:.898039215686275},{name:"2708",r:.686274509803922,g:.737254901960784,b:.858823529411765},{name:"271",r:.619607843137255,g:.568627450980392,b:.776470588235294},{name:"2715",r:.576470588235294,g:.47843137254902,b:.8},{name:"2716",r:.647058823529412,g:.627450980392157,b:.83921568627451},{name:"2717",r:.647058823529412,g:.729411764705882,b:.87843137254902},{name:"2718",r:.356862745098039,g:.466666666666667,b:.8},{name:"272",r:.537254901960784,g:.466666666666667,b:.729411764705882},{name:"2725",r:.447058823529412,g:.317647058823529,b:.737254901960784},{name:"2726",r:.4,g:.337254901960784,b:.737254901960784},{name:"2727",r:.368627450980392,g:.407843137254902,b:.768627450980392},{name:"2728",r:.188235294117647,g:.266666666666667,b:.709803921568627},{name:"273",r:.219607843137255,
|
17
|
+
g:.0980392156862745,b:.47843137254902},{name:"2735",r:.309803921568627,g:0,b:.576470588235294},{name:"2736",r:.286274509803922,g:.188235294117647,b:.67843137254902},{name:"2738",r:.176470588235294,g:0,b:.556862745098039},{name:"274",r:.168627450980392,g:.0666666666666667,b:.4},{name:"2745",r:.247058823529412,g:0,b:.466666666666667},{name:"2746",r:.247058823529412,g:.156862745098039,b:.576470588235294},{name:"2747",r:.109803921568627,g:.0784313725490196,b:.419607843137255},{name:"2748",r:.117647058823529,g:.109803921568627,b:.466666666666667},{name:"275",r:.149019607843137,g:.0588235294117647,b:.329411764705882},{name:"2755",r:.207843137254902,g:0,b:.427450980392157},{name:"2756",r:.2,g:.156862745098039,b:.458823529411765},{name:"2757",r:.0784313725490196,g:.0862745098039216,b:.329411764705882},{name:"2758",r:.0980392156862745,g:.129411764705882,b:.407843137254902},{name:"276",r:.168627450980392,g:.129411764705882,b:.27843137254902},{name:"2765",r:.168627450980392,g:.0470588235294118,b:.337254901960784},{name:"2766",r:.168627450980392,g:.149019607843137,b:.356862745098039},{name:"2767",r:.0784313725490196,g:.129411764705882,b:.23921568627451},{name:"2768",r:.0666666666666667,g:.129411764705882,b:.317647058823529},{name:"277",r:.709803921568627,g:.819607843137255,b:.909803921568627},{name:"278",r:.6,g:.729411764705882,b:.866666666666667},{name:"279",r:.4,g:.537254901960784,b:.8},{name:"280",r:0,g:.168627450980392,b:.498039215686275},{name:"281",r:0,g:.156862745098039,b:.407843137254902},{name:"282",r:0,g:.149019607843137,b:.329411764705882},{name:"283",r:.607843137254902,g:.768627450980392,b:.886274509803922},{name:"284",r:.458823529411765,g:.666666666666667,b:.858823529411765},{name:"285",r:.227450980392157,g:.458823529411765,b:.768627450980392},{name:"286",r:0,g:.219607843137255,b:.658823529411765},{name:"287",r:0,g:.219607843137255,b:.576470588235294},{name:"288",r:0,g:.2,b:.498039215686275},{name:"289",r:0,g:.149019607843137,b:.286274509803922},{name:"290",r:.768627450980392,g:.847058823529412,b:.886274509803922},{name:"2905",r:.576470588235294,g:.776470588235294,b:.87843137254902},{name:"291",r:.658823529411765,g:.807843137254902,b:.886274509803922},{name:"2915",r:.376470588235294,g:.686274509803922,b:.866666666666667},{name:"292",r:.458823529411765,g:.698039215686274,b:.866666666666667},{name:"2925",r:0,g:.556862745098039,b:.83921568627451},{name:"293",r:0,g:.317647058823529,b:.729411764705882},{name:"2935",r:0,g:.356862745098039,b:.749019607843137},{name:"294",r:0,g:.247058823529412,b:.529411764705882},{name:"2945",r:0,g:.329411764705882,b:.627450980392157},{name:"295",r:0,g:.219607843137255,b:.419607843137255},{name:"2955",r:0,g:.23921568627451,b:.419607843137255},{name:"296",r:0,g:.176470588235294,b:.27843137254902},{name:"2965",r:0,g:.2,b:.298039215686275},{name:"297",r:.509803921568627,g:.776470588235294,b:.886274509803922},{name:"2975",r:.729411764705882,g:.87843137254902,b:.886274509803922},{name:"298",r:.317647058823529,g:.709803921568627,b:.87843137254902},{name:"2985",r:.317647058823529,g:.749019607843137,b:.886274509803922},{name:"299",r:0,g:.63921568627451,b:.866666666666667},{name:"2995",r:0,g:.647058823529412,b:.858823529411765},{name:"300",r:0,g:.447058823529412,b:.776470588235294},{name:"3005",r:0,g:.517647058823529,b:.788235294117647},{name:"301",r:0,g:.356862745098039,b:.6},{name:"3015",r:0,g:.43921568627451,b:.619607843137255},{name:"302",r:0,g:.309803921568627,b:.427450980392157},{name:"3025",r:0,g:.329411764705882,b:.419607843137255},{name:"303",r:0,g:.247058823529412,b:.329411764705882},{name:"3035",r:0,g:.266666666666667,b:.329411764705882},{name:"304",r:.647058823529412,g:.866666666666667,b:.886274509803922},{name:"305",r:.43921568627451,g:.807843137254902,b:.886274509803922},{name:"306",r:0,g:.737254901960784,b:.886274509803922},{name:"306 2X",r:0,g:.63921568627451,b:.819607843137255},{name:"307",r:0,g:.47843137254902,b:.647058823529412},{name:"308",r:0,g:.376470588235294,b:.486274509803922},{name:"309",r:0,g:.247058823529412,b:.286274509803922},{name:"310",r:.447058823529412,g:.819607843137255,b:.866666666666667},{name:"3105",r:.498039215686275,g:.83921568627451,b:.858823529411765},{name:"311",r:.156862745098039,g:.768627450980392,b:.847058823529412},{name:"3115",r:.176470588235294,g:.776470588235294,b:.83921568627451},{name:"312",r:0,g:.67843137254902,b:.776470588235294},{name:"3125",r:0,g:.717647058823529,b:.776470588235294},{name:"313",r:0,g:.6,b:.709803921568627},{name:"3135",r:0,g:.607843137254902,b:.666666666666667},{name:"314",r:0,g:.509803921568627,b:.607843137254902},{name:"3145",r:0,g:.517647058823529,b:.556862745098039},{name:"315",r:0,g:.419607843137255,b:.466666666666667},{name:"3155",r:0,g:.427450980392157,b:.458823529411765},{name:"316",r:0,g:.286274509803922,b:.309803921568627},{name:"3165",r:0,g:.337254901960784,b:.356862745098039},{name:"317",r:.788235294117647,g:.909803921568627,b:.866666666666667},{name:"318",r:.576470588235294,g:.866666666666667,b:.858823529411765},{name:"319",r:.298039215686275,g:.807843137254902,b:.819607843137255},{name:"320",r:0,g:.619607843137255,b:.627450980392157},{name:"320 2X",r:0,g:.498039215686275,b:.509803921568627},{name:"321",r:0,g:.529411764705882,b:.537254901960784},{name:"322",r:0,g:.447058823529412,b:.447058823529412},{name:"323",r:0,g:.4,b:.388235294117647},{name:"324",r:.666666666666667,g:.866666666666667,b:.83921568627451},{name:"3242",r:.529411764705882,g:.866666666666667,b:.819607843137255},{name:"3245",r:.549019607843137,g:.87843137254902,b:.819607843137255},{name:"3248",r:.47843137254902,g:.827450980392157,b:.756862745098039},{name:"325",r:.337254901960784,g:.788235294117647,b:.756862745098039},{name:"3252",r:.337254901960784,g:.83921568627451,b:.788235294117647},{name:"3255",r:.27843137254902,g:.83921568627451,b:.756862745098039},{name:"3258",r:.207843137254902,g:.768627450980392,b:.686274509803922},{name:"326",r:0,g:.698039215686274,b:.666666666666667},{name:"3262",r:0,g:.756862745098039,b:.709803921568627},{name:"3265",r:0,g:.776470588235294,b:.698039215686274},{name:"3268",r:0,g:.686274509803922,b:.6},{name:"327",r:0,g:.549019607843137,b:.509803921568627},{name:"327 2X",r:0,g:.537254901960784,b:.466666666666667},{name:"3272",r:0,g:.666666666666667,b:.619607843137255},{name:"3275",r:0,g:.698039215686274,b:.627450980392157},{name:"3278",r:0,g:.607843137254902,b:.517647058823529},{name:"328",r:0,g:.466666666666667,b:.43921568627451},{name:"3282",r:0,g:.549019607843137,b:.509803921568627},{name:"3285",r:0,g:.6,b:.529411764705882},{name:"3288",r:0,g:.509803921568627,b:.43921568627451},{name:"329",r:0,g:.427450980392157,b:.4},{name:"3292",r:0,g:.376470588235294,b:.337254901960784},{name:"3295",r:0,g:.509803921568627,b:.447058823529412},{name:"3298",r:0,g:.419607843137255,b:.356862745098039},{name:"330",r:0,g:.349019607843137,b:.317647058823529},{name:"3302",r:0,g:.286274509803922,b:.247058823529412},{name:"3305",r:0,g:.309803921568627,b:.258823529411765},{name:"3308",r:0,g:.266666666666667,b:.219607843137255},{name:"331",r:.729411764705882,g:.917647058823529,b:.83921568627451},{name:"332",r:.627450980392157,g:.898039215686275,b:.807843137254902},{name:"333",r:.368627450980392,g:.866666666666667,b:.756862745098039},{name:"334",r:0,g:.6,b:.486274509803922},{name:"335",r:0,g:.486274509803922,b:.4},{name:"336",r:0,g:.407843137254902,b:.329411764705882},{name:"337",r:.607843137254902,g:.858823529411765,b:.756862745098039},{name:"3375",r:.556862745098039,g:.886274509803922,b:.737254901960784},{name:"338",r:.47843137254902,g:.819607843137255,b:.709803921568627},{name:"3385",r:.329411764705882,g:.847058823529412,b:.658823529411765},{name:"339",r:0,g:.698039215686274,b:.549019607843137},{name:"3395",r:0,g:.788235294117647,b:.576470588235294},{name:"340",r:0,g:.6,b:.466666666666667},{name:"3405",r:0,g:.698039215686274,b:.47843137254902},{name:"341",r:0,g:.47843137254902,b:.368627450980392},{name:"3415",r:0,g:.486274509803922,b:.349019607843137},{name:"342",r:0,g:.419607843137255,b:.329411764705882},{name:"3425",r:0,g:.407843137254902,b:.27843137254902},{name:"343",r:0,g:.337254901960784,b:.247058823529412},{name:"3435",r:.00784313725490196,g:.286274509803922,b:.188235294117647},{name:"344",r:.709803921568627,g:.886274509803922,b:.749019607843137},{name:"345",r:.588235294117647,g:.847058823529412,b:.686274509803922},{name:"346",r:.43921568627451,g:.807843137254902,b:.607843137254902},{name:"347",r:0,g:.619607843137255,b:.376470588235294},{name:"348",r:0,g:.529411764705882,b:.317647058823529},{name:"349",r:0,g:.419607843137255,b:.247058823529412},{name:"350",r:.137254901960784,g:.309803921568627,b:.2},{name:"351",r:.709803921568627,g:.909803921568627,b:.749019607843137},{name:"352",r:.6,g:.898039215686275,b:.698039215686274},{name:"353",r:.517647058823529,g:.886274509803922,b:.658823529411765},{name:"354",r:0,g:.717647058823529,b:.376470588235294},{name:"355",r:0,g:.619607843137255,b:.286274509803922},{name:"356",r:0,g:.47843137254902,b:.23921568627451},{name:"357",r:.129411764705882,g:.356862745098039,b:.2},{name:"358",r:.666666666666667,g:.866666666666667,b:.588235294117647},{name:"359",r:.627450980392157,g:.858823529411765,b:.556862745098039},{name:"360",r:.376470588235294,g:.776470588235294,b:.349019607843137},{name:"361",r:.117647058823529,g:.709803921568627,b:.227450980392157},{name:"362",r:.2,g:.619607843137255,b:.207843137254902},{name:"363",r:.23921568627451,g:.556862745098039,b:.2},{name:"364",r:.227450980392157,g:.466666666666667,b:.156862745098039},{name:"365",r:.827450980392157,g:.909803921568627,b:.63921568627451},{name:"366",r:.768627450980392,g:.898039215686275,b:.556862745098039},{name:"367",r:.666666666666667,g:.866666666666667,b:.427450980392157},{name:"368",r:.356862745098039,g:.749019607843137,b:.129411764705882},{name:"368 2X",r:0,g:.619607843137255,b:.0588235294117647},{name:"369",r:.337254901960784,g:.666666666666667,b:.109803921568627},{name:"370",r:.337254901960784,g:.556862745098039,b:.0784313725490196},{name:"371",r:.337254901960784,g:.419607843137255,b:.129411764705882},{name:"372",r:.847058823529412,g:.929411764705882,b:.588235294117647},{name:"373",r:.807843137254902,g:.917647058823529,b:.509803921568627},{name:"374",r:.729411764705882,g:.909803921568627,b:.376470588235294},{name:"375",r:.549019607843137,g:.83921568627451,b:0},{name:"375 2X",r:.329411764705882,g:.737254901960784,b:0},{name:"376",r:.498039215686275,g:.729411764705882,b:0},{name:"377",r:.43921568627451,g:.576470588235294,b:.00784313725490196},{name:"378",r:.337254901960784,g:.388235294117647,b:.0784313725490196},{name:"379",r:.87843137254902,g:.917647058823529,b:.407843137254902},{name:"380",r:.83921568627451,g:.898039215686275,b:.258823529411765},{name:"381",r:.8,g:.886274509803922,b:.149019607843137},{name:"382",r:.729411764705882,g:.847058823529412,b:.0392156862745098},{name:"382 2X",r:.619607843137255,g:.768627450980392,b:0},{name:"383",r:.63921568627451,g:.686274509803922,b:.0274509803921569},{name:"384",r:.576470588235294,g:.6,b:.0196078431372549},{name:"385",r:.43921568627451,g:.43921568627451,b:.0784313725490196},{name:"386",r:.909803921568627,g:.929411764705882,b:.376470588235294},{name:"387",r:.87843137254902,g:.929411764705882,b:.266666666666667},{name:"388",r:.83921568627451,g:.909803921568627,b:.0588235294117647},{name:"389",r:.807843137254902,g:.87843137254902,b:.0274509803921569},{name:"390",r:.729411764705882,g:.768627450980392,b:.0196078431372549},{name:"391",r:.619607843137255,g:.619607843137255,b:.0274509803921569},{name:"392",r:.517647058823529,g:.509803921568627,b:.0196078431372549},{name:"393",r:.949019607843137,g:.937254901960784,b:.529411764705882},{name:"3935",r:.949019607843137,g:.929411764705882,b:.427450980392157},{name:"394",r:.917647058823529,g:.929411764705882,b:.207843137254902},{name:"3945",r:.937254901960784,g:.917647058823529,b:.0274509803921569},{name:"395",r:.898039215686275,g:.909803921568627,b:.0666666666666667},{name:"3955",r:.929411764705882,g:.886274509803922,b:.0666666666666667},{name:"396",r:.87843137254902,g:.886274509803922,b:.0470588235294118},{name:"3965",r:.909803921568627,g:.866666666666667,b:.0666666666666667},{name:"397",r:.756862745098039,g:.749019607843137,b:.0392156862745098},{name:"3975",r:.709803921568627,g:.658823529411765,b:.0470588235294118},{name:"398",r:.686274509803922,g:.658823529411765,b:.0392156862745098},{name:"3985",r:.6,g:.549019607843137,b:.0392156862745098},{name:"399",r:.6,g:.556862745098039,b:.0274509803921569},{name:"3995",r:.427450980392157,g:.376470588235294,b:.00784313725490196},{name:"400",r:.819607843137255,g:.776470588235294,b:.709803921568627},{name:"401",r:.756862745098039,g:.709803921568627,b:.647058823529412},{name:"402",r:.686274509803922,g:.647058823529412,b:.576470588235294},{name:"403",r:.6,g:.549019607843137,b:.486274509803922},{name:"404",r:.509803921568627,g:.458823529411765,b:.4},{name:"405",r:.419607843137255,g:.368627450980392,b:.309803921568627},{name:"406",r:.807843137254902,g:.756862745098039,b:.709803921568627},{name:"408",r:.658823529411765,g:.6,b:.549019607843137},{name:"409",r:.6,g:.537254901960784,b:.486274509803922},{name:"410",r:.486274509803922,g:.427450980392157,b:.388235294117647},{name:"411",r:.4,g:.349019607843137,b:.298039215686275},{name:"412",r:.23921568627451,g:.188235294117647,b:.156862745098039},{name:"413",r:.776470588235294,g:.756862745098039,b:.698039215686274},{name:"414",r:.709803921568627,g:.686274509803922,b:.627450980392157},{name:"415",r:.63921568627451,g:.619607843137255,b:.549019607843137},{name:"416",r:.556862745098039,g:.549019607843137,b:.47843137254902},{name:"417",r:.466666666666667,g:.447058823529412,b:.388235294117647},{name:"418",r:.376470588235294,g:.368627450980392,b:.309803921568627},{name:"419",r:.156862745098039,g:.156862745098039,b:.129411764705882},{name:"420",r:.819607843137255,g:.8,b:.749019607843137},{name:"421",r:.749019607843137,g:.729411764705882,b:.686274509803922},{name:"422",r:.686274509803922,g:.666666666666667,b:.63921568627451},{name:"423",r:.588235294117647,g:.576470588235294,b:.556862745098039},{name:"424",r:.509803921568627,g:.498039215686275,b:.466666666666667},{name:"425",r:.376470588235294,g:.376470588235294,b:.356862745098039},{name:"426",r:.168627450980392,g:.168627450980392,b:.156862745098039},{name:"427",r:.866666666666667,g:.858823529411765,b:.819607843137255},{name:"428",r:.819607843137255,g:.807843137254902,b:.776470588235294},{name:"429",r:.67843137254902,g:.686274509803922,b:.666666666666667},{name:"430",r:.568627450980392,g:.588235294117647,b:.576470588235294},{name:"431",r:.4,g:.427450980392157,b:.43921568627451},{name:"432",r:.266666666666667,g:.309803921568627,b:.317647058823529},{name:"433",r:.188235294117647,g:.219607843137255,b:.227450980392157},{name:"433 2X",r:.0392156862745098,g:.0470588235294118,b:.0666666666666667},{name:"434",r:.87843137254902,g:.819607843137255,b:.776470588235294},{name:"435",r:.827450980392157,g:.749019607843137,b:.717647058823529},{name:"436",r:.737254901960784,g:.647058823529412,b:.619607843137255},{name:"437",r:.549019607843137,g:.43921568627451,b:.419607843137255},{name:"438",r:.349019607843137,g:.247058823529412,b:.23921568627451},{name:"439",r:.286274509803922,g:.207843137254902,b:.2},{name:"440",r:.247058823529412,g:.188235294117647,b:.168627450980392},{name:"441",r:.819607843137255,g:.819607843137255,b:.776470588235294},{name:"442",r:.729411764705882,g:.749019607843137,b:.717647058823529},{name:"443",r:.63921568627451,g:.658823529411765,b:.63921568627451},{name:"444",r:.537254901960784,g:.556862745098039,b:.549019607843137},{name:"445",r:.337254901960784,g:.349019607843137,b:.349019607843137},{name:"446",r:.286274509803922,g:.298039215686275,b:.286274509803922},{name:"447",r:.247058823529412,g:.247058823529412,b:.219607843137255},{name:"448",r:.329411764705882,g:.27843137254902,b:.176470588235294},{name:"4485",r:.376470588235294,g:.298039215686275,b:.0666666666666667},{name:"449",r:.329411764705882,g:.27843137254902,b:.149019607843137},{name:"4495",r:.529411764705882,g:.458823529411765,b:.188235294117647},{name:"450",r:.376470588235294,g:.329411764705882,b:.168627450980392},{name:"4505",r:.627450980392157,g:.568627450980392,b:.317647058823529},{name:"451",r:.67843137254902,g:.627450980392157,b:.47843137254902},{name:"4515",r:.737254901960784,g:.67843137254902,b:.458823529411765},{name:"452",r:.768627450980392,g:.717647058823529,b:.588235294117647},{name:"4525",r:.8,g:.749019607843137,b:.556862745098039},{name:"453",r:.83921568627451,g:.8,b:.686274509803922},{name:"4535",r:.858823529411765,g:.807843137254902,b:.647058823529412},{name:"454",r:.886274509803922,g:.847058823529412,b:.749019607843137},{name:"4545",r:.898039215686275,g:.858823529411765,b:.729411764705882},{name:"455",r:.4,g:.337254901960784,b:.0784313725490196},{name:"456",r:.6,g:.529411764705882,b:.0784313725490196},{name:"457",r:.709803921568627,g:.607843137254902,b:.0470588235294118},{name:"458",r:.866666666666667,g:.8,b:.419607843137255},{name:"459",r:.886274509803922,g:.83921568627451,b:.486274509803922},{name:"460",r:.917647058823529,g:.866666666666667,b:.588235294117647},{name:"461",r:.929411764705882,g:.898039215686275,b:.67843137254902},{name:"462",r:.356862745098039,g:.27843137254902,b:.137254901960784},{name:"4625",r:.27843137254902,g:.137254901960784,b:.0666666666666667},{name:"463",r:.458823529411765,g:.329411764705882,b:.149019607843137},{name:"4635",r:.549019607843137,g:.349019607843137,b:.2},{name:"464",r:.529411764705882,g:.376470588235294,b:.156862745098039},{name:"464 2X",r:.43921568627451,g:.258823529411765,b:.0784313725490196},{name:"4645",r:.698039215686274,g:.509803921568627,b:.376470588235294},{name:"465",r:.756862745098039,g:.658823529411765,b:.458823529411765},{name:"4655",r:.768627450980392,g:.6,b:.466666666666667},{name:"466",r:.819607843137255,g:.749019607843137,b:.568627450980392},{name:"4665",r:.847058823529412,g:.709803921568627,b:.588235294117647},{name:"467",r:.866666666666667,g:.8,b:.647058823529412},{name:"4675",r:.898039215686275,g:.776470588235294,b:.666666666666667},{name:"468",r:.886274509803922,g:.83921568627451,b:.709803921568627},{name:"4685",r:.929411764705882,g:.827450980392157,b:.737254901960784},{name:"469",r:.376470588235294,g:.2,b:.0666666666666667},{name:"4695",r:.317647058823529,g:.149019607843137,b:.109803921568627},{name:"470",r:.607843137254902,g:.309803921568627,b:.0980392156862745},{name:"4705",r:.486274509803922,g:.317647058823529,b:.23921568627451},{name:"471",r:.737254901960784,g:.368627450980392,b:.117647058823529},{name:"471 2X",r:.63921568627451,g:.266666666666667,b:.00784313725490196},{name:"4715",r:.6,g:.43921568627451,b:.356862745098039},{name:"472",r:.917647058823529,g:.666666666666667,b:.47843137254902},{name:"4725",r:.709803921568627,g:.568627450980392,b:.486274509803922},{name:"473",r:.956862745098039,g:.768627450980392,b:.627450980392157},{name:"4735",r:.8,g:.686274509803922,b:.607843137254902},{name:"474",r:.956862745098039,g:.8,b:.666666666666667},{name:"4745",r:.847058823529412,g:.749019607843137,b:.666666666666667},{name:"475",r:.968627450980392,g:.827450980392157,b:.709803921568627},{name:"4755",r:.886274509803922,g:.8,b:.729411764705882},{name:"476",r:.349019607843137,g:.23921568627451,b:.168627450980392},{name:"477",r:.388235294117647,g:.219607843137255,b:.149019607843137},{name:"478",r:.47843137254902,g:.247058823529412,b:.156862745098039},{name:"479",r:.686274509803922,g:.537254901960784,b:.43921568627451},{name:"480",r:.827450980392157,g:.717647058823529,b:.63921568627451},{name:"481",r:.87843137254902,g:.8,b:.729411764705882},{name:"482",r:.898039215686275,g:.827450980392157,b:.756862745098039},{name:"483",r:.419607843137255,g:.188235294117647,b:.129411764705882},{name:"484",r:.607843137254902,g:.188235294117647,b:.109803921568627},{name:"485",r:.847058823529412,g:.117647058823529,b:.0196078431372549},{name:"485 2X",r:.8,g:.0470588235294118,b:0},{name:"486",r:.929411764705882,g:.619607843137255,b:.517647058823529},{name:"487",r:.937254901960784,g:.709803921568627,b:.627450980392157},{name:"488",r:.949019607843137,g:.768627450980392,b:.686274509803922},{name:"489",r:.949019607843137,g:.819607843137255,b:.749019607843137},{name:"490",r:.356862745098039,g:.149019607843137,b:.149019607843137},{name:"491",r:.458823529411765,g:.156862745098039,b:.156862745098039},{name:"492",r:.568627450980392,g:.2,b:.219607843137255},{name:"494",r:.949019607843137,g:.67843137254902,b:.698039215686274},{name:"495",r:.956862745098039,g:.737254901960784,b:.749019607843137},{name:"496",r:.968627450980392,g:.788235294117647,b:.776470588235294},{name:"497",r:.317647058823529,g:.156862745098039,b:.149019607843137},{name:"4975",r:.266666666666667,g:.117647058823529,b:.109803921568627},{name:"498",r:.427450980392157,g:.2,b:.168627450980392},{name:"4985",r:.517647058823529,g:.286274509803922,b:.286274509803922},{name:"499",r:.47843137254902,g:.219607843137255,b:.176470588235294},{name:"4995",r:.647058823529412,g:.419607843137255,b:.427450980392157},{name:"500",r:.807843137254902,g:.537254901960784,b:.549019607843137},{name:"5005",r:.737254901960784,g:.529411764705882,b:.529411764705882},{name:"501",r:.917647058823529,g:.698039215686274,b:.698039215686274},{name:"5015",r:.847058823529412,g:.67843137254902,b:.658823529411765},{name:"502",r:.949019607843137,g:.776470588235294,b:.768627450980392},{name:"5025",r:.886274509803922,g:.737254901960784,b:.717647058823529},{name:"503",r:.956862745098039,g:.819607843137255,b:.8},{name:"5035",r:.929411764705882,g:.807843137254902,b:.776470588235294},{name:"504",r:.317647058823529,g:.117647058823529,b:.149019607843137},{name:"505",r:.4,g:.117647058823529,b:.168627450980392},{name:"506",r:.47843137254902,g:.149019607843137,b:.219607843137255},{name:"507",r:.847058823529412,g:.537254901960784,b:.607843137254902},{name:"508",r:.909803921568627,g:.647058823529412,b:.686274509803922},{name:"509",r:.949019607843137,g:.729411764705882,b:.749019607843137},{name:"510",r:.956862745098039,g:.776470588235294,b:.788235294117647},{name:"511",r:.376470588235294,g:.129411764705882,b:.266666666666667},{name:"5115",r:.309803921568627,g:.129411764705882,b:.227450980392157},{name:"512",r:.517647058823529,g:.129411764705882,b:.419607843137255},{name:"5125",r:.458823529411765,g:.27843137254902,b:.376470588235294},{name:"513",r:.619607843137255,g:.137254901960784,b:.529411764705882},{name:"5135",r:.576470588235294,g:.419607843137255,b:.498039215686275},{name:"514",r:.847058823529412,g:.517647058823529,b:.737254901960784},{name:"5145",r:.67843137254902,g:.529411764705882,b:.6},{name:"515",r:.909803921568627,g:.63921568627451,b:.788235294117647},{name:"5155",r:.8,g:.686274509803922,b:.717647058823529},{name:"516",r:.949019607843137,g:.729411764705882,b:.827450980392157},{name:"5165",r:.87843137254902,g:.788235294117647,b:.8},{name:"517",r:.956862745098039,g:.8,b:.847058823529412},{name:"5175",r:.909803921568627,g:.83921568627451,b:.819607843137255},{name:"518",r:.317647058823529,g:.176470588235294,b:.266666666666667},{name:"5185",r:.27843137254902,g:.156862745098039,b:.207843137254902},{name:"519",r:.388235294117647,g:.188235294117647,b:.368627450980392},{name:"5195",r:.349019607843137,g:.2,b:.266666666666667},{name:"520",r:.43921568627451,g:.207843137254902,b:.447058823529412},{name:"5205",r:.556862745098039,g:.407843137254902,b:.466666666666667},{name:"521",r:.709803921568627,g:.549019607843137,b:.698039215686274},{name:"5215",r:.709803921568627,g:.576470588235294,b:.607843137254902},{name:"522",r:.776470588235294,g:.63921568627451,b:.756862745098039},{name:"5225",r:.8,g:.67843137254902,b:.686274509803922},{name:"523",r:.827450980392157,g:.717647058823529,b:.8},{name:"5235",r:.866666666666667,g:.776470588235294,b:.768627450980392},{name:"524",r:.886274509803922,g:.8,b:.827450980392157},{name:"5245",r:.898039215686275,g:.827450980392157,b:.8},{name:"525",r:.317647058823529,g:.149019607843137,b:.329411764705882},{name:"5255",r:.207843137254902,g:.149019607843137,b:.309803921568627},{name:"526",r:.407843137254902,g:.129411764705882,b:.47843137254902},{name:"5265",r:.286274509803922,g:.23921568627451,b:.388235294117647},{name:"527",r:.47843137254902,g:.117647058823529,b:.6},{name:"5275",r:.376470588235294,g:.337254901960784,b:.466666666666667},{name:"528",r:.686274509803922,g:.447058823529412,b:.756862745098039},{name:"5285",r:.549019607843137,g:.509803921568627,b:.6},{name:"529",r:.807843137254902,g:.63921568627451,b:.827450980392157},{name:"5295",r:.698039215686274,g:.658823529411765,b:.709803921568627},{name:"530",r:.83921568627451,g:.686274509803922,b:.83921568627451},{name:"5305",r:.8,g:.756862745098039,b:.776470588235294},{name:"531",r:.898039215686275,g:.776470588235294,b:.858823529411765},{name:"5315",r:.858823529411765,g:.827450980392157,b:.827450980392157},{name:"532",r:.207843137254902,g:.219607843137255,b:.258823529411765},{name:"533",r:.207843137254902,g:.247058823529412,b:.356862745098039},{name:"534",r:.227450980392157,g:.286274509803922,b:.447058823529412},{name:"535",r:.607843137254902,g:.63921568627451,b:.717647058823529},{name:"536",r:.67843137254902,g:.698039215686274,b:.756862745098039},{name:"537",r:.768627450980392,g:.776470588235294,b:.807843137254902},{name:"538",r:.83921568627451,g:.827450980392157,b:.83921568627451},{name:"539",r:0,g:.188235294117647,b:.286274509803922},{name:"5395",r:.00784313725490196,g:.156862745098039,b:.227450980392157},{name:"540",r:0,g:.2,b:.356862745098039},{name:"5405",r:.247058823529412,g:.376470588235294,b:.458823529411765},{name:"541",r:0,g:.247058823529412,b:.466666666666667},{name:"5415",r:.376470588235294,g:.486274509803922,b:.549019607843137},{name:"542",r:.4,g:.576470588235294,b:.737254901960784},{name:"5425",r:.517647058823529,g:.6,b:.647058823529412},{name:"543",r:.576470588235294,g:.717647058823529,b:.819607843137255},{name:"5435",r:.686274509803922,g:.737254901960784,b:.749019607843137},{name:"544",r:.717647058823529,g:.8,b:.858823529411765},{name:"5445",r:.768627450980392,g:.8,b:.8},{name:"545",r:.768627450980392,g:.827450980392157,b:.866666666666667},{name:"5455",r:.83921568627451,g:.847058823529412,b:.827450980392157},{name:"546",r:.0470588235294118,g:.219607843137255,b:.266666666666667},{name:"5463",r:0,g:.207843137254902,b:.227450980392157},{name:"5467",r:.0980392156862745,g:.219607843137255,b:.2},{name:"547",r:0,g:.247058823529412,b:.329411764705882},{name:"5473",r:.149019607843137,g:.407843137254902,b:.427450980392157},{name:"5477",r:.227450980392157,g:.337254901960784,b:.309803921568627},{name:"548",r:0,g:.266666666666667,b:.349019607843137},{name:"5483",r:.376470588235294,g:.568627450980392,b:.568627450980392},{name:"5487",r:.4,g:.486274509803922,b:.447058823529412},{name:"549",r:.368627450980392,g:.6,b:.666666666666667},{name:"5493",r:.549019607843137,g:.686274509803922,b:.67843137254902},{name:"5497",r:.568627450980392,g:.63921568627451,b:.6},{name:"550",r:.529411764705882,g:.686274509803922,b:.749019607843137},{name:"5503",r:.666666666666667,g:.768627450980392,b:.749019607843137},{name:"5507",r:.686274509803922,g:.729411764705882,b:.698039215686274},{name:"551",r:.63921568627451,g:.756862745098039,b:.788235294117647},{name:"5513",r:.807843137254902,g:.847058823529412,b:.819607843137255},{name:"5517",r:.788235294117647,g:.807843137254902,b:.768627450980392},{name:"552",r:.768627450980392,g:.83921568627451,b:.83921568627451},{name:"5523",r:.83921568627451,g:.866666666666667,b:.83921568627451},{name:"5527",r:.807843137254902,g:.819607843137255,b:.776470588235294},{name:"553",r:.137254901960784,g:.266666666666667,b:.207843137254902},{name:"5535",r:.129411764705882,g:.23921568627451,b:.188235294117647},{name:"554",r:.0980392156862745,g:.368627450980392,b:.27843137254902},{name:"5545",r:.309803921568627,g:.427450980392157,b:.368627450980392},{name:"555",r:.0274509803921569,g:.427450980392157,b:.329411764705882},{name:"5555",r:.466666666666667,g:.568627450980392,b:.509803921568627},{name:"556",r:.47843137254902,g:.658823529411765,b:.568627450980392},{name:"5565",r:.588235294117647,g:.666666666666667,b:.6},{name:"557",r:.63921568627451,g:.756862745098039,b:.67843137254902},{name:"5575",r:.686274509803922,g:.749019607843137,b:.67843137254902},{name:"558",r:.717647058823529,g:.807843137254902,b:.737254901960784},{name:"5585",r:.768627450980392,g:.807843137254902,b:.749019607843137},{name:"559",r:.776470588235294,g:.83921568627451,b:.768627450980392},{name:"5595",r:.847058823529412,g:.858823529411765,b:.8},{name:"560",r:.168627450980392,g:.298039215686275,b:.247058823529412},{name:"5605",r:.137254901960784,g:.227450980392157,b:.176470588235294},{name:"561",r:.149019607843137,g:.4,b:.349019607843137},{name:"5615",r:.329411764705882,g:.407843137254902,b:.337254901960784},{name:"562",r:.117647058823529,g:.47843137254902,b:.427450980392157},{name:"5625",r:.447058823529412,g:.517647058823529,b:.43921568627451},{name:"563",r:.498039215686275,g:.737254901960784,b:.666666666666667},{name:"5635",r:.619607843137255,g:.666666666666667,b:.6},{name:"564",r:.0196078431372549,g:.43921568627451,b:.368627450980392},{name:"5645",r:.737254901960784,g:.756862745098039,b:.698039215686274},{name:"565",r:.737254901960784,g:.858823529411765,b:.8},{name:"5655",r:.776470588235294,g:.8,b:.729411764705882},{name:"566",r:.819607843137255,g:.886274509803922,b:.827450980392157},{name:"5665",r:.83921568627451,g:.83921568627451,b:.776470588235294},{name:"567",r:.149019607843137,g:.317647058823529,b:.258823529411765},{name:"568",r:0,g:.447058823529412,b:.388235294117647},{name:"569",r:0,g:.529411764705882,b:.447058823529412},{name:"570",r:.498039215686275,g:.776470588235294,b:.698039215686274},{name:"571",r:.666666666666667,g:.858823529411765,b:.776470588235294},{name:"572",r:.737254901960784,g:.886274509803922,b:.807843137254902},{name:"573",r:.8,g:.898039215686275,b:.83921568627451},{name:"574",r:.286274509803922,g:.349019607843137,b:.156862745098039},{name:"5743",r:.247058823529412,g:.286274509803922,b:.149019607843137},{name:"5747",r:.258823529411765,g:.27843137254902,b:.0862745098039216},{name:"575",r:.329411764705882,g:.466666666666667,b:.188235294117647},{name:"5753",r:.368627450980392,g:.4,b:.227450980392157},{name:"5757",r:.419607843137255,g:.43921568627451,b:.168627450980392},{name:"576",r:.376470588235294,g:.556862745098039,b:.227450980392157},{name:"5763",r:.466666666666667,g:.486274509803922,b:.309803921568627},{name:"5767",r:.549019607843137,g:.568627450980392,b:.309803921568627},{name:"577",r:.709803921568627,g:.8,b:.556862745098039},{name:"5773",r:.607843137254902,g:.619607843137255,b:.447058823529412},{name:"5777",r:.666666666666667,g:.67843137254902,b:.458823529411765},{name:"578",r:.776470588235294,g:.83921568627451,b:.627450980392157},{name:"5783",r:.709803921568627,g:.709803921568627,b:.556862745098039},{name:"5787",r:.776470588235294,g:.776470588235294,b:.6},{name:"579",r:.788235294117647,g:.83921568627451,b:.63921568627451},{name:"5793",r:.776470588235294,g:.776470588235294,b:.647058823529412},{name:"5797",r:.827450980392157,g:.819607843137255,b:.666666666666667},{name:"580",r:.847058823529412,g:.866666666666667,b:.709803921568627},{name:"5803",r:.847058823529412,g:.83921568627451,b:.717647058823529},{name:"5807",r:.87843137254902,g:.866666666666667,b:.737254901960784},{name:"581",r:.376470588235294,g:.368627450980392,b:.0666666666666667},{name:"5815",r:.286274509803922,g:.266666666666667,b:.0666666666666667},{name:"582",r:.529411764705882,g:.537254901960784,b:.0196078431372549},{name:"5825",r:.458823529411765,g:.43921568627451,b:.168627450980392},{name:"583",r:.666666666666667,g:.729411764705882,b:.0392156862745098},{name:"5835",r:.619607843137255,g:.6,b:.349019607843137},{name:"584",r:.807843137254902,g:.83921568627451,b:.286274509803922},{name:"5845",r:.698039215686274,g:.666666666666667,b:.43921568627451},{name:"585",r:.858823529411765,g:.87843137254902,b:.419607843137255},{name:"5855",r:.8,g:.776470588235294,b:.576470588235294
|
18
|
+
},{name:"586",r:.886274509803922,g:.898039215686275,b:.517647058823529},{name:"5865",r:.83921568627451,g:.807843137254902,b:.63921568627451},{name:"587",r:.909803921568627,g:.909803921568627,b:.607843137254902},{name:"5875",r:.87843137254902,g:.858823529411765,b:.709803921568627},{name:"600",r:.956862745098039,g:.929411764705882,b:.686274509803922},{name:"601",r:.949019607843137,g:.929411764705882,b:.619607843137255},{name:"602",r:.949019607843137,g:.917647058823529,b:.529411764705882},{name:"603",r:.929411764705882,g:.909803921568627,b:.356862745098039},{name:"604",r:.909803921568627,g:.866666666666667,b:.129411764705882},{name:"605",r:.866666666666667,g:.807843137254902,b:.0666666666666667},{name:"606",r:.827450980392157,g:.749019607843137,b:.0666666666666667},{name:"607",r:.949019607843137,g:.917647058823529,b:.737254901960784},{name:"608",r:.937254901960784,g:.909803921568627,b:.67843137254902},{name:"609",r:.917647058823529,g:.898039215686275,b:.588235294117647},{name:"610",r:.886274509803922,g:.858823529411765,b:.447058823529412},{name:"611",r:.83921568627451,g:.807843137254902,b:.286274509803922},{name:"612",r:.768627450980392,g:.729411764705882,b:0},{name:"613",r:.686274509803922,g:.627450980392157,b:.0470588235294118},{name:"614",r:.917647058823529,g:.886274509803922,b:.717647058823529},{name:"615",r:.886274509803922,g:.858823529411765,b:.666666666666667},{name:"616",r:.866666666666667,g:.83921568627451,b:.607843137254902},{name:"617",r:.8,g:.768627450980392,b:.486274509803922},{name:"618",r:.709803921568627,g:.666666666666667,b:.349019607843137},{name:"619",r:.588235294117647,g:.549019607843137,b:.156862745098039},{name:"620",r:.517647058823529,g:.466666666666667,b:.0666666666666667},{name:"621",r:.847058823529412,g:.866666666666667,b:.807843137254902},{name:"622",r:.756862745098039,g:.819607843137255,b:.749019607843137},{name:"623",r:.647058823529412,g:.749019607843137,b:.666666666666667},{name:"624",r:.498039215686275,g:.627450980392157,b:.549019607843137},{name:"625",r:.356862745098039,g:.529411764705882,b:.447058823529412},{name:"626",r:.129411764705882,g:.329411764705882,b:.247058823529412},{name:"627",r:.0470588235294118,g:.188235294117647,b:.149019607843137},{name:"628",r:.8,g:.886274509803922,b:.866666666666667},{name:"629",r:.698039215686274,g:.847058823529412,b:.847058823529412},{name:"630",r:.549019607843137,g:.8,b:.827450980392157},{name:"631",r:.329411764705882,g:.717647058823529,b:.776470588235294},{name:"632",r:0,g:.627450980392157,b:.729411764705882},{name:"633",r:0,g:.498039215686275,b:.6},{name:"634",r:0,g:.4,b:.498039215686275},{name:"635",r:.729411764705882,g:.87843137254902,b:.87843137254902},{name:"636",r:.6,g:.83921568627451,b:.866666666666667},{name:"637",r:.419607843137255,g:.788235294117647,b:.858823529411765},{name:"638",r:0,g:.709803921568627,b:.83921568627451},{name:"639",r:0,g:.627450980392157,b:.768627450980392},{name:"640",r:0,g:.549019607843137,b:.698039215686274},{name:"641",r:0,g:.47843137254902,b:.647058823529412},{name:"642",r:.819607843137255,g:.847058823529412,b:.847058823529412},{name:"643",r:.776470588235294,g:.819607843137255,b:.83921568627451},{name:"644",r:.607843137254902,g:.686274509803922,b:.768627450980392},{name:"645",r:.466666666666667,g:.588235294117647,b:.698039215686274},{name:"646",r:.368627450980392,g:.509803921568627,b:.63921568627451},{name:"647",r:.149019607843137,g:.329411764705882,b:.486274509803922},{name:"648",r:0,g:.188235294117647,b:.368627450980392},{name:"649",r:.83921568627451,g:.83921568627451,b:.847058823529412},{name:"650",r:.749019607843137,g:.776470588235294,b:.819607843137255},{name:"651",r:.607843137254902,g:.666666666666667,b:.749019607843137},{name:"652",r:.427450980392157,g:.529411764705882,b:.658823529411765},{name:"653",r:.2,g:.337254901960784,b:.529411764705882},{name:"654",r:.0588235294117647,g:.168627450980392,b:.356862745098039},{name:"655",r:.0470588235294118,g:.109803921568627,b:.27843137254902},{name:"656",r:.83921568627451,g:.858823529411765,b:.87843137254902},{name:"657",r:.756862745098039,g:.788235294117647,b:.866666666666667},{name:"658",r:.647058823529412,g:.686274509803922,b:.83921568627451},{name:"659",r:.498039215686275,g:.549019607843137,b:.749019607843137},{name:"660",r:.349019607843137,g:.376470588235294,b:.658823529411765},{name:"661",r:.176470588235294,g:.2,b:.556862745098039},{name:"662",r:.0470588235294118,g:.0980392156862745,b:.458823529411765},{name:"663",r:.886274509803922,g:.827450980392157,b:.83921568627451},{name:"664",r:.847058823529412,g:.8,b:.819607843137255},{name:"665",r:.776470588235294,g:.709803921568627,b:.768627450980392},{name:"666",r:.658823529411765,g:.576470588235294,b:.67843137254902},{name:"667",r:.498039215686275,g:.4,b:.537254901960784},{name:"668",r:.4,g:.286274509803922,b:.458823529411765},{name:"669",r:.27843137254902,g:.168627450980392,b:.349019607843137},{name:"670",r:.949019607843137,g:.83921568627451,b:.847058823529412},{name:"671",r:.937254901960784,g:.776470588235294,b:.827450980392157},{name:"672",r:.917647058823529,g:.666666666666667,b:.768627450980392},{name:"673",r:.87843137254902,g:.549019607843137,b:.698039215686274},{name:"674",r:.827450980392157,g:.419607843137255,b:.619607843137255},{name:"675",r:.737254901960784,g:.219607843137255,b:.466666666666667},{name:"676",r:.627450980392157,g:0,b:.329411764705882},{name:"677",r:.929411764705882,g:.83921568627451,b:.83921568627451},{name:"678",r:.917647058823529,g:.8,b:.807843137254902},{name:"679",r:.898039215686275,g:.749019607843137,b:.776470588235294},{name:"680",r:.827450980392157,g:.619607843137255,b:.686274509803922},{name:"681",r:.717647058823529,g:.447058823529412,b:.556862745098039},{name:"682",r:.627450980392157,g:.317647058823529,b:.458823529411765},{name:"683",r:.498039215686275,g:.156862745098039,b:.309803921568627},{name:"684",r:.937254901960784,g:.8,b:.807843137254902},{name:"685",r:.917647058823529,g:.749019607843137,b:.768627450980392},{name:"686",r:.87843137254902,g:.666666666666667,b:.729411764705882},{name:"687",r:.788235294117647,g:.537254901960784,b:.619607843137255},{name:"688",r:.698039215686274,g:.4,b:.517647058823529},{name:"689",r:.576470588235294,g:.258823529411765,b:.4},{name:"690",r:.43921568627451,g:.137254901960784,b:.258823529411765},{name:"691",r:.937254901960784,g:.819607843137255,b:.788235294117647},{name:"692",r:.909803921568627,g:.749019607843137,b:.729411764705882},{name:"693",r:.858823529411765,g:.658823529411765,b:.647058823529412},{name:"694",r:.788235294117647,g:.549019607843137,b:.549019607843137},{name:"695",r:.698039215686274,g:.419607843137255,b:.43921568627451},{name:"696",r:.556862745098039,g:.27843137254902,b:.286274509803922},{name:"697",r:.498039215686275,g:.219607843137255,b:.227450980392157},{name:"698",r:.968627450980392,g:.819607843137255,b:.8},{name:"699",r:.968627450980392,g:.749019607843137,b:.749019607843137},{name:"700",r:.949019607843137,g:.647058823529412,b:.666666666666667},{name:"701",r:.909803921568627,g:.529411764705882,b:.556862745098039},{name:"702",r:.83921568627451,g:.376470588235294,b:.427450980392157},{name:"703",r:.717647058823529,g:.219607843137255,b:.266666666666667},{name:"704",r:.619607843137255,g:.156862745098039,b:.156862745098039},{name:"705",r:.976470588235294,g:.866666666666667,b:.83921568627451},{name:"706",r:.988235294117647,g:.788235294117647,b:.776470588235294},{name:"707",r:.988235294117647,g:.67843137254902,b:.686274509803922},{name:"708",r:.976470588235294,g:.556862745098039,b:.6},{name:"709",r:.949019607843137,g:.407843137254902,b:.466666666666667},{name:"710",r:.87843137254902,g:.258823529411765,b:.317647058823529},{name:"711",r:.819607843137255,g:.176470588235294,b:.2},{name:"712",r:1,g:.827450980392157,b:.666666666666667},{name:"713",r:.976470588235294,g:.788235294117647,b:.63921568627451},{name:"714",r:.976470588235294,g:.729411764705882,b:.509803921568627},{name:"715",r:.988235294117647,g:.619607843137255,b:.286274509803922},{name:"716",r:.949019607843137,g:.517647058823529,b:.0666666666666667},{name:"717",r:.827450980392157,g:.427450980392157,b:0},{name:"718",r:.749019607843137,g:.356862745098039,b:0},{name:"719",r:.956862745098039,g:.819607843137255,b:.686274509803922},{name:"720",r:.937254901960784,g:.768627450980392,b:.619607843137255},{name:"721",r:.909803921568627,g:.698039215686274,b:.509803921568627},{name:"722",r:.819607843137255,g:.556862745098039,b:.329411764705882},{name:"723",r:.729411764705882,g:.458823529411765,b:.188235294117647},{name:"724",r:.556862745098039,g:.286274509803922,b:.0196078431372549},{name:"725",r:.458823529411765,g:.219607843137255,b:.00784313725490196},{name:"726",r:.929411764705882,g:.827450980392157,b:.709803921568627},{name:"727",r:.886274509803922,g:.749019607843137,b:.607843137254902},{name:"728",r:.827450980392157,g:.658823529411765,b:.486274509803922},{name:"729",r:.756862745098039,g:.556862745098039,b:.376470588235294},{name:"730",r:.666666666666667,g:.458823529411765,b:.247058823529412},{name:"731",r:.447058823529412,g:.247058823529412,b:.0392156862745098},{name:"732",r:.376470588235294,g:.2,b:.0392156862745098},{name:"801",r:0,g:.666666666666667,b:.8},{name:"801 2X",r:0,g:.537254901960784,b:.686274509803922},{name:"802",r:.376470588235294,g:.866666666666667,b:.286274509803922},{name:"802 2X",r:.109803921568627,g:.807843137254902,b:.156862745098039},{name:"803",r:1,g:.929411764705882,b:.219607843137255},{name:"803 2X",r:1,g:.847058823529412,b:.0862745098039216},{name:"804",r:1,g:.576470588235294,b:.219607843137255},{name:"804 2X",r:1,g:.498039215686275,b:.117647058823529},{name:"805",r:.976470588235294,g:.349019607843137,b:.317647058823529},{name:"805 2X",r:.976470588235294,g:.227450980392157,b:.168627450980392},{name:"806",r:1,g:0,b:.576470588235294},{name:"806 2X",r:.968627450980392,g:.00784313725490196,b:.486274509803922},{name:"807",r:.83921568627451,g:0,b:.619607843137255},{name:"807 2X",r:.749019607843137,g:0,b:.549019607843137},{name:"808",r:0,g:.709803921568627,b:.607843137254902},{name:"808 2X",r:0,g:.627450980392157,b:.529411764705882},{name:"809",r:.866666666666667,g:.87843137254902,b:.0588235294117647},{name:"809 2X",r:.83921568627451,g:.83921568627451,b:.0470588235294118},{name:"810",r:1,g:.8,b:.117647058823529},{name:"810 2X",r:1,g:.737254901960784,b:.129411764705882},{name:"811",r:1,g:.447058823529412,b:.27843137254902},{name:"811 2X",r:1,g:.329411764705882,b:.0862745098039216},{name:"812",r:.988235294117647,g:.137254901960784,b:.4},{name:"812 2X",r:.988235294117647,g:.0274509803921569,b:.309803921568627},{name:"813",r:.898039215686275,g:0,b:.6},{name:"813 2X",r:.819607843137255,g:0,b:.517647058823529},{name:"814",r:.549019607843137,g:.376470588235294,b:.756862745098039},{name:"814 2X",r:.43921568627451,g:.247058823529412,b:.686274509803922}]}),jQuery(function($){function setGradient(element,startColor,endColor){var start=startColor.toCSS(),end=endColor.toCSS(),prefixes={mozilla:"-moz-",webkit:"-webkit-",msie:"-ms-",opera:"-o-"},prefix="";$.each(prefixes,function(key,p){return $.browser[key]?(prefix=p,!1):void 0}),element.css("background-image",prefix+"linear-gradient(left, "+start+" 0%, "+end+" 100%)")}$.colorpicker.parts.rgbslider=function(inst){var sliders={r:$('<div class="ui-colorpicker-slider"/>'),g:$('<div class="ui-colorpicker-slider"/>'),b:$('<div class="ui-colorpicker-slider"/>')};this.init=function(){function refresh(){var r=sliders.r.slider("value")/255,g=sliders.g.slider("value")/255,b=sliders.b.slider("value")/255;inst.color.setRGB(r,g,b),setGradient(sliders.r,new $.colorpicker.Color(0,g,b),new $.colorpicker.Color(1,g,b)),setGradient(sliders.g,new $.colorpicker.Color(r,0,b),new $.colorpicker.Color(r,1,b)),setGradient(sliders.b,new $.colorpicker.Color(r,g,0),new $.colorpicker.Color(r,g,1)),inst._change()}$('<div class="ui-colorpicker-rgbslider"/>').append(sliders.r,sliders.g,sliders.b).appendTo($(".ui-colorpicker-rgbslider-container",inst.dialog)),$(sliders.r).add(sliders.g).add(sliders.b).slider({min:0,max:255,step:1,slide:refresh,change:refresh})},this.repaint=function(){$.each(inst.color.getRGB(),function(index,value){var input=sliders[index];value=Math.round(255*value),input.slider("value")!==value&&input.slider("value",value)})},this.update=function(){this.repaint()}}}),jQuery(function($){$.colorpicker.parts.memory=function(inst){var container,selectNode=function(node){inst._setColor($(node).css("backgroundColor")),inst._change()},deleteNode=function(node){node.remove()},addNode=function(color){var $node=$("<div/>").addClass("ui-colorpicker-swatch").css("backgroundColor",color);$node.mousedown(function(e){switch(e.stopPropagation(),e.which){case 1:selectNode(this);break;case 3:deleteNode($node),setMemory()}}).bind("contextmenu",function(e){e.preventDefault()}),container.append($node)},getMemory=function(){if(window.localStorage){var memory=localStorage.getItem("colorpicker-memory");if(memory)return JSON.parse(memory)}return $.map((document.cookie.match(/\bcolorpicker-memory=([^;]*)/)||[0,""])[1].split(","),unescape)};setMemory=function(){var colors=[];if($("> *",container).each(function(){colors.push($(this).css("backgroundColor"))}),window.localStorage)localStorage.setItem("colorpicker-memory",JSON.stringify(colors));else{var expdate=new Date;expdate.setDate(expdate.getDate()+3650),document.cookie="colorpicker-memory="+$.map(colors,escape).join()+";expires="+expdate.toUTCString()}},this.init=function(){container=$("<div/>").addClass("ui-colorpicker-memory ui-colorpicker-border ui-colorpicker-swatches").css({width:84,height:84,cursor:"crosshair"}).appendTo($(".ui-colorpicker-memory-container",inst.dialog)),$.each(getMemory(),function(){addNode(this)}),container.mousedown(function(e){addNode(inst.color.toCSS()),setMemory()})}}}),jQuery(function($){$.colorpicker.parsers.CMYK=function(color){var m=/^cmyk\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/.exec(color);return m?(new $.colorpicker.Color).setCMYK(m[1]/255,m[2]/255,m[3]/255,m[4]/255):void 0}}),jQuery(function($){$.colorpicker.parsers["CMYK%"]=function(color){var m=/^cmyk\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*\)$/.exec(color);return m?(new $.colorpicker.Color).setCMYK(m[1]/100,m[2]/100,m[3]/100,m[4]/100):void 0}});
|
19
|
+
//# sourceMappingURL=igv-all.min.map
|