diff --git a/dashboard-ui/bower_components/vibrant/dist/vibrant.js b/dashboard-ui/bower_components/vibrant/dist/vibrant.js index 69b8a63f76..ee421a4f01 100644 --- a/dashboard-ui/bower_components/vibrant/dist/vibrant.js +++ b/dashboard-ui/bower_components/vibrant/dist/vibrant.js @@ -1 +1 @@ -define([],function(){"use strict";var CanvasImage,Swatch,Vibrant,pv={map:function(array,f){var o={};return f?array.map(function(d,i){return o.index=i,f.call(o,d)}):array.slice()},naturalOrder:function(a,b){return ab?1:0},sum:function(array,f){var o={};return array.reduce(f?function(p,d,i){return o.index=i,p+f.call(o,d)}:function(p,d){return p+d},0)},max:function(array,f){return Math.max.apply(null,f?pv.map(array,f):array)}},MMCQ=function(){function getColorIndex(r,g,b){return(r<<2*sigbits)+(g<>rshift,gval=pixel[1]>>rshift,bval=pixel[2]>>rshift,index=getColorIndex(rval,gval,bval),histo[index]=(histo[index]||0)+1}),histo}function vboxFromPixels(pixels,histo){var rval,gval,bval,rmin=1e6,rmax=0,gmin=1e6,gmax=0,bmin=1e6,bmax=0;return pixels.forEach(function(pixel){rval=pixel[0]>>rshift,gval=pixel[1]>>rshift,bval=pixel[2]>>rshift,rvalrmax&&(rmax=rval),gvalgmax&&(gmax=gval),bvalbmax&&(bmax=bval)}),new VBox(rmin,rmax,gmin,gmax,bmin,bmax,histo)}function medianCutApply(histo,vbox){function doCut(color){var left,right,vbox1,vbox2,d2,dim1=color+"1",dim2=color+"2",count2=0;for(i=vbox[dim1];i<=vbox[dim2];i++)if(partialsum[i]>total/2){for(vbox1=vbox.copy(),vbox2=vbox.copy(),left=i-vbox[dim1],right=vbox[dim2]-i,d2=left<=right?Math.min(vbox[dim2]-1,~~(i+right/2)):Math.max(vbox[dim1],~~(i-1-left/2));!partialsum[d2];)d2++;for(count2=lookaheadsum[d2];!count2&&partialsum[d2-1];)count2=lookaheadsum[--d2];return vbox1[dim2]=d2,vbox2[dim1]=vbox1[dim2]+1,[vbox1,vbox2]}}var vBoxCount=vbox.count();if(vBoxCount){var rw=vbox.r2-vbox.r1+1,gw=vbox.g2-vbox.g1+1,bw=vbox.b2-vbox.b1+1,maxw=pv.max([rw,gw,bw]);if(1===vBoxCount)return[vbox.copy()];var i,j,k,sum,index,total=0,partialsum=[],lookaheadsum=[];if(maxw===rw)for(i=vbox.r1;i<=vbox.r2;i++){for(sum=0,j=vbox.g1;j<=vbox.g2;j++)for(k=vbox.b1;k<=vbox.b2;k++)index=getColorIndex(i,j,k),sum+=histo[index]||0;total+=sum,partialsum[i]=total}else if(maxw===gw)for(i=vbox.g1;i<=vbox.g2;i++){for(sum=0,j=vbox.r1;j<=vbox.r2;j++)for(k=vbox.b1;k<=vbox.b2;k++)index=getColorIndex(j,i,k),sum+=histo[index]||0;total+=sum,partialsum[i]=total}else for(i=vbox.b1;i<=vbox.b2;i++){for(sum=0,j=vbox.r1;j<=vbox.r2;j++)for(k=vbox.g1;k<=vbox.g2;k++)index=getColorIndex(j,k,i),sum+=histo[index]||0;total+=sum,partialsum[i]=total}return partialsum.forEach(function(d,i){lookaheadsum[i]=total-d}),doCut(maxw===rw?"r":maxw===gw?"g":"b")}}function quantize(pixels,maxcolors){function iter(lh,target){for(var vbox,ncolors=1,niters=0;niters=target)return;if(niters++>maxIterations)return}else lh.push(vbox),niters++}if(!pixels.length||maxcolors<2||maxcolors>256)return!1;var histo=getHisto(pixels),nColors=0;histo.forEach(function(){nColors++});var vbox=vboxFromPixels(pixels,histo),pq=new PQueue(function(a,b){return pv.naturalOrder(a.count(),b.count())});pq.push(vbox),iter(pq,fractByPopulations*maxcolors);for(var pq2=new PQueue(function(a,b){return pv.naturalOrder(a.count()*a.volume(),b.count()*b.volume())});pq.size();)pq2.push(pq.pop());iter(pq2,maxcolors-pq2.size());for(var cmap=new CMap;pq2.size();)cmap.push(pq2.pop());return cmap}var sigbits=5,rshift=8-sigbits,maxIterations=1e3,fractByPopulations=.75;return VBox.prototype={volume:function(force){var vbox=this;return vbox._volume&&!force||(vbox._volume=(vbox.r2-vbox.r1+1)*(vbox.g2-vbox.g1+1)*(vbox.b2-vbox.b1+1)),vbox._volume},count:function(force){var vbox=this,histo=vbox.histo;if(!vbox._count_set||force){var i,j,k,index,npix=0;for(i=vbox.r1;i<=vbox.r2;i++)for(j=vbox.g1;j<=vbox.g2;j++)for(k=vbox.b1;k<=vbox.b2;k++)index=getColorIndex(i,j,k),npix+=histo[index]||0;vbox._count=npix,vbox._count_set=!0}return vbox._count},copy:function(){var vbox=this;return new VBox(vbox.r1,vbox.r2,vbox.g1,vbox.g2,vbox.b1,vbox.b2,vbox.histo)},avg:function(force){var vbox=this,histo=vbox.histo;if(!vbox._avg||force){var hval,i,j,k,histoindex,ntot=0,mult=1<<8-sigbits,rsum=0,gsum=0,bsum=0;for(i=vbox.r1;i<=vbox.r2;i++)for(j=vbox.g1;j<=vbox.g2;j++)for(k=vbox.b1;k<=vbox.b2;k++)histoindex=getColorIndex(i,j,k),hval=histo[histoindex]||0,ntot+=hval,rsum+=hval*(i+.5)*mult,gsum+=hval*(j+.5)*mult,bsum+=hval*(k+.5)*mult;ntot?vbox._avg=[~~(rsum/ntot),~~(gsum/ntot),~~(bsum/ntot)]:vbox._avg=[~~(mult*(vbox.r1+vbox.r2+1)/2),~~(mult*(vbox.g1+vbox.g2+1)/2),~~(mult*(vbox.b1+vbox.b2+1)/2)]}return vbox._avg},contains:function(pixel){var vbox=this,rval=pixel[0]>>rshift;return gval=pixel[1]>>rshift,bval=pixel[2]>>rshift,rval>=vbox.r1&&rval<=vbox.r2&&gval>=vbox.g1&&gval<=vbox.g2&&bval>=vbox.b1&&bval<=vbox.b2}},CMap.prototype={push:function(vbox){this.vboxes.push({vbox:vbox,color:vbox.avg()})},palette:function(){return this.vboxes.map(function(vb){return vb.color})},size:function(){return this.vboxes.size()},map:function(color){for(var vboxes=this.vboxes,i=0;i251&&highest[1]>251&&highest[2]>251&&(vboxes[idx].color=[255,255,255])}},{quantize:quantize}}(),bind=function(fn,me){return function(){return fn.apply(me,arguments)}},slice=[].slice;window.Swatch=Swatch=function(){function Swatch(rgb,population){this.rgb=rgb,this.population=population}return Swatch.prototype.hsl=void 0,Swatch.prototype.rgb=void 0,Swatch.prototype.population=1,Swatch.yiq=0,Swatch.prototype.getHsl=function(){return this.hsl||(this.hsl=Vibrant.rgbToHsl(this.rgb[0],this.rgb[1],this.rgb[2])),this.hsl},Swatch.prototype.getPopulation=function(){return this.population},Swatch.prototype.getRgb=function(){return this.rgb},Swatch.prototype.getHex=function(){return"#"+((1<<24)+(this.rgb[0]<<16)+(this.rgb[1]<<8)+this.rgb[2]).toString(16).slice(1,7)},Swatch.prototype.getTitleTextColor=function(){return this._ensureTextColors(),this.yiq<200?"#fff":"#000"},Swatch.prototype.getBodyTextColor=function(){return this._ensureTextColors(),this.yiq<150?"#fff":"#000"},Swatch.prototype._ensureTextColors=function(){if(!this.yiq)return this.yiq=(299*this.rgb[0]+587*this.rgb[1]+114*this.rgb[2])/1e3,this.yiq},Swatch}(),window.Vibrant=Vibrant=function(){function Vibrant(sourceImage,colorCount,quality){this.swatches=bind(this.swatches,this);var a,allPixels,b,cmap,g,i,image,imageData,offset,pixelCount,pixels,r;"undefined"==typeof colorCount&&(colorCount=16),"undefined"==typeof quality&&(quality=5),image=new CanvasImage(sourceImage);try{for(imageData=image.getImageData(),pixels=imageData.data,pixelCount=image.getPixelCount(),allPixels=[],i=0;i=125&&(r>250&&g>250&&b>250||allPixels.push([r,g,b])),i+=quality;cmap=this.quantize(allPixels,colorCount),this._swatches=cmap.vboxes.map(function(_this){return function(vbox){return new Swatch(vbox.color,vbox.vbox.count())}}(this)),this.maxPopulation=this.findMaxPopulation,this.generateVarationColors(),this.generateEmptySwatches()}finally{image.removeCanvas()}}return Vibrant.prototype.quantize=MMCQ.quantize,Vibrant.prototype._swatches=[],Vibrant.prototype.TARGET_DARK_LUMA=.26,Vibrant.prototype.MAX_DARK_LUMA=.45,Vibrant.prototype.MIN_LIGHT_LUMA=.55,Vibrant.prototype.TARGET_LIGHT_LUMA=.74,Vibrant.prototype.MIN_NORMAL_LUMA=.3,Vibrant.prototype.TARGET_NORMAL_LUMA=.5,Vibrant.prototype.MAX_NORMAL_LUMA=.7,Vibrant.prototype.TARGET_MUTED_SATURATION=.3,Vibrant.prototype.MAX_MUTED_SATURATION=.4,Vibrant.prototype.TARGET_VIBRANT_SATURATION=1,Vibrant.prototype.MIN_VIBRANT_SATURATION=.35,Vibrant.prototype.WEIGHT_SATURATION=3,Vibrant.prototype.WEIGHT_LUMA=6,Vibrant.prototype.WEIGHT_POPULATION=1,Vibrant.prototype.VibrantSwatch=void 0,Vibrant.prototype.MutedSwatch=void 0,Vibrant.prototype.DarkVibrantSwatch=void 0,Vibrant.prototype.DarkMutedSwatch=void 0,Vibrant.prototype.LightVibrantSwatch=void 0,Vibrant.prototype.LightMutedSwatch=void 0,Vibrant.prototype.HighestPopulation=0,Vibrant.prototype.generateVarationColors=function(){return this.VibrantSwatch=this.findColorVariation(this.TARGET_NORMAL_LUMA,this.MIN_NORMAL_LUMA,this.MAX_NORMAL_LUMA,this.TARGET_VIBRANT_SATURATION,this.MIN_VIBRANT_SATURATION,1),this.LightVibrantSwatch=this.findColorVariation(this.TARGET_LIGHT_LUMA,this.MIN_LIGHT_LUMA,1,this.TARGET_VIBRANT_SATURATION,this.MIN_VIBRANT_SATURATION,1),this.DarkVibrantSwatch=this.findColorVariation(this.TARGET_DARK_LUMA,0,this.MAX_DARK_LUMA,this.TARGET_VIBRANT_SATURATION,this.MIN_VIBRANT_SATURATION,1),this.MutedSwatch=this.findColorVariation(this.TARGET_NORMAL_LUMA,this.MIN_NORMAL_LUMA,this.MAX_NORMAL_LUMA,this.TARGET_MUTED_SATURATION,0,this.MAX_MUTED_SATURATION),this.LightMutedSwatch=this.findColorVariation(this.TARGET_LIGHT_LUMA,this.MIN_LIGHT_LUMA,1,this.TARGET_MUTED_SATURATION,0,this.MAX_MUTED_SATURATION),this.DarkMutedSwatch=this.findColorVariation(this.TARGET_DARK_LUMA,0,this.MAX_DARK_LUMA,this.TARGET_MUTED_SATURATION,0,this.MAX_MUTED_SATURATION),this.DarkMutedSwatch},Vibrant.prototype.generateEmptySwatches=function(){var hsl;if(void 0===this.VibrantSwatch&&void 0!==this.DarkVibrantSwatch&&(hsl=this.DarkVibrantSwatch.getHsl(),hsl[2]=this.TARGET_NORMAL_LUMA,this.VibrantSwatch=new Swatch(Vibrant.hslToRgb(hsl[0],hsl[1],hsl[2]),0)),void 0===this.DarkVibrantSwatch&&void 0!==this.VibrantSwatch)return hsl=this.VibrantSwatch.getHsl(),hsl[2]=this.TARGET_DARK_LUMA,this.DarkVibrantSwatch=new Swatch(Vibrant.hslToRgb(hsl[0],hsl[1],hsl[2]),0),this.DarkVibrantSwatch},Vibrant.prototype.findMaxPopulation=function(){var j,len,population,ref,swatch;for(population=0,ref=this._swatches,j=0,len=ref.length;j=minSaturation&&sat<=maxSaturation&&luma>=minLuma&&luma<=maxLuma&&!this.isAlreadySelected(swatch)&&(value=this.createComparisonValue(sat,targetSaturation,luma,targetLuma,swatch.getPopulation(),this.HighestPopulation),(void 0===max||value>maxValue)&&(max=swatch,maxValue=value));return max},Vibrant.prototype.createComparisonValue=function(saturation,targetSaturation,luma,targetLuma,population,maxPopulation){return this.weightedMean(this.invertDiff(saturation,targetSaturation),this.WEIGHT_SATURATION,this.invertDiff(luma,targetLuma),this.WEIGHT_LUMA,population/maxPopulation,this.WEIGHT_POPULATION)},Vibrant.prototype.invertDiff=function(value,targetValue){return 1-Math.abs(value-targetValue)},Vibrant.prototype.weightedMean=function(){var i,sum,sumWeight,value,values,weight;for(values=1<=arguments.length?slice.call(arguments,0):[],sum=0,sumWeight=0,i=0;i.5?d/(2-max-min):d/(max+min),max){case r:h=(g-b)/d+(g1&&(t-=1),t<1/6?p+6*(q-p)*t:t<.5?q:t<2/3?p+(q-p)*(2/3-t)*6:p},0===s?r=g=b=l:(q=l<.5?l*(1+s):l+s-l*s,p=2*l-q,r=hue2rgb(p,q,h+1/3),g=hue2rgb(p,q,h),b=hue2rgb(p,q,h-1/3)),[255*r,255*g,255*b]},Vibrant}(),window.CanvasImage=CanvasImage=function(){function CanvasImage(image){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d");var originalWidth=image.width,originalHeight=image.height,maxArea=9e4,bitmapArea=originalWidth*originalHeight,scaleRatio=1;bitmapArea>maxArea&&(scaleRatio=maxArea/bitmapArea),this.width=this.canvas.width=originalWidth*scaleRatio,this.height=this.canvas.height=originalHeight*scaleRatio,this.context.drawImage(image,0,0,originalWidth,originalHeight,0,0,this.width,this.height)}return CanvasImage.prototype.getPixelCount=function(){return this.width*this.height},CanvasImage.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)},CanvasImage.prototype.removeCanvas=function(){this.context=null,this.canvas=null},CanvasImage}()}); \ No newline at end of file +define([],function(){"use strict";var CanvasImage,Swatch,Vibrant,pv={map:function(array,f){var o={};return f?array.map(function(d,i){return o.index=i,f.call(o,d)}):array.slice()},naturalOrder:function(a,b){return ab?1:0},sum:function(array,f){var o={};return array.reduce(f?function(p,d,i){return o.index=i,p+f.call(o,d)}:function(p,d){return p+d},0)},max:function(array,f){return Math.max.apply(null,f?pv.map(array,f):array)}},MMCQ=function(){function getColorIndex(r,g,b){return(r<<2*sigbits)+(g<>rshift,gval=pixel[1]>>rshift,bval=pixel[2]>>rshift,index=getColorIndex(rval,gval,bval),histo[index]=(histo[index]||0)+1}),histo}function vboxFromPixels(pixels,histo){var rval,gval,bval,rmin=1e6,rmax=0,gmin=1e6,gmax=0,bmin=1e6,bmax=0;return pixels.forEach(function(pixel){rval=pixel[0]>>rshift,gval=pixel[1]>>rshift,bval=pixel[2]>>rshift,rvalrmax&&(rmax=rval),gvalgmax&&(gmax=gval),bvalbmax&&(bmax=bval)}),new VBox(rmin,rmax,gmin,gmax,bmin,bmax,histo)}function medianCutApply(histo,vbox){function doCut(color){var left,right,vbox1,vbox2,d2,dim1=color+"1",dim2=color+"2",count2=0;for(i=vbox[dim1];i<=vbox[dim2];i++)if(partialsum[i]>total/2){for(vbox1=vbox.copy(),vbox2=vbox.copy(),left=i-vbox[dim1],right=vbox[dim2]-i,d2=left<=right?Math.min(vbox[dim2]-1,~~(i+right/2)):Math.max(vbox[dim1],~~(i-1-left/2));!partialsum[d2];)d2++;for(count2=lookaheadsum[d2];!count2&&partialsum[d2-1];)count2=lookaheadsum[--d2];return vbox1[dim2]=d2,vbox2[dim1]=vbox1[dim2]+1,[vbox1,vbox2]}}var vBoxCount=vbox.count();if(vBoxCount){var rw=vbox.r2-vbox.r1+1,gw=vbox.g2-vbox.g1+1,bw=vbox.b2-vbox.b1+1,maxw=pv.max([rw,gw,bw]);if(1===vBoxCount)return[vbox.copy()];var i,j,k,sum,index,total=0,partialsum=[],lookaheadsum=[];if(maxw===rw)for(i=vbox.r1;i<=vbox.r2;i++){for(sum=0,j=vbox.g1;j<=vbox.g2;j++)for(k=vbox.b1;k<=vbox.b2;k++)index=getColorIndex(i,j,k),sum+=histo[index]||0;total+=sum,partialsum[i]=total}else if(maxw===gw)for(i=vbox.g1;i<=vbox.g2;i++){for(sum=0,j=vbox.r1;j<=vbox.r2;j++)for(k=vbox.b1;k<=vbox.b2;k++)index=getColorIndex(j,i,k),sum+=histo[index]||0;total+=sum,partialsum[i]=total}else for(i=vbox.b1;i<=vbox.b2;i++){for(sum=0,j=vbox.r1;j<=vbox.r2;j++)for(k=vbox.g1;k<=vbox.g2;k++)index=getColorIndex(j,k,i),sum+=histo[index]||0;total+=sum,partialsum[i]=total}return partialsum.forEach(function(d,i){lookaheadsum[i]=total-d}),doCut(maxw===rw?"r":maxw===gw?"g":"b")}}function quantize(pixels,maxcolors){function iter(lh,target){for(var vbox,ncolors=1,niters=0;niters=target)return;if(niters++>maxIterations)return}else lh.push(vbox),niters++}if(!pixels.length||maxcolors<2||maxcolors>256)return!1;var histo=getHisto(pixels),nColors=0;histo.forEach(function(){nColors++});var vbox=vboxFromPixels(pixels,histo),pq=new PQueue(function(a,b){return pv.naturalOrder(a.count(),b.count())});pq.push(vbox),iter(pq,fractByPopulations*maxcolors);for(var pq2=new PQueue(function(a,b){return pv.naturalOrder(a.count()*a.volume(),b.count()*b.volume())});pq.size();)pq2.push(pq.pop());iter(pq2,maxcolors-pq2.size());for(var cmap=new CMap;pq2.size();)cmap.push(pq2.pop());return cmap}var sigbits=5,rshift=8-sigbits,maxIterations=1e3,fractByPopulations=.75;return VBox.prototype={volume:function(force){var vbox=this;return vbox._volume&&!force||(vbox._volume=(vbox.r2-vbox.r1+1)*(vbox.g2-vbox.g1+1)*(vbox.b2-vbox.b1+1)),vbox._volume},count:function(force){var vbox=this,histo=vbox.histo;if(!vbox._count_set||force){var i,j,k,index,npix=0;for(i=vbox.r1;i<=vbox.r2;i++)for(j=vbox.g1;j<=vbox.g2;j++)for(k=vbox.b1;k<=vbox.b2;k++)index=getColorIndex(i,j,k),npix+=histo[index]||0;vbox._count=npix,vbox._count_set=!0}return vbox._count},copy:function(){var vbox=this;return new VBox(vbox.r1,vbox.r2,vbox.g1,vbox.g2,vbox.b1,vbox.b2,vbox.histo)},avg:function(force){var vbox=this,histo=vbox.histo;if(!vbox._avg||force){var hval,i,j,k,histoindex,ntot=0,mult=1<<8-sigbits,rsum=0,gsum=0,bsum=0;for(i=vbox.r1;i<=vbox.r2;i++)for(j=vbox.g1;j<=vbox.g2;j++)for(k=vbox.b1;k<=vbox.b2;k++)histoindex=getColorIndex(i,j,k),hval=histo[histoindex]||0,ntot+=hval,rsum+=hval*(i+.5)*mult,gsum+=hval*(j+.5)*mult,bsum+=hval*(k+.5)*mult;ntot?vbox._avg=[~~(rsum/ntot),~~(gsum/ntot),~~(bsum/ntot)]:vbox._avg=[~~(mult*(vbox.r1+vbox.r2+1)/2),~~(mult*(vbox.g1+vbox.g2+1)/2),~~(mult*(vbox.b1+vbox.b2+1)/2)]}return vbox._avg},contains:function(pixel){var vbox=this,rval=pixel[0]>>rshift;return gval=pixel[1]>>rshift,bval=pixel[2]>>rshift,rval>=vbox.r1&&rval<=vbox.r2&&gval>=vbox.g1&&gval<=vbox.g2&&bval>=vbox.b1&&bval<=vbox.b2}},CMap.prototype={push:function(vbox){this.vboxes.push({vbox:vbox,color:vbox.avg()})},palette:function(){return this.vboxes.map(function(vb){return vb.color})},size:function(){return this.vboxes.size()},map:function(color){for(var vboxes=this.vboxes,i=0;i251&&highest[1]>251&&highest[2]>251&&(vboxes[idx].color=[255,255,255])}},{quantize:quantize}}(),bind=function(fn,me){return function(){return fn.apply(me,arguments)}},slice=[].slice;window.Swatch=Swatch=function(){function Swatch(rgb,population){this.rgb=rgb,this.population=population}return Swatch.prototype.hsl=void 0,Swatch.prototype.rgb=void 0,Swatch.prototype.population=1,Swatch.yiq=0,Swatch.prototype.getHsl=function(){return this.hsl||(this.hsl=Vibrant.rgbToHsl(this.rgb[0],this.rgb[1],this.rgb[2])),this.hsl},Swatch.prototype.getPopulation=function(){return this.population},Swatch.prototype.getRgb=function(){return this.rgb},Swatch.prototype.getHex=function(){return"#"+((1<<24)+(this.rgb[0]<<16)+(this.rgb[1]<<8)+this.rgb[2]).toString(16).slice(1,7)},Swatch.prototype.getTitleTextColor=function(){return this._ensureTextColors(),this.yiq<200?"#fff":"#000"},Swatch.prototype.getBodyTextColor=function(){return this._ensureTextColors(),this.yiq<150?"#fff":"#000"},Swatch.prototype._ensureTextColors=function(){if(!this.yiq)return this.yiq=(299*this.rgb[0]+587*this.rgb[1]+114*this.rgb[2])/1e3,this.yiq},Swatch}(),window.Vibrant=Vibrant=function(){function Vibrant(sourceImage,colorCount,quality){this.swatches=bind(this.swatches,this);var a,allPixels,b,cmap,g,i,image,imageData,offset,pixelCount,pixels,r;"undefined"==typeof colorCount&&(colorCount=16),"undefined"==typeof quality&&(quality=5),image=new CanvasImage(sourceImage);try{for(imageData=image.getImageData(),pixels=imageData.data,pixelCount=image.getPixelCount(),allPixels=[],i=0;i=125&&(r>250&&g>250&&b>250||allPixels.push([r,g,b])),i+=quality;cmap=this.quantize(allPixels,colorCount),this._swatches=(cmap.vboxes||[]).map(function(_this){return function(vbox){return new Swatch(vbox.color,vbox.vbox.count())}}(this)),this.maxPopulation=this.findMaxPopulation,this.generateVarationColors(),this.generateEmptySwatches()}finally{image.removeCanvas()}}return Vibrant.prototype.quantize=MMCQ.quantize,Vibrant.prototype._swatches=[],Vibrant.prototype.TARGET_DARK_LUMA=.26,Vibrant.prototype.MAX_DARK_LUMA=.45,Vibrant.prototype.MIN_LIGHT_LUMA=.55,Vibrant.prototype.TARGET_LIGHT_LUMA=.74,Vibrant.prototype.MIN_NORMAL_LUMA=.3,Vibrant.prototype.TARGET_NORMAL_LUMA=.5,Vibrant.prototype.MAX_NORMAL_LUMA=.7,Vibrant.prototype.TARGET_MUTED_SATURATION=.3,Vibrant.prototype.MAX_MUTED_SATURATION=.4,Vibrant.prototype.TARGET_VIBRANT_SATURATION=1,Vibrant.prototype.MIN_VIBRANT_SATURATION=.35,Vibrant.prototype.WEIGHT_SATURATION=3,Vibrant.prototype.WEIGHT_LUMA=6,Vibrant.prototype.WEIGHT_POPULATION=1,Vibrant.prototype.VibrantSwatch=void 0,Vibrant.prototype.MutedSwatch=void 0,Vibrant.prototype.DarkVibrantSwatch=void 0,Vibrant.prototype.DarkMutedSwatch=void 0,Vibrant.prototype.LightVibrantSwatch=void 0,Vibrant.prototype.LightMutedSwatch=void 0,Vibrant.prototype.HighestPopulation=0,Vibrant.prototype.generateVarationColors=function(){return this.VibrantSwatch=this.findColorVariation(this.TARGET_NORMAL_LUMA,this.MIN_NORMAL_LUMA,this.MAX_NORMAL_LUMA,this.TARGET_VIBRANT_SATURATION,this.MIN_VIBRANT_SATURATION,1),this.LightVibrantSwatch=this.findColorVariation(this.TARGET_LIGHT_LUMA,this.MIN_LIGHT_LUMA,1,this.TARGET_VIBRANT_SATURATION,this.MIN_VIBRANT_SATURATION,1),this.DarkVibrantSwatch=this.findColorVariation(this.TARGET_DARK_LUMA,0,this.MAX_DARK_LUMA,this.TARGET_VIBRANT_SATURATION,this.MIN_VIBRANT_SATURATION,1),this.MutedSwatch=this.findColorVariation(this.TARGET_NORMAL_LUMA,this.MIN_NORMAL_LUMA,this.MAX_NORMAL_LUMA,this.TARGET_MUTED_SATURATION,0,this.MAX_MUTED_SATURATION),this.LightMutedSwatch=this.findColorVariation(this.TARGET_LIGHT_LUMA,this.MIN_LIGHT_LUMA,1,this.TARGET_MUTED_SATURATION,0,this.MAX_MUTED_SATURATION),this.DarkMutedSwatch=this.findColorVariation(this.TARGET_DARK_LUMA,0,this.MAX_DARK_LUMA,this.TARGET_MUTED_SATURATION,0,this.MAX_MUTED_SATURATION),this.DarkMutedSwatch},Vibrant.prototype.generateEmptySwatches=function(){var hsl;if(void 0===this.VibrantSwatch&&void 0!==this.DarkVibrantSwatch&&(hsl=this.DarkVibrantSwatch.getHsl(),hsl[2]=this.TARGET_NORMAL_LUMA,this.VibrantSwatch=new Swatch(Vibrant.hslToRgb(hsl[0],hsl[1],hsl[2]),0)),void 0===this.DarkVibrantSwatch&&void 0!==this.VibrantSwatch)return hsl=this.VibrantSwatch.getHsl(),hsl[2]=this.TARGET_DARK_LUMA,this.DarkVibrantSwatch=new Swatch(Vibrant.hslToRgb(hsl[0],hsl[1],hsl[2]),0),this.DarkVibrantSwatch},Vibrant.prototype.findMaxPopulation=function(){var j,len,population,ref,swatch;for(population=0,ref=this._swatches,j=0,len=ref.length;j=minSaturation&&sat<=maxSaturation&&luma>=minLuma&&luma<=maxLuma&&!this.isAlreadySelected(swatch)&&(value=this.createComparisonValue(sat,targetSaturation,luma,targetLuma,swatch.getPopulation(),this.HighestPopulation),(void 0===max||value>maxValue)&&(max=swatch,maxValue=value));return max},Vibrant.prototype.createComparisonValue=function(saturation,targetSaturation,luma,targetLuma,population,maxPopulation){return this.weightedMean(this.invertDiff(saturation,targetSaturation),this.WEIGHT_SATURATION,this.invertDiff(luma,targetLuma),this.WEIGHT_LUMA,population/maxPopulation,this.WEIGHT_POPULATION)},Vibrant.prototype.invertDiff=function(value,targetValue){return 1-Math.abs(value-targetValue)},Vibrant.prototype.weightedMean=function(){var i,sum,sumWeight,value,values,weight;for(values=1<=arguments.length?slice.call(arguments,0):[],sum=0,sumWeight=0,i=0;i.5?d/(2-max-min):d/(max+min),max){case r:h=(g-b)/d+(g1&&(t-=1),t<1/6?p+6*(q-p)*t:t<.5?q:t<2/3?p+(q-p)*(2/3-t)*6:p},0===s?r=g=b=l:(q=l<.5?l*(1+s):l+s-l*s,p=2*l-q,r=hue2rgb(p,q,h+1/3),g=hue2rgb(p,q,h),b=hue2rgb(p,q,h-1/3)),[255*r,255*g,255*b]},Vibrant}(),window.CanvasImage=CanvasImage=function(){function CanvasImage(image){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d");var originalWidth=image.width,originalHeight=image.height,maxArea=9e4,bitmapArea=originalWidth*originalHeight,scaleRatio=1;bitmapArea>maxArea&&(scaleRatio=maxArea/bitmapArea),this.width=this.canvas.width=originalWidth*scaleRatio,this.height=this.canvas.height=originalHeight*scaleRatio;try{this.context.drawImage(image,0,0,originalWidth,originalHeight,0,0,this.width,this.height)}catch(err){console.log("Error in drawImage: "+err)}}return CanvasImage.prototype.getPixelCount=function(){return this.width*this.height},CanvasImage.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)},CanvasImage.prototype.removeCanvas=function(){this.context=null,this.canvas=null},CanvasImage}()}); \ No newline at end of file diff --git a/dashboard-ui/scripts/livetvrecordings.js b/dashboard-ui/scripts/livetvrecordings.js index ab5e1b70c0..6c1baf21e4 100644 --- a/dashboard-ui/scripts/livetvrecordings.js +++ b/dashboard-ui/scripts/livetvrecordings.js @@ -1 +1 @@ -define(["components/categorysyncbuttons","cardBuilder","apphost","imageLoader","scripts/livetvcomponents","emby-button","listViewStyle","emby-itemscontainer"],function(categorysyncbuttons,cardBuilder,appHost,imageLoader){"use strict";function getRecordingGroupHtml(group){var html="";return html+='"}function renderRecordingGroups(context,groups){groups.length?context.querySelector("#recordingGroups").classList.remove("hide"):context.querySelector("#recordingGroups").classList.add("hide");var html="";html+='
';for(var i=0,length=groups.length;i",context.querySelector("#recordingGroupItems").innerHTML=html,Dashboard.hideLoadingMsg()}function enableScrollX(){return browserInfo.mobile}function renderRecordings(elem,recordings,cardOptions){recordings.length?elem.classList.remove("hide"):elem.classList.add("hide");var recordingItems=elem.querySelector(".recordingItems");enableScrollX()?(recordingItems.classList.add("hiddenScrollX"),recordingItems.classList.remove("vertical-wrap")):(recordingItems.classList.remove("hiddenScrollX"),recordingItems.classList.add("vertical-wrap"));var supportsImageAnalysis=appHost.supports("imageanalysis"),cardLayout=appHost.preferVisualCards||supportsImageAnalysis;recordingItems.innerHTML=cardBuilder.getCardsHtml(Object.assign({items:recordings,shape:enableScrollX()?"autooverflow":"auto",showTitle:!0,showParentTitle:!0,coverImage:!0,lazy:!0,cardLayout:cardLayout,centerText:!cardLayout,vibrant:supportsImageAnalysis,allowBottomPadding:!enableScrollX(),preferThumb:"auto",overlayText:!1},cardOptions||{})),imageLoader.lazyChildren(recordingItems)}function getBackdropShape(){return enableScrollX()?"overflowBackdrop":"backdrop"}function renderActiveRecordings(context,promise){promise.then(function(result){result.Items.length&&"InProgress"!=result.Items[0].Status&&(result.Items=[]),renderRecordings(context.querySelector("#activeRecordings"),result.Items,{shape:getBackdropShape(),showParentTitle:!1,showTitle:!0,showAirTime:!0,showAirEndTime:!0,showChannelName:!0,cardLayout:!0,vibrant:!0,preferThumb:!0,coverImage:!0})})}function renderLatestRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#latestRecordings"),result.Items,{shape:enableScrollX()?"overflowBackdrop":"backdrop",showYear:!0,lines:2}),Dashboard.hideLoadingMsg()})}function renderMovieRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#movieRecordings"),result.Items,{showYear:!0,showParentTitle:!1})})}function renderEpisodeRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#episodeRecordings"),result.Items,{showSeriesYear:!0,showParentTitle:!1})})}function renderSportsRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#sportsRecordings"),result.Items,{showYear:!0,showParentTitle:!1})})}function renderKidsRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#kidsRecordings"),result.Items,{showYear:!0,showParentTitle:!1})})}function onMoreClick(e){var type=this.getAttribute("data-type");switch(type){case"latest":Dashboard.navigate("livetvitems.html?type=Recordings");break;case"movies":Dashboard.navigate("livetvitems.html?type=Recordings&IsMovie=true");break;case"episodes":Dashboard.navigate("livetvitems.html?type=RecordingSeries");break;case"programs":Dashboard.navigate("livetvitems.html?type=Recordings&IsSeries=false&IsMovie=false");break;case"kids":Dashboard.navigate("livetvitems.html?type=Recordings&IsKids=true");break;case"sports":Dashboard.navigate("livetvitems.html?type=Recordings&IsSports=true")}}return function(view,params,tabContent){function enableFullRender(){return(new Date).getTime()-lastFullRender>3e5}var activeRecordingsPromise,sportsPromise,kidsPromise,moviesPromise,seriesPromise,latestPromise,self=this,lastFullRender=0;categorysyncbuttons.init(tabContent);for(var moreButtons=tabContent.querySelectorAll(".more"),i=0,length=moreButtons.length;i',html+="
",html+=group.Name,html+="
",html+='
',html+=1==group.RecordingCount?Globalize.translate("ValueItemCount",group.RecordingCount):Globalize.translate("ValueItemCountPlural",group.RecordingCount),html+="
",html+="",html+="
",html+=""}function renderRecordingGroups(context,groups){groups.length?context.querySelector("#recordingGroups").classList.remove("hide"):context.querySelector("#recordingGroups").classList.add("hide");var html="";html+='
';for(var i=0,length=groups.length;i",context.querySelector("#recordingGroupItems").innerHTML=html,Dashboard.hideLoadingMsg()}function enableScrollX(){return browserInfo.mobile}function renderRecordings(elem,recordings,cardOptions){recordings.length?elem.classList.remove("hide"):elem.classList.add("hide");var recordingItems=elem.querySelector(".recordingItems");enableScrollX()?(recordingItems.classList.add("hiddenScrollX"),recordingItems.classList.remove("vertical-wrap")):(recordingItems.classList.remove("hiddenScrollX"),recordingItems.classList.add("vertical-wrap"));var supportsImageAnalysis=appHost.supports("imageanalysis"),cardLayout=appHost.preferVisualCards||supportsImageAnalysis;recordingItems.innerHTML=cardBuilder.getCardsHtml(Object.assign({items:recordings,shape:enableScrollX()?"autooverflow":"auto",showTitle:!0,showParentTitle:!0,coverImage:!0,lazy:!0,cardLayout:cardLayout,centerText:!cardLayout,vibrant:supportsImageAnalysis,allowBottomPadding:!enableScrollX(),preferThumb:"auto",overlayText:!1},cardOptions||{})),imageLoader.lazyChildren(recordingItems)}function getBackdropShape(){return enableScrollX()?"overflowBackdrop":"backdrop"}function renderActiveRecordings(context,promise){promise.then(function(result){result.Items.length&&"InProgress"!=result.Items[0].Status&&(result.Items=[]),renderRecordings(context.querySelector("#activeRecordings"),result.Items,{shape:getBackdropShape(),showParentTitle:!1,showTitle:!0,showAirTime:!0,showAirEndTime:!0,showChannelName:!0,cardLayout:!0,vibrant:!0,preferThumb:!0,coverImage:!0})})}function renderLatestRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#latestRecordings"),result.Items,{shape:enableScrollX()?"overflowBackdrop":"backdrop",showYear:!0,lines:2}),Dashboard.hideLoadingMsg()})}function renderMovieRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#movieRecordings"),result.Items,{showYear:!0,showParentTitle:!1})})}function renderEpisodeRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#episodeRecordings"),result.Items,{showSeriesYear:!0,showParentTitle:!1})})}function renderSportsRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#sportsRecordings"),result.Items,{showYear:!0,showParentTitle:!1})})}function renderKidsRecordings(context,promise){promise.then(function(result){renderRecordings(context.querySelector("#kidsRecordings"),result.Items,{shape:enableScrollX()?"overflowBackdrop":"backdrop",showYear:!0,lines:2})})}function onMoreClick(e){var type=this.getAttribute("data-type");switch(type){case"latest":Dashboard.navigate("livetvitems.html?type=Recordings");break;case"movies":Dashboard.navigate("livetvitems.html?type=Recordings&IsMovie=true");break;case"episodes":Dashboard.navigate("livetvitems.html?type=RecordingSeries");break;case"programs":Dashboard.navigate("livetvitems.html?type=Recordings&IsSeries=false&IsMovie=false");break;case"kids":Dashboard.navigate("livetvitems.html?type=Recordings&IsKids=true");break;case"sports":Dashboard.navigate("livetvitems.html?type=Recordings&IsSports=true")}}return function(view,params,tabContent){function enableFullRender(){return(new Date).getTime()-lastFullRender>3e5}var activeRecordingsPromise,sportsPromise,kidsPromise,moviesPromise,seriesPromise,latestPromise,self=this,lastFullRender=0;categorysyncbuttons.init(tabContent);for(var moreButtons=tabContent.querySelectorAll(".more"),i=0,length=moreButtons.length;i',html+='',html+='",server.Id&&(html+=''),html+="
"}function renderServers(page,servers){servers.length?(page.querySelector(".noServersMessage").classList.add("hide"),page.querySelector(".serverList").classList.remove("hide")):(page.querySelector(".serverList").classList.add("hide"),page.querySelector(".noServersMessage").classList.remove("hide"));var html="";html+=servers.map(getServerHtml).join(""),page.querySelector(".serverList").innerHTML=html}function alertText(text,title){alertTextWithOptions({title:title,text:text})}function alertTextWithOptions(options){require(["alert"],function(alert){alert(options)})}function showGeneralError(){Dashboard.hideLoadingMsg(),alertText(Globalize.translate("DefaultErrorMessage"))}function parentWithClass(elem,className){for(;!elem.classList||!elem.classList.contains(className);)if(elem=elem.parentNode,!elem)return null;return elem}return function(view,params){function connectToServer(page,server){Dashboard.showLoadingMsg(),ConnectionManager.connectToServer(server,{enableAutoLogin:appSettings.enableAutoLogin()}).then(function(result){Dashboard.hideLoadingMsg();var apiClient=result.ApiClient;switch(result.State){case MediaBrowser.ConnectionState.SignedIn:Dashboard.onServerChanged(apiClient.getCurrentUserId(),apiClient.accessToken(),apiClient),Dashboard.navigate("home.html");break;case MediaBrowser.ConnectionState.ServerSignIn:Dashboard.onServerChanged(null,null,apiClient),Dashboard.navigate("login.html?serverid="+result.Servers[0].Id);break;case MediaBrowser.ConnectionState.ServerUpdateNeeded:alertTextWithOptions({text:Globalize.translate("core#ServerUpdateNeeded","https://emby.media"),html:Globalize.translate("core#ServerUpdateNeeded",'https://emby.media')});break;default:showServerConnectionFailure()}})}function acceptInvitation(page,id){Dashboard.showLoadingMsg(),ConnectionManager.acceptServer(id).then(function(){Dashboard.hideLoadingMsg(),loadPage(page)},function(){showGeneralError()})}function deleteServer(page,serverId){Dashboard.showLoadingMsg(),ConnectionManager.deleteServer(serverId).then(function(){Dashboard.hideLoadingMsg(),loadPage(page)},function(){showGeneralError()})}function rejectInvitation(page,id){Dashboard.showLoadingMsg(),ConnectionManager.rejectServer(id).then(function(){Dashboard.hideLoadingMsg(),loadPage(page)},function(){showGeneralError()})}function showServerMenu(elem){var card=parentWithClass(elem,"serverItem"),page=parentWithClass(elem,"page"),serverId=card.getAttribute("data-id"),menuItems=[];menuItems.push({name:Globalize.translate("ButtonDelete"),id:"delete"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"delete":deleteServer(page,serverId)}}})})}function showPendingInviteMenu(elem){var card=parentWithClass(elem,"inviteItem"),page=parentWithClass(elem,"page"),invitationId=card.getAttribute("data-id"),menuItems=[];menuItems.push({name:Globalize.translate("ButtonAccept"),id:"accept"}),menuItems.push({name:Globalize.translate("ButtonReject"),id:"reject"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"accept":acceptInvitation(page,invitationId);break;case"reject":rejectInvitation(page,invitationId)}}})})}function getPendingInviteHtml(invite){var html="";return html+='
',html+='',html+='
',html+="
",html+=invite.Name,html+="
",html+="
",html+='",html+="
"}function renderInvitations(page,list){list.length?page.querySelector(".invitationSection").classList.remove("hide"):page.querySelector(".invitationSection").classList.add("hide");var html=list.map(getPendingInviteHtml).join("");page.querySelector(".invitationList").innerHTML=html}function loadInvitations(page){ConnectionManager.isLoggedIntoConnect()?ConnectionManager.getUserInvitations().then(function(list){renderInvitations(page,list)}):renderInvitations(page,[])}function loadPage(page){Dashboard.showLoadingMsg(),ConnectionManager.getAvailableServers().then(function(servers){servers=servers.slice(0),cachedServers=servers,renderServers(page,servers),Dashboard.hideLoadingMsg()}),loadInvitations(page),ConnectionManager.isLoggedIntoConnect()?page.querySelector(".connectLogin").classList.add("hide"):page.querySelector(".connectLogin").classList.remove("hide")}var cachedServers;view.querySelector(".invitationList").addEventListener("click",function(e){var btnInviteMenu=parentWithClass(e.target,"btnInviteMenu");btnInviteMenu&&showPendingInviteMenu(btnInviteMenu)}),view.querySelector(".serverList").addEventListener("click",function(e){var lnkServer=parentWithClass(e.target,"lnkServer");if(lnkServer){var item=parentWithClass(lnkServer,"serverItem"),id=item.getAttribute("data-id"),server=cachedServers.filter(function(s){return s.Id==id})[0];connectToServer(view,server)}var btnServerMenu=parentWithClass(e.target,"btnServerMenu");btnServerMenu&&showServerMenu(btnServerMenu)}),view.addEventListener("viewbeforeshow",function(){updatePageStyle(this)}),view.addEventListener("viewshow",function(){loadPage(this)})}}); \ No newline at end of file +define(["appSettings","paper-icon-button-light"],function(appSettings){"use strict";function updatePageStyle(page){"1"==getParameterByName("showuser")?(page.classList.add("libraryPage"),page.classList.add("noSecondaryNavPage"),page.classList.remove("standalonePage")):(page.classList.add("standalonePage"),page.classList.remove("noSecondaryNavPage"),page.classList.remove("libraryPage"))}function showServerConnectionFailure(){alertText(Globalize.translate("MessageUnableToConnectToServer"),Globalize.translate("HeaderConnectionFailure"))}function getServerHtml(server){var html="";return html+='
',html+='',html+='",server.Id&&(html+=''),html+="
"}function renderServers(page,servers){servers.length?(page.querySelector(".noServersMessage").classList.add("hide"),page.querySelector(".serverList").classList.remove("hide")):(page.querySelector(".serverList").classList.add("hide"),page.querySelector(".noServersMessage").classList.remove("hide"));var html="";html+=servers.map(getServerHtml).join(""),page.querySelector(".serverList").innerHTML=html}function alertText(text,title){alertTextWithOptions({title:title,text:text})}function alertTextWithOptions(options){require(["alert"],function(alert){alert(options)})}function showGeneralError(){Dashboard.hideLoadingMsg(),alertText(Globalize.translate("DefaultErrorMessage"))}function parentWithClass(elem,className){for(;!elem.classList||!elem.classList.contains(className);)if(elem=elem.parentNode,!elem)return null;return elem}return function(view,params){function connectToServer(page,server){Dashboard.showLoadingMsg(),ConnectionManager.connectToServer(server,{enableAutoLogin:appSettings.enableAutoLogin()}).then(function(result){Dashboard.hideLoadingMsg();var apiClient=result.ApiClient;switch(result.State){case MediaBrowser.ConnectionState.SignedIn:Dashboard.onServerChanged(apiClient.getCurrentUserId(),apiClient.accessToken(),apiClient),Dashboard.navigate("home.html");break;case MediaBrowser.ConnectionState.ServerSignIn:Dashboard.onServerChanged(null,null,apiClient),Dashboard.navigate("login.html?serverid="+result.Servers[0].Id);break;case MediaBrowser.ConnectionState.ServerUpdateNeeded:alertTextWithOptions({text:Globalize.translate("core#ServerUpdateNeeded","https://emby.media"),html:Globalize.translate("core#ServerUpdateNeeded",'https://emby.media')});break;default:showServerConnectionFailure()}})}function acceptInvitation(page,id){Dashboard.showLoadingMsg(),ConnectionManager.acceptServer(id).then(function(){Dashboard.hideLoadingMsg(),loadPage(page)},function(){showGeneralError()})}function deleteServer(page,serverId){Dashboard.showLoadingMsg(),ConnectionManager.deleteServer(serverId).then(function(){Dashboard.hideLoadingMsg(),loadPage(page)},function(){showGeneralError()})}function rejectInvitation(page,id){Dashboard.showLoadingMsg(),ConnectionManager.rejectServer(id).then(function(){Dashboard.hideLoadingMsg(),loadPage(page)},function(){showGeneralError()})}function showServerMenu(elem){var card=parentWithClass(elem,"serverItem"),page=parentWithClass(elem,"page"),serverId=card.getAttribute("data-id"),menuItems=[];menuItems.push({name:Globalize.translate("ButtonDelete"),id:"delete"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"delete":deleteServer(page,serverId)}}})})}function showPendingInviteMenu(elem){var card=parentWithClass(elem,"inviteItem"),page=parentWithClass(elem,"page"),invitationId=card.getAttribute("data-id"),menuItems=[];menuItems.push({name:Globalize.translate("ButtonAccept"),id:"accept"}),menuItems.push({name:Globalize.translate("ButtonReject"),id:"reject"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"accept":acceptInvitation(page,invitationId);break;case"reject":rejectInvitation(page,invitationId)}}})})}function getPendingInviteHtml(invite){var html="";return html+='
',html+='',html+='
',html+="
",html+=invite.Name,html+="
",html+="
",html+='',html+="
"}function renderInvitations(page,list){list.length?page.querySelector(".invitationSection").classList.remove("hide"):page.querySelector(".invitationSection").classList.add("hide");var html=list.map(getPendingInviteHtml).join("");page.querySelector(".invitationList").innerHTML=html}function loadInvitations(page){ConnectionManager.isLoggedIntoConnect()?ConnectionManager.getUserInvitations().then(function(list){renderInvitations(page,list)}):renderInvitations(page,[])}function loadPage(page){Dashboard.showLoadingMsg(),ConnectionManager.getAvailableServers().then(function(servers){servers=servers.slice(0),cachedServers=servers,renderServers(page,servers),Dashboard.hideLoadingMsg()}),loadInvitations(page),ConnectionManager.isLoggedIntoConnect()?page.querySelector(".connectLogin").classList.add("hide"):page.querySelector(".connectLogin").classList.remove("hide")}var cachedServers;view.querySelector(".invitationList").addEventListener("click",function(e){var btnInviteMenu=parentWithClass(e.target,"btnInviteMenu");btnInviteMenu&&showPendingInviteMenu(btnInviteMenu)}),view.querySelector(".serverList").addEventListener("click",function(e){var lnkServer=parentWithClass(e.target,"lnkServer");if(lnkServer){var item=parentWithClass(lnkServer,"serverItem"),id=item.getAttribute("data-id"),server=cachedServers.filter(function(s){return s.Id==id})[0];connectToServer(view,server)}var btnServerMenu=parentWithClass(e.target,"btnServerMenu");btnServerMenu&&showServerMenu(btnServerMenu)}),view.addEventListener("viewbeforeshow",function(){updatePageStyle(this)}),view.addEventListener("viewshow",function(){loadPage(this)})}}); \ No newline at end of file