diff --git a/build/vulcanized.js b/build/vulcanized.js index 987dac0..c1d6e10 100755 --- a/build/vulcanized.js +++ b/build/vulcanized.js @@ -19,13 +19,12 @@ if(!template.parentNode){this.close();return}ArrayObserver.applySplices(this.ite var self=this;events.findController=function(){return self.model};var syntax=new PolymerExpressions;var prepareBinding=syntax.prepareBinding;syntax.prepareBinding=function(pathString,name,node){return events.prepareEventBinding(pathString,name,node)||prepareBinding.call(syntax,pathString,name,node)};return syntax}})})();Polymer.mixin2=function(prototype,mixin){if(mixin.mixinPublish){prototype.publish=prototype.publish||{};Polymer.mixin(prototype.publish,mixin.mixinPublish)}if(mixin.mixinDelegates){prototype.eventDelegates=prototype.eventDelegates||{};for(var e in mixin.mixinDelegates){if(!prototype.eventDelegates[e]){prototype.eventDelegates[e]=mixin.mixinDelegates[e]}}}if(mixin.mixinObserve){prototype.observe=prototype.observe||{};for(var o in mixin.mixinObserve){if(!prototype.observe[o]&&!prototype[o+"Changed"]){prototype.observe[o]=mixin.mixinObserve[o]}}}Polymer.mixin(prototype,mixin);delete prototype.mixinPublish;delete prototype.mixinDelegates;delete prototype.mixinObserve;return prototype};Polymer.CoreFocusable={mixinPublish:{active:{value:false,reflect:true},focused:{value:false,reflect:true},pressed:{value:false,reflect:true},disabled:{value:false,reflect:true},toggle:false},mixinDelegates:{contextMenu:"_contextMenuAction",down:"_downAction",up:"_upAction",focus:"_focusAction",blur:"_blurAction"},mixinObserve:{disabled:"_disabledChanged"},_disabledChanged:function(){if(this.disabled){this.style.pointerEvents="none";this.removeAttribute("tabindex");this.setAttribute("aria-disabled","")}else{this.style.pointerEvents="";this.setAttribute("tabindex",0);this.removeAttribute("aria-disabled")}},_downAction:function(){this.pressed=true;if(this.toggle){this.active=!this.active}else{this.active=true}},_contextMenuAction:function(e){this._upAction(e);this._focusAction()},_upAction:function(){this.pressed=false;if(!this.toggle){this.active=false}},_focusAction:function(){if(!this.pressed){this.focused=true}},_blurAction:function(){this.focused=false}};(function(scope){scope.CoreResizable={resizableAttachedHandler:function(cb){cb=cb||this._notifyResizeSelf;this.async(function(){var detail={callback:cb,hasParentResizer:false};this.fire("core-request-resize",detail);if(!detail.hasParentResizer){this._boundWindowResizeHandler=cb.bind(this);window.addEventListener("resize",this._boundWindowResizeHandler)}}.bind(this))},resizableDetachedHandler:function(){this.fire("core-request-resize-cancel",null,this,false);if(this._boundWindowResizeHandler){window.removeEventListener("resize",this._boundWindowResizeHandler)}},_notifyResizeSelf:function(){return this.fire("core-resize",null,this,false).defaultPrevented}};scope.CoreResizer=Polymer.mixin({resizerAttachedHandler:function(){this.resizableAttachedHandler(this.notifyResize);this._boundResizeRequested=this._boundResizeRequested||this._handleResizeRequested.bind(this);var listener;if(this.resizerIsPeer){listener=this.parentElement||this.parentNode&&this.parentNode.host;listener._resizerPeers=listener._resizerPeers||[];listener._resizerPeers.push(this)}else{listener=this}listener.addEventListener("core-request-resize",this._boundResizeRequested);this._resizerListener=listener},resizerDetachedHandler:function(){this.resizableDetachedHandler();this._resizerListener.removeEventListener("core-request-resize",this._boundResizeRequested)},notifyResize:function(){if(!this._notifyResizeSelf()){var r=this.resizeRequestors;if(r){for(var i=0;ia||a>1||0>c||c>1?y:function(e){function f(a,b,c){return 3*a*(1-c)*(1-c)*c+3*b*(1-c)*c*c+c*c*c}for(var g=0,h=1;;){var i=(g+h)/2,j=f(a,c,i);if(Math.abs(e-j)<.001)return f(b,d,i);e>j?g=i:h=i}}}function e(a,b){return function(c){if(c>=1)return 1;var d=1/a;return c+=b*d,c-c%d}}function f(a){var b=w.exec(a);if(b)return d.apply(this,b.slice(1).map(Number));var c=x.exec(a);if(c)return e(Number(c[1]),{start:r,middle:s,end:t}[c[2]]);var f=u[a];return f?f:y}function g(a){return Math.abs(h(a)/a.playbackRate)}function h(a){return a.duration*a.iterations}function i(a,b,c){return null==b?z:b=c.delay+a?B:C}function j(a,b,c,d,e){switch(d){case A:return"backwards"==b||"both"==b?0:null;case C:return c-e;case B:return"forwards"==b||"both"==b?a:null;case z:return null}}function k(a,b,c,d){return(d.playbackRate<0?b-a:b)*d.playbackRate+c}function l(a,b,c,d,e){return 1/0===c||c===-1/0||c-d==b&&e.iterations&&(e.iterations+e.iterationStart)%1==0?a:c%a}function m(a,b,c,d){return 0===c?0:b==a?d.iterationStart+d.iterations-1:Math.floor(c/a)}function n(a,b,c,d){var e=a%2>=1,f="normal"==d.direction||d.direction==(e?"alternate-reverse":"alternate"),g=f?c:b-c,h=g/b;return b*d.easing(h)}function o(a,b,c){var d=i(a,b,c),e=j(a,c.fill,b,d,c.delay);if(null===e)return null;if(0===a)return d===A?0:1;var f=c.iterationStart*c.duration,g=k(a,e,f,c),o=l(c.duration,h(c),g,f,c),p=m(c.duration,o,g,c);return n(p,c.duration,o,c)/c.duration}var p="backwards|forwards|both|none".split("|"),q="reverse|alternate|alternate-reverse".split("|"),r=1,s=.5,t=0,u={ease:d(.25,.1,.25,1),"ease-in":d(.42,0,1,1),"ease-out":d(0,0,.58,1),"ease-in-out":d(.42,0,.58,1),"step-start":e(1,r),"step-middle":e(1,s),"step-end":e(1,t)},v="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",w=new RegExp("cubic-bezier\\("+v+","+v+","+v+","+v+"\\)"),x=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/,y=function(a){return a},z=0,A=1,B=2,C=3;a.makeTiming=b,a.normalizeTimingInput=c,a.calculateActiveDuration=g,a.calculateTimeFraction=o,a.calculatePhase=i,a.toTimingFunction=f}(c,f),function(a){function b(a,b){return a in h?h[a][b]||b:b}function c(a,c,d){var g=e[a];if(g){f.style[a]=c;for(var h in g){var i=g[h],j=f.style[i];d[i]=b(i,j)}}else d[a]=b(a,c)}function d(b){function d(){var a=e.length;null==e[a-1].offset&&(e[a-1].offset=1),a>1&&null==e[0].offset&&(e[0].offset=0);for(var b=0,c=e[0].offset,d=1;a>d;d++){var f=e[d].offset;if(null!=f){for(var g=1;d-b>g;g++)e[b+g].offset=c+(f-c)*g/(d-b);b=d,c=f}}}if(!Array.isArray(b)&&null!==b)throw new TypeError("Keyframe effect must be null or an array of keyframes");if(null==b)return[];for(var e=b.map(function(b){var d={};for(var e in b){var f=b[e];if("offset"==e){if(null!=f&&(f=Number(f),!isFinite(f)))throw new TypeError("keyframe offsets must be numbers.")}else{if("composite"==e)throw{type:DOMException.NOT_SUPPORTED_ERR,name:"NotSupportedError",message:"add compositing is not supported"};f="easing"==e?a.toTimingFunction(f):""+f}c(e,f,d)}return void 0==d.offset&&(d.offset=null),void 0==d.easing&&(d.easing=a.toTimingFunction("linear")),d}),f=!0,g=-1/0,h=0;hi)throw{code:DOMException.INVALID_MODIFICATION_ERR,name:"InvalidModificationError",message:"Keyframes are not loosely sorted by offset. Sort or specify offsets."};g=i}else f=!1}return e=e.filter(function(a){return a.offset>=0&&a.offset<=1}),f||d(),e}var e={background:["backgroundImage","backgroundPosition","backgroundSize","backgroundRepeat","backgroundAttachment","backgroundOrigin","backgroundClip","backgroundColor"],border:["borderTopColor","borderTopStyle","borderTopWidth","borderRightColor","borderRightStyle","borderRightWidth","borderBottomColor","borderBottomStyle","borderBottomWidth","borderLeftColor","borderLeftStyle","borderLeftWidth"],borderBottom:["borderBottomWidth","borderBottomStyle","borderBottomColor"],borderColor:["borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"],borderLeft:["borderLeftWidth","borderLeftStyle","borderLeftColor"],borderRadius:["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"],borderRight:["borderRightWidth","borderRightStyle","borderRightColor"],borderTop:["borderTopWidth","borderTopStyle","borderTopColor"],borderWidth:["borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth"],flex:["flexGrow","flexShrink","flexBasis"],font:["fontFamily","fontSize","fontStyle","fontVariant","fontWeight","lineHeight"],margin:["marginTop","marginRight","marginBottom","marginLeft"],outline:["outlineColor","outlineStyle","outlineWidth"],padding:["paddingTop","paddingRight","paddingBottom","paddingLeft"]},f=document.createElementNS("http://www.w3.org/1999/xhtml","div"),g={thin:"1px",medium:"3px",thick:"5px"},h={borderBottomWidth:g,borderLeftWidth:g,borderRightWidth:g,borderTopWidth:g,fontSize:{"xx-small":"60%","x-small":"75%",small:"89%",medium:"100%",large:"120%","x-large":"150%","xx-large":"200%"},fontWeight:{normal:"400",bold:"700"},outlineWidth:g,textShadow:{none:"0px 0px 0px transparent"},boxShadow:{none:"0px 0px 0px 0px transparent"}};a.normalizeKeyframes=d}(c,f),function(a){var b={};a.isDeprecated=function(a,c,d,e){var f=e?"are":"is",g=new Date,h=new Date(c);return h.setMonth(h.getMonth()+3),h>g?(a in b||console.warn("Web Animations: "+a+" "+f+" deprecated and will stop working on "+h.toDateString()+". "+d),b[a]=!0,!1):!0},a.deprecated=function(b,c,d,e){if(a.isDeprecated(b,c,d,e))throw new Error(b+" "+auxVerb+" no longer supported. "+d)}}(c),function(){if(document.documentElement.animate){var a=document.documentElement.animate([],0),b=!0;if(a&&(b=!1,"play|currentTime|pause|reverse|playbackRate|cancel|finish|startTime|playState".split("|").forEach(function(c){void 0===a[c]&&(b=!0)})),!b)return}!function(a,b){b.AnimationNode=function(b){var c=a.calculateActiveDuration(b),d=function(d){return a.calculateTimeFraction(c,d,b)};return d._totalDuration=b.delay+c+b.endDelay,d._isCurrent=function(d){var e=a.calculatePhase(c,d,b);return e===PhaseActive||e===PhaseBefore},d}}(c,d),function(a,b){function c(a){for(var b={},c=0;c=c&&0==a.startTime||c>=1&&1==a.endTime||c>=a.startTime&&c<=a.endTime}).forEach(function(d){var e=c-d.startTime,f=d.endTime-d.startTime,g=0==f?0:d.easing(e/f);b.apply(a,d.property,d.interpolation(g))});else for(var d in g)"offset"!=d&&"easing"!=d&&"composite"!=d&&b.clear(a,d)}}}(c,d,f),function(a){function b(a,b,c){e[c]=e[c]||[],e[c].push([a,b])}function c(a,c,d){for(var e=0;ed?a:c;if(a.length==c.length){for(var e=[],f=0;f0?this._totalDuration:0),this._ensureAlive())},get currentTime(){return this._idle||this._currentTimePending?null:this._currentTime},set currentTime(b){b=+b,isNaN(b)||(a.restart(),this.paused||null==this._startTime||(this._startTime=this._timeline.currentTime-b/this._playbackRate),this._currentTimePending=!1,this._currentTime!=b&&(this._tickCurrentTime(b,!0),a.invalidateEffects()))},get startTime(){return this._startTime},set startTime(b){b=+b,isNaN(b)||this.paused||this._idle||(this._startTime=b,this._tickCurrentTime((this._timeline.currentTime-this._startTime)*this.playbackRate),a.invalidateEffects())},get playbackRate(){return this._playbackRate},set playbackRate(a){var b=this.currentTime;this._playbackRate=a,null!=b&&(this.currentTime=b)},get finished(){return!this._idle&&(this._playbackRate>0&&this._currentTime>=this._totalDuration||this._playbackRate<0&&this._currentTime<=0)},get _totalDuration(){return this._source._totalDuration},get playState(){return this._idle?"idle":null==this._startTime&&!this.paused&&0!=this.playbackRate||this._currentTimePending?"pending":this.paused?"paused":this.finished?"finished":"running"},play:function(){this.paused=!1,(this.finished||this._idle)&&(this._currentTime=this._playbackRate>0?0:this._totalDuration,this._startTime=null,a.invalidateEffects()),this._finishedFlag=!1,a.restart(),this._idle=!1,this._ensureAlive()},pause:function(){this.finished||this.paused||this._idle||(this._currentTimePending=!0),this._startTime=null,this.paused=!0},finish:function(){this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this._currentTimePending=!1)},cancel:function(){this._inEffect=!1,this._idle=!0,this.currentTime=0,this._startTime=null},reverse:function(){this._playbackRate*=-1,this._startTime=null,this.play()},addEventListener:function(a,b){"function"==typeof b&&"finish"==a&&this._finishHandlers.push(b)},removeEventListener:function(a,b){if("finish"==a){var c=this._finishHandlers.indexOf(b);c>=0&&this._finishHandlers.splice(c,1)}},_fireEvents:function(a){var b=this.finished;if((b||this._idle)&&!this._finishedFlag){var d=new c(this,this._currentTime,a),e=this._finishHandlers.concat(this.onfinish?[this.onfinish]:[]);setTimeout(function(){e.forEach(function(a){a.call(d.target,d)})},0)}this._finishedFlag=b},_tick:function(a){return this._idle||this.paused||(null==this._startTime?this.startTime=a-this._currentTime/this.playbackRate:this.finished||this._tickCurrentTime((a-this._startTime)*this.playbackRate)),this._currentTimePending=!1,this._fireEvents(a),!this._idle&&(this._inEffect||!this._finishedFlag)}}}(d,f),function(a,b){function c(a){var b=i;i=[],g(a),b.forEach(function(b){b[1](a)}),m&&g(a),f()}function d(a,b){return a._sequenceNumber-b._sequenceNumber}function e(){this._players=[],this.currentTime=window.performance&&performance.now?performance.now():0}function f(){n.forEach(function(a){a()}),n.length=0}function g(a){l=!1;var c=b.timeline;c.currentTime=a,c._players.sort(d),k=!1;var e=c._players;c._players=[];var f=[],g=[];e=e.filter(function(b){return b._inTimeline=b._tick(a),b._inEffect?g.push(b._source):f.push(b._source),b.finished||b.paused||b._idle||(k=!0),b._inTimeline}),n.push.apply(n,f),n.push.apply(n,g),c._players.push.apply(c._players,e),m=!1,k&&requestAnimationFrame(function(){})}var h=window.requestAnimationFrame,i=[],j=0;window.requestAnimationFrame=function(a){var b=j++;return 0==i.length&&h(c),i.push([b,a]),b},window.cancelAnimationFrame=function(a){i.forEach(function(b){b[0]==a&&(b[1]=function(){})})},e.prototype={_play:function(c){c._timing=a.normalizeTimingInput(c.timing);var d=new b.Player(c);return d._idle=!1,d._timeline=this,this._players.push(d),b.restart(),b.invalidateEffects(),d}};var k=!1,l=!1;b.restart=function(){return k||(k=!0,requestAnimationFrame(function(){}),l=!0),l};var m=!1;b.invalidateEffects=function(){m=!0};var n=[],o=window.getComputedStyle;Object.defineProperty(window,"getComputedStyle",{configurable:!0,enumerable:!0,value:function(){return m&&g(p.currentTime),f(),o.apply(this,arguments)}});var p=new e;b.timeline=p}(c,d,f),function(a){function b(a,b){var c=a.exec(b);return c?(c=a.ignoreCase?c[0].toLowerCase():c[0],[c,b.substr(c.length)]):void 0}function c(a,b){b=b.replace(/^\s*/,"");var c=a(b);return c?[c[0],c[1].replace(/^\s*/,"")]:void 0}function d(a,d,e){a=c.bind(null,a);for(var f=[];;){var g=a(e);if(!g)return[f,e];if(f.push(g[0]),e=g[1],g=b(d,e),!g||""==g[1])return[f,e];e=g[1]}}function e(a,b){for(var c=0,d=0;d=c))break;var e=a(b.substr(0,d));return void 0==e?void 0:[e,b.substr(d)]}function f(a,b){for(var c=a,d=b;c&&d;)c>d?c%=d:d%=c;return c=a*b/(c+d)}function g(a){return function(b){var c=a(b);return c&&(c[0]=void 0),c}}function h(a,b){return function(c){var d=a(c);return d?d:[b,c]}}function i(b,c){for(var d=[],e=0;ek;k++){var l=b(d[k%d.length],e[k%e.length]);if(!l)return;g.push(l[0]),h.push(l[1]),i.push(l[2])}return[g,h,function(b){var d=b.map(function(a,b){return i[b](a)}).join(c);return a?a(d):d}]}function k(a,b,c){for(var d=[],e=[],f=[],g=0,h=0;h=c?a:c>=1?b:"visible"}]:void 0}a.addPropertiesHandler(String,b,["visibility"])}(d),function(a){function b(a){a=a.trim(),e.fillStyle="#000",e.fillStyle=a;var b=e.fillStyle;if(e.fillStyle="#fff",e.fillStyle=a,b==e.fillStyle){e.fillRect(0,0,1,1);var c=e.getImageData(0,0,1,1).data;e.clearRect(0,0,1,1);var d=c[3]/255;return[c[0]*d,c[1]*d,c[2]*d,d]}}function c(b,c){return[b,c,function(b){function c(a){return Math.max(0,Math.min(255,a))}if(b[3])for(var d=0;3>d;d++)b[d]=Math.round(c(b[d]/b[3]));return b[3]=a.numberToString(a.clamp(0,1,b[3])),"rgba("+b.join(",")+")"}]}var d=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");d.width=d.height=1;var e=d.getContext("2d");a.addPropertiesHandler(b,c,["background-color","border-bottom-color","border-left-color","border-right-color","border-top-color","color","outline-color","text-decoration-color"]),a.consumeColor=a.consumeParenthesised.bind(null,b),a.mergeColors=c}(d,f),function(a,b){function c(a,b){if(b=b.trim().toLowerCase(),"0"==b&&"px".search(a)>=0)return{px:0};if(/^[^(]*$|^calc/.test(b)){b=b.replace(/calc\(/g,"(");var c={};b=b.replace(a,function(a){return c[a]=null,"U"+a});for(var d="U("+a.source+")",e=b.replace(/[-+]?(\d*\.)?\d+/g,"N").replace(new RegExp("N"+d,"g"),"D").replace(/\s[+-]\s/g,"O").replace(/\s/g,""),f=[/N\*(D)/g,/(N|D)[*/]N/g,/(N|D)O\1/g,/\((N|D)\)/g],g=0;g1?"calc("+c+")":c}]}var f="px|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc",g=c.bind(null,new RegExp(f,"g")),h=c.bind(null,new RegExp(f+"|%","g")),i=c.bind(null,/deg|rad|grad|turn/g);a.parseLength=g,a.parseLengthOrPercent=h,a.consumeLengthOrPercent=a.consumeParenthesised.bind(null,h),a.parseAngle=i,a.mergeDimensions=e;var j=a.consumeParenthesised.bind(null,g),k=a.consumeRepeated.bind(void 0,j,/^/),l=a.consumeRepeated.bind(void 0,k,/^,/);a.consumeSizePairList=l;var m=function(a){var b=l(a);return b&&""==b[1]?b[0]:void 0},n=a.mergeNestedRepeated.bind(void 0,d," "),o=a.mergeNestedRepeated.bind(void 0,n,",");a.mergeNonNegativeSizePair=n,a.addPropertiesHandler(m,o,["background-size"]),a.addPropertiesHandler(h,d,["border-bottom-width","border-image-width","border-left-width","border-right-width","border-top-width","flex-basis","font-size","height","line-height","max-height","max-width","outline-width","width"]),a.addPropertiesHandler(h,e,["border-bottom-left-radius","border-bottom-right-radius","border-top-left-radius","border-top-right-radius","bottom","left","letter-spacing","margin-bottom","margin-left","margin-right","margin-top","min-height","min-width","outline-offset","padding-bottom","padding-left","padding-right","padding-top","perspective","right","shape-margin","text-indent","top","vertical-align","word-spacing"])}(d,f),function(a){function b(b){return a.consumeLengthOrPercent(b)||a.consumeToken(/^auto/,b)}function c(c){var d=a.consumeList([a.ignore(a.consumeToken.bind(null,/^rect/)),a.ignore(a.consumeToken.bind(null,/^\(/)),a.consumeRepeated.bind(null,b,/^,/),a.ignore(a.consumeToken.bind(null,/^\)/))],c);return d&&4==d[0].length?d[0]:void 0}function d(b,c){return"auto"==b||"auto"==c?[!0,!1,function(d){var e=d?b:c;if("auto"==e)return"auto";var f=a.mergeDimensions(e,e);return f[2](f[0])}]:a.mergeDimensions(b,c)}function e(a){return"rect("+a+")"}var f=a.mergeWrappedNestedRepeated.bind(null,e,d,", ");a.parseBox=c,a.mergeBoxes=f,a.addPropertiesHandler(c,f,["clip"])}(d,f),function(a){function b(a){return function(b){var c=0;return a.map(function(a){return a===j?b[c++]:a})}}function c(a){return a}function d(b){if(b=b.toLowerCase().trim(),"none"==b)return[];for(var c,d=/\s*(\w+)\(([^)]*)\)/g,e=[],f=0;c=d.exec(b);){if(c.index!=f)return;f=c.index+c[0].length;var g=c[1],h=m[g];if(!h)return;var i=c[2].split(","),j=h[0];if(j.length=0){this.metaArray.splice(i,1)}},get list(){return this.metaArray},byId:function(id){return this.metaData[id]}})})();Polymer("core-iconset",{src:"",width:0,icons:"",iconSize:24,offsetX:0,offsetY:0,type:"iconset",created:function(){this.iconMap={};this.iconNames=[];this.themes={}},ready:function(){if(this.src&&this.ownerDocument!==document){this.src=this.resolvePath(this.src,this.ownerDocument.baseURI)}this.super();this.updateThemes()},iconsChanged:function(){var ox=this.offsetX;var oy=this.offsetY;this.icons&&this.icons.split(/\s+/g).forEach(function(name,i){this.iconNames.push(name);this.iconMap[name]={offsetX:ox,offsetY:oy};if(ox+this.iconSize=Math.min(wave.maxRadius,waveMaxRadius)}function waveAtMaximum(wave,radius,anim){var waveOpacity=waveOpacityFn(wave.tDown,wave.tUp,anim);return waveOpacity>=anim.initialOpacity&&radius>=Math.min(wave.maxRadius,waveMaxRadius)}function drawRipple(ctx,x,y,radius,innerAlpha,outerAlpha){if(outerAlpha!==undefined){ctx.bg.style.opacity=outerAlpha}ctx.wave.style.opacity=innerAlpha;var s=radius/(ctx.containerSize/2);var dx=x-ctx.containerWidth/2;var dy=y-ctx.containerHeight/2;ctx.wc.style.webkitTransform="translate3d("+dx+"px,"+dy+"px,0)";ctx.wc.style.transform="translate3d("+dx+"px,"+dy+"px,0)";ctx.wave.style.webkitTransform="scale("+s+","+s+")";ctx.wave.style.transform="scale3d("+s+","+s+",1)"}function createWave(elem){var elementStyle=window.getComputedStyle(elem);var fgColor=elementStyle.color;var inner=document.createElement("div");inner.style.backgroundColor=fgColor;inner.classList.add("wave");var outer=document.createElement("div");outer.classList.add("wave-container");outer.appendChild(inner);var container=elem.$.waves;container.appendChild(outer);elem.$.bg.style.backgroundColor=fgColor;var wave={bg:elem.$.bg,wc:outer,wave:inner,waveColor:fgColor,maxRadius:0,isMouseDown:false,mouseDownStart:0,mouseUpStart:0,tDown:0,tUp:0};return wave}function removeWaveFromScope(scope,wave){if(scope.waves){var pos=scope.waves.indexOf(wave);scope.waves.splice(pos,1);wave.wc.remove()}}var pow=Math.pow;var now=Date.now;if(window.performance&&performance.now){now=performance.now.bind(performance)}function cssColorWithAlpha(cssColor,alpha){var parts=cssColor.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(typeof alpha=="undefined"){alpha=1}if(!parts){return"rgba(255, 255, 255, "+alpha+")"}return"rgba("+parts[1]+", "+parts[2]+", "+parts[3]+", "+alpha+")"}function dist(p1,p2){return Math.sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2))}function distanceFromPointToFurthestCorner(point,size){var tl_d=dist(point,{x:0,y:0});var tr_d=dist(point,{x:size.w,y:0});var bl_d=dist(point,{x:0,y:size.h});var br_d=dist(point,{x:size.w,y:size.h});return Math.max(tl_d,tr_d,bl_d,br_d)}Polymer("paper-ripple",{initialOpacity:.25,opacityDecayVelocity:.8,backgroundFill:true,pixelDensity:2,eventDelegates:{down:"downAction",up:"upAction"},ready:function(){this.waves=[]},downAction:function(e){var wave=createWave(this);this.cancelled=false;wave.isMouseDown=true;wave.tDown=0;wave.tUp=0;wave.mouseUpStart=0;wave.mouseDownStart=now();var rect=this.getBoundingClientRect();var width=rect.width;var height=rect.height;var touchX=e.x-rect.left;var touchY=e.y-rect.top;wave.startPosition={x:touchX,y:touchY};if(this.classList.contains("recenteringTouch")){wave.endPosition={x:width/2,y:height/2};wave.slideDistance=dist(wave.startPosition,wave.endPosition)}wave.containerSize=Math.max(width,height);wave.containerWidth=width;wave.containerHeight=height;wave.maxRadius=distanceFromPointToFurthestCorner(wave.startPosition,{w:width,h:height});wave.wc.style.top=(wave.containerHeight-wave.containerSize)/2+"px";wave.wc.style.left=(wave.containerWidth-wave.containerSize)/2+"px";wave.wc.style.width=wave.containerSize+"px";wave.wc.style.height=wave.containerSize+"px";this.waves.push(wave);if(!this._loop){this._loop=this.animate.bind(this,{width:width,height:height});requestAnimationFrame(this._loop)}},upAction:function(){for(var i=0;i0){wave.tDown=now()-wave.mouseDownStart}if(wave.mouseUpStart>0){wave.tUp=now()-wave.mouseUpStart}var tUp=wave.tUp;var tDown=wave.tDown;longestTouchDownDuration=Math.max(longestTouchDownDuration,tDown);longestTouchUpDuration=Math.max(longestTouchUpDuration,tUp);var radius=waveRadiusFn(tDown,tUp,anim);var waveAlpha=waveOpacityFn(tDown,tUp,anim);var waveColor=cssColorWithAlpha(wave.waveColor,waveAlpha);lastWaveColor=wave.waveColor;var x=wave.startPosition.x;var y=wave.startPosition.y;if(wave.endPosition){var translateFraction=Math.min(1,radius/wave.containerSize*2/Math.sqrt(2));x+=translateFraction*(wave.endPosition.x-wave.startPosition.x);y+=translateFraction*(wave.endPosition.y-wave.startPosition.y)}var bgFillColor=null;if(this.backgroundFill){var bgFillAlpha=waveOuterOpacityFn(tDown,tUp,anim);bgFillColor=cssColorWithAlpha(wave.waveColor,bgFillAlpha)}drawRipple(wave,x,y,radius,waveAlpha,bgFillAlpha);var maximumWave=waveAtMaximum(wave,radius,anim);var waveDissipated=waveDidFinish(wave,radius,anim);var shouldKeepWave=!waveDissipated||maximumWave;var shouldRenderWaveAgain=wave.mouseUpStart?!waveDissipated:!maximumWave;shouldRenderNextFrame=shouldRenderNextFrame||shouldRenderWaveAgain;if(!shouldKeepWave||this.cancelled){deleteTheseWaves.push(wave)}}if(shouldRenderNextFrame){requestAnimationFrame(this._loop)}for(var i=0;i=0},setItemSelected:function(item,isSelected){if(item!==undefined&&item!==null){if(isSelected){this.selection.push(item)}else{var i=this.selection.indexOf(item);if(i>=0){this.selection.splice(i,1)}}this.fire("core-select",{isSelected:isSelected,item:item})}},select:function(item){if(this.multi){this.toggle(item)}else if(this.getSelection()!==item){this.setItemSelected(this.getSelection(),false);this.setItemSelected(item,true)}},toggle:function(item){this.setItemSelected(item,!this.isSelected(item))}});Polymer("core-selector",{selected:null,multi:false,valueattr:"name",selectedClass:"core-selected",selectedProperty:"",selectedAttribute:"active",selectedItem:null,selectedModel:null,selectedIndex:-1,excludedLocalNames:"",target:null,itemsSelector:"",activateEvent:"tap",notap:false,defaultExcludedLocalNames:"template",observe:{"selected multi":"selectedChanged"},ready:function(){this.activateListener=this.activateHandler.bind(this);this.itemFilter=this.filterItem.bind(this);this.excludedLocalNamesChanged();this.observer=new MutationObserver(this.updateSelected.bind(this));if(!this.target){this.target=this}},get items(){if(!this.target){return[]}var nodes=this.target!==this?this.itemsSelector?this.target.querySelectorAll(this.itemsSelector):this.target.children:this.$.items.getDistributedNodes();return Array.prototype.filter.call(nodes,this.itemFilter)},filterItem:function(node){return!this._excludedNames[node.localName]},excludedLocalNamesChanged:function(){this._excludedNames={};var s=this.defaultExcludedLocalNames;if(this.excludedLocalNames){s+=" "+this.excludedLocalNames}s.split(/\s+/g).forEach(function(n){this._excludedNames[n]=1},this)},targetChanged:function(old){if(old){this.removeListener(old);this.observer.disconnect();this.clearSelection()}if(this.target){this.addListener(this.target);this.observer.observe(this.target,{childList:true});this.updateSelected()}},addListener:function(node){Polymer.addEventListener(node,this.activateEvent,this.activateListener)},removeListener:function(node){Polymer.removeEventListener(node,this.activateEvent,this.activateListener)},get selection(){return this.$.selection.getSelection()},selectedChanged:function(){if(arguments.length===1){this.processSplices(arguments[0])}else{this.updateSelected()}},updateSelected:function(){this.validateSelected();if(this.multi){this.clearSelection(this.selected);this.selected&&this.selected.forEach(function(s){this.setValueSelected(s,true)},this)}else{this.valueToSelection(this.selected)}},validateSelected:function(){if(this.multi&&!Array.isArray(this.selected)&&this.selected!=null){this.selected=[this.selected]}else if(!this.multi&&Array.isArray(this.selected)){var s=this.selected[0];this.clearSelection([s]);this.selected=s}},processSplices:function(splices){for(var i=0,splice;splice=splices[i];i++){for(var j=0;j=0){var item=this.items[i];var s=this.valueForNode(item)||i;if(this.multi){if(this.selected){this.addRemoveSelected(s)}else{this.selected=[s]}}else{this.selected=s}this.asyncFire("core-activate",{item:item})}}},addRemoveSelected:function(value){var i=this.selected.indexOf(value);if(i>=0){this.selected.splice(i,1)}else{this.selected.push(value)}},findDistributedTarget:function(target,nodes){while(target&&target!=this){var i=Array.prototype.indexOf.call(nodes,target);if(i>=0){return i}target=target.parentNode}},selectIndex:function(index){var item=this.items[index];if(item){this.selected=this.valueForNode(item)||index;return item}},selectPrevious:function(wrapped){var i=wrapped&&!this.selectedIndex?this.items.length-1:this.selectedIndex-1;return this.selectIndex(i)},selectNext:function(wrapped){var i=wrapped&&this.selectedIndex>=this.items.length-1?0:this.selectedIndex+1;return this.selectIndex(i)}});(function(){window.CoreStyle=window.CoreStyle||{g:{},list:{},refMap:{}};Polymer("core-style",{publish:{ref:""},g:CoreStyle.g,refMap:CoreStyle.refMap,list:CoreStyle.list,ready:function(){if(this.id){this.provide()}else{this.registerRef(this.ref);if(!window.ShadowDOMPolyfill){this.require()}}},attached:function(){if(!this.id&&window.ShadowDOMPolyfill){this.require()}},provide:function(){this.register();if(this.textContent){this._completeProvide()}else{this.async(this._completeProvide)}},register:function(){var i=this.list[this.id];if(i){if(!Array.isArray(i)){this.list[this.id]=[i]}this.list[this.id].push(this)}else{this.list[this.id]=this}},_completeProvide:function(){this.createShadowRoot();this.domObserver=new MutationObserver(this.domModified.bind(this)).observe(this.shadowRoot,{subtree:true,characterData:true,childList:true});this.provideContent()},provideContent:function(){this.ensureTemplate();this.shadowRoot.textContent="";this.shadowRoot.appendChild(this.instanceTemplate(this.template));this.cssText=this.shadowRoot.textContent},ensureTemplate:function(){if(!this.template){this.template=this.querySelector("template:not([repeat]):not([bind])");if(!this.template){this.template=document.createElement("template");var n=this.firstChild;while(n){this.template.content.appendChild(n.cloneNode(true));n=n.nextSibling}}}},domModified:function(){this.cssText=this.shadowRoot.textContent;this.notify()},notify:function(){var s$=this.refMap[this.id];if(s$){for(var i=0,s;s=s$[i];i++){s.require()}}},registerRef:function(ref){this.refMap[this.ref]=this.refMap[this.ref]||[];this.refMap[this.ref].push(this)},applyRef:function(ref){this.ref=ref;this.registerRef(this.ref);this.require()},require:function(){var cssText=this.cssTextForRef(this.ref);if(cssText){this.ensureStyleElement();if(this.styleElement._cssText===cssText){return}this.styleElement._cssText=cssText;if(window.ShadowDOMPolyfill){this.styleElement.textContent=cssText;cssText=WebComponents.ShadowCSS.shimStyle(this.styleElement,this.getScopeSelector())}this.styleElement.textContent=cssText}},cssTextForRef:function(ref){var s$=this.byId(ref);var cssText="";if(s$){if(Array.isArray(s$)){var p=[];for(var i=0,l=s$.length,s;i=0;i--){m=shadows[i].querySelector(selector);if(m){return m}}while(el){m=queryShadow(el,selector);if(m){return m}el=el.nextElementSibling}return null}function _queryAllShadows(node,selector,results){var el=node.firstElementChild;var temp,sr,shadows,i,j;shadows=[];sr=node.shadowRoot;while(sr){shadows.push(sr);sr=sr.olderShadowRoot}for(i=shadows.length-1;i>=0;i--){temp=shadows[i].querySelectorAll(selector);for(j=0;j0?"&":"?")+params}var xhrParams=this.isBodyMethod(method)?options.body||params:null;xhr.open(method,url,async);if(options.responseType){xhr.responseType=options.responseType}if(options.withCredentials){xhr.withCredentials=true}this.makeReadyStateHandler(xhr,options.callback);this.setRequestHeaders(xhr,options.headers);xhr.send(xhrParams);if(!async){xhr.onreadystatechange(xhr)}return xhr},toQueryString:function(params){var r=[];for(var n in params){var v=params[n];n=encodeURIComponent(n);r.push(v==null?n:n+"="+encodeURIComponent(v))}return r.join("&")},isBodyMethod:function(method){return this.bodyMethods[(method||"").toUpperCase()]},bodyMethods:{POST:1,PUT:1,PATCH:1,DELETE:1},makeReadyStateHandler:function(xhr,callback){xhr.onreadystatechange=function(){if(xhr.readyState==4){callback&&callback.call(null,xhr.response,xhr)}}},setRequestHeaders:function(xhr,headers){if(headers){for(var name in headers){xhr.setRequestHeader(name,headers[name])}}}});Polymer("core-ajax",{url:"",handleAs:"",auto:false,params:"",response:null,error:null,loading:false,progress:null,method:"",headers:null,body:null,contentType:"application/x-www-form-urlencoded",withCredentials:false,xhrArgs:null,created:function(){this.progress={}},ready:function(){this.xhr=document.createElement("core-xhr")},receive:function(response,xhr){if(this.isSuccess(xhr)){this.processResponse(xhr)}else{this.processError(xhr)}this.complete(xhr)},isSuccess:function(xhr){var status=xhr.status||0;return status>=200&&status<300},processResponse:function(xhr){var response=this.evalResponse(xhr);if(xhr===this.activeRequest){this.response=response}this.fire("core-response",{response:response,xhr:xhr})},processError:function(xhr){var response=this.evalResponse(xhr);var error={statusCode:xhr.status,response:response};if(xhr===this.activeRequest){this.error=error}this.fire("core-error",{response:error,xhr:xhr})},processProgress:function(progress,xhr){if(xhr!==this.activeRequest){return}var progressProxy={lengthComputable:progress.lengthComputable,loaded:progress.loaded,total:progress.total};this.progress=progressProxy},complete:function(xhr){if(xhr===this.activeRequest){this.loading=false}this.fire("core-complete",{response:xhr.status,xhr:xhr})},evalResponse:function(xhr){return this[(this.handleAs||"text")+"Handler"](xhr)},xmlHandler:function(xhr){return xhr.responseXML},textHandler:function(xhr){return xhr.responseText},jsonHandler:function(xhr){var r=xhr.responseText;try{return JSON.parse(r)}catch(x){console.warn("core-ajax caught an exception trying to parse response as JSON:");console.warn("url:",this.url);console.warn(x);return r}},documentHandler:function(xhr){return xhr.response},blobHandler:function(xhr){return xhr.response},arraybufferHandler:function(xhr){return xhr.response},urlChanged:function(){if(!this.handleAs){var ext=String(this.url).split(".").pop();switch(ext){case"json":this.handleAs="json";break}}this.autoGo()},paramsChanged:function(){this.autoGo()},bodyChanged:function(){this.autoGo()},autoChanged:function(){this.autoGo()},autoGo:function(){if(this.auto){this.goJob=this.job(this.goJob,this.go,0)}},getParams:function(params){params=this.params||params;if(params&&typeof params=="string"){params=JSON.parse(params)}return params},go:function(){var args=this.xhrArgs||{};args.body=this.body||args.body;args.params=this.getParams(args.params);args.headers=this.headers||args.headers||{};if(args.headers&&typeof args.headers=="string"){args.headers=JSON.parse(args.headers)}var hasContentType=Object.keys(args.headers).some(function(header){return header.toLowerCase()==="content-type"});if(args.body instanceof FormData){delete args.headers["Content-Type"]}else if(!hasContentType&&this.contentType){args.headers["Content-Type"]=this.contentType}if(this.handleAs==="arraybuffer"||this.handleAs==="blob"||this.handleAs==="document"){args.responseType=this.handleAs}args.withCredentials=this.withCredentials;args.callback=this.receive.bind(this);args.url=this.url;args.method=this.method;this.response=this.error=this.progress=null;this.activeRequest=args.url&&this.xhr.request(args);if(this.activeRequest){this.loading=true;var activeRequest=this.activeRequest;if("onprogress"in activeRequest){this.activeRequest.addEventListener("progress",function(progress){this.processProgress(progress,activeRequest)}.bind(this),false)}else{this.progress={lengthComputable:false}}}return this.activeRequest},abort:function(){if(!this.activeRequest)return;this.activeRequest.abort();this.activeRequest=null;this.progress={};this.loading=false}});Polymer("core-item",{});(function(){function toNumber(value,allowInfinity){return allowInfinity&&value==="Infinity"?Number.POSITIVE_INFINITY:Number(value)}Polymer("core-animation",{publish:{target:{value:null,reflect:true},keyframes:{value:null,reflect:true},customEffect:{value:null,reflect:true},composite:{value:"replace",reflect:true},duration:{value:"auto",reflect:true},fill:{value:"auto",reflect:true},easing:{value:"linear",reflect:true},delay:{value:0,reflect:true},endDelay:{value:0,reflect:true},iterations:{value:1,reflect:true},iterationStart:{value:0,reflect:true},iterationComposite:{value:"replace",reflect:true},direction:{value:"normal",reflect:true},playbackRate:{value:1,reflect:true},autoplay:{value:false,reflect:true}},animation:false,observe:{target:"apply",keyframes:"apply",customEffect:"apply",composite:"apply",duration:"apply",fill:"apply",easing:"apply",iterations:"apply",iterationStart:"apply",iterationComposite:"apply",delay:"apply",endDelay:"apply",direction:"apply",playbackRate:"apply",autoplay:"apply"},ready:function(){this.apply()},play:function(){this.apply();if(this.animation&&!this.autoplay){this.player=document.timeline.play(this.animation);this.player.onfinish=this.animationFinishHandler.bind(this);return this.player}},cancel:function(){if(this.player){this.player.cancel()}},finish:function(){if(this.player){this.player.finish()}},pause:function(){if(this.player){this.player.pause()}},hasTarget:function(){return this.target!==null},apply:function(){this.animation=this.makeAnimation();if(this.autoplay&&this.animation){this.play()}return this.animation},makeSingleAnimation:function(target){target.classList.add("core-animation-target");return new Animation(target,this.animationEffect,this.timingProps)},makeAnimation:function(){if(!this.target){return null}var animation;if(Array.isArray(this.target)){var array=[];this.target.forEach(function(t){array.push(this.makeSingleAnimation(t))}.bind(this));animation=new AnimationGroup(array)}else{animation=this.makeSingleAnimation(this.target)}return animation},animationChanged:function(){this.fire("core-animation-change",this)},targetChanged:function(old){if(old){old.classList.remove("core-animation-target")}},get timingProps(){var props={};var timing={delay:{isNumber:true},endDelay:{isNumber:true},fill:{},iterationStart:{isNumber:true},iterations:{isNumber:true,allowInfinity:true},duration:{isNumber:true},playbackRate:{isNumber:true},direction:{},easing:{}};for(t in timing){if(this[t]!==null){var name=timing[t].property||t;props[name]=timing[t].isNumber&&this[t]!=="auto"?toNumber(this[t],timing[t].allowInfinity):this[t]}}return props},get animationEffect(){var props={};var frames=[];var effect;if(this.keyframes){frames=this.keyframes}else if(!this.customEffect){var children=this.querySelectorAll("core-animation-keyframe");if(children.length===0&&this.shadowRoot){children=this.shadowRoot.querySelectorAll("core-animation-keyframe")}Array.prototype.forEach.call(children,function(c){frames.push(c.properties)})}if(this.customEffect){effect=this.customEffect}else{effect=frames}return effect},animationFinishHandler:function(){this.fire("core-animation-finish")}})})();Polymer("core-animation-keyframe",{publish:{offset:{value:null,reflect:true}},get properties(){var props={};var children=this.querySelectorAll("core-animation-prop");Array.prototype.forEach.call(children,function(c){props[c.name]=c.value});if(this.offset!==null){props.offset=this.offset}return props}});Polymer("core-animation-prop",{publish:{name:{value:"",reflect:true},value:{value:"",reflect:true}}});Polymer("album-art",{moreLikeThis:chrome.i18n.getMessage("moreLikeThis"),backButton:chrome.i18n.getMessage("backButton"),playTrackLabel:chrome.i18n.getMessage("playTrack"),moreOptionsLabel:chrome.i18n.getMessage("moreOptionsLabel"),closeLabel:chrome.i18n.getMessage("closeLabel"),created:function(){"use strict";this.imgURL="../../../images/default-cover-art.png"},ready:function(){"use strict";this.page=this.page||"cover";this.artist=this.artist||"Artist Name";this.album=this.album||"Album Title";this.defaultImgURL="images/default-cover-art.png";this.app=document.getElementById("tmpl");this.audio=document.getElementById("audio");this.playerArt=document.getElementById("coverArt");this.app.colorThiefAlbum=this.app.colorThiefAlbum||"#db4437";this.app.colorThiefAlbumOff=this.app.colorThiefAlbumOff||"white";this.add2PlayQueue=chrome.i18n.getMessage("add2PlayQueue");this.favoriteAlbum=chrome.i18n.getMessage("favoriteAlbum");this.downloadButton=chrome.i18n.getMessage("downloadButton");this.albumTracklist=chrome.i18n.getMessage("albumTracklist")},listModeChanged:function(){"use strict";this.async(function(){if(this.listMode==="list"){this.page="small";this.width="520px";this.height="75px";this.style.margin="0px"}else{this.page="cover";this.width="250px";this.height="250px";this.style.margin="2px"}})},dbErrorHandler:function(e){"use strict";this.app.doToast(e);console.log(e)},setImage:function(event,callback){"use strict";var imgFile=event.target.result,imgURL=window.URL.createObjectURL(imgFile),imgElement,i=0;this.showArt(imgURL);this.isLoading=false;this.imgURL=imgURL;if(callback){callback(imgURL)}},showArt:function(image){"use strict";if(this.page==="cover"){this.async(function(){this.$.card.style.backgroundImage="url('"+image+"')"})}else if(this.page==="small"){this.async(function(){this.$.smallCover.style.backgroundImage="url('"+image+"')";this.$.card.style.backgroundImage=""})}this.$.topper.style.backgroundImage="url('"+image+"')";this.imgURL=image},defaultArt:function(){"use strict";this.showArt(this.defaultImgURL)},slideUp:function(){"use strict";this.page="info"},closeSlide:function(){"use strict";if(this.page==="info"){this.page="cover"}},doDialog:function(){"use strict";this.async(function(){this.app.dataLoading=false;this.app.tracker.sendAppView("Album Details");if(this.colorThiefEnabled&&this.playlist[0].palette){this.app.colorThiefAlbum=this.playlist[0].palette[0];this.app.colorThiefAlbumOff=this.playlist[0].palette[1]}this.closeSlide();this.$.detailsDialog.open();this.app.$.fab.state="mid";this.app.$.fab.ident=this.id})},closeDialog:function(){"use strict";this.app.tracker.sendAppView("Album Wall");this.$.detailsDialog.close();this.app.$.fab.state="off"},defaultPlayerImage:function(){"use strict";var art=this.app.$.coverArt;art.style.backgroundImage="url('images/default-cover-art.png')"},add2Playlist:function(){"use strict";this.app.dataLoading=false;var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+this.playlist[0].id;if(this.audio.paused){this.app.playing=0;this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,url,this.imgURL,this.playlist[0].id);this.app.getImageForPlayer(this.imgURL,function(){this.app.setFabColor(this.playlist[0])}.bind(this))}Array.prototype.forEach.call(this.playlist,function(e){this.app.playlist.push(e)}.bind(this));this.app.doToast(chrome.i18n.getMessage("added2Queue"))},doDownload:function(event,detail,sender){"use strict";var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();this.doQuery(function(){animation.cancel();window.open(this.url+"/rest/download.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+this.albumID,"_blank")}.bind(this))},playTrack:function(event,detail,sender){"use strict";this.app.setFabColor(this.playlist[0]);var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+sender.attributes.ident.value;this.$.detailsDialog.close();this.playerArt.style.backgroundImage="url('"+this.imgURL+"')";this.app.playlist=[{artist:sender.attributes.artist.value,title:sender.attributes.trackTitle.value,cover:this.imgURL,duration:sender.attributes.duration.value,id:sender.attributes.ident.value}];this.app.playing=0;this.app.playAudio(sender.attributes.artist.value,sender.attributes.trackTitle.value,url,this.imgURL,sender.attributes.ident.value);this.app.page=1},addSingle2Playlist:function(event,detail,sender){"use strict";var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+sender.attributes.ident.value,obj={id:sender.attributes.ident.value,artist:sender.attributes.artist.value,title:sender.attributes.trackTitle.value,duration:sender.attributes.duration.value,cover:this.imgURL};this.app.playlist.push(obj);if(this.audio.paused){this.app.setFabColor(this.playlist[0]);this.app.playAudio(sender.attributes.artist.value,sender.attributes.trackTitle.value,url,this.imgURL,sender.attributes.ident.value);this.app.playing=0;if(this.imgURL){this.playerArt.style.backgroundImage="url('"+this.imgURL+"')"}else{this.playerArt.style.backgroundImage="url('images/default-cover-art.png')"}}this.app.doToast(chrome.i18n.getMessage("added2Queue"))},playAlbum:function(){"use strict";this.app.dataLoading=false;this.$.detailsDialog.close();this.app.setFabColor(this.playlist[0]);var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+this.playlist[0].id;this.app.page=1;this.app.getImageForPlayer(this.imgURL,function(){this.app.playlist=this.playlist;this.app.playing=0;this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,url,this.imgURL,this.playlist[0].id)}.bind(this))},addFavorite:function(event,detail,sender){"use strict";var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();url=this.url+"/rest/star.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&albumId="+sender.attributes.ident.value;this.app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){this.isFavorite=true;animation.cancel()}}.bind(this))},removeFavorite:function(event,detail,sender){"use strict";var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();url=this.url+"/rest/unstar.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&albumId="+sender.attributes.ident.value;this.app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){this.isFavorite=false;animation.cancel()}}.bind(this))},paletteChanged:function(){"use strict";if(this.palette!==undefined){Array.prototype.forEach.call(this.playlist,function(element){element.palette=this.palette}.bind(this))}},getPalette:function(callback){"use strict";var artId="al-"+this.item;this.app.getDbItem(artId+"-palette",function(e){this.palette=e.target.result;this.async(callback)}.bind(this))},doPlayback:function(){"use strict";this.app.dataLoading=true;this.getPalette(function(){this.doQuery(this.playAlbum.bind(this))}.bind(this))},doDetails:function(){"use strict";this.app.dataLoading=true;this.getPalette(function(){this.doQuery(this.doDialog.bind(this))}.bind(this))},doAdd2Playlist:function(){"use strict";this.app.dataLoading=true;this.getPalette(function(){this.doQuery(this.add2Playlist.bind(this))}.bind(this))},processJSON:function(callback){"use strict";var i=0;this.playlist.length=0;this.albumID=this.trackResponse["subsonic-response"].album.song[0].parent;this.tracks=this.trackResponse["subsonic-response"].album.song;this.tracks.sort(function(a,b){var da=a.discNumber||0,db=b.discNumber||0,ta=a.track||0,tb=b.track||0;if(da===db){return ta-tb}else{return da-db}});this.async(function(){Array.prototype.forEach.call(this.tracks,function(e){var mins=Math.floor(e.duration/60),seconds=Math.floor(e.duration-mins*60),timeString=mins+":"+("0"+seconds).slice(-2),obj={id:e.id,artist:e.artist,title:e.title,duration:timeString,cover:this.imgURL,palette:this.palette,disk:e.diskNumber,track:e.track};this.playlist.push(obj);i=i+1;if(i===this.tracks.length){this.async(callback)}}.bind(this))})},doQuery:function(callback){"use strict";this.async(function(){this.app.getDbItem(this.item,function(event){if(event.target.result){this.trackResponse=event.target.result;this.async(function(){this.processJSON(callback)})}else{var url=this.url+"/rest/getAlbum.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+this.item;this.async(function(){this.app.doXhr(url,"json",function(e){this.trackResponse=e.target.response;this.async(function(){this.app.putInDb(this.trackResponse,this.item,function(){this.async(function(){this.processJSON(callback)});console.log("JSON Data Added to indexedDB "+this.item)}.bind(this))})}.bind(this))})}}.bind(this))})},itemChanged:function(){"use strict";this.async(function(){var artId="al-"+this.item,url=this.url+"/rest/getCoverArt.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&size=550&id="+artId;if(this.item){this.isLoading=true;this.defaultArt();this.playlist=null;this.playlist=[];this.async(function(){this.app.getDbItem(artId,function(e){if(e.target.result){this.setImage(e)}else{this.async(function(){this.app.getImageFile(url,artId,function(event){this.setImage(event,function(imgURL){this.async(function(){this.app.colorThiefHandler(imgURL,artId)})}.bind(this))}.bind(this))})}}.bind(this))})}})},moreLike:function(event,detail,sender){"use strict";var id=sender.attributes.ident.value,url=this.url+"/rest/getSimilarSongs.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&f=json&c=PolySonic&count=50&id="+id,i=0,array=[],callback=function(){this.app.getImageForPlayer(this.app.playlist[0].cover,function(){this.app.setFabColor(this.playlist[0]);var playURL=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+this.app.playlist[0].id;this.app.playing=0;this.app.playAudio(this.app.playlist[0].artist,this.app.playlist[0].title,playURL,this.app.playlist[0].cover,this.app.playlist[0].id);this.app.dataLoading=false;this.app.page=1}.bind(this))}.bind(this);this.$.detailsDialog.close();this.app.$.fab.state="off";this.app.dataLoading=true;this.app.doXhr(url,"json",function(e){var response=e.target.response["subsonic-response"].similarSongs.song;if(response){this.app.$.audio.pause();this.app.playlist=null;this.app.playlist=[];Array.prototype.forEach.call(response,function(element){var mins=Math.floor(element.duration/60),seconds=Math.floor(element.duration-mins*60),timeString=mins+":"+("0"+seconds).slice(-2),obj={id:element.id,artist:element.artist,title:element.title,duration:timeString},artId="al-"+element.albumId,url2=this.url+"/rest/getCoverArt.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&size=550&id="+artId;this.app.getDbItem(artId,function(ev){if(ev.target.result){var imgFile=ev.target.result,imgURL=window.URL.createObjectURL(imgFile);obj.cover=imgURL;this.app.getDbItem(artId+"-palette",function(e){obj.palette=e.target.result;this.app.playlist.push(obj);i=i+1;if(i===response.length){callback()}}.bind(this))}else{this.app.getImageFile(url2,artId,function(event){var imgFile=event.target.result,imgURL=window.URL.createObjectURL(imgFile);obj.cover=imgURL;this.app.colorThiefHandler(imgURL,artId,function(colorArray){obj.palette=colorArray;this.app.playlist.push(obj);i=i+1;if(i===response.length){callback()}}.bind(this))}.bind(this))}}.bind(this))}.bind(this))}else{this.app.dataLoading=false;this.app.doToast(chrome.i18n.getMessage("noResults"))}}.bind(this))}});Polymer("paper-spinner",{eventDelegates:{animationend:"reset",webkitAnimationEnd:"reset"},publish:{active:{value:false,reflect:true},alt:{value:"loading",reflect:true}},ready:function(){if(this.hasAttribute("aria-label")){this.alt=this.getAttribute("aria-label")}else{this.setAttribute("aria-label",this.alt)}if(!this.active){this.setAttribute("aria-hidden","true")}},activeChanged:function(){if(this.active){this.$.spinnerContainer.classList.remove("cooldown");this.$.spinnerContainer.classList.add("active");this.removeAttribute("aria-hidden")}else{this.$.spinnerContainer.classList.add("cooldown");this.setAttribute("aria-hidden","true")}},altChanged:function(){if(this.alt===""){this.setAttribute("aria-hidden","true")}else{this.removeAttribute("aria-hidden")}this.setAttribute("aria-label",this.alt)},reset:function(){this.$.spinnerContainer.classList.remove("active","cooldown")}});(function(){var KEY_IDENTIFIER={"U+0009":"tab","U+001B":"esc","U+0020":"space","U+002A":"*","U+0030":"0","U+0031":"1","U+0032":"2","U+0033":"3","U+0034":"4","U+0035":"5","U+0036":"6","U+0037":"7","U+0038":"8","U+0039":"9","U+0041":"a","U+0042":"b","U+0043":"c","U+0044":"d","U+0045":"e","U+0046":"f","U+0047":"g","U+0048":"h","U+0049":"i","U+004A":"j","U+004B":"k","U+004C":"l","U+004D":"m","U+004E":"n","U+004F":"o","U+0050":"p","U+0051":"q","U+0052":"r","U+0053":"s","U+0054":"t","U+0055":"u","U+0056":"v","U+0057":"w","U+0058":"x","U+0059":"y","U+005A":"z","U+007F":"del"};var KEY_CODE={9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del",106:"*"};var KEY_CHAR=/[a-z0-9*]/;function transformKey(key){var validKey="";if(key){var lKey=key.toLowerCase();if(lKey.length==1){if(KEY_CHAR.test(lKey)){validKey=lKey}}else if(lKey=="multiply"){validKey="*"}else{validKey=lKey}}return validKey}var IDENT_CHAR=/U\+/;function transformKeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(IDENT_CHAR.test(keyIdent)){validKey=KEY_IDENTIFIER[keyIdent]}else{validKey=keyIdent.toLowerCase()}}return validKey}function transformKeyCode(keyCode){var validKey="";if(Number(keyCode)){if(keyCode>=65&&keyCode<=90){validKey=String.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode<=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&keyCode<=57){validKey=String(48-keyCode)}else if(keyCode>=96&&keyCode<=105){validKey=String(96-keyCode)}else{validKey=KEY_CODE[keyCode]}}return validKey}function keyboardEventToKey(ev){var normalizedKey=transformKey(ev.key)||transformKeyIdentifier(ev.keyIdentifier)||transformKeyCode(ev.keyCode)||transformKey(ev.detail.key)||"";return{shift:ev.shiftKey,ctrl:ev.ctrlKey,meta:ev.metaKey,alt:ev.altKey,key:normalizedKey}}function stringToKey(keyCombo){var keys=keyCombo.split("+");var keyObj=Object.create(null);keys.forEach(function(key){if(key=="shift"){keyObj.shift=true}else if(key=="ctrl"){keyObj.ctrl=true}else if(key=="alt"){keyObj.alt=true}else{keyObj.key=key}});return keyObj}function keyMatches(a,b){return Boolean(a.alt)==Boolean(b.alt)&&Boolean(a.ctrl)==Boolean(b.ctrl)&&Boolean(a.shift)==Boolean(b.shift)&&a.key===b.key}function processKeys(ev){var current=keyboardEventToKey(ev);for(var i=0,dk;i=0;i--){m=shadows[i].querySelector(selector);if(m){return m}}while(el){m=queryShadow(el,selector);if(m){return m}el=el.nextElementSibling}return null}function _queryAllShadows(node,selector,results){var el=node.firstElementChild;var temp,sr,shadows,i,j;shadows=[];sr=node.shadowRoot;while(sr){shadows.push(sr);sr=sr.olderShadowRoot}for(i=shadows.length-1;i>=0;i--){temp=shadows[i].querySelectorAll(selector);for(j=0;j0?"&":"?")+params}var xhrParams=this.isBodyMethod(method)?options.body||params:null;xhr.open(method,url,async);if(options.responseType){xhr.responseType=options.responseType}if(options.withCredentials){xhr.withCredentials=true}this.makeReadyStateHandler(xhr,options.callback);this.setRequestHeaders(xhr,options.headers);xhr.send(xhrParams);if(!async){xhr.onreadystatechange(xhr)}return xhr},toQueryString:function(params){var r=[];for(var n in params){var v=params[n];n=encodeURIComponent(n);r.push(v==null?n:n+"="+encodeURIComponent(v))}return r.join("&")},isBodyMethod:function(method){return this.bodyMethods[(method||"").toUpperCase()]},bodyMethods:{POST:1,PUT:1,PATCH:1,DELETE:1},makeReadyStateHandler:function(xhr,callback){xhr.onreadystatechange=function(){if(xhr.readyState==4){callback&&callback.call(null,xhr.response,xhr)}}},setRequestHeaders:function(xhr,headers){if(headers){for(var name in headers){xhr.setRequestHeader(name,headers[name])}}}});Polymer("core-ajax",{url:"",handleAs:"",auto:false,params:"",response:null,error:null,loading:false,progress:null,method:"",headers:null,body:null,contentType:"application/x-www-form-urlencoded",withCredentials:false,xhrArgs:null,created:function(){this.progress={}},ready:function(){this.xhr=document.createElement("core-xhr")},receive:function(response,xhr){if(this.isSuccess(xhr)){this.processResponse(xhr)}else{this.processError(xhr)}this.complete(xhr)},isSuccess:function(xhr){var status=xhr.status||0;return status>=200&&status<300},processResponse:function(xhr){var response=this.evalResponse(xhr);if(xhr===this.activeRequest){this.response=response}this.fire("core-response",{response:response,xhr:xhr})},processError:function(xhr){var response=this.evalResponse(xhr);var error={statusCode:xhr.status,response:response};if(xhr===this.activeRequest){this.error=error}this.fire("core-error",{response:error,xhr:xhr})},processProgress:function(progress,xhr){if(xhr!==this.activeRequest){return}var progressProxy={lengthComputable:progress.lengthComputable,loaded:progress.loaded,total:progress.total};this.progress=progressProxy},complete:function(xhr){if(xhr===this.activeRequest){this.loading=false}this.fire("core-complete",{response:xhr.status,xhr:xhr})},evalResponse:function(xhr){return this[(this.handleAs||"text")+"Handler"](xhr)},xmlHandler:function(xhr){return xhr.responseXML},textHandler:function(xhr){return xhr.responseText},jsonHandler:function(xhr){var r=xhr.responseText;try{return JSON.parse(r)}catch(x){console.warn("core-ajax caught an exception trying to parse response as JSON:");console.warn("url:",this.url);console.warn(x);return r}},documentHandler:function(xhr){return xhr.response},blobHandler:function(xhr){return xhr.response},arraybufferHandler:function(xhr){return xhr.response},urlChanged:function(){if(!this.handleAs){var ext=String(this.url).split(".").pop();switch(ext){case"json":this.handleAs="json";break}}this.autoGo()},paramsChanged:function(){this.autoGo()},bodyChanged:function(){this.autoGo()},autoChanged:function(){this.autoGo()},autoGo:function(){if(this.auto){this.goJob=this.job(this.goJob,this.go,0)}},getParams:function(params){params=this.params||params;if(params&&typeof params=="string"){params=JSON.parse(params)}return params},go:function(){var args=this.xhrArgs||{};args.body=this.body||args.body;args.params=this.getParams(args.params);args.headers=this.headers||args.headers||{};if(args.headers&&typeof args.headers=="string"){args.headers=JSON.parse(args.headers)}var hasContentType=Object.keys(args.headers).some(function(header){return header.toLowerCase()==="content-type"});if(args.body instanceof FormData){delete args.headers["Content-Type"]}else if(!hasContentType&&this.contentType){args.headers["Content-Type"]=this.contentType}if(this.handleAs==="arraybuffer"||this.handleAs==="blob"||this.handleAs==="document"){args.responseType=this.handleAs}args.withCredentials=this.withCredentials;args.callback=this.receive.bind(this);args.url=this.url;args.method=this.method;this.response=this.error=this.progress=null;this.activeRequest=args.url&&this.xhr.request(args);if(this.activeRequest){this.loading=true;var activeRequest=this.activeRequest;if("onprogress"in activeRequest){this.activeRequest.addEventListener("progress",function(progress){this.processProgress(progress,activeRequest)}.bind(this),false)}else{this.progress={lengthComputable:false}}}return this.activeRequest},abort:function(){if(!this.activeRequest)return;this.activeRequest.abort();this.activeRequest=null;this.progress={};this.loading=false}});Polymer("core-item",{});(function(){function toNumber(value,allowInfinity){return allowInfinity&&value==="Infinity"?Number.POSITIVE_INFINITY:Number(value)}Polymer("core-animation",{publish:{target:{value:null,reflect:true},keyframes:{value:null,reflect:true},customEffect:{value:null,reflect:true},composite:{value:"replace",reflect:true},duration:{value:"auto",reflect:true},fill:{value:"auto",reflect:true},easing:{value:"linear",reflect:true},delay:{value:0,reflect:true},endDelay:{value:0,reflect:true},iterations:{value:1,reflect:true},iterationStart:{value:0,reflect:true},iterationComposite:{value:"replace",reflect:true},direction:{value:"normal",reflect:true},playbackRate:{value:1,reflect:true},autoplay:{value:false,reflect:true}},animation:false,observe:{target:"apply",keyframes:"apply",customEffect:"apply",composite:"apply",duration:"apply",fill:"apply",easing:"apply",iterations:"apply",iterationStart:"apply",iterationComposite:"apply",delay:"apply",endDelay:"apply",direction:"apply",playbackRate:"apply",autoplay:"apply"},ready:function(){this.apply()},play:function(){this.apply();if(this.animation&&!this.autoplay){this.player=document.timeline.play(this.animation);this.player.onfinish=this.animationFinishHandler.bind(this);return this.player}},cancel:function(){if(this.player){this.player.cancel()}},finish:function(){if(this.player){this.player.finish()}},pause:function(){if(this.player){this.player.pause()}},hasTarget:function(){return this.target!==null},apply:function(){this.animation=this.makeAnimation();if(this.autoplay&&this.animation){this.play()}return this.animation},makeSingleAnimation:function(target){target.classList.add("core-animation-target");return new Animation(target,this.animationEffect,this.timingProps)},makeAnimation:function(){if(!this.target){return null}var animation;if(Array.isArray(this.target)){var array=[];this.target.forEach(function(t){array.push(this.makeSingleAnimation(t))}.bind(this));animation=new AnimationGroup(array)}else{animation=this.makeSingleAnimation(this.target)}return animation},animationChanged:function(){this.fire("core-animation-change",this)},targetChanged:function(old){if(old){old.classList.remove("core-animation-target")}},get timingProps(){var props={};var timing={delay:{isNumber:true},endDelay:{isNumber:true},fill:{},iterationStart:{isNumber:true},iterations:{isNumber:true,allowInfinity:true},duration:{isNumber:true},playbackRate:{isNumber:true},direction:{},easing:{}};for(t in timing){if(this[t]!==null){var name=timing[t].property||t;props[name]=timing[t].isNumber&&this[t]!=="auto"?toNumber(this[t],timing[t].allowInfinity):this[t]}}return props},get animationEffect(){var props={};var frames=[];var effect;if(this.keyframes){frames=this.keyframes}else if(!this.customEffect){var children=this.querySelectorAll("core-animation-keyframe");if(children.length===0&&this.shadowRoot){children=this.shadowRoot.querySelectorAll("core-animation-keyframe")}Array.prototype.forEach.call(children,function(c){frames.push(c.properties)})}if(this.customEffect){effect=this.customEffect}else{effect=frames}return effect},animationFinishHandler:function(){this.fire("core-animation-finish")}})})();Polymer("core-animation-keyframe",{publish:{offset:{value:null,reflect:true}},get properties(){var props={};var children=this.querySelectorAll("core-animation-prop");Array.prototype.forEach.call(children,function(c){props[c.name]=c.value});if(this.offset!==null){props.offset=this.offset}return props}});Polymer("core-animation-prop",{publish:{name:{value:"",reflect:true},value:{value:"",reflect:true}}});Polymer("album-art",{moreLikeThis:chrome.i18n.getMessage("moreLikeThis"),backButton:chrome.i18n.getMessage("backButton"),playTrackLabel:chrome.i18n.getMessage("playTrack"),moreOptionsLabel:chrome.i18n.getMessage("moreOptionsLabel"),closeLabel:chrome.i18n.getMessage("closeLabel"),created:function(){"use strict";this.imgURL="../../../images/default-cover-art.png"},ready:function(){"use strict";this.page=this.page||"cover";this.artist=this.artist||"Artist Name";this.album=this.album||"Album Title";this.defaultImgURL="images/default-cover-art.png";this.app=document.getElementById("tmpl");this.audio=document.getElementById("audio");this.playerArt=document.getElementById("coverArt");this.app.colorThiefAlbum=this.app.colorThiefAlbum||"#db4437";this.app.colorThiefAlbumOff=this.app.colorThiefAlbumOff||"white";this.add2PlayQueue=chrome.i18n.getMessage("add2PlayQueue");this.favoriteAlbum=chrome.i18n.getMessage("favoriteAlbum");this.downloadButton=chrome.i18n.getMessage("downloadButton");this.albumTracklist=chrome.i18n.getMessage("albumTracklist")},listModeChanged:function(){"use strict";this.async(function(){if(this.listMode==="list"){this.page="small";this.width="520px";this.height="75px";this.style.margin="0px"}else{this.page="cover";this.width="250px";this.height="250px";this.style.margin="2px"}})},dbErrorHandler:function(e){"use strict";this.app.doToast(e);console.log(e)},setImage:function(event,callback){"use strict";var imgFile=event.target.result,imgURL=window.URL.createObjectURL(imgFile),imgElement,i=0;this.showArt(imgURL);this.isLoading=false;this.imgURL=imgURL;if(callback){callback(imgURL)}},showArt:function(image){"use strict";if(this.page==="cover"){this.async(function(){this.$.card.style.backgroundImage="url('"+image+"')"})}else if(this.page==="small"){this.async(function(){this.$.smallCover.style.backgroundImage="url('"+image+"')";this.$.card.style.backgroundImage=""})}this.$.topper.style.backgroundImage="url('"+image+"')";this.imgURL=image},defaultArt:function(){"use strict";this.showArt(this.defaultImgURL)},slideUp:function(){"use strict";this.page="info"},closeSlide:function(){"use strict";if(this.page==="info"){this.page="cover"}},doDialog:function(){"use strict";this.async(function(){this.app.dataLoading=false;this.app.tracker.sendAppView("Album Details");if(this.colorThiefEnabled&&this.playlist[0].palette){this.app.colorThiefAlbum=this.playlist[0].palette[0];this.app.colorThiefAlbumOff=this.playlist[0].palette[1]}this.closeSlide();this.$.detailsDialog.open();this.app.$.fab.state="mid";this.app.$.fab.ident=this.id})},closeDialog:function(){"use strict";this.app.tracker.sendAppView("Album Wall");this.$.detailsDialog.close();this.app.$.fab.state="off"},defaultPlayerImage:function(){"use strict";var art=this.app.$.coverArt;art.style.backgroundImage="url('images/default-cover-art.png')"},add2Playlist:function(){"use strict";this.app.dataLoading=false;var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+this.playlist[0].id;if(this.audio.paused){this.app.playing=0;this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,url,this.imgURL,this.playlist[0].id);this.app.getImageForPlayer(this.imgURL,function(){this.app.setFabColor(this.playlist[0])}.bind(this))}Array.prototype.forEach.call(this.playlist,function(e){this.app.playlist.push(e)}.bind(this));this.app.doToast(chrome.i18n.getMessage("added2Queue"))},doDownload:function(event,detail,sender){"use strict";var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();this.doQuery(function(){animation.cancel();window.open(this.url+"/rest/download.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+this.albumID,"_blank")}.bind(this))},playTrack:function(event,detail,sender){"use strict";this.app.setFabColor(this.playlist[0]);var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+sender.attributes.ident.value;this.$.detailsDialog.close();this.playerArt.style.backgroundImage="url('"+this.imgURL+"')";this.app.playlist=[{artist:sender.attributes.artist.value,title:sender.attributes.trackTitle.value,cover:this.imgURL,duration:sender.attributes.duration.value,id:sender.attributes.ident.value}];this.app.playing=0;this.app.playAudio(sender.attributes.artist.value,sender.attributes.trackTitle.value,url,this.imgURL,sender.attributes.ident.value);this.app.page=1},addSingle2Playlist:function(event,detail,sender){"use strict";var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+sender.attributes.ident.value,obj={id:sender.attributes.ident.value,artist:sender.attributes.artist.value,title:sender.attributes.trackTitle.value,duration:sender.attributes.duration.value,cover:this.imgURL};this.app.playlist.push(obj);if(this.audio.paused){this.app.setFabColor(this.playlist[0]);this.app.playAudio(sender.attributes.artist.value,sender.attributes.trackTitle.value,url,this.imgURL,sender.attributes.ident.value);this.app.playing=0;if(this.imgURL){this.playerArt.style.backgroundImage="url('"+this.imgURL+"')"}else{this.playerArt.style.backgroundImage="url('images/default-cover-art.png')"}}this.app.doToast(chrome.i18n.getMessage("added2Queue"))},playAlbum:function(){"use strict";this.app.dataLoading=false;this.$.detailsDialog.close();this.app.setFabColor(this.playlist[0]);var url=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+this.playlist[0].id;this.app.page=1;this.app.getImageForPlayer(this.imgURL,function(){this.app.playlist=this.playlist;this.app.playing=0;this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,url,this.imgURL,this.playlist[0].id)}.bind(this))},addFavorite:function(event,detail,sender){"use strict";var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();url=this.url+"/rest/star.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&albumId="+sender.attributes.ident.value;this.app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){this.isFavorite=true;animation.cancel()}}.bind(this))},removeFavorite:function(event,detail,sender){"use strict";var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();url=this.url+"/rest/unstar.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&albumId="+sender.attributes.ident.value;this.app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){this.isFavorite=false;animation.cancel()}}.bind(this))},paletteChanged:function(){"use strict";if(this.palette!==undefined){Array.prototype.forEach.call(this.playlist,function(element){element.palette=this.palette}.bind(this))}},getPalette:function(callback){"use strict";var artId="al-"+this.item;this.app.getDbItem(artId+"-palette",function(e){this.palette=e.target.result;this.async(callback)}.bind(this))},doPlayback:function(){"use strict";this.app.dataLoading=true;this.getPalette(function(){this.doQuery(this.playAlbum.bind(this))}.bind(this))},doDetails:function(){"use strict";this.app.dataLoading=true;this.getPalette(function(){this.doQuery(this.doDialog.bind(this))}.bind(this))},doAdd2Playlist:function(){"use strict";this.app.dataLoading=true;this.getPalette(function(){this.doQuery(this.add2Playlist.bind(this))}.bind(this))},processJSON:function(callback){"use strict";var i=0;this.playlist.length=0;this.albumID=this.trackResponse["subsonic-response"].album.song[0].parent;this.tracks=this.trackResponse["subsonic-response"].album.song;this.tracks.sort(function(a,b){var da=a.discNumber||0,db=b.discNumber||0,ta=a.track||0,tb=b.track||0;if(da===db){return ta-tb}else{return da-db}});this.async(function(){Array.prototype.forEach.call(this.tracks,function(e){var mins=Math.floor(e.duration/60),seconds=Math.floor(e.duration-mins*60),timeString=mins+":"+("0"+seconds).slice(-2),obj={id:e.id,artist:e.artist,title:e.title,duration:timeString,cover:this.imgURL,palette:this.palette,disk:e.diskNumber,track:e.track};this.playlist.push(obj);i=i+1;if(i===this.tracks.length){callback()}}.bind(this))})},doQuery:function(callback){"use strict";this.async(function(){this.app.getDbItem(this.item,function(event){if(event.target.result){this.trackResponse=event.target.result;this.async(function(){this.processJSON(callback)})}else{var url=this.url+"/rest/getAlbum.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+this.item;this.app.doXhr(url,"json",function(e){this.trackResponse=e.target.response;this.async(function(){this.processJSON(callback);this.app.putInDb(this.trackResponse,this.item,function(){console.log("JSON Data Added to indexedDB "+this.item)}.bind(this))})}.bind(this))}}.bind(this))})},itemChanged:function(){"use strict";this.async(function(){var artId="al-"+this.item,url=this.url+"/rest/getCoverArt.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&size=550&id="+artId;if(this.item){this.isLoading=true;this.defaultArt();this.playlist=null;this.playlist=[];this.async(function(){this.app.getDbItem(artId,function(e){if(e.target.result){this.setImage(e)}else{this.app.getImageFile(url,artId,function(event){this.setImage(event,function(imgURL){this.async(function(){this.app.colorThiefHandler(imgURL,artId)})}.bind(this))}.bind(this))}}.bind(this))})}})},moreLike:function(event,detail,sender){"use strict";var id=sender.attributes.ident.value,url=this.url+"/rest/getSimilarSongs.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&f=json&c=PolySonic&count=50&id="+id,i=0,array=[],callback=function(){this.app.getImageForPlayer(this.app.playlist[0].cover,function(){this.app.playing=0;var playURL=this.url+"/rest/stream.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&maxBitRate="+this.bitRate+"&id="+this.app.playlist[0].id;this.app.setFabColor(this.app.playlist[0]);this.app.playAudio(this.app.playlist[0].artist,this.app.playlist[0].title,playURL,this.app.playlist[0].cover,this.app.playlist[0].id);this.app.dataLoading=false;this.app.page=1}.bind(this))}.bind(this);this.$.detailsDialog.close();this.app.$.fab.state="off";this.app.dataLoading=true;this.app.doXhr(url,"json",function(e){var response=e.target.response["subsonic-response"].similarSongs.song;if(response){this.app.$.audio.pause();this.app.playlist=null;this.app.playlist=[];Array.prototype.forEach.call(response,function(element){var mins=Math.floor(element.duration/60),seconds=Math.floor(element.duration-mins*60),timeString=mins+":"+("0"+seconds).slice(-2),obj={id:element.id,artist:element.artist,title:element.title,duration:timeString},artId="al-"+element.albumId,url2=this.url+"/rest/getCoverArt.view?u="+this.user+"&p="+this.pass+"&v="+this.version+"&c=PolySonic&size=550&id="+artId;this.app.getDbItem(artId,function(ev){if(ev.target.result){var imgFile=ev.target.result,imgURL=window.URL.createObjectURL(imgFile);obj.cover=imgURL;this.app.getDbItem(artId+"-palette",function(e){obj.palette=e.target.result;this.app.playlist.push(obj);i=i+1;if(i===response.length){callback()}}.bind(this))}else{this.app.getImageFile(url2,artId,function(event){var imgFile=event.target.result,imgURL=window.URL.createObjectURL(imgFile);obj.cover=imgURL;this.app.colorThiefHandler(imgURL,artId,function(colorArray){obj.palette=colorArray;this.app.playlist.push(obj);i=i+1;if(i===response.length){callback()}}.bind(this))}.bind(this))}}.bind(this))}.bind(this))}else{this.app.dataLoading=false;this.app.doToast(chrome.i18n.getMessage("noResults"))}}.bind(this))}});Polymer("paper-spinner",{eventDelegates:{animationend:"reset",webkitAnimationEnd:"reset"},publish:{active:{value:false,reflect:true},alt:{value:"loading",reflect:true}},ready:function(){if(this.hasAttribute("aria-label")){this.alt=this.getAttribute("aria-label")}else{this.setAttribute("aria-label",this.alt)}if(!this.active){this.setAttribute("aria-hidden","true")}},activeChanged:function(){if(this.active){this.$.spinnerContainer.classList.remove("cooldown");this.$.spinnerContainer.classList.add("active");this.removeAttribute("aria-hidden")}else{this.$.spinnerContainer.classList.add("cooldown");this.setAttribute("aria-hidden","true")}},altChanged:function(){if(this.alt===""){this.setAttribute("aria-hidden","true")}else{this.removeAttribute("aria-hidden")}this.setAttribute("aria-label",this.alt)},reset:function(){this.$.spinnerContainer.classList.remove("active","cooldown")}});(function(){var KEY_IDENTIFIER={"U+0009":"tab","U+001B":"esc","U+0020":"space","U+002A":"*","U+0030":"0","U+0031":"1","U+0032":"2","U+0033":"3","U+0034":"4","U+0035":"5","U+0036":"6","U+0037":"7","U+0038":"8","U+0039":"9","U+0041":"a","U+0042":"b","U+0043":"c","U+0044":"d","U+0045":"e","U+0046":"f","U+0047":"g","U+0048":"h","U+0049":"i","U+004A":"j","U+004B":"k","U+004C":"l","U+004D":"m","U+004E":"n","U+004F":"o","U+0050":"p","U+0051":"q","U+0052":"r","U+0053":"s","U+0054":"t","U+0055":"u","U+0056":"v","U+0057":"w","U+0058":"x","U+0059":"y","U+005A":"z","U+007F":"del"};var KEY_CODE={9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del",106:"*"};var KEY_CHAR=/[a-z0-9*]/;function transformKey(key){var validKey="";if(key){var lKey=key.toLowerCase();if(lKey.length==1){if(KEY_CHAR.test(lKey)){validKey=lKey}}else if(lKey=="multiply"){validKey="*"}else{validKey=lKey}}return validKey}var IDENT_CHAR=/U\+/;function transformKeyIdentifier(keyIdent){var validKey="";if(keyIdent){if(IDENT_CHAR.test(keyIdent)){validKey=KEY_IDENTIFIER[keyIdent]}else{validKey=keyIdent.toLowerCase()}}return validKey}function transformKeyCode(keyCode){var validKey="";if(Number(keyCode)){if(keyCode>=65&&keyCode<=90){validKey=String.fromCharCode(32+keyCode)}else if(keyCode>=112&&keyCode<=123){validKey="f"+(keyCode-112)}else if(keyCode>=48&&keyCode<=57){validKey=String(48-keyCode)}else if(keyCode>=96&&keyCode<=105){validKey=String(96-keyCode)}else{validKey=KEY_CODE[keyCode]}}return validKey}function keyboardEventToKey(ev){var normalizedKey=transformKey(ev.key)||transformKeyIdentifier(ev.keyIdentifier)||transformKeyCode(ev.keyCode)||transformKey(ev.detail.key)||"";return{shift:ev.shiftKey,ctrl:ev.ctrlKey,meta:ev.metaKey,alt:ev.altKey,key:normalizedKey}}function stringToKey(keyCombo){var keys=keyCombo.split("+");var keyObj=Object.create(null);keys.forEach(function(key){if(key=="shift"){keyObj.shift=true}else if(key=="ctrl"){keyObj.ctrl=true}else if(key=="alt"){keyObj.alt=true}else{keyObj.key=key}});return keyObj}function keyMatches(a,b){return Boolean(a.alt)==Boolean(b.alt)&&Boolean(a.ctrl)==Boolean(b.ctrl)&&Boolean(a.shift)==Boolean(b.shift)&&a.key===b.key}function processKeys(ev){var current=keyboardEventToKey(ev);for(var i=0,dk;i=0){overlays.splice(i,1);setZ(overlay,"")}}function applyOverlayZ(overlay,aboveZ){setZ(overlay.target,aboveZ+2)}function setZ(element,z){element.style.zIndex=z}function currentOverlay(){return overlays[overlays.length-1]}var DEFAULT_Z=10;function currentOverlayZ(){var z;var current=currentOverlay();if(current){var z1=window.getComputedStyle(current.target).zIndex;if(!isNaN(z1)){z=Number(z1)}}return z||DEFAULT_Z}function focusOverlay(){var current=currentOverlay();if(current&&!current.transitioning){current.applyFocus()}}var backdrops=[];function trackBackdrop(element){if(element.opened){backdrops.push(element)}else{var i=backdrops.indexOf(element);if(i>=0){backdrops.splice(i,1)}}}function getBackdrops(){return backdrops}})();Polymer("core-transition-css",{baseClass:"core-transition",openedClass:"core-opened",closedClass:"core-closed",completeEventName:"transitionend",publish:{transitionType:null},registerCallback:function(element){this.transitionStyle=element.templateContent().firstElementChild},fetchTemplate:function(){return null},go:function(node,state){if(state.opened!==undefined){this.transitionOpened(node,state.opened)}},setup:function(node){if(!node._hasTransitionStyle){if(!node.shadowRoot){node.createShadowRoot().innerHTML=""}this.installScopeStyle(this.transitionStyle,"transition",node.shadowRoot);node._hasTransitionStyle=true}node.classList.add(this.baseClass);if(this.transitionType){node.classList.add(this.baseClass+"-"+this.transitionType)}},teardown:function(node){node.classList.remove(this.baseClass);if(this.transitionType){node.classList.remove(this.baseClass+"-"+this.transitionType)}},transitionOpened:function(node,opened){this.listenOnce(node,this.completeEventName,function(){if(!opened){node.classList.remove(this.closedClass)}this.complete(node)});node.classList.toggle(this.openedClass,opened);node.classList.toggle(this.closedClass,!opened)}});(function(){var currentToast;Polymer("paper-toast",{text:"",duration:3e3,opened:false,responsiveWidth:"480px",swipeDisabled:false,autoCloseDisabled:false,narrowMode:false,eventDelegates:{trackstart:"trackStart",track:"track",trackend:"trackEnd",transitionend:"transitionEnd"},narrowModeChanged:function(){this.classList.toggle("fit-bottom",this.narrowMode);if(this.opened){this.$.overlay.resizeHandler()}},openedChanged:function(){if(this.opened){this.dismissJob=this.job(this.dismissJob,this.dismiss,this.duration)}else{this.dismissJob&&this.dismissJob.stop();this.dismiss()}},toggle:function(){this.opened=!this.opened},show:function(){if(currentToast){currentToast.dismiss()}currentToast=this;this.opened=true},dismiss:function(){if(this.dragging){this.shouldDismiss=true}else{this.opened=false;if(currentToast===this){currentToast=null}}},trackStart:function(e){if(!this.swipeDisabled){e.preventTap();this.vertical=e.yDirection;this.w=this.offsetWidth;this.h=this.offsetHeight;this.dragging=true;this.classList.add("dragging")}},track:function(e){if(this.dragging){var s=this.style;if(this.vertical){var y=e.dy;s.opacity=(this.h-Math.abs(y))/this.h;s.transform=s.webkitTransform="translate3d(0, "+y+"px, 0)"}else{var x=e.dx;s.opacity=(this.w-Math.abs(x))/this.w;s.transform=s.webkitTransform="translate3d("+x+"px, 0, 0)"}}},trackEnd:function(e){if(this.dragging){this.classList.remove("dragging");this.style.opacity="";this.style.transform=this.style.webkitTransform="";var cl=this.classList;if(this.vertical){cl.toggle("fade-out-down",e.yDirection===1&&e.dy>0);cl.toggle("fade-out-up",e.yDirection===-1&&e.dy<0)}else{cl.toggle("fade-out-right",e.xDirection===1&&e.dx>0);cl.toggle("fade-out-left",e.xDirection===-1&&e.dx<0)}this.dragging=false}},transitionEnd:function(){var cl=this.classList;if(cl.contains("fade-out-right")||cl.contains("fade-out-left")||cl.contains("fade-out-down")||cl.contains("fade-out-up")){this.dismiss();cl.remove("fade-out-right","fade-out-left","fade-out-down","fade-out-up")}else if(this.shouldDismiss){this.dismiss()}this.shouldDismiss=false}})})();Polymer("core-menu");Polymer("core-collapse",{target:null,horizontal:false,opened:false,duration:.33,fixedSize:false,allowOverflow:false,created:function(){this.transitionEndListener=this.transitionEnd.bind(this)},ready:function(){this.target=this.target||this},domReady:function(){this.async(function(){this.afterInitialUpdate=true})},detached:function(){if(this.target){this.removeListeners(this.target)}},targetChanged:function(old){if(old){this.removeListeners(old)}if(!this.target){return}this.isTargetReady=!!this.target;this.classList.toggle("core-collapse-closed",this.target!==this);this.toggleOpenedStyle(false);this.horizontalChanged();this.addListeners(this.target);this.toggleClosedClass(true);this.update()},addListeners:function(node){node.addEventListener("transitionend",this.transitionEndListener)},removeListeners:function(node){node.removeEventListener("transitionend",this.transitionEndListener)},horizontalChanged:function(){this.dimension=this.horizontal?"width":"height"},openedChanged:function(){this.update();this.fire("core-collapse-open",this.opened)},toggle:function(){this.opened=!this.opened},setTransitionDuration:function(duration){var s=this.target.style;s.transition=duration?this.dimension+" "+duration+"s":null;if(duration===0){this.async("transitionEnd")}},transitionEnd:function(){if(this.opened&&!this.fixedSize){this.updateSize("auto",null)}this.setTransitionDuration(null);this.toggleOpenedStyle(this.opened);this.toggleClosedClass(!this.opened);this.asyncFire("core-resize",null,this.target)},toggleClosedClass:function(closed){this.hasClosedClass=closed;this.target.classList.toggle("core-collapse-closed",closed)},toggleOpenedStyle:function(opened){this.target.style.overflow=this.allowOverflow&&opened?"":"hidden"},updateSize:function(size,duration,forceEnd){this.setTransitionDuration(duration);this.calcSize();var s=this.target.style;var nochange=s[this.dimension]===size;s[this.dimension]=size;if(forceEnd&&nochange){this.transitionEnd()}},update:function(){if(!this.target){return}if(!this.isTargetReady){this.targetChanged()}this.horizontalChanged();this[this.opened?"show":"hide"]()},calcSize:function(){return this.target.getBoundingClientRect()[this.dimension]+"px"},getComputedSize:function(){return getComputedStyle(this.target)[this.dimension]},show:function(){this.toggleClosedClass(false);if(!this.afterInitialUpdate){this.transitionEnd();return}if(!this.fixedSize){this.updateSize("auto",null);var s=this.calcSize();if(s=="0px"){this.transitionEnd();return}this.updateSize(0,null)}this.async(function(){this.updateSize(this.size||s,this.duration,true)})},hide:function(){this.toggleOpenedStyle(false);if(this.hasClosedClass&&!this.fixedSize){return}if(this.fixedSize){this.size=this.getComputedSize()}else{this.updateSize(this.calcSize(),null)}this.async(function(){this.updateSize(0,this.duration)})}});Polymer("core-submenu",{publish:{active:{value:false,reflect:true}},opened:false,get items(){return this.$.submenu.items},hasItems:function(){return!!this.items.length},unselectAllItems:function(){this.$.submenu.selected=null;this.$.submenu.clearSelection()},activeChanged:function(){if(this.hasItems()){this.opened=this.active}if(!this.active){this.unselectAllItems()}},toggle:function(){this.opened=!this.opened},activate:function(){if(this.hasItems()&&this.active){this.toggle();this.unselectAllItems()}}});Polymer("core-scroll-threshold",{publish:{scrollTarget:null,orient:"v",upperThreshold:null,lowerThreshold:null,upperTriggered:false,lowerTriggered:false},observe:{"upperThreshold lowerThreshold scrollTarget orient":"setup"},ready:function(){this._boundScrollHandler=this.checkThreshold.bind(this)},setup:function(){if(this._scrollTarget&&this._scrollTarget!=this.target){this._scrollTarget.removeEventListener(this._boundScrollHandler)}var target=this.scrollTarget||this;if(target){this._scrollTarget=target;this._scrollTarget.addEventListener("scroll",this._boundScrollHandler)}this.style.overflow=target==this?"auto":null;this.scrollPosition=this.orient=="v"?"scrollTop":"scrollLeft";this.sizeExtent=this.orient=="v"?"offsetHeight":"offsetWidth";this.scrollExtent=this.orient=="v"?"scrollHeight":"scrollWidth";if(!this.upperThreshold){this.upperTriggered=false}if(!this.lowerThreshold){this.lowerTriggered=false}},checkThreshold:function(e){var top=this._scrollTarget[this.scrollPosition];if(!this.upperTriggered&&this.upperThreshold!=null){if(top=0){overlays.splice(i,1);setZ(overlay,"")}}function applyOverlayZ(overlay,aboveZ){setZ(overlay.target,aboveZ+2)}function setZ(element,z){element.style.zIndex=z}function currentOverlay(){return overlays[overlays.length-1]}var DEFAULT_Z=10;function currentOverlayZ(){var z;var current=currentOverlay();if(current){var z1=window.getComputedStyle(current.target).zIndex;if(!isNaN(z1)){z=Number(z1)}}return z||DEFAULT_Z}function focusOverlay(){var current=currentOverlay();if(current&&!current.transitioning){current.applyFocus()}}var backdrops=[];function trackBackdrop(element){if(element.opened){backdrops.push(element)}else{var i=backdrops.indexOf(element);if(i>=0){backdrops.splice(i,1)}}}function getBackdrops(){return backdrops}})();Polymer("core-transition-css",{baseClass:"core-transition",openedClass:"core-opened",closedClass:"core-closed",completeEventName:"transitionend",publish:{transitionType:null},registerCallback:function(element){this.transitionStyle=element.templateContent().firstElementChild},fetchTemplate:function(){return null},go:function(node,state){if(state.opened!==undefined){this.transitionOpened(node,state.opened)}},setup:function(node){if(!node._hasTransitionStyle){if(!node.shadowRoot){node.createShadowRoot().innerHTML=""}this.installScopeStyle(this.transitionStyle,"transition",node.shadowRoot);node._hasTransitionStyle=true}node.classList.add(this.baseClass);if(this.transitionType){node.classList.add(this.baseClass+"-"+this.transitionType)}},teardown:function(node){node.classList.remove(this.baseClass);if(this.transitionType){node.classList.remove(this.baseClass+"-"+this.transitionType)}},transitionOpened:function(node,opened){this.listenOnce(node,this.completeEventName,function(){if(!opened){node.classList.remove(this.closedClass)}this.complete(node)});node.classList.toggle(this.openedClass,opened);node.classList.toggle(this.closedClass,!opened)}});(function(){var currentToast;Polymer("paper-toast",{text:"",duration:3e3,opened:false,responsiveWidth:"480px",swipeDisabled:false,autoCloseDisabled:false,narrowMode:false,eventDelegates:{trackstart:"trackStart",track:"track",trackend:"trackEnd",transitionend:"transitionEnd"},narrowModeChanged:function(){this.classList.toggle("fit-bottom",this.narrowMode);if(this.opened){this.$.overlay.resizeHandler()}},openedChanged:function(){if(this.opened){this.dismissJob=this.job(this.dismissJob,this.dismiss,this.duration)}else{this.dismissJob&&this.dismissJob.stop();this.dismiss()}},toggle:function(){this.opened=!this.opened},show:function(){if(currentToast){currentToast.dismiss()}currentToast=this;this.opened=true},dismiss:function(){if(this.dragging){this.shouldDismiss=true}else{this.opened=false;if(currentToast===this){currentToast=null}}},trackStart:function(e){if(!this.swipeDisabled){e.preventTap();this.vertical=e.yDirection;this.w=this.offsetWidth;this.h=this.offsetHeight;this.dragging=true;this.classList.add("dragging")}},track:function(e){if(this.dragging){var s=this.style;if(this.vertical){var y=e.dy;s.opacity=(this.h-Math.abs(y))/this.h;s.transform=s.webkitTransform="translate3d(0, "+y+"px, 0)"}else{var x=e.dx;s.opacity=(this.w-Math.abs(x))/this.w;s.transform=s.webkitTransform="translate3d("+x+"px, 0, 0)"}}},trackEnd:function(e){if(this.dragging){this.classList.remove("dragging");this.style.opacity="";this.style.transform=this.style.webkitTransform="";var cl=this.classList;if(this.vertical){cl.toggle("fade-out-down",e.yDirection===1&&e.dy>0);cl.toggle("fade-out-up",e.yDirection===-1&&e.dy<0)}else{cl.toggle("fade-out-right",e.xDirection===1&&e.dx>0);cl.toggle("fade-out-left",e.xDirection===-1&&e.dx<0)}this.dragging=false}},transitionEnd:function(){var cl=this.classList;if(cl.contains("fade-out-right")||cl.contains("fade-out-left")||cl.contains("fade-out-down")||cl.contains("fade-out-up")){this.dismiss();cl.remove("fade-out-right","fade-out-left","fade-out-down","fade-out-up")}else if(this.shouldDismiss){this.dismiss()}this.shouldDismiss=false}})})();Polymer("core-menu");Polymer("core-collapse",{target:null,horizontal:false,opened:false,duration:.33,fixedSize:false,allowOverflow:false,created:function(){this.transitionEndListener=this.transitionEnd.bind(this)},ready:function(){this.target=this.target||this},domReady:function(){this.async(function(){this.afterInitialUpdate=true})},detached:function(){if(this.target){this.removeListeners(this.target)}},targetChanged:function(old){if(old){this.removeListeners(old)}if(!this.target){return}this.isTargetReady=!!this.target;this.classList.toggle("core-collapse-closed",this.target!==this);this.toggleOpenedStyle(false);this.horizontalChanged();this.addListeners(this.target);this.toggleClosedClass(true);this.update()},addListeners:function(node){node.addEventListener("transitionend",this.transitionEndListener)},removeListeners:function(node){node.removeEventListener("transitionend",this.transitionEndListener)},horizontalChanged:function(){this.dimension=this.horizontal?"width":"height"},openedChanged:function(){this.update();this.fire("core-collapse-open",this.opened)},toggle:function(){this.opened=!this.opened},setTransitionDuration:function(duration){var s=this.target.style;s.transition=duration?this.dimension+" "+duration+"s":null;if(duration===0){this.async("transitionEnd")}},transitionEnd:function(){if(this.opened&&!this.fixedSize){this.updateSize("auto",null)}this.setTransitionDuration(null);this.toggleOpenedStyle(this.opened);this.toggleClosedClass(!this.opened);this.asyncFire("core-resize",null,this.target)},toggleClosedClass:function(closed){this.hasClosedClass=closed;this.target.classList.toggle("core-collapse-closed",closed)},toggleOpenedStyle:function(opened){this.target.style.overflow=this.allowOverflow&&opened?"":"hidden"},updateSize:function(size,duration,forceEnd){this.setTransitionDuration(duration);this.calcSize();var s=this.target.style;var nochange=s[this.dimension]===size;s[this.dimension]=size;if(forceEnd&&nochange){this.transitionEnd()}},update:function(){if(!this.target){return}if(!this.isTargetReady){this.targetChanged()}this.horizontalChanged();this[this.opened?"show":"hide"]()},calcSize:function(){return this.target.getBoundingClientRect()[this.dimension]+"px"},getComputedSize:function(){return getComputedStyle(this.target)[this.dimension]},show:function(){this.toggleClosedClass(false);if(!this.afterInitialUpdate){this.transitionEnd();return}if(!this.fixedSize){this.updateSize("auto",null);var s=this.calcSize();if(s=="0px"){this.transitionEnd();return}this.updateSize(0,null)}this.async(function(){this.updateSize(this.size||s,this.duration,true)})},hide:function(){this.toggleOpenedStyle(false);if(this.hasClosedClass&&!this.fixedSize){return}if(this.fixedSize){this.size=this.getComputedSize()}else{this.updateSize(this.calcSize(),null)}this.async(function(){this.updateSize(0,this.duration)})}});Polymer("core-submenu",{publish:{active:{value:false,reflect:true}},opened:false,get items(){return this.$.submenu.items},hasItems:function(){return!!this.items.length},unselectAllItems:function(){this.$.submenu.selected=null;this.$.submenu.clearSelection()},activeChanged:function(){if(this.hasItems()){this.opened=this.active}if(!this.active){this.unselectAllItems()}},toggle:function(){this.opened=!this.opened},activate:function(){if(this.hasItems()&&this.active){this.toggle();this.unselectAllItems()}}});Polymer("core-scroll-threshold",{publish:{scrollTarget:null,orient:"v",upperThreshold:null,lowerThreshold:null,upperTriggered:false,lowerTriggered:false},observe:{"upperThreshold lowerThreshold scrollTarget orient":"setup"},ready:function(){this._boundScrollHandler=this.checkThreshold.bind(this)},setup:function(){if(this._scrollTarget&&this._scrollTarget!=this.target){this._scrollTarget.removeEventListener(this._boundScrollHandler)}var target=this.scrollTarget||this;if(target){this._scrollTarget=target;this._scrollTarget.addEventListener("scroll",this._boundScrollHandler)}this.style.overflow=target==this?"auto":null;this.scrollPosition=this.orient=="v"?"scrollTop":"scrollLeft";this.sizeExtent=this.orient=="v"?"offsetHeight":"offsetWidth";this.scrollExtent=this.orient=="v"?"scrollHeight":"scrollWidth";if(!this.upperThreshold){this.upperTriggered=false}if(!this.lowerThreshold){this.lowerTriggered=false}},checkThreshold:function(e){var top=this._scrollTarget[this.scrollPosition];if(!this.upperTriggered&&this.upperThreshold!=null){if(top=this.offsetWidth-this.edgeSwipeSensitivity:e.pageX<=this.edgeSwipeSensitivity)},trackStart:function(e){if(this.swipeAllowed()){this.dragging=true;if(this.isMainSelected()){this.dragging=this.peeking||this.isEdgeTouch(e)}if(this.dragging){this.width=this.$.drawer.offsetWidth;this.transition=false;e.preventTap()}}},translateXForDeltaX:function(deltaX){var isMain=this.isMainSelected();if(this.rightDrawer){return Math.max(0,isMain?this.width+deltaX:deltaX)}else{return Math.min(0,isMain?deltaX-this.width:deltaX)}},trackx:function(e){if(this.dragging){if(this.peeking){if(Math.abs(e.dx)<=this.edgeSwipeSensitivity){return}this.peeking=false}this.moveDrawer(this.translateXForDeltaX(e.dx))}},trackEnd:function(e){if(this.dragging){this.dragging=false;this.transition=true;this.moveDrawer(null);if(this.rightDrawer){this.selected=e.xDirection>0?"main":"drawer"}else{this.selected=e.xDirection>0?"drawer":"main"}}},transformForTranslateX:function(translateX){if(translateX===null){return""}return this.hasWillChange?"translateX("+translateX+"px)":"translate3d("+translateX+"px, 0, 0)"},moveDrawer:function(translateX){var s=this.$.drawer.style;if(this.hasTransform){s.transform=this.transformForTranslateX(translateX)}else{s.webkitTransform=this.transformForTranslateX(translateX)}}});Polymer("core-range",{value:0,min:0,max:100,step:1,ratio:0,observe:{"value min max step":"update"},calcRatio:function(value){return(this.clampValue(value)-this.min)/(this.max-this.min)},clampValue:function(value){return Math.min(this.max,Math.max(this.min,this.calcStep(value)))},calcStep:function(value){return this.step?Math.round(value/this.step)/(1/this.step):value},validateValue:function(){var v=this.clampValue(this.value);this.value=this.oldValue=isNaN(v)?this.oldValue:v;return this.value!==v},update:function(){this.validateValue();this.ratio=this.calcRatio(this.value)*100}});Polymer("paper-progress",{secondaryProgress:0,indeterminate:false,step:0,observe:{"value secondaryProgress min max indeterminate":"update"},update:function(){this.super();this.secondaryProgress=this.clampValue(this.secondaryProgress);this.secondaryRatio=this.calcRatio(this.secondaryProgress)*100;this.$.activeProgress.classList.toggle("indeterminate",this.indeterminate)},transformProgress:function(progress,ratio){var transform="scaleX("+ratio/100+")";progress.style.transform=progress.style.webkitTransform=transform},ratioChanged:function(){this.transformProgress(this.$.activeProgress,this.ratio)},secondaryRatioChanged:function(){this.transformProgress(this.$.secondaryProgress,this.secondaryRatio)}});Polymer("core-input",{publish:{committedValue:"",preventInvalidInput:false},previousValidInput:"",eventDelegates:{input:"inputAction",change:"changeAction"},ready:function(){this.disabledHandler();this.placeholderHandler()},attributeChanged:function(attr,old){if(this[attr+"Handler"]){this[attr+"Handler"](old)}},disabledHandler:function(){if(this.disabled){this.setAttribute("aria-disabled","")}else{this.removeAttribute("aria-disabled")}},placeholderHandler:function(){if(this.placeholder){this.setAttribute("aria-label",this.placeholder)}else{this.removeAttribute("aria-label")}},commit:function(){this.committedValue=this.value},changeAction:function(){this.commit()},inputAction:function(e){if(this.preventInvalidInput){if(!e.target.validity.valid){e.target.value=this.previousValidInput}else{this.previousValidInput=e.target.value}}}});(function(){var paperInput=CoreStyle.g.paperInput=CoreStyle.g.paperInput||{};paperInput.labelColor="#757575";paperInput.focusedColor="#4059a9";paperInput.invalidColor="#d34336";Polymer("paper-input-decorator",{publish:{label:"",floatingLabel:false,disabled:{value:false,reflect:true},labelVisible:null,isInvalid:false,autoValidate:false,error:"",focused:{value:false,reflect:true}},computed:{floatingLabelVisible:"floatingLabel && !_labelVisible",_labelVisible:"(labelVisible === true || labelVisible === false) ? labelVisible : _autoLabelVisible"},ready:function(){Polymer.addEventListener(this,"focus",this.focusAction.bind(this),true);Polymer.addEventListener(this,"blur",this.blurAction.bind(this),true)},attached:function(){this.input=this.querySelector("input,textarea");this.mo=new MutationObserver(function(){this.input=this.querySelector("input,textarea")}.bind(this));this.mo.observe(this,{childList:true})},detached:function(){this.mo.disconnect();this.mo=null},prepareLabelTransform:function(){var toRect=this.$.floatedLabelText.getBoundingClientRect();var fromRect=this.$.labelText.getBoundingClientRect();if(toRect.width!==0){var sy=toRect.height/fromRect.height;this.$.labelText.cachedTransform="scale3d("+toRect.width/fromRect.width+","+sy+",1) "+"translate3d(0,"+(toRect.top-fromRect.top)/sy+"px,0)"}},animateFloatingLabel:function(){if(!this.floatingLabel||this.labelAnimated){return false}if(!this.$.labelText.cachedTransform){this.prepareLabelTransform()}if(!this.$.labelText.cachedTransform){return false}this.labelAnimated=true;this.async(function(){this.transitionEndAction()},null,250);if(this._labelVisible){if(!this.$.labelText.style.webkitTransform&&!this.$.labelText.style.transform){this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform;this.$.labelText.style.transform=this.$.labelText.cachedTransform;this.$.labelText.offsetTop}this.$.labelText.style.webkitTransform="";this.$.labelText.style.transform=""}else{this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform;this.$.labelText.style.transform=this.$.labelText.cachedTransform;this.input.placeholder=""}return true},animateUnderline:function(e){if(this.focused){var rect=this.$.underline.getBoundingClientRect();var right=e.x-rect.left;this.$.focusedUnderline.style.mozTransformOrigin=right+"px";this.$.focusedUnderline.style.webkitTransformOrigin=right+"px ";this.$.focusedUnderline.style.transformOriginX=right+"px";this.underlineAnimated=true}},validate:function(){this.isInvalid=!this.input.validity.valid;return this.input.validity.valid},_labelVisibleChanged:function(old){if(old!==undefined){if(!this.animateFloatingLabel()){this.updateInputLabel(this.input,this.label)}}},labelVisibleChanged:function(){if(this.labelVisible==="true"){this.labelVisible=true}else if(this.labelVisible==="false"){this.labelVisible=false}},labelChanged:function(){if(this.input){this.updateInputLabel(this.input,this.label)}},isInvalidChanged:function(){this.classList.toggle("invalid",this.isInvalid)},focusedChanged:function(){this.updateLabelVisibility(this.input&&this.input.value);if(this.lastEvent){this.animateUnderline(this.lastEvent);this.lastEvent=null}this.underlineVisible=this.focused},inputChanged:function(old){if(this.input){this.updateLabelVisibility(this.input.value);this.updateInputLabel(this.input,this.label);if(this.autoValidate){this.validate()}}if(old){this.updateInputLabel(old,"")}},focusAction:function(){this.focused=true},blurAction:function(){this.focused=false},updateLabelVisibility:function(value){var v=value!==null&&value!==undefined?String(value):value;this._autoLabelVisible=!this.focused&&!v||!this.floatingLabel&&!v},updateInputLabel:function(input,label){if(this._labelVisible){this.input.placeholder=this.label}else{this.input.placeholder=""}if(label){input.setAttribute("aria-label",label)}else{input.removeAttribute("aria-label")}},inputAction:function(){this.updateLabelVisibility(this.input.value);if(this.autoValidate){this.validate()}},downAction:function(e){if(e.target!==this.input&&this.focused){e.preventDefault();return}this.lastEvent=e},tapAction:function(e){if(this.disabled){return}if(this.focused){return}if(this.input){this.input.focus();e.preventDefault()}},transitionEndAction:function(){this.underlineAnimated=false;this.labelAnimated=false;if(this._labelVisible){this.input.placeholder=this.label}},charCounterErrorAction:function(e){this.isInvalid=e.detail.hasError;this.$.errorIcon.hidden=e.detail.hideErrorIcon}})})();Polymer("paper-input",{publish:{label:"",floatingLabel:false,disabled:{value:false,reflect:true},value:"",committedValue:""},focus:function(){this.$.input.focus()},valueChanged:function(){this.$.decorator.updateLabelVisibility(this.value)},changeAction:function(e){this.fire("change",null,this)}});Polymer("paper-slider",{snaps:false,pin:false,disabled:false,secondaryProgress:0,editable:false,maxMarkers:100,dragging:false,observe:{"step snaps":"update"},ready:function(){this.update()},update:function(){this.positionKnob(this.calcRatio(this.value));this.updateMarkers()},minChanged:function(){this.update();this.setAttribute("aria-valuemin",this.min)},maxChanged:function(){this.update();this.setAttribute("aria-valuemax",this.max)},valueChanged:function(){this.update();this.setAttribute("aria-valuenow",this.value);this.fire("core-change")},disabledChanged:function(){if(this.disabled){this.removeAttribute("tabindex")}else{this.tabIndex=0}},immediateValueChanged:function(){if(!this.dragging){this.value=this.immediateValue}this.fire("immediate-value-change")},expandKnob:function(){this.expand=true},resetKnob:function(){this.expandJob&&this.expandJob.stop();this.expand=false},positionKnob:function(ratio){this.immediateValue=this.calcStep(this.calcKnobPosition(ratio))||0;this._ratio=this.snaps?this.calcRatio(this.immediateValue):ratio;this.$.sliderKnob.style.left=this._ratio*100+"%"},inputChange:function(){this.value=this.$.input.value;this.fire("change")},calcKnobPosition:function(ratio){return(this.max-this.min)*ratio+this.min},trackStart:function(e){this._w=this.$.sliderBar.offsetWidth;this._x=this._ratio*this._w;this._startx=this._x||0;this._minx=-this._startx;this._maxx=this._w-this._startx;this.$.sliderKnob.classList.add("dragging");this.dragging=true;e.preventTap()},trackx:function(e){var x=Math.min(this._maxx,Math.max(this._minx,e.dx));this._x=this._startx+x;this.immediateValue=this.calcStep(this.calcKnobPosition(this._x/this._w))||0;var s=this.$.sliderKnob.style;s.transform=s.webkitTransform="translate3d("+(this.snaps?this.calcRatio(this.immediateValue)*this._w-this._startx:x)+"px, 0, 0)"},trackEnd:function(){var s=this.$.sliderKnob.style;s.transform=s.webkitTransform="";this.$.sliderKnob.classList.remove("dragging");this.dragging=false;this.resetKnob();this.value=this.immediateValue;this.fire("change")},knobdown:function(e){e.preventDefault();this.expandKnob()},bardown:function(e){e.preventDefault();this.transiting=true;this._w=this.$.sliderBar.offsetWidth;var rect=this.$.sliderBar.getBoundingClientRect();var ratio=(e.x-rect.left)/this._w;this.positionKnob(ratio);this.expandJob=this.job(this.expandJob,this.expandKnob,60);this.asyncFire("change")},knobTransitionEnd:function(e){if(e.target===this.$.sliderKnob){this.transiting=false}},updateMarkers:function(){this.markers=[];var l=(this.max-this.min)/this.step;if(!this.snaps&&l>this.maxMarkers){return}for(var i=0;iself.innerWidth||(h=Math.max(doc.clientHeight,body.clientHeight))>self.innerHeight?{w:body.clientWidth,h:body.clientHeight}:{w:w,h:h}}Polymer("core-dropdown",{publish:{relatedTarget:null,halign:"left",valign:"top"},measure:function(){var target=this.target;var pos=target.style.position;target.style.position="fixed";target.style.left="0px";target.style.top="0px";var rect=target.getBoundingClientRect();target.style.position=pos;target.style.left=null;target.style.top=null;return rect},resetTargetDimensions:function(){var dims=this.dimensions;var style=this.target.style;if(dims.position.h_by===this.localName){style[dims.position.h]=null;dims.position.h_by=null}if(dims.position.v_by===this.localName){style[dims.position.v]=null;dims.position.v_by=null}style.width=null;style.height=null;this.super()},positionTarget:function(){if(!this.relatedTarget){this.relatedTarget=this.target.parentElement||this.target.parentNode&&this.target.parentNode.host;if(!this.relatedTarget){this.super();return}}var target=this.sizingTarget;var rect=this.measure();target.style.width=Math.ceil(rect.width)+"px";target.style.height=Math.ceil(rect.height)+"px";if(this.layered){this.positionLayeredTarget()}else{this.positionNestedTarget()}},positionLayeredTarget:function(){var target=this.target;var rect=this.relatedTarget.getBoundingClientRect();var dims=this.dimensions;var margin=dims.margin;var vp=viewSize();if(!dims.position.h){if(this.halign==="right"){target.style.right=vp.w-rect.right-margin.right+"px";dims.position.h="right"}else{target.style.left=rect.left-margin.left+"px";dims.position.h="left"}dims.position.h_by=this.localName}if(!dims.position.v){if(this.valign==="bottom"){target.style.bottom=vp.h-rect.bottom-margin.bottom+"px";dims.position.v="bottom"}else{target.style.top=rect.top-margin.top+"px";dims.position.v="top"}dims.position.v_by=this.localName}if(dims.position.h_by||dims.position.v_by){target.style.position="fixed"}},positionNestedTarget:function(){var target=this.target;var related=this.relatedTarget;var t_op=target.offsetParent;var r_op=related.offsetParent;if(window.ShadowDOMPolyfill){t_op=wrap(t_op);r_op=wrap(r_op)}if(t_op!==r_op&&t_op!==related){console.warn("core-dropdown-overlay: dropdown's offsetParent must be the relatedTarget or the relatedTarget's offsetParent!")}var dims=this.dimensions;var margin=dims.margin;var inside=t_op===related;if(!dims.position.h){if(this.halign==="right"){target.style.right=(inside?0:t_op.offsetWidth-related.offsetLeft-related.offsetWidth)-margin.right+"px";dims.position.h="right"}else{target.style.left=(inside?0:related.offsetLeft)-margin.left+"px";dims.position.h="left"}dims.position.h_by=this.localName}if(!dims.position.v){if(this.valign==="bottom"){target.style.bottom=(inside?0:t_op.offsetHeight-related.offsetTop-related.offsetHeight)-margin.bottom+"px";dims.position.v="bottom"}else{target.style.top=(inside?0:related.offsetTop)-margin.top+"px";dims.position.v="top"}dims.position.v_by=this.localName}}})})();Polymer("paper-dropdown-transition",{publish:{duration:500},setup:function(node){this.super(arguments);var to={top:"0%",left:"0%",bottom:"100%",right:"100%"};var bg=node.$.background;bg.style.webkitTransformOrigin=to[node.halign]+" "+to[node.valign];bg.style.transformOrigin=to[node.halign]+" "+to[node.valign]},transitionOpened:function(node,opened){this.super(arguments);if(opened){if(this.player){this.player.cancel()}var duration=Number(node.getAttribute("duration"))||this.duration;var anims=[];var size=node.getBoundingClientRect();var ink=node.$.ripple;var offset=.2;anims.push(new Animation(ink,[{opacity:.9,transform:"scale(0)"},{opacity:.9,transform:"scale(1)"}],{duration:duration*offset}));var bg=node.$.background;var sx=40/size.width;var sy=40/size.height;anims.push(new Animation(bg,[{opacity:.9,transform:"scale("+sx+","+sy+")"},{opacity:1,transform:"scale("+Math.max(sx,.95)+","+Math.max(sy,.5)+")"},{opacity:1,transform:"scale(1, 1)"}],{delay:duration*offset,duration:duration*(1-offset),fill:"forwards"}));var menu=node.querySelector(".menu");if(menu){var items=menu.items||menu.children.array();var itemDelay=offset+(1-offset)/2;var itemDuration=duration*(1-itemDelay)/items.length;var reverse=this.valign==="bottom";items.forEach(function(item,i){anims.push(new Animation(item,[{opacity:0},{opacity:1}],{delay:duration*itemDelay+itemDuration*(reverse?items.length-1-i:i),duration:itemDuration,fill:"both"}))}.bind(this));anims.push(new Animation(node.$.scroller,[{opacity:1},{opacity:1}],{delay:duration*itemDelay,duration:itemDuration*items.length,fill:"both"}))}else{anims.push(new Animation(node.$.scroller,[{opacity:0},{opacity:1}],{delay:duration*(offset+(1-offset)/2),duration:duration*.5,fill:"both"}))}var group=new AnimationGroup(anims,{easing:"cubic-bezier(0.4, 0, 0.2, 1)"});this.player=document.timeline.play(group);this.player.onfinish=function(){this.fire("core-transitionend",this,node)}.bind(this)}else{this.fire("core-transitionend",this,node)}}});Polymer("paper-dropdown",{publish:{transition:"paper-dropdown-transition"},ready:function(){this.super();this.sizingTarget=this.$.scroller}});(function(){var ID=0;function generate(node){if(!node.id){node.id="core-label-"+ID++}return node.id}Polymer("core-label",{publish:{"for":{reflect:true,value:""}},eventDelegates:{tap:"tapHandler"},created:function(){generate(this);this._forElement=null},ready:function(){if(!this.for){this._forElement=this.querySelector("[for]");this._tie()}},tapHandler:function(ev){if(!this._forElement){return}if(ev.target===this._forElement){return}this._forElement.focus();this._forElement.click();this.fire("tap",null,this._forElement)},_tie:function(){if(this._forElement){this._forElement.setAttribute("aria-labelledby",this.id)}},_findScope:function(){var n=this.parentNode;while(n&&n.parentNode){n=n.parentNode}return n},forChanged:function(oldFor,newFor){if(this._forElement){this._forElement.removeAttribute("aria-labelledby")}var scope=this._findScope();if(!scope){return}this._forElement=scope.querySelector(newFor);if(this._forElement){this._tie()}}})})();Polymer("volume-slider",{created:function(){this.volume=this.volume||100},volumeChanged:function(){var audio=document.getElementById("audio");audio.volume=this.volume/100;chrome.storage.sync.set({volume:this.volume})}});(function(){var p={publish:{label:"Select an item",openedIcon:"arrow-drop-up",closedIcon:"arrow-drop-down"},selectedItemLabel:"",overlayListeners:{"core-overlay-open":"openAction","core-activate":"activateAction","core-select":"selectAction"},activateAction:function(e){this.opened=false},selectAction:function(e){var detail=e.detail;if(detail.isSelected){this.$.label.classList.add("selectedItem");this.selectedItemLabel=detail.item.label||detail.item.textContent}else{this.$.label.classList.remove("selectedItem");this.selectedItemLabel=""}}};Polymer.mixin2(p,Polymer.CoreFocusable);Polymer("paper-dropdown-menu",p)})();Polymer("subsonic-login",{timer:0,ready:function(){"use strict";this.post=[];this.app=document.getElementById("tmpl");this.urlError=chrome.i18n.getMessage("urlError");this.urlLabel=chrome.i18n.getMessage("urlLabel");this.usernameError=chrome.i18n.getMessage("usernameError");this.usernameLabel=chrome.i18n.getMessage("usernameLabel");this.passwordLabel=chrome.i18n.getMessage("passwordLabel");this.showPass=chrome.i18n.getMessage("showPass");this.hideThePass=chrome.i18n.getMessage("hidePass");this.submitButton=chrome.i18n.getMessage("submitButton")},submit:function(){"use strict";if(this.invalid1&&this.invalid2&&this.post.version===undefined){this.app.doToast("URL, Username & Version Required")}else if(this.invalid1){this.app.doToast("URL Required")}else if(this.invalid2){this.app.doToast("Username Required")}else if(!this.invalid1&&!this.invalid2&&!this.invalid3){var lastChar=this.post.url.substr(-1);if(lastChar==="/"){this.post.url=this.post.url.substring(0,this.post.url.length-1)}this.$.ajax.go()}},hidePass:function(event,detail,sender){"use strict";var type=this.$.password.type,button=this.$.showPass,timer=this.timer;if(type==="text"){this.$.password.type="password";button.innerHTML=this.showPass;if(timer){clearTimeout(timer);timer=0}}else{this.$.password.type="text";button.innerHTML=this.hideThePass;timer=setTimeout(function(){this.$.password.type="password";button.innerHTML=this.showPass;timer=0}.bind(this),15e3)}},responseChanged:function(){"use strict";var wall=document.getElementById("wall");if(this.response){if(this.response["subsonic-response"].status==="ok"){chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass});this.app.url=this.post.url;this.app.user=this.post.user;this.app.pass=this.post.pass;this.app.userDetails();this.app.version=this.response["subsonic-response"].version;this.app.doToast("Loading Data");this.app.tracker.sendEvent("API Version",this.response["subsonic-response"].version);this.app.$.firstRun.close();this.app.doXhr(this.url+"/rest/getMusicFolders.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic","json",function(e){this.app.mediaFolders=e.target.response["subsonic-response"].musicFolders.musicFolder;if(!e.target.response["subsonic-response"].musicFolders.musicFolder[1]){this.app.$.sortBox.style.display="none"}}.bind(this));setTimeout(function(){wall.doAjax()},100)}else{console.log(this.response);this.app.doToast(this.response["subsonic-response"].error.message)}}},errorChanged:function(){"use strict";if(this.error.statusCode===0){this.app.doToast(chrome.i18n.getMessage("connectionError"))}},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version}});Polymer("paper-radio-button",{publish:{checked:{value:false,reflect:true},label:"",toggles:false,disabled:{value:false, +reflect:true}},eventDelegates:{tap:"tap"},tap:function(){if(this.disabled){return}var old=this.checked;this.toggle();if(this.checked!==old){this.fire("change")}},toggle:function(){this.checked=!this.toggles||!this.checked},checkedChanged:function(){this.setAttribute("aria-checked",this.checked?"true":"false");this.fire("core-change")},labelChanged:function(){this.setAttribute("aria-label",this.label)}});Polymer("paper-toggle-button",{checked:false,disabled:false,eventDelegates:{down:"downAction",up:"upAction",tap:"tap",trackstart:"trackStart",trackx:"trackx",trackend:"trackEnd"},downAction:function(e){var rect=this.$.ink.getBoundingClientRect();this.$.ink.downAction({x:rect.left+rect.width/2,y:rect.top+rect.height/2})},upAction:function(e){this.$.ink.upAction()},tap:function(){if(this.disabled){return}this.checked=!this.checked;this.fire("change")},trackStart:function(e){if(this.disabled){return}this._w=this.$.toggleBar.offsetWidth/2;e.preventTap()},trackx:function(e){this._x=Math.min(this._w,Math.max(0,this.checked?this._w+e.dx:e.dx));this.$.toggleButton.classList.add("dragging");var s=this.$.toggleButton.style;s.webkitTransform=s.transform="translate3d("+this._x+"px,0,0)"},trackEnd:function(){var s=this.$.toggleButton.style;s.transform=s.webkitTransform="";this.$.toggleButton.classList.remove("dragging");var old=this.checked;this.checked=Math.abs(this._x)>this._w/2;if(this.checked!==old){this.fire("change")}},checkedChanged:function(){this.setAttribute("aria-pressed",Boolean(this.checked));this.fire("core-change")}});Polymer("settings-menu",{post:{},manifest:chrome.runtime.getManifest(),urlError:chrome.i18n.getMessage("urlError"),urlLabel:chrome.i18n.getMessage("urlLabel"),usernameError:chrome.i18n.getMessage("usernameError"),usernameLabel:chrome.i18n.getMessage("usernameLabel"),passwordLabel:chrome.i18n.getMessage("passwordLabel"),showPass:chrome.i18n.getMessage("showPass"),hideThePass:chrome.i18n.getMessage("hidePass"),submitButton:chrome.i18n.getMessage("submitButton"),bitrateLabel:chrome.i18n.getMessage("bitrateLabel"),cacheDetails:chrome.i18n.getMessage("cacheDetails"),clearCacheLabel:chrome.i18n.getMessage("clearCacheLabel"),clearSettingsLabel:chrome.i18n.getMessage("clearSettingsLabel"),appName:chrome.i18n.getMessage("appName"),licenseInfoLink:chrome.i18n.getMessage("licenseInfoLink"),showLicenseLabel:chrome.i18n.getMessage("showLicenseLabel"),speeds:[96,128,192,256,320],timer:0,created:function(){this.elementReady=false},domReady:function(){this.app=document.getElementById("tmpl");this.wall=document.getElementById("wall");this.outputVersion(this.manifest);setTimeout(function(){this.elementReady=true}.bind(this),500)},outputVersion:function(manifest){this.polysonicVersion=manifest.version;console.log("App version: "+this.polysonicVersion)},validate:function(callback){"use strict";var $d=this.$.validate.querySelectorAll("paper-input-decorator");Array.prototype.forEach.call($d,function(d){d.isInvalid=!d.querySelector("input").validity.valid});callback()},submit:function(){"use strict";this.validate(function(){var invalid1=this.$.input1.classList.contains("invalid"),invalid2=this.$.input2.classList.contains("invalid"),invalid3=this.$.input3.classList.contains("invalid");if(invalid1&&invalid2&&this.post.version===undefined){this.app.doToast("URL, Username & Version Required")}else if(invalid1){this.app.doToast("URL Required")}else if(invalid2){this.app.doToast("Username Required")}else if(this.version===undefined){this.app.doToast("Version Required")}if(!invalid1&&!invalid2&&!invalid3&&this.post.version!==undefined&&this.post.bitRate!==undefined){var lastChar=this.post.url.substr(-1);if(lastChar==="/"){this.post.url=this.post.url.substring(0,this.post.url.length-1)}this.$.ajax.go();this.wall.clearData(function(){this.wall.doAjax()}.bind(this))}}.bind(this))},hidePass:function(event,detail,sender){"use strict";var type=this.$.password.type,button=this.$.showPass,timer=this.timer;if(type==="text"){this.$.password.type="password";button.innerHTML=this.showPass;if(timer){clearTimeout(timer);timer=0}}else{this.$.password.type="text";button.innerHTML=this.hideThePass;timer=setTimeout(function(){this.$.password.type="password";button.innerHTML=this.showPass;timer=0}.bind(this),15e3)}},doClearCache:function(){this.clearCache(function(){this.app.$.recommendReloadDialog.open()}.bind(this))},clearCache:function(callback){var req=indexedDB.deleteDatabase("albumInfo");req.onsuccess=function(){console.log("Deleted database successfully");this.app.createObjectStore();this.app.calculateStorageSize()}.bind(this);req.onerror=function(){console.log("Error deleting database");this.app.calculateStorageSize()}.bind(this);req.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked");this.app.calculateStorageSize()}.bind(this);callback()},clearSettings:function(){chrome.storage.sync.clear();this.app.url="";this.app.user="";this.app.pass="";this.app.version="";this.app.bitRate="";this.app.querySize="";this.post=[];this.clearCache(function(){this.app.$.reloadAppDialog.open()}.bind(this))},responseChanged:function(){"use strict";if(this.response){if(this.response["subsonic-response"].status==="ok"){if(this.post.url!==this.url){var req=indexedDB.deleteDatabase("albumInfo");req.onsuccess=function(){console.log("Deleted database successfully");this.app.createObjectStore()};req.onerror=function(){console.log("Error deleting database")};req.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked")}}chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass,version:this.response["subsonic-response"].version,bitRate:this.post.bitRate,querySize:this.post.querySize,queryMethod:this.post.queryMethod});this.app.url=this.post.url;this.app.user=this.post.user;this.app.pass=this.post.pass;this.app.version=this.response["subsonic-response"].version;this.app.bitRate=this.post.bitRate;this.app.querySize=this.post.querySize;this.app.queryMethod=this.post.queryMethod;this.app.doToast("Settings Saved")}else if(this.response["subsonic-response"].status==="failed"){this.app.doToast(this.response["subsonic-response"].error.message)}else{this.app.doToast("Error Connecting to Server. Check Settings")}}},bitRateSelect:function(){chrome.storage.sync.set({bitRate:this.post.bitRate});this.app.bitRate=this.post.bitRate;console.log("Bitrate: "+this.post.bitRate)},querySelect:function(){chrome.storage.sync.set({querySize:this.post.querySize});this.app.querySize=this.post.querySize;console.log("Query Size: "+this.post.querySize)},methodSelect:function(){chrome.storage.sync.set({queryMethod:this.post.queryMethod});this.app.queryMethod=this.post.queryMethod;console.log("Query Method: "+this.post.queryMethod)},errorChanged:function(){"use strict";if(this.error.statusCode===0){this.app.doToast(chrome.i18n.getMessage("connectionError"))}},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version},bitRateChanged:function(){this.post.bitRate=this.bitRate},querySizeChanged:function(){this.post.querySize=this.querySize},queryMethodChanged:function(){this.post.queryMethod=this.queryMethod},showQuota:function(){this.app.calculateStorageSize();this.$.quota.toggle()},linkGo:function(event,detail,sender){var url=sender.attributes.link.value;window.open(url,"_blank")},analisticsToggle:function(){chrome.storage.sync.set({analistics:this.app.analisticsEnabled})},getLicense:function(event,detail,sender){var animation=new CoreAnimation;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();this.app.getLicense(function(){animation.cancel()})}});Polymer("paper-fab",{publish:{src:"",icon:"",mini:false,raised:true,recenteringTouch:true,fill:false},iconChanged:function(oldIcon){var label=this.getAttribute("aria-label");if(!label||label===oldIcon){this.setAttribute("aria-label",this.icon)}}});Polymer("animated-fab",{created:function(){this.state=this.state||"off";this.page=this.page||0},pageChanged:function(){var pName;if(this.page===1){pName="Player";this.state="top"}else if(this.page===0){pName="Album Wall";this.state="off"}else if(this.page===2){pName="Settings";this.state="off"}else if(this.page===3){pName="Artist Details";this.state="off"}else{this.state="off"}if(this.page===0&&this.showing==="podcast"){this.state="podcast"}document.getElementById("tmpl").tracker.sendAppView(pName)},playingChanged:function(){if(this.playing){document.getElementById("tmpl").playThis()}}});(function(){var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;Polymer("core-list",Polymer.mixin({publish:{data:null,groups:null,scrollTarget:null,selectionEnabled:true,multi:false,selection:null,grid:false,width:null,height:200,runwayFactor:4},eventDelegates:{tap:"tapHandler","core-resize":"updateSize"},_scrollTop:0,observe:{"isAttached data grid width template scrollTarget":"initialize","multi selectionEnabled":"_resetSelection"},ready:function(){this._boundScrollHandler=this.scrollHandler.bind(this);this._boundPositionItems=this._positionItems.bind(this);this._oldMulti=this.multi;this._oldSelectionEnabled=this.selectionEnabled;this._virtualStart=0;this._virtualCount=0;this._physicalStart=0;this._physicalOffset=0;this._physicalSize=0;this._physicalSizes=[];this._physicalAverage=0;this._itemSizes=[];this._dividerSizes=[];this._repositionedItems=[];this._aboveSize=0;this._nestedGroups=false;this._groupStart=0;this._groupStartIndex=0},attached:function(){this.isAttached=true;this.template=this.querySelector("template");if(!this.template.bindingDelegate){this.template.bindingDelegate=this.element.syntax}this.resizableAttachedHandler()},detached:function(){this.isAttached=false;if(this._target){this._target.removeEventListener("scroll",this._boundScrollHandler)}this.resizableDetachedHandler()},updateSize:function(){if(!this._positionPending&&!this._needItemInit){this._resetIndex(this._getFirstVisibleIndex()||0);this.initialize()}},_resetSelection:function(){if(this._oldMulti!=this.multi&&!this.multi||this._oldSelectionEnabled!=this.selectionEnabled&&!this.selectionEnabled){this._clearSelection();this.refresh()}else{this.selection=this.$.selection.getSelection()}this._oldMulti=this.multi;this._oldSelectionEnabled=this.selectionEnabled},_adjustVirtualIndex:function(splices,group){if(this._targetSize===0){return}var totalDelta=0;for(var i=0;i=this._virtualStart){break}var delta=Math.max(s.addedCount-s.removed.length,idx-this._virtualStart);totalDelta+=delta;this._physicalStart+=delta;this._virtualStart+=delta;if(this._grouped){if(group){gitem=s.index}else{var g=this.groupForVirtualIndex(s.index);gidx=g.group;gitem=g.groupIndex}if(gidx==this._groupStart&&gitem0){var groupMax=this.getGroupLen()-this._groupStartIndex-1;if(inc>groupMax){inc-=groupMax+1;this._groupStart++;this._groupStartIndex=0}else{this._groupStartIndex+=inc;inc=0}}while(inc<0){if(-inc>this._groupStartIndex){inc+=this._groupStartIndex;this._groupStart--;this._groupStartIndex=this.getGroupLen()}else{this._groupStartIndex+=inc;inc=this.getGroupLen()}}}if(this.grid){if(this._grouped){inc=this._groupStartIndex%this._rowFactor}else{inc=this._virtualStart%this._rowFactor}if(inc){this.changeStartIndex(-inc)}}},getRowCount:function(dir){if(!this.grid){return dir}else if(!this._grouped){return dir*this._rowFactor}else{if(dir<0){if(this._groupStartIndex>0){return-Math.min(this._rowFactor,this._groupStartIndex)}else{var prevLen=this.getGroupLen(this._groupStart-1);return-Math.min(this._rowFactor,prevLen%this._rowFactor||this._rowFactor)}}else{return Math.min(this._rowFactor,this.getGroupLen()-this._groupStartIndex)}}},_virtualToPhysical:function(virtualIndex){var physicalIndex=(virtualIndex-this._physicalStart)%this._physicalCount;return physicalIndex<0?this._physicalCount+physicalIndex:physicalIndex},groupForVirtualIndex:function(virtual){if(!this._grouped){return{}}else{var group;for(group=0;groupvirtual){break}else{virtual-=groupLen}}return{group:group,groupIndex:virtual}}},virtualIndexForGroup:function(group,groupIndex){groupIndex=groupIndex?Math.min(groupIndex,this.getGroupLen(group)):0;group--;while(group>=0){groupIndex+=this.getGroupLen(group--)}return groupIndex},dataForIndex:function(virtual,group,groupIndex){if(this.data){if(this._nestedGroups){if(virtual0?1:0;if(Math.abs(scrollDelta)>Math.max(this._physicalSize,this._targetSize)){deltaCount=Math.round(scrollDelta/this._physicalAverage*this._rowFactor);deltaCount=Math.max(deltaCount,-this._virtualStart);deltaCount=Math.min(deltaCount,this._virtualCount-this._virtualStart-1);this._physicalOffset+=Math.max(scrollDelta,-this._physicalOffset);this.changeStartIndex(deltaCount)}else{var base=this._aboveSize+this._physicalOffset;var margin=.3*Math.max((this._physicalSize-this._targetSize,this._physicalSize));this._upperBound=base+margin;this._lowerBound=base+this._physicalSize-this._targetSize-margin;var flipBound=this._dir>0?this._upperBound:this._lowerBound;if(this._dir>0&&this._scrollTop>flipBound||this._dir<0&&this._scrollTop0&&(this._dir<0&&this._virtualStart>0||this._dir>0&&this._virtualStart0?this._virtualStart:this._virtualStart+this._physicalCount-1);var size=this._physicalSizes[idx];flipSize-=size;var cnt=this.getRowCount(this._dir);if(this._dir>0){this._physicalOffset+=size}this.changeStartIndex(cnt);if(this._dir<0){this._repositionedItems.push(this._virtualStart)}}}}if(this._updateItems(!scrollDelta)){if(Observer.hasObjectObserve){this.async(this._boundPositionItems)}else{Platform.flush();Platform.endOfMicrotask(this._boundPositionItems)}}},_updateItems:function(force){var i,virtualIndex,physicalIndex;var needsReposition=false;var groupIndex=this._groupStart;var groupItemIndex=this._groupStartIndex;for(i=0;i=this.getGroupLen(groupIndex)){groupItemIndex=0;groupIndex++}}}return needsReposition},_positionItems:function(){var i,virtualIndex,physicalIndex,physicalItem;this.updateMetrics();if(this._dir<0){while(this._repositionedItems.length){virtualIndex=this._repositionedItems.pop();physicalIndex=this._virtualToPhysical(virtualIndex);this._physicalOffset-=this._physicalSizes[physicalIndex]}if(this._scrollTop+this._targetSize=this._rowFactor){rowx=0;y+=lastHeight}x=this._rowMargin+rowx*this.width}else{y+=lastHeight}}if(this._scrollTop>=0){this._updateViewportHeight()}},_updateViewportHeight:function(){var remaining=Math.max(this._virtualCount-this._virtualStart-this._physicalCount,0);remaining=Math.ceil(remaining/this._rowFactor);var vs=this._physicalOffset+this._physicalSize+remaining*this._physicalAverage;if(this._viewportSize!=vs){this._viewportSize=vs;this.$.viewport.style.height=this._viewportSize+"px";this.syncScroller()}},_updateScrollPosition:function(scrollTop){var deltaHeight=this._virtualStart===0?this._physicalOffset:Math.min(scrollTop+this._physicalOffset,0);if(deltaHeight){if(this.adjustPositionAllowed){this._scrollTop=this.setScrollTop(scrollTop-deltaHeight)}this._physicalOffset-=deltaHeight}},tapHandler:function(e){var n=e.target;var p=e.path;if(!this.selectionEnabled||n===this){return}requestAnimationFrame(function(){var active=window.ShadowDOMPolyfill?wrap(document.activeElement):this.shadowRoot.activeElement;if(active&&active!=this&&active.parentElement!=this&&document.activeElement!=document.body){return}if(p[0].localName=="input"||p[0].localName=="button"||p[0].localName=="select"){return}var model=n.templateInstance&&n.templateInstance.model;if(model){var data=this.dataForIndex(model.index,model.groupIndex,model.groupItemIndex);var item=this._physicalItems[model.physicalIndex];if(!this.multi&&data==this.selection){this.$.selection.select(null)}else{this.$.selection.select(data)}this.asyncFire("core-activate",{data:data,item:item})}}.bind(this))},selectedHandler:function(e,detail){this.selection=this.$.selection.getSelection();var id=this.indexesForData(detail.item);this._selectedData.set(detail.item,detail.isSelected);if(id.physical>=0&&id.virtual>=0){this.refresh()}},selectItem:function(index){if(!this.selectionEnabled){return}var data=this.data[index];if(data){this.$.selection.select(data)}},setItemSelected:function(index,isSelected){var data=this.data[index];if(data){this.$.selection.setItemSelected(data,isSelected)}},indexesForData:function(data){var virtual=-1;var groupsLen=0;if(this._nestedGroups){for(var i=0;i=this._scrollTop-this._aboveSize){return virtualIndex}}},_resetIndex:function(index){index=Math.min(index,this._virtualCount-1);index=Math.max(index,0);this.changeStartIndex(index-this._virtualStart);this._scrollTop=this.setScrollTop(this._aboveSize+index/this._rowFactor*this._physicalAverage);this._physicalOffset=this._scrollTop-this._aboveSize;this._dir=0},scrollToItem:function(index){this.scrollToGroupItem(null,index)},scrollToGroup:function(group){this.scrollToGroupItem(group,0)},scrollToGroupItem:function(group,index){if(group!=null){index=this.virtualIndexForGroup(group,index)}this._resetIndex(index);this.refresh()}},Polymer.CoreResizable))})();Polymer("artist-details",{created:function(){this.data=[]},domReady:function(){this.tmpl=document.getElementById("tmpl");this.scrollTarget=this.tmpl.appScroller()},queryData:function(){this.tmpl.page=3;this.data=null;this.data=[];var url=this.url+"/rest/getArtist.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+this.artistId,i=0;this.async(function(){this.tmpl.doXhr(url,"json",function(event){var response=event.target.response["subsonic-response"];this.async(function(){Array.prototype.forEach.call(response.artist.album,function(e){var obj={name:e.name,artist:e.artist,coverArt:e.coverArt,id:e.id,starred:e.starred,url:this.url,user:this.user,pass:this.pass,version:this.version,listMode:this.listMode,bitRate:this.bitRate,colorThiefEnabled:this.colorThiefEnabled};this.data.push(obj);i=i+1;if(i===response.artist.album.length){this.tmpl.dataLoading=false}}.bind(this))})}.bind(this))})},playSomething:function(id,callback){var album=this.$.all.querySelector("#"+id);album.playAlbum();callback()}});(function(){"use strict";var app=document.querySelector("#tmpl");app.addEventListener("template-bound",function(){this.loadData();this.service=analytics.getService("PolySonic");this.tracker=this.service.getTracker("UA-50154238-6")});app.appName=chrome.i18n.getMessage("appName");app.appDesc=chrome.i18n.getMessage("appDesc");app.folderSelector=chrome.i18n.getMessage("folderSelector");app.shuffleButton=chrome.i18n.getMessage("shuffleButton");app.artistButton=chrome.i18n.getMessage("artistButton");app.podcastButton=chrome.i18n.getMessage("podcastButton");app.favoritesButton=chrome.i18n.getMessage("favoritesButton");app.searchButton=chrome.i18n.getMessage("searchButton");app.settingsButton=chrome.i18n.getMessage("settingsButton");app.nowPlayingLabel=chrome.i18n.getMessage("nowPlayingLabel");app.folderSelectorLabel=chrome.i18n.getMessage("folderSelectorLabel");app.clearQueue=chrome.i18n.getMessage("clearQueue");app.volumeLabel=chrome.i18n.getMessage("volumeLabel");app.analistics=chrome.i18n.getMessage("analistics");app.accept=chrome.i18n.getMessage("accept");app.decline=chrome.i18n.getMessage("decline");app.shuffleOptionsLabel=chrome.i18n.getMessage("shuffleOptionsLabel");app.optional=chrome.i18n.getMessage("optional");app.artistLabel=chrome.i18n.getMessage("artistLabel");app.albumLabel=chrome.i18n.getMessage("albumLabel");app.genreLabel=chrome.i18n.getMessage("genreLabel");app.songReturn=chrome.i18n.getMessage("songReturn");app.playButton=chrome.i18n.getMessage("playButton");app.yearError=chrome.i18n.getMessage("yearError");app.releasedAfter=chrome.i18n.getMessage("releasedAfter");app.releasedBefore=chrome.i18n.getMessage("releasedBefore");app.submitButton=chrome.i18n.getMessage("submitButton");app.deleteConfirm=chrome.i18n.getMessage("deleteConfirm");app.noResults=chrome.i18n.getMessage("noResults");app.urlError=chrome.i18n.getMessage("urlError");app.podcastSubmissionLabel=chrome.i18n.getMessage("podcastSubmissionLabel");app.diskUsed=chrome.i18n.getMessage("diskused");app.diskRemaining=chrome.i18n.getMessage("diskRemaining");app.playlistsButton=chrome.i18n.getMessage("playlistsButton");app.createPlaylistLabel=chrome.i18n.getMessage("createPlaylistLabel");app.playlistLabel=chrome.i18n.getMessage("playlistLabel");app.reloadAppLabel=chrome.i18n.getMessage("reloadApp");app.settingsDeleted=chrome.i18n.getMessage("settingsDeleted"); -this.app.dataLoading=true;if(sender.attributes.cover.value){this.app.getDbItem(sender.attributes.cover.value,function(ev){if(ev.target.result){var imgFile=ev.target.result;imgURL=window.URL.createObjectURL(imgFile);obj={id:sender.attributes.streamId.value,artist:"",title:sender.attributes.trackTitle.value,cover:imgURL};this.getPaletteFromDb(sender.attributes.cover.value,function(palette){obj.palette=palette;if(this.audio.paused){this.app.getImageForPlayer(imgURL,function(){this.app.setFabColor(obj);this.doPlay(obj,url);this.app.dataLoading=false;this.app.doToast(chrome.i18n.getMessage("added2Queue"))}.bind(this))}else{this.app.dataLoading=false;this.app.playlist.push(obj);this.app.doToast(chrome.i18n.getMessage("added2Queue"))}}.bind(this))}else{this.app.getImageFile(artURL,sender.attributes.cover.value,function(ev){var imgFile=ev.target.result;imgURL=window.URL.createObjectURL(imgFile);obj={id:sender.attributes.streamId.value,artist:"",title:sender.attributes.trackTitle.value,cover:imgURL};this.app.colorThiefHandler(imgURL,sender.attributes.cover.value,function(colorArray){obj.palette=colorArray});if(this.audio.paused){this.app.getImageForPlayer(imgURL,function(){this.app.dataLoading=false;this.app.setFabColor(obj);this.doPlay(obj,url);this.app.doToast(chrome.i18n.getMessage("added2Queue"))}.bind(this))}else{this.app.dataLoading=false;this.app.playlist.push(obj);this.app.doToast(chrome.i18n.getMessage("added2Queue"))}}.bind(this))}}.bind(this))}else{imgURL="../../../images/default-cover-art.png";if(this.audio.paused){obj={id:sender.attributes.streamId.value,artist:"",title:sender.attributes.trackTitle.value,cover:imgURL};this.app.getImageForPlayer(imgURL);this.doPlay(obj,url)}else{obj={id:sender.attributes.streamId.value,artist:"",title:sender.attributes.trackTitle.value,cover:imgURL};this.app.playlist.push(obj);this.app.doToast(chrome.i18n.getMessage("added2Queue"))}}},showingChanged:function(){"use strict";var fab=document.getElementById("fab");if(this.showing==="podcast"){fab.state="podcast"}else{fab.state="off"}},topOfPage:function(){"use strict";this.scrollTarget.scrollTop=0},deleteDialog:function(event,detail,sender){"use strict";this.app.delID=sender.attributes.ident.value;this.app.$.confirmDelete.open()},deleteChannel:function(id){"use strict";var url=this.url+"/rest/deletePodcastChannel.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+id;this.app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){this.clearData(function(){this.$.ajax.go()}.bind(this))}}.bind(this))},refreshContent:function(){"use strict";if(this.post.offset!==0){this.post.offset=0}this.clearData(function(){this.$.ajax.go()}.bind(this))},downloadEpisode:function(event,detail,sender){"use strict";var url=this.url+"/rest/downloadPodcastEpisode.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+sender.attributes.ident.value;this.app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){this.clearData(function(){this.$.ajax.go();this.app.doToast(chrome.i18n.getMessage("downloadPodcast"))}.bind(this))}}.bind(this))},episodeDialog:function(event,detail,sender){"use strict";this.app.delID=sender.attributes.ident.value;this.app.$.episodeConfirm.open()},deleteEpisode:function(id){"use strict";var url=this.url+"/rest/deletePodcastEpisode.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+id;this.app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){this.clearData(function(){this.$.ajax.go()}.bind(this))}}.bind(this))},toggleCollapse:function(event,detail,sender){"use strict";var id="#"+sender.attributes.ident.value;this.$.all.querySelector(id).toggle()},playSomething:function(id,callback){"use strict";var album=this.$.all.querySelector("#"+id);album.playAlbum();callback()},jumpToLetter:function(letter){"use strict";var i,findIndexByKeyValue=function(arraytosearch,key,valuetosearch){for(i=0;i=this.offsetWidth-this.edgeSwipeSensitivity:e.pageX<=this.edgeSwipeSensitivity)},trackStart:function(e){if(this.swipeAllowed()){this.dragging=true;if(this.isMainSelected()){this.dragging=this.peeking||this.isEdgeTouch(e)}if(this.dragging){this.width=this.$.drawer.offsetWidth;this.transition=false;e.preventTap()}}},translateXForDeltaX:function(deltaX){var isMain=this.isMainSelected();if(this.rightDrawer){return Math.max(0,isMain?this.width+deltaX:deltaX)}else{return Math.min(0,isMain?deltaX-this.width:deltaX)}},trackx:function(e){if(this.dragging){if(this.peeking){if(Math.abs(e.dx)<=this.edgeSwipeSensitivity){return}this.peeking=false}this.moveDrawer(this.translateXForDeltaX(e.dx))}},trackEnd:function(e){if(this.dragging){this.dragging=false;this.transition=true;this.moveDrawer(null);if(this.rightDrawer){this.selected=e.xDirection>0?"main":"drawer"}else{this.selected=e.xDirection>0?"drawer":"main"}}},transformForTranslateX:function(translateX){if(translateX===null){return""}return this.hasWillChange?"translateX("+translateX+"px)":"translate3d("+translateX+"px, 0, 0)"},moveDrawer:function(translateX){var s=this.$.drawer.style;if(this.hasTransform){s.transform=this.transformForTranslateX(translateX)}else{s.webkitTransform=this.transformForTranslateX(translateX)}}});Polymer("core-range",{value:0,min:0,max:100,step:1,ratio:0,observe:{"value min max step":"update"},calcRatio:function(value){return(this.clampValue(value)-this.min)/(this.max-this.min)},clampValue:function(value){return Math.min(this.max,Math.max(this.min,this.calcStep(value)))},calcStep:function(value){return this.step?Math.round(value/this.step)/(1/this.step):value},validateValue:function(){var v=this.clampValue(this.value);this.value=this.oldValue=isNaN(v)?this.oldValue:v;return this.value!==v},update:function(){this.validateValue();this.ratio=this.calcRatio(this.value)*100}});Polymer("paper-progress",{secondaryProgress:0,indeterminate:false,step:0,observe:{"value secondaryProgress min max indeterminate":"update"},update:function(){this.super();this.secondaryProgress=this.clampValue(this.secondaryProgress);this.secondaryRatio=this.calcRatio(this.secondaryProgress)*100;this.$.activeProgress.classList.toggle("indeterminate",this.indeterminate)},transformProgress:function(progress,ratio){var transform="scaleX("+ratio/100+")";progress.style.transform=progress.style.webkitTransform=transform},ratioChanged:function(){this.transformProgress(this.$.activeProgress,this.ratio)},secondaryRatioChanged:function(){this.transformProgress(this.$.secondaryProgress,this.secondaryRatio)}});Polymer("core-input",{publish:{committedValue:"",preventInvalidInput:false},previousValidInput:"",eventDelegates:{input:"inputAction",change:"changeAction"},ready:function(){this.disabledHandler();this.placeholderHandler()},attributeChanged:function(attr,old){if(this[attr+"Handler"]){this[attr+"Handler"](old)}},disabledHandler:function(){if(this.disabled){this.setAttribute("aria-disabled","")}else{this.removeAttribute("aria-disabled")}},placeholderHandler:function(){if(this.placeholder){this.setAttribute("aria-label",this.placeholder)}else{this.removeAttribute("aria-label")}},commit:function(){this.committedValue=this.value},changeAction:function(){this.commit()},inputAction:function(e){if(this.preventInvalidInput){if(!e.target.validity.valid){e.target.value=this.previousValidInput}else{this.previousValidInput=e.target.value}}}});(function(){var paperInput=CoreStyle.g.paperInput=CoreStyle.g.paperInput||{};paperInput.labelColor="#757575";paperInput.focusedColor="#4059a9";paperInput.invalidColor="#d34336";Polymer("paper-input-decorator",{publish:{label:"",floatingLabel:false,disabled:{value:false,reflect:true},labelVisible:null,isInvalid:false,autoValidate:false,error:"",focused:{value:false,reflect:true}},computed:{floatingLabelVisible:"floatingLabel && !_labelVisible",_labelVisible:"(labelVisible === true || labelVisible === false) ? labelVisible : _autoLabelVisible"},ready:function(){Polymer.addEventListener(this,"focus",this.focusAction.bind(this),true);Polymer.addEventListener(this,"blur",this.blurAction.bind(this),true)},attached:function(){this.input=this.querySelector("input,textarea");this.mo=new MutationObserver(function(){this.input=this.querySelector("input,textarea")}.bind(this));this.mo.observe(this,{childList:true})},detached:function(){this.mo.disconnect();this.mo=null},prepareLabelTransform:function(){var toRect=this.$.floatedLabelText.getBoundingClientRect();var fromRect=this.$.labelText.getBoundingClientRect();if(toRect.width!==0){var sy=toRect.height/fromRect.height;this.$.labelText.cachedTransform="scale3d("+toRect.width/fromRect.width+","+sy+",1) "+"translate3d(0,"+(toRect.top-fromRect.top)/sy+"px,0)"}},animateFloatingLabel:function(){if(!this.floatingLabel||this.labelAnimated){return false}if(!this.$.labelText.cachedTransform){this.prepareLabelTransform()}if(!this.$.labelText.cachedTransform){return false}this.labelAnimated=true;this.async(function(){this.transitionEndAction()},null,250);if(this._labelVisible){if(!this.$.labelText.style.webkitTransform&&!this.$.labelText.style.transform){this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform;this.$.labelText.style.transform=this.$.labelText.cachedTransform;this.$.labelText.offsetTop}this.$.labelText.style.webkitTransform="";this.$.labelText.style.transform=""}else{this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform;this.$.labelText.style.transform=this.$.labelText.cachedTransform;this.input.placeholder=""}return true},animateUnderline:function(e){if(this.focused){var rect=this.$.underline.getBoundingClientRect();var right=e.x-rect.left;this.$.focusedUnderline.style.mozTransformOrigin=right+"px";this.$.focusedUnderline.style.webkitTransformOrigin=right+"px ";this.$.focusedUnderline.style.transformOriginX=right+"px";this.underlineAnimated=true}},validate:function(){this.isInvalid=!this.input.validity.valid;return this.input.validity.valid},_labelVisibleChanged:function(old){if(old!==undefined){if(!this.animateFloatingLabel()){this.updateInputLabel(this.input,this.label)}}},labelVisibleChanged:function(){if(this.labelVisible==="true"){this.labelVisible=true}else if(this.labelVisible==="false"){this.labelVisible=false}},labelChanged:function(){if(this.input){this.updateInputLabel(this.input,this.label)}},isInvalidChanged:function(){this.classList.toggle("invalid",this.isInvalid)},focusedChanged:function(){this.updateLabelVisibility(this.input&&this.input.value);if(this.lastEvent){this.animateUnderline(this.lastEvent);this.lastEvent=null}this.underlineVisible=this.focused},inputChanged:function(old){if(this.input){this.updateLabelVisibility(this.input.value);this.updateInputLabel(this.input,this.label);if(this.autoValidate){this.validate()}}if(old){this.updateInputLabel(old,"")}},focusAction:function(){this.focused=true},blurAction:function(){this.focused=false},updateLabelVisibility:function(value){var v=value!==null&&value!==undefined?String(value):value;this._autoLabelVisible=!this.focused&&!v||!this.floatingLabel&&!v},updateInputLabel:function(input,label){if(this._labelVisible){this.input.placeholder=this.label}else{this.input.placeholder=""}if(label){input.setAttribute("aria-label",label)}else{input.removeAttribute("aria-label")}},inputAction:function(){this.updateLabelVisibility(this.input.value);if(this.autoValidate){this.validate()}},downAction:function(e){if(e.target!==this.input&&this.focused){e.preventDefault();return}this.lastEvent=e},tapAction:function(e){if(this.disabled){return}if(this.focused){return}if(this.input){this.input.focus();e.preventDefault()}},transitionEndAction:function(){this.underlineAnimated=false;this.labelAnimated=false;if(this._labelVisible){this.input.placeholder=this.label}},charCounterErrorAction:function(e){this.isInvalid=e.detail.hasError;this.$.errorIcon.hidden=e.detail.hideErrorIcon}})})();Polymer("paper-input",{publish:{label:"",floatingLabel:false,disabled:{value:false,reflect:true},value:"",committedValue:""},focus:function(){this.$.input.focus()},valueChanged:function(){this.$.decorator.updateLabelVisibility(this.value)},changeAction:function(e){this.fire("change",null,this)}});Polymer("paper-slider",{snaps:false,pin:false,disabled:false,secondaryProgress:0,editable:false,maxMarkers:100,dragging:false,observe:{"step snaps":"update"},ready:function(){this.update()},update:function(){this.positionKnob(this.calcRatio(this.value));this.updateMarkers()},minChanged:function(){this.update();this.setAttribute("aria-valuemin",this.min)},maxChanged:function(){this.update();this.setAttribute("aria-valuemax",this.max)},valueChanged:function(){this.update();this.setAttribute("aria-valuenow",this.value);this.fire("core-change")},disabledChanged:function(){if(this.disabled){this.removeAttribute("tabindex")}else{this.tabIndex=0}},immediateValueChanged:function(){if(!this.dragging){this.value=this.immediateValue}this.fire("immediate-value-change")},expandKnob:function(){this.expand=true},resetKnob:function(){this.expandJob&&this.expandJob.stop();this.expand=false},positionKnob:function(ratio){this.immediateValue=this.calcStep(this.calcKnobPosition(ratio))||0;this._ratio=this.snaps?this.calcRatio(this.immediateValue):ratio;this.$.sliderKnob.style.left=this._ratio*100+"%"},inputChange:function(){this.value=this.$.input.value;this.fire("change")},calcKnobPosition:function(ratio){return(this.max-this.min)*ratio+this.min},trackStart:function(e){this._w=this.$.sliderBar.offsetWidth;this._x=this._ratio*this._w;this._startx=this._x||0;this._minx=-this._startx;this._maxx=this._w-this._startx;this.$.sliderKnob.classList.add("dragging");this.dragging=true;e.preventTap()},trackx:function(e){var x=Math.min(this._maxx,Math.max(this._minx,e.dx));this._x=this._startx+x;this.immediateValue=this.calcStep(this.calcKnobPosition(this._x/this._w))||0;var s=this.$.sliderKnob.style;s.transform=s.webkitTransform="translate3d("+(this.snaps?this.calcRatio(this.immediateValue)*this._w-this._startx:x)+"px, 0, 0)"},trackEnd:function(){var s=this.$.sliderKnob.style;s.transform=s.webkitTransform="";this.$.sliderKnob.classList.remove("dragging");this.dragging=false;this.resetKnob();this.value=this.immediateValue;this.fire("change")},knobdown:function(e){e.preventDefault();this.expandKnob()},bardown:function(e){e.preventDefault();this.transiting=true;this._w=this.$.sliderBar.offsetWidth;var rect=this.$.sliderBar.getBoundingClientRect();var ratio=(e.x-rect.left)/this._w;this.positionKnob(ratio);this.expandJob=this.job(this.expandJob,this.expandKnob,60);this.asyncFire("change")},knobTransitionEnd:function(e){if(e.target===this.$.sliderKnob){this.transiting=false}},updateMarkers:function(){this.markers=[];var l=(this.max-this.min)/this.step;if(!this.snaps&&l>this.maxMarkers){return}for(var i=0;iself.innerWidth||(h=Math.max(doc.clientHeight,body.clientHeight))>self.innerHeight?{w:body.clientWidth,h:body.clientHeight}:{w:w,h:h}}Polymer("core-dropdown",{publish:{relatedTarget:null,halign:"left",valign:"top"},measure:function(){var target=this.target;var pos=target.style.position;target.style.position="fixed";target.style.left="0px";target.style.top="0px";var rect=target.getBoundingClientRect();target.style.position=pos;target.style.left=null;target.style.top=null;return rect},resetTargetDimensions:function(){var dims=this.dimensions;var style=this.target.style;if(dims.position.h_by===this.localName){style[dims.position.h]=null;dims.position.h_by=null}if(dims.position.v_by===this.localName){style[dims.position.v]=null;dims.position.v_by=null}style.width=null;style.height=null;this.super()},positionTarget:function(){if(!this.relatedTarget){this.relatedTarget=this.target.parentElement||this.target.parentNode&&this.target.parentNode.host;if(!this.relatedTarget){this.super();return}}var target=this.sizingTarget;var rect=this.measure();target.style.width=Math.ceil(rect.width)+"px";target.style.height=Math.ceil(rect.height)+"px";if(this.layered){this.positionLayeredTarget()}else{this.positionNestedTarget()}},positionLayeredTarget:function(){var target=this.target;var rect=this.relatedTarget.getBoundingClientRect();var dims=this.dimensions;var margin=dims.margin;var vp=viewSize();if(!dims.position.h){if(this.halign==="right"){target.style.right=vp.w-rect.right-margin.right+"px";dims.position.h="right"}else{target.style.left=rect.left-margin.left+"px";dims.position.h="left"}dims.position.h_by=this.localName}if(!dims.position.v){if(this.valign==="bottom"){target.style.bottom=vp.h-rect.bottom-margin.bottom+"px";dims.position.v="bottom"}else{target.style.top=rect.top-margin.top+"px";dims.position.v="top"}dims.position.v_by=this.localName}if(dims.position.h_by||dims.position.v_by){target.style.position="fixed"}},positionNestedTarget:function(){var target=this.target;var related=this.relatedTarget;var t_op=target.offsetParent;var r_op=related.offsetParent;if(window.ShadowDOMPolyfill){t_op=wrap(t_op);r_op=wrap(r_op)}if(t_op!==r_op&&t_op!==related){console.warn("core-dropdown-overlay: dropdown's offsetParent must be the relatedTarget or the relatedTarget's offsetParent!")}var dims=this.dimensions;var margin=dims.margin;var inside=t_op===related;if(!dims.position.h){if(this.halign==="right"){target.style.right=(inside?0:t_op.offsetWidth-related.offsetLeft-related.offsetWidth)-margin.right+"px";dims.position.h="right"}else{target.style.left=(inside?0:related.offsetLeft)-margin.left+"px";dims.position.h="left"}dims.position.h_by=this.localName}if(!dims.position.v){if(this.valign==="bottom"){target.style.bottom=(inside?0:t_op.offsetHeight-related.offsetTop-related.offsetHeight)-margin.bottom+"px";dims.position.v="bottom"}else{target.style.top=(inside?0:related.offsetTop)-margin.top+"px";dims.position.v="top"}dims.position.v_by=this.localName}}})})();Polymer("paper-dropdown-transition",{publish:{duration:500},setup:function(node){this.super(arguments);var to={top:"0%",left:"0%",bottom:"100%",right:"100%"};var bg=node.$.background;bg.style.webkitTransformOrigin=to[node.halign]+" "+to[node.valign];bg.style.transformOrigin=to[node.halign]+" "+to[node.valign]},transitionOpened:function(node,opened){this.super(arguments);if(opened){if(this.player){this.player.cancel()}var duration=Number(node.getAttribute("duration"))||this.duration;var anims=[];var size=node.getBoundingClientRect();var ink=node.$.ripple;var offset=.2;anims.push(new Animation(ink,[{opacity:.9,transform:"scale(0)"},{opacity:.9,transform:"scale(1)"}],{duration:duration*offset}));var bg=node.$.background;var sx=40/size.width;var sy=40/size.height;anims.push(new Animation(bg,[{opacity:.9,transform:"scale("+sx+","+sy+")"},{opacity:1,transform:"scale("+Math.max(sx,.95)+","+Math.max(sy,.5)+")"},{opacity:1,transform:"scale(1, 1)"}],{delay:duration*offset,duration:duration*(1-offset),fill:"forwards"}));var menu=node.querySelector(".menu");if(menu){var items=menu.items||menu.children.array();var itemDelay=offset+(1-offset)/2;var itemDuration=duration*(1-itemDelay)/items.length;var reverse=this.valign==="bottom";items.forEach(function(item,i){anims.push(new Animation(item,[{opacity:0},{opacity:1}],{delay:duration*itemDelay+itemDuration*(reverse?items.length-1-i:i),duration:itemDuration,fill:"both"}))}.bind(this));anims.push(new Animation(node.$.scroller,[{opacity:1},{opacity:1}],{delay:duration*itemDelay,duration:itemDuration*items.length,fill:"both"}))}else{anims.push(new Animation(node.$.scroller,[{opacity:0},{opacity:1}],{delay:duration*(offset+(1-offset)/2),duration:duration*.5,fill:"both"}))}var group=new AnimationGroup(anims,{easing:"cubic-bezier(0.4, 0, 0.2, 1)"});this.player=document.timeline.play(group);this.player.onfinish=function(){this.fire("core-transitionend",this,node)}.bind(this)}else{this.fire("core-transitionend",this,node)}}});Polymer("paper-dropdown",{publish:{transition:"paper-dropdown-transition"},ready:function(){this.super();this.sizingTarget=this.$.scroller}});(function(){var ID=0;function generate(node){if(!node.id){node.id="core-label-"+ID++}return node.id}Polymer("core-label",{publish:{"for":{reflect:true,value:""}},eventDelegates:{tap:"tapHandler"},created:function(){generate(this);this._forElement=null},ready:function(){if(!this.for){this._forElement=this.querySelector("[for]");this._tie()}},tapHandler:function(ev){if(!this._forElement){return}if(ev.target===this._forElement){return}this._forElement.focus();this._forElement.click();this.fire("tap",null,this._forElement)},_tie:function(){if(this._forElement){this._forElement.setAttribute("aria-labelledby",this.id)}},_findScope:function(){var n=this.parentNode;while(n&&n.parentNode){n=n.parentNode}return n},forChanged:function(oldFor,newFor){if(this._forElement){this._forElement.removeAttribute("aria-labelledby")}var scope=this._findScope();if(!scope){return}this._forElement=scope.querySelector(newFor);if(this._forElement){this._tie()}}})})();Polymer("volume-slider",{created:function(){this.volume=this.volume||100},volumeChanged:function(){var audio=document.getElementById("audio");audio.volume=this.volume/100;chrome.storage.sync.set({volume:this.volume})}});(function(){var p={publish:{label:"Select an item",openedIcon:"arrow-drop-up",closedIcon:"arrow-drop-down"},selectedItemLabel:"",overlayListeners:{"core-overlay-open":"openAction","core-activate":"activateAction","core-select":"selectAction"},activateAction:function(e){this.opened=false},selectAction:function(e){var detail=e.detail;if(detail.isSelected){this.$.label.classList.add("selectedItem");this.selectedItemLabel=detail.item.label||detail.item.textContent}else{this.$.label.classList.remove("selectedItem");this.selectedItemLabel=""}}};Polymer.mixin2(p,Polymer.CoreFocusable);Polymer("paper-dropdown-menu",p)})();Polymer("subsonic-login",{timer:0,ready:function(){"use strict";this.post=[];this.app=document.getElementById("tmpl");this.urlError=chrome.i18n.getMessage("urlError");this.urlLabel=chrome.i18n.getMessage("urlLabel");this.usernameError=chrome.i18n.getMessage("usernameError");this.usernameLabel=chrome.i18n.getMessage("usernameLabel");this.passwordLabel=chrome.i18n.getMessage("passwordLabel");this.showPass=chrome.i18n.getMessage("showPass");this.hideThePass=chrome.i18n.getMessage("hidePass");this.submitButton=chrome.i18n.getMessage("submitButton")},submit:function(){"use strict";if(this.invalid1&&this.invalid2&&this.post.version===undefined){this.app.doToast("URL, Username & Version Required")}else if(this.invalid1){this.app.doToast("URL Required")}else if(this.invalid2){this.app.doToast("Username Required")}else if(!this.invalid1&&!this.invalid2&&!this.invalid3){var lastChar=this.post.url.substr(-1);if(lastChar==="/"){this.post.url=this.post.url.substring(0,this.post.url.length-1)}this.$.ajax.go()}},hidePass:function(event,detail,sender){"use strict";var type=this.$.password.type,button=this.$.showPass,timer=this.timer;if(type==="text"){this.$.password.type="password";button.innerHTML=this.showPass;if(timer){clearTimeout(timer);timer=0}}else{this.$.password.type="text";button.innerHTML=this.hideThePass;timer=setTimeout(function(){this.$.password.type="password";button.innerHTML=this.showPass;timer=0}.bind(this),15e3)}},responseChanged:function(){"use strict";var wall=document.getElementById("wall");if(this.response){if(this.response["subsonic-response"].status==="ok"){chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass});this.app.url=this.post.url;this.app.user=this.post.user;this.app.pass=this.post.pass;this.app.userDetails();this.app.version=this.response["subsonic-response"].version;this.app.doToast("Loading Data");this.app.tracker.sendEvent("API Version",this.response["subsonic-response"].version);this.app.$.firstRun.close();this.app.doXhr(this.url+"/rest/getMusicFolders.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic","json",function(e){this.app.mediaFolders=e.target.response["subsonic-response"].musicFolders.musicFolder;if(!e.target.response["subsonic-response"].musicFolders.musicFolder[1]){this.app.$.sortBox.style.display="none"}}.bind(this));setTimeout(function(){wall.doAjax()},100)}else{console.log(this.response);this.app.doToast(this.response["subsonic-response"].error.message)}}},errorChanged:function(){"use strict";if(this.error.statusCode===0){this.app.doToast(chrome.i18n.getMessage("connectionError"))}},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version}});Polymer("paper-radio-button",{publish:{checked:{value:false,reflect:true},label:"",toggles:false, -disabled:{value:false,reflect:true}},eventDelegates:{tap:"tap"},tap:function(){if(this.disabled){return}var old=this.checked;this.toggle();if(this.checked!==old){this.fire("change")}},toggle:function(){this.checked=!this.toggles||!this.checked},checkedChanged:function(){this.setAttribute("aria-checked",this.checked?"true":"false");this.fire("core-change")},labelChanged:function(){this.setAttribute("aria-label",this.label)}});Polymer("paper-toggle-button",{checked:false,disabled:false,eventDelegates:{down:"downAction",up:"upAction",tap:"tap",trackstart:"trackStart",trackx:"trackx",trackend:"trackEnd"},downAction:function(e){var rect=this.$.ink.getBoundingClientRect();this.$.ink.downAction({x:rect.left+rect.width/2,y:rect.top+rect.height/2})},upAction:function(e){this.$.ink.upAction()},tap:function(){if(this.disabled){return}this.checked=!this.checked;this.fire("change")},trackStart:function(e){if(this.disabled){return}this._w=this.$.toggleBar.offsetWidth/2;e.preventTap()},trackx:function(e){this._x=Math.min(this._w,Math.max(0,this.checked?this._w+e.dx:e.dx));this.$.toggleButton.classList.add("dragging");var s=this.$.toggleButton.style;s.webkitTransform=s.transform="translate3d("+this._x+"px,0,0)"},trackEnd:function(){var s=this.$.toggleButton.style;s.transform=s.webkitTransform="";this.$.toggleButton.classList.remove("dragging");var old=this.checked;this.checked=Math.abs(this._x)>this._w/2;if(this.checked!==old){this.fire("change")}},checkedChanged:function(){this.setAttribute("aria-pressed",Boolean(this.checked));this.fire("core-change")}});Polymer("settings-menu",{post:{},manifest:chrome.runtime.getManifest(),urlError:chrome.i18n.getMessage("urlError"),urlLabel:chrome.i18n.getMessage("urlLabel"),usernameError:chrome.i18n.getMessage("usernameError"),usernameLabel:chrome.i18n.getMessage("usernameLabel"),passwordLabel:chrome.i18n.getMessage("passwordLabel"),showPass:chrome.i18n.getMessage("showPass"),hideThePass:chrome.i18n.getMessage("hidePass"),submitButton:chrome.i18n.getMessage("submitButton"),bitrateLabel:chrome.i18n.getMessage("bitrateLabel"),cacheDetails:chrome.i18n.getMessage("cacheDetails"),clearCacheLabel:chrome.i18n.getMessage("clearCacheLabel"),clearSettingsLabel:chrome.i18n.getMessage("clearSettingsLabel"),appName:chrome.i18n.getMessage("appName"),licenseInfoLink:chrome.i18n.getMessage("licenseInfoLink"),showLicenseLabel:chrome.i18n.getMessage("showLicenseLabel"),speeds:[96,128,192,256,320],timer:0,created:function(){this.elementReady=false},domReady:function(){this.app=document.getElementById("tmpl");this.wall=document.getElementById("wall");this.outputVersion(this.manifest);setTimeout(function(){this.elementReady=true}.bind(this),500)},outputVersion:function(manifest){this.polysonicVersion=manifest.version;console.log("App version: "+this.polysonicVersion)},validate:function(callback){"use strict";var $d=this.$.validate.querySelectorAll("paper-input-decorator");Array.prototype.forEach.call($d,function(d){d.isInvalid=!d.querySelector("input").validity.valid});callback()},submit:function(){"use strict";this.validate(function(){var invalid1=this.$.input1.classList.contains("invalid"),invalid2=this.$.input2.classList.contains("invalid"),invalid3=this.$.input3.classList.contains("invalid");if(invalid1&&invalid2&&this.post.version===undefined){this.app.doToast("URL, Username & Version Required")}else if(invalid1){this.app.doToast("URL Required")}else if(invalid2){this.app.doToast("Username Required")}else if(this.version===undefined){this.app.doToast("Version Required")}if(!invalid1&&!invalid2&&!invalid3&&this.post.version!==undefined&&this.post.bitRate!==undefined){var lastChar=this.post.url.substr(-1);if(lastChar==="/"){this.post.url=this.post.url.substring(0,this.post.url.length-1)}this.$.ajax.go();this.wall.clearData(function(){this.wall.doAjax()}.bind(this))}}.bind(this))},hidePass:function(event,detail,sender){"use strict";var type=this.$.password.type,button=this.$.showPass,timer=this.timer;if(type==="text"){this.$.password.type="password";button.innerHTML=this.showPass;if(timer){clearTimeout(timer);timer=0}}else{this.$.password.type="text";button.innerHTML=this.hideThePass;timer=setTimeout(function(){this.$.password.type="password";button.innerHTML=this.showPass;timer=0}.bind(this),15e3)}},doClearCache:function(){this.clearCache(function(){this.app.$.recommendReloadDialog.open()}.bind(this))},clearCache:function(callback){var req=indexedDB.deleteDatabase("albumInfo");req.onsuccess=function(){console.log("Deleted database successfully");this.app.createObjectStore();this.app.calculateStorageSize()}.bind(this);req.onerror=function(){console.log("Error deleting database");this.app.calculateStorageSize()}.bind(this);req.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked");this.app.calculateStorageSize()}.bind(this);callback()},clearSettings:function(){chrome.storage.sync.clear();this.app.url="";this.app.user="";this.app.pass="";this.app.version="";this.app.bitRate="";this.app.querySize="";this.post=[];this.clearCache(function(){this.app.$.reloadAppDialog.open()}.bind(this))},responseChanged:function(){"use strict";if(this.response){if(this.response["subsonic-response"].status==="ok"){if(this.post.url!==this.url){var req=indexedDB.deleteDatabase("albumInfo");req.onsuccess=function(){console.log("Deleted database successfully");this.app.createObjectStore()};req.onerror=function(){console.log("Error deleting database")};req.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked")}}chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass,version:this.response["subsonic-response"].version,bitRate:this.post.bitRate,querySize:this.post.querySize,queryMethod:this.post.queryMethod});this.app.url=this.post.url;this.app.user=this.post.user;this.app.pass=this.post.pass;this.app.version=this.response["subsonic-response"].version;this.app.bitRate=this.post.bitRate;this.app.querySize=this.post.querySize;this.app.queryMethod=this.post.queryMethod;this.app.doToast("Settings Saved")}else if(this.response["subsonic-response"].status==="failed"){this.app.doToast(this.response["subsonic-response"].error.message)}else{this.app.doToast("Error Connecting to Server. Check Settings")}}},bitRateSelect:function(){chrome.storage.sync.set({bitRate:this.post.bitRate});this.app.bitRate=this.post.bitRate;console.log("Bitrate: "+this.post.bitRate)},querySelect:function(){chrome.storage.sync.set({querySize:this.post.querySize});this.app.querySize=this.post.querySize;console.log("Query Size: "+this.post.querySize)},methodSelect:function(){chrome.storage.sync.set({queryMethod:this.post.queryMethod});this.app.queryMethod=this.post.queryMethod;console.log("Query Method: "+this.post.queryMethod)},errorChanged:function(){"use strict";if(this.error.statusCode===0){this.app.doToast(chrome.i18n.getMessage("connectionError"))}},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version},bitRateChanged:function(){this.post.bitRate=this.bitRate},querySizeChanged:function(){this.post.querySize=this.querySize},queryMethodChanged:function(){this.post.queryMethod=this.queryMethod},showQuota:function(){this.app.calculateStorageSize();this.$.quota.toggle()},linkGo:function(event,detail,sender){var url=sender.attributes.link.value;window.open(url,"_blank")},analisticsToggle:function(){chrome.storage.sync.set({analistics:this.app.analisticsEnabled})},getLicense:function(event,detail,sender){var animation=new CoreAnimation;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();this.app.getLicense(function(){animation.cancel()})}});Polymer("paper-fab",{publish:{src:"",icon:"",mini:false,raised:true,recenteringTouch:true,fill:false},iconChanged:function(oldIcon){var label=this.getAttribute("aria-label");if(!label||label===oldIcon){this.setAttribute("aria-label",this.icon)}}});Polymer("animated-fab",{created:function(){this.state=this.state||"off";this.page=this.page||0},pageChanged:function(){var pName;if(this.page===1){pName="Player";this.state="top"}else if(this.page===0){pName="Album Wall";this.state="off"}else if(this.page===2){pName="Settings";this.state="off"}else if(this.page===3){pName="Artist Details";this.state="off"}else{this.state="off"}if(this.page===0&&this.showing==="podcast"){this.state="podcast"}document.getElementById("tmpl").tracker.sendAppView(pName)},playingChanged:function(){if(this.playing){document.getElementById("tmpl").playThis()}}});(function(){var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);var IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8;Polymer("core-list",Polymer.mixin({publish:{data:null,groups:null,scrollTarget:null,selectionEnabled:true,multi:false,selection:null,grid:false,width:null,height:200,runwayFactor:4},eventDelegates:{tap:"tapHandler","core-resize":"updateSize"},_scrollTop:0,observe:{"isAttached data grid width template scrollTarget":"initialize","multi selectionEnabled":"_resetSelection"},ready:function(){this._boundScrollHandler=this.scrollHandler.bind(this);this._boundPositionItems=this._positionItems.bind(this);this._oldMulti=this.multi;this._oldSelectionEnabled=this.selectionEnabled;this._virtualStart=0;this._virtualCount=0;this._physicalStart=0;this._physicalOffset=0;this._physicalSize=0;this._physicalSizes=[];this._physicalAverage=0;this._itemSizes=[];this._dividerSizes=[];this._repositionedItems=[];this._aboveSize=0;this._nestedGroups=false;this._groupStart=0;this._groupStartIndex=0},attached:function(){this.isAttached=true;this.template=this.querySelector("template");if(!this.template.bindingDelegate){this.template.bindingDelegate=this.element.syntax}this.resizableAttachedHandler()},detached:function(){this.isAttached=false;if(this._target){this._target.removeEventListener("scroll",this._boundScrollHandler)}this.resizableDetachedHandler()},updateSize:function(){if(!this._positionPending&&!this._needItemInit){this._resetIndex(this._getFirstVisibleIndex()||0);this.initialize()}},_resetSelection:function(){if(this._oldMulti!=this.multi&&!this.multi||this._oldSelectionEnabled!=this.selectionEnabled&&!this.selectionEnabled){this._clearSelection();this.refresh()}else{this.selection=this.$.selection.getSelection()}this._oldMulti=this.multi;this._oldSelectionEnabled=this.selectionEnabled},_adjustVirtualIndex:function(splices,group){if(this._targetSize===0){return}var totalDelta=0;for(var i=0;i=this._virtualStart){break}var delta=Math.max(s.addedCount-s.removed.length,idx-this._virtualStart);totalDelta+=delta;this._physicalStart+=delta;this._virtualStart+=delta;if(this._grouped){if(group){gitem=s.index}else{var g=this.groupForVirtualIndex(s.index);gidx=g.group;gitem=g.groupIndex}if(gidx==this._groupStart&&gitem0){var groupMax=this.getGroupLen()-this._groupStartIndex-1;if(inc>groupMax){inc-=groupMax+1;this._groupStart++;this._groupStartIndex=0}else{this._groupStartIndex+=inc;inc=0}}while(inc<0){if(-inc>this._groupStartIndex){inc+=this._groupStartIndex;this._groupStart--;this._groupStartIndex=this.getGroupLen()}else{this._groupStartIndex+=inc;inc=this.getGroupLen()}}}if(this.grid){if(this._grouped){inc=this._groupStartIndex%this._rowFactor}else{inc=this._virtualStart%this._rowFactor}if(inc){this.changeStartIndex(-inc)}}},getRowCount:function(dir){if(!this.grid){return dir}else if(!this._grouped){return dir*this._rowFactor}else{if(dir<0){if(this._groupStartIndex>0){return-Math.min(this._rowFactor,this._groupStartIndex)}else{var prevLen=this.getGroupLen(this._groupStart-1);return-Math.min(this._rowFactor,prevLen%this._rowFactor||this._rowFactor)}}else{return Math.min(this._rowFactor,this.getGroupLen()-this._groupStartIndex)}}},_virtualToPhysical:function(virtualIndex){var physicalIndex=(virtualIndex-this._physicalStart)%this._physicalCount;return physicalIndex<0?this._physicalCount+physicalIndex:physicalIndex},groupForVirtualIndex:function(virtual){if(!this._grouped){return{}}else{var group;for(group=0;groupvirtual){break}else{virtual-=groupLen}}return{group:group,groupIndex:virtual}}},virtualIndexForGroup:function(group,groupIndex){groupIndex=groupIndex?Math.min(groupIndex,this.getGroupLen(group)):0;group--;while(group>=0){groupIndex+=this.getGroupLen(group--)}return groupIndex},dataForIndex:function(virtual,group,groupIndex){if(this.data){if(this._nestedGroups){if(virtual0?1:0;if(Math.abs(scrollDelta)>Math.max(this._physicalSize,this._targetSize)){deltaCount=Math.round(scrollDelta/this._physicalAverage*this._rowFactor);deltaCount=Math.max(deltaCount,-this._virtualStart);deltaCount=Math.min(deltaCount,this._virtualCount-this._virtualStart-1);this._physicalOffset+=Math.max(scrollDelta,-this._physicalOffset);this.changeStartIndex(deltaCount)}else{var base=this._aboveSize+this._physicalOffset;var margin=.3*Math.max((this._physicalSize-this._targetSize,this._physicalSize));this._upperBound=base+margin;this._lowerBound=base+this._physicalSize-this._targetSize-margin;var flipBound=this._dir>0?this._upperBound:this._lowerBound;if(this._dir>0&&this._scrollTop>flipBound||this._dir<0&&this._scrollTop0&&(this._dir<0&&this._virtualStart>0||this._dir>0&&this._virtualStart0?this._virtualStart:this._virtualStart+this._physicalCount-1);var size=this._physicalSizes[idx];flipSize-=size;var cnt=this.getRowCount(this._dir);if(this._dir>0){this._physicalOffset+=size}this.changeStartIndex(cnt);if(this._dir<0){this._repositionedItems.push(this._virtualStart)}}}}if(this._updateItems(!scrollDelta)){if(Observer.hasObjectObserve){this.async(this._boundPositionItems)}else{Platform.flush();Platform.endOfMicrotask(this._boundPositionItems)}}},_updateItems:function(force){var i,virtualIndex,physicalIndex;var needsReposition=false;var groupIndex=this._groupStart;var groupItemIndex=this._groupStartIndex;for(i=0;i=this.getGroupLen(groupIndex)){groupItemIndex=0;groupIndex++}}}return needsReposition},_positionItems:function(){var i,virtualIndex,physicalIndex,physicalItem;this.updateMetrics();if(this._dir<0){while(this._repositionedItems.length){virtualIndex=this._repositionedItems.pop();physicalIndex=this._virtualToPhysical(virtualIndex);this._physicalOffset-=this._physicalSizes[physicalIndex]}if(this._scrollTop+this._targetSize=this._rowFactor){rowx=0;y+=lastHeight}x=this._rowMargin+rowx*this.width}else{y+=lastHeight}}if(this._scrollTop>=0){this._updateViewportHeight()}},_updateViewportHeight:function(){var remaining=Math.max(this._virtualCount-this._virtualStart-this._physicalCount,0);remaining=Math.ceil(remaining/this._rowFactor);var vs=this._physicalOffset+this._physicalSize+remaining*this._physicalAverage;if(this._viewportSize!=vs){this._viewportSize=vs;this.$.viewport.style.height=this._viewportSize+"px";this.syncScroller()}},_updateScrollPosition:function(scrollTop){var deltaHeight=this._virtualStart===0?this._physicalOffset:Math.min(scrollTop+this._physicalOffset,0);if(deltaHeight){if(this.adjustPositionAllowed){this._scrollTop=this.setScrollTop(scrollTop-deltaHeight)}this._physicalOffset-=deltaHeight}},tapHandler:function(e){var n=e.target;var p=e.path;if(!this.selectionEnabled||n===this){return}requestAnimationFrame(function(){var active=window.ShadowDOMPolyfill?wrap(document.activeElement):this.shadowRoot.activeElement;if(active&&active!=this&&active.parentElement!=this&&document.activeElement!=document.body){return}if(p[0].localName=="input"||p[0].localName=="button"||p[0].localName=="select"){return}var model=n.templateInstance&&n.templateInstance.model;if(model){var data=this.dataForIndex(model.index,model.groupIndex,model.groupItemIndex);var item=this._physicalItems[model.physicalIndex];if(!this.multi&&data==this.selection){this.$.selection.select(null)}else{this.$.selection.select(data)}this.asyncFire("core-activate",{data:data,item:item})}}.bind(this))},selectedHandler:function(e,detail){this.selection=this.$.selection.getSelection();var id=this.indexesForData(detail.item);this._selectedData.set(detail.item,detail.isSelected);if(id.physical>=0&&id.virtual>=0){this.refresh()}},selectItem:function(index){if(!this.selectionEnabled){return}var data=this.data[index];if(data){this.$.selection.select(data)}},setItemSelected:function(index,isSelected){var data=this.data[index];if(data){this.$.selection.setItemSelected(data,isSelected)}},indexesForData:function(data){var virtual=-1;var groupsLen=0;if(this._nestedGroups){for(var i=0;i=this._scrollTop-this._aboveSize){return virtualIndex}}},_resetIndex:function(index){index=Math.min(index,this._virtualCount-1);index=Math.max(index,0);this.changeStartIndex(index-this._virtualStart);this._scrollTop=this.setScrollTop(this._aboveSize+index/this._rowFactor*this._physicalAverage);this._physicalOffset=this._scrollTop-this._aboveSize;this._dir=0},scrollToItem:function(index){this.scrollToGroupItem(null,index)},scrollToGroup:function(group){this.scrollToGroupItem(group,0)},scrollToGroupItem:function(group,index){if(group!=null){index=this.virtualIndexForGroup(group,index)}this._resetIndex(index);this.refresh()}},Polymer.CoreResizable))})();Polymer("artist-details",{created:function(){this.data=[]},domReady:function(){this.tmpl=document.getElementById("tmpl");this.scrollTarget=this.tmpl.appScroller()},queryData:function(){this.tmpl.page=3;this.data=null;this.data=[];var url=this.url+"/rest/getArtist.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic&id="+this.artistId,i=0;this.async(function(){this.tmpl.doXhr(url,"json",function(event){var response=event.target.response["subsonic-response"];this.async(function(){Array.prototype.forEach.call(response.artist.album,function(e){var obj={name:e.name,artist:e.artist,coverArt:e.coverArt,id:e.id,starred:e.starred,url:this.url,user:this.user,pass:this.pass,version:this.version,listMode:this.listMode,bitRate:this.bitRate,colorThiefEnabled:this.colorThiefEnabled};this.data.push(obj);i=i+1;if(i===response.artist.album.length){this.tmpl.dataLoading=false}}.bind(this))})}.bind(this))})},playSomething:function(id,callback){var album=this.$.all.querySelector("#"+id);album.playAlbum();callback()}});(function(){"use strict";var app=document.querySelector("#tmpl");app.addEventListener("template-bound",function(){this.loadData();this.service=analytics.getService("PolySonic");this.tracker=this.service.getTracker("UA-50154238-6")});app.appName=chrome.i18n.getMessage("appName");app.appDesc=chrome.i18n.getMessage("appDesc");app.folderSelector=chrome.i18n.getMessage("folderSelector");app.shuffleButton=chrome.i18n.getMessage("shuffleButton");app.artistButton=chrome.i18n.getMessage("artistButton");app.podcastButton=chrome.i18n.getMessage("podcastButton");app.favoritesButton=chrome.i18n.getMessage("favoritesButton");app.searchButton=chrome.i18n.getMessage("searchButton");app.settingsButton=chrome.i18n.getMessage("settingsButton");app.nowPlayingLabel=chrome.i18n.getMessage("nowPlayingLabel");app.folderSelectorLabel=chrome.i18n.getMessage("folderSelectorLabel");app.clearQueue=chrome.i18n.getMessage("clearQueue");app.volumeLabel=chrome.i18n.getMessage("volumeLabel");app.analistics=chrome.i18n.getMessage("analistics");app.accept=chrome.i18n.getMessage("accept");app.decline=chrome.i18n.getMessage("decline");app.shuffleOptionsLabel=chrome.i18n.getMessage("shuffleOptionsLabel");app.optional=chrome.i18n.getMessage("optional");app.artistLabel=chrome.i18n.getMessage("artistLabel");app.albumLabel=chrome.i18n.getMessage("albumLabel");app.genreLabel=chrome.i18n.getMessage("genreLabel");app.songReturn=chrome.i18n.getMessage("songReturn");app.playButton=chrome.i18n.getMessage("playButton");app.yearError=chrome.i18n.getMessage("yearError");app.releasedAfter=chrome.i18n.getMessage("releasedAfter");app.releasedBefore=chrome.i18n.getMessage("releasedBefore");app.submitButton=chrome.i18n.getMessage("submitButton");app.deleteConfirm=chrome.i18n.getMessage("deleteConfirm");app.noResults=chrome.i18n.getMessage("noResults");app.urlError=chrome.i18n.getMessage("urlError");app.podcastSubmissionLabel=chrome.i18n.getMessage("podcastSubmissionLabel");app.diskUsed=chrome.i18n.getMessage("diskused");app.diskRemaining=chrome.i18n.getMessage("diskRemaining");app.playlistsButton=chrome.i18n.getMessage("playlistsButton");app.createPlaylistLabel=chrome.i18n.getMessage("createPlaylistLabel");app.playlistLabel=chrome.i18n.getMessage("playlistLabel");app.reloadAppLabel=chrome.i18n.getMessage("reloadApp");app.settingsDeleted=chrome.i18n.getMessage("settingsDeleted"); - -app.recommendReload=chrome.i18n.getMessage("recommendReload");app.jumpToLabel=chrome.i18n.getMessage("jumpToLabel");app.closeLabel=chrome.i18n.getMessage("closeLabel");app.moreOptionsLabel=chrome.i18n.getMessage("moreOptionsLabel");app.refreshPodcastLabel=chrome.i18n.getMessage("refreshPodcast");app.registeredEmail=chrome.i18n.getMessage("registeredEmail");app.licenseKey=chrome.i18n.getMessage("licenseKey");app.keyDate=chrome.i18n.getMessage("keyDate");app.validLicense=chrome.i18n.getMessage("validLicense");app.invalidLicense=chrome.i18n.getMessage("invalidLicense");app.adjustVolumeLabel=chrome.i18n.getMessage("adjustVolumeLabel");app.shuffleSizes=[20,40,50,75,100,200];app.sortTypes=[{sort:"newest",name:chrome.i18n.getMessage("newButton")},{sort:"alphabeticalByArtist",name:chrome.i18n.getMessage("byArtistButton")},{sort:"alphabeticalByName",name:chrome.i18n.getMessage("titleButton")},{sort:"frequent",name:chrome.i18n.getMessage("frequentButton")},{sort:"recent",name:chrome.i18n.getMessage("recentButton")}];app.indexedDB=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB;app.IDBTransaction=window.IDBTransaction||window.webkitIDBTransaction||window.OIDBTransaction||window.msIDBTransaction;app.dbVersion=1;app.request=app.indexedDB.open("albumInfo",app.dbVersion);app.request.onerror=function(){console.log("Error creating/accessing IndexedDB database")};app.request.onsuccess=function(){console.log("Success creating/accessing IndexedDB database");app.db=app.request.result;if(app.db.setVersion){if(app.db.version!==app.dbVersion){var setVersion=app.db.setVersion(this.dbVersion);setVersion.onsuccess=function(){app.createObjectStore(this.db)}}}};app.request.onupgradeneeded=function(event){app.createObjectStore(event.target.result)};app.createObjectStore=function(dataBase){console.log("Creating objectStore");dataBase.createObjectStore("albumInfo")};app.dbErrorHandler=function(e){console.error(e)};app.getImageFile=function(url,id,callback){app.doXhr(url,"blob",function(e){var blob=new Blob([e.target.response],{type:"image/jpeg"});app.putInDb(blob,id,callback);console.log("Image Added to indexedDB "+id)})};app.putInDb=function(data,id,callback){var transaction=app.db.transaction(["albumInfo"],"readwrite");if(id){transaction.objectStore("albumInfo").put(data,id);transaction.objectStore("albumInfo").get(id).onsuccess=callback}};app.calculateStorageSize=function(){navigator.webkitTemporaryStorage.queryUsageAndQuota(function(used,remaining){var usedQuota=Math.round(10*(used/1e3/1e3))/10,remainingQuota=Math.round(10*(remaining/1e3/1e3))/10,bytes="MB";if(remainingQuota>1e3){remainingQuota=Math.round(10*(remaining/1e3/1e3/1e3))/10;bytes="GB"}app.storageQuota=app.diskUsed+": "+usedQuota+" MB, "+app.diskRemaining+": "+remainingQuota+" "+bytes},function(e){console.log("Error",e)})};app.getDbItem=function(id,callback){if(id){var transaction=app.db.transaction(["albumInfo"],"readwrite"),request=transaction.objectStore("albumInfo").get(id);request.onsuccess=callback;request.onerror=app.dbErrorHandler}};app.xhrError=function(e){app.dataLoading=false;console.log(e);app.doToast(chrome.i18n.getMessage("connectionError"))};app.doXhr=function(url,dataType,callback){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType=dataType;xhr.onload=callback;xhr.onerror=app.xhrError;xhr.send()};app.playlist=[];app.page=app.page||0;app.pageLimit=false;app.reloadApp=function(){chrome.runtime.reload()};app.minimize=function(){chrome.app.window.current().minimize()};app.maximize=function(){var maximized=chrome.app.window.current().isMaximized(),button=this.$.max;if(maximized){button.icon="check-box-outline-blank";chrome.app.window.current().restore()}else{button.icon="flip-to-back";chrome.app.window.current().maximize()}};app.close=function(){window.close()};app.closeDrawer=function(callback){var panel=app.$.panel;panel.closeDrawer();if(callback){app.async(callback)}};app.openPanel=function(){var panel=app.$.panel;panel.openDrawer()};app.appScroller=function(){return app.$.headerPanel.scroller};app.doToast=function(text){var toast=app.$.toast;toast.text=text;toast.show()};app.getColor=function(image){var colorThief=new ColorThief;return colorThief.getPalette(image,4)};app.getContrast50=function(hexcolor){return parseInt(hexcolor,16)>16777215/2?"black":"white"};app.componentToHex=function(c){var hex=c.toString(16);return hex.length===1?"0"+hex:hex};app.rgbToHex=function(r,g,b){return app.componentToHex(r)+app.componentToHex(g)+app.componentToHex(b)};app.colorThiefHandler=function(imgURL,artId,callback){var imgElement=new Image;imgElement.src=imgURL;imgElement.onload=function(){var color=app.getColor(imgElement),colorArray=[],r=color[1][0],g=color[1][1],b=color[1][2],hex=app.rgbToHex(r,g,b);colorArray[0]="rgb("+r+","+g+","+b+");";colorArray[1]=app.getContrast50(hex);colorArray[2]="rgba("+r+","+g+","+b+",0.4);";if(colorArray[1]!=="white"){colorArray[3]="#444444"}else{colorArray[3]="#c8c8c8"}app.putInDb(colorArray,artId+"-palette",function(){if(callback){callback(colorArray)}console.log("Color palette saved "+artId)})}};app.playAudio=function(artist,title,src,image,id){var audio=app.$.audio,note=app.$.playNotify,time=new Date,now=time.getTime(),url;if(artist===""){app.currentPlaying=title;note.title=title}else{app.currentPlaying=artist+" - "+title;note.title=artist+" - "+title}if(app.activeUser.scrobblingEnabled){url=app.url+"/rest/scrobble.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+id+"&time="+now;app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="failed"){console.log("Last FM submission: "+e.target.response["subsonic-response"].status);app.tracker.sendEvent("Last FM submission","Failed")}})}audio.src=src;audio.play();note.icon=image;note.show();app.tracker.sendEvent("Audio","Playing")};app.playNext=function(next){var audio=app.$.audio;if(app.playlist[next]){app.playing=next}else{audio.pause();app.clearPlaylist()}};app.nextTrack=function(){var next=app.playing+1;app.playNext(next)};app.lastTrack=function(){var next=app.playing-1;app.playNext(next)};app.playThis=function(){app.setFabColor(this.playlist[this.playing]);var url;if(app.playlist[app.playing].artist===""){url=this.url+"/rest/stream.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&format=raw&estimateContentLength=true&id="+app.playlist[this.playing].id}else{url=this.url+"/rest/stream.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&maxBitRate="+app.bitRate+"&id="+app.playlist[this.playing].id}app.playAudio(app.playlist[app.playing].artist,app.playlist[app.playing].title,url,app.playlist[app.playing].cover,app.playlist[app.playing].id);if(app.playlist[app.playing].cover){app.getImageForPlayer(app.playlist[app.playing].cover)}else{app.defaultPlayImage()}};app.playPause=function(){var audio=app.$.audio;if(!audio.paused){audio.pause()}else{audio.play()}};app.playPlaylist=function(event,detail,sender){var url=app.url+"/rest/getPlaylist.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+sender.attributes.ident.value,tracks,mins,seconds,artId,obj,timeString,i=0;app.dataLoading=true;app.playlist=null;app.playlist=[];app.$.audio.pause();app.doXhr(url,"json",function(e){tracks=e.target.response["subsonic-response"].playlist.entry;Array.prototype.forEach.call(tracks,function(item){mins=Math.floor(item.duration/60);seconds=Math.floor(item.duration-mins*60);timeString=mins+":"+("0"+seconds).slice(-2);artId="al-"+item.albumId;obj={id:item.id,artist:item.artist,title:item.title,duration:timeString,cover:artId};app.fixCoverArtForShuffle(obj,function(){i=i+1;if(i===tracks.length){app.doShufflePlayback();app.dataLoading=false;app.closePlaylists()}})})})};app.shufflePlay=function(){app.dataLoading=true;app.shuffleLoading=true;app.playlist=null;app.playlist=[];var url,imgURL,artId,obj,mins,seconds,timeString,i=0;if(!app.startYearInvalid&&!app.endYearInvalid){app.$.audio.pause();if(app.endingYear&&app.startingYear&&app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)+"&fromYear="+app.startingYear+"&toYear="+app.endingYear}else if(app.endingYear&&app.startingYear){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&fromYear="+app.startingYear+"&toYear="+app.endingYear}else if(app.endingYear&&app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)+"&toYear="+app.endingYear}else if(app.startingYear&&app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)+"&fromYear="+app.startingYear}else if(app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)}else if(app.startingYear){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&fromYear="+app.startingYear}else if(app.endingYear){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&toYear="+app.endingYear}else{url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize}app.doXhr(url,"json",function(event){var data=event.target.response["subsonic-response"];if(data.randomSongs.song){Array.prototype.forEach.call(data.randomSongs.song,function(item){mins=Math.floor(item.duration/60);seconds=Math.floor(item.duration-mins*60);timeString=mins+":"+("0"+seconds).slice(-2);artId="al-"+item.albumId;obj={id:item.id,artist:item.artist,title:item.title,duration:timeString,cover:artId};app.fixCoverArtForShuffle(obj,function(){i=i+1;if(i===data.randomSongs.song.length){app.doShufflePlayback();app.dataLoading=false}})})}else{app.doToast(chrome.i18n.getMessage("noMatch"));app.shuffleLoading=false}})}else{app.shuffleLoading=false;app.doToast(chrome.i18n.getMessage("invalidEntry"))}};app.doShufflePlayback=function(){if(app.$.audio.paused){var art=app.url+"/rest/stream.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&maxBitRate="+app.bitRate+"&id="+app.playlist[0].id;app.playing=0;app.playAudio(app.playlist[0].artist,app.playlist[0].title,art,app.playlist[0].cover,app.playlist[0].id);app.getImageForPlayer(app.playlist[0].cover,function(){app.page=1;app.setFabColor(app.playlist[0]);app.$.shuffleOptions.close();app.shuffleLoading=false})}};app.clearPlaylist=function(){app.$.audio.pause();app.$.playlistDialog.close();app.page=0;app.playlist=null;app.playlist=[]};app.toggleVolume=function(){var dialog=app.$.volumeDialog;dialog.open()};app.closeVolume=function(){var dialog=app.$.volumeDialog;dialog.close()};app.volUp=function(){if(app.volume<100){app.volume=app.volume+2}};app.volDown=function(){if(app.volume>0){app.volume=app.volume-2}};app.getImageForPlayer=function(url,callback){var art=app.$.coverArt,note=app.$.playNotify;art.style.backgroundImage="url('"+url+"')";note.icon=url;if(callback){app.async(callback)}};app.defaultPlayImage=function(){var art=app.$.coverArt,note=app.$.playNotify;art.style.backgroundImage="url('images/default-cover-art.png')";note.icon="images/default-cover-art.png"};app.playerProgress=function(e){var audio,button,progress,currentMins,currentSecs,totalMins,totalSecs;if(e){if(e.type==="waiting"){app.waitingToPlay=true}else if(e.type==="timeupdate"){app.waitingToPlay=false}audio=e.srcElement}else{audio=app.$.audio}button=app.$.avIcon;progress=Math.round(audio.currentTime/audio.duration*100*100)/100;currentMins=Math.floor(audio.currentTime/60);currentSecs=Math.floor(audio.currentTime-currentMins*60);totalMins=Math.floor(audio.duration/60);totalSecs=Math.floor(audio.duration-totalMins*60);if(audio.duration){app.buffer=Math.floor(audio.buffered.end(0)/audio.duration*100)}else{app.buffer=0}if(!audio.paused){button.icon="av:pause";app.isNowPlaying=true;if(!audio.duration){app.playTime=currentMins+":"+("0"+currentSecs).slice(-2)+" / ?:??";app.progress=0}else{app.playTime=currentMins+":"+("0"+currentSecs).slice(-2)+" / "+totalMins+":"+("0"+totalSecs).slice(-2);app.progress=progress}}else{app.isNowPlaying=false;button.icon="av:play-arrow"}};app.showApp=function(){var loader=document.getElementById("loader"),visible=loader.classList.contains("hide"),box=document.getElementById("box");if(!visible){loader.classList.add("hide");box.classList.add("hide");box.classList.add("hide");app.askAnalistics()}};app.sizePlayer=function(){var height=window.innerHeight-256+"px",width=window.innerWidth+"px",art=app.$.coverArt;art.style.width=width;art.style.height=height;art.style.backgroundSize=width};app.askAnalistics=function(){chrome.storage.sync.get(function(result){app.service.getConfig().addCallback(function(config){if(result.analistics===undefined){app.$.analistics.open()}else{config.setTrackingPermitted(result.analistics);app.analisticsEnabled=result.analistics}app.allowAnalistics=function(){app.analisticsEnabled=true;config.setTrackingPermitted(true);chrome.storage.sync.set({analistics:true})};app.disAllowAnalistics=function(){app.analisticsEnabled=false;config.setTrackingPermitted(false);chrome.storage.sync.set({analistics:false})}})})};app.jumpTo=function(event,detail,sender){app.$.wall.jumpToLetter(sender.attributes.it.value)};app.setFolder=function(event,detail,sender){var value=parseInt(sender.attributes.i.value,10);app.folder=value;chrome.storage.sync.set({mediaFolder:value})};app.fixCoverArtForShuffle=function(obj,callback){var artId=obj.cover,img=app.url+"/rest/getCoverArt.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+artId;app.getDbItem(artId,function(ev){if(ev.target.result){var raw=ev.target.result,imgURL=window.URL.createObjectURL(raw);obj.cover=imgURL;app.getDbItem(artId+"-palette",function(ev){obj.palette=ev.target.result;app.playlist.push(obj);app.async(callback)})}else{app.getImageFile(img,artId,function(ev){var raw=ev.target.result,imgURL=window.URL.createObjectURL(raw);obj.cover=imgURL;app.colorThiefHandler(imgURL,artId,function(colorArray){obj.palette=colorArray;app.playlist.push(obj);app.async(callback)})})}})};app.setFabColor=function(array){if(app.colorThiefEnabled&&array.palette){app.colorThiefFab=array.palette[0];app.colorThiefFabOff=array.palette[1];app.colorThiefBuffered=array.palette[2];app.colorThiefProgBg=array.palette[3]}};app.progressClick=function(event){var audio=app.$.audio,clicked=event.x/window.innerWidth,sum=audio.duration-(audio.duration-audio.duration*clicked),bar=app.$.progress;bar.value=clicked*100;audio.currentTime=sum};app.savePlayQueue=function(){app.$.playlistDialog.close();app.$.createPlaylist.open();app.defaultName=new Date};app.savePlayQueue2Playlist=function(){var url=app.url+"/rest/createPlaylist.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&name="+encodeURIComponent(app.defaultName),hasRun=false,i=0;app.savingPlaylist=true;Array.prototype.forEach.call(app.playlist,function(item){url=url+"&songId="+item.id;i=i+1;if(i===app.playlist.length){app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){app.doToast(chrome.i18n.getMessage("playlistCreated"));app.$.createPlaylist.close();app.savingPlaylist=false}else{app.doToast(chrome.i18n.getMessage("playlistError"));app.savingPlaylist=false}})}})};app.closePlaylistSaver=function(){app.$.createPlaylist.close()};app.loadData=function(){chrome.storage.sync.get(function(result){if(result.url===undefined){app.$.firstRun.open()}app.url=result.url;app.user=result.user;app.pass=result.pass;app.listMode="cover";app.bitRate=result.bitRate||320;app.shuffleSize=app.shuffleSize||"50";app.version="1.11.0";app.querySize=30;app.volume=result.volume||100;app.queryMethod=result.queryMethod||"ID3";app.colorThiefEnabled=true;app.dataLoading=false;app.sizePlayer();app.calculateStorageSize();if(app.url&&app.user&&app.pass&&app.version){var url=app.url+"/rest/ping.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json",url2;app.doXhr(url,"json",function(e){if(e.target.status===200){app.version=e.target.response["subsonic-response"].version;url2=app.url+"/rest/getMusicFolders.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic";if(e.target.response["subsonic-response"].status==="ok"){app.userDetails();console.log("Connected to Subconic loading data");app.doXhr(url2,"json",function(e){app.mediaFolders=e.target.response["subsonic-response"].musicFolders.musicFolder;app.folder=result.mediaFolder||0;if(!e.target.response["subsonic-response"].musicFolders.musicFolder[1]){app.$.sortBox.style.display="none"}app.tracker.sendAppView("Album Wall")})}else{app.tracker.sendEvent("Connection Error",e.target.response["subsonic-response"].error.meessage);app.$.firstRun.toggle();app.doToast(e.target.response["subsonic-response"].error.meessage)}}else{app.tracker.sendEvent("Connection Error",e.target.response["subsonic-response"].error.meessage);app.$.firstRun.toggle();app.doToast(e.target.response["subsonic-response"].error.meessage)}})}});var scroller=app.appScroller(),audio=app.$.audio,maximized=chrome.app.window.current().isMaximized(),button=app.$.max,timer;if(maximized){button.icon="check-box-outline-blank"}else{button.icon="flip-to-back"}scroller.onscroll=function(){var fab=app.$.fab,wall=app.$.wall;if(app.page===0&&fab.state!=="off"&&scroller.scrollTopapp.position&&wall.showing!=="podcast"){fab.state="bottom"}app.position=scroller.scrollTop};audio.onwaiting=app.playerProgress;audio.onstalled=function(e){if(timer){clearInterval(timer)}timer=setInterval(function(){app.playerProgress()},250)};audio.onplay=function(e){if(timer){clearInterval(timer)}};audio.onpause=function(e){if(timer){clearInterval(timer)}timer=setInterval(function(){app.playerProgress()},250)};audio.ontimeupdate=app.playerProgress;audio.onended=app.nextTrack;audio.onerror=function(e){app.page=0;console.error("audio playback error ",e);app.doToast("Audio Playback Error");app.tracker.sendEvent("Audio Playback Error",e.target)}};app.doAction=function(event,detail,sender){var scroller=app.appScroller(),wall=app.$.wall,animation=new CoreAnimation;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;if(app.page===0&&scroller.scrollTop!==0&&wall.showing!=="podcast"&&app.$.fab.state==="bottom"){scroller.scrollTop=0}if(app.page===0&&wall.showing==="podcast"){app.$.addPodcast.open()}if(app.page===1){app.showPlaylist()}if(app.page===0&&app.$.fab.state==="mid"){animation.play();app.$.wall.playSomething(sender.ident,function(){animation.cancel()})}if(app.page===3){animation.play();app.$.aDetails.playSomething(sender.ident,function(){animation.cancel()})}};app.fixScroller=function(event,detail,sender){};app.doSearch=function(){if(app.searchQuery){app.async(function(){app.closeDrawer(function(){var url=app.url+"/rest/search3.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&query="+encodeURIComponent(app.searchQuery);app.async(function(){app.doXhr(url,"json",function(e){app.dataLoading=true;if(e.target.response["subsonic-response"].status==="ok"){app.searchQuery="";var response=e.target.response;if(response["subsonic-response"].searchResult3.album){app.async(function(){app.$.wall.clearData(function(){app.async(function(){app.$.wall.response=response;app.showing=app.listMode})})})}else{app.dataLoading=false;app.doToast(chrome.i18n.getMessage("noResults"))}}})})})})}else{app.doToast(chrome.i18n.getMessage("noSearch"))}};app.showPlaylist=function(){var dialog=app.$.playlistDialog;app.async(function(){dialog.toggle()})};app.closePlaylist=function(){var dialog=app.$.playlistDialog;app.async(function(){dialog.close()})};app.openPlaylists=function(){app.closeDrawer(function(){app.playlistsLoading=true;var url=app.url+"/rest/getPlaylists.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json";app.doXhr(url,"json",function(e){app.playlistsLoading=false;app.playlists=e.target.response["subsonic-response"].playlists.playlist;app.$.playlistsDialog.open()})})};app.closePlaylists=function(){app.$.playlistsDialog.close()};app.reallyDelete=function(event,detail,sender){app.delID=sender.attributes.ident.value;app.$.playlistsDialog.close();app.$.playlistConfirm.open()};app.deletePlaylist=function(event,detail,sender){var url=app.url+"/rest/deletePlaylist.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+sender.attributes.ident.value,url2=app.url+"/rest/getPlaylists.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json";app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){app.playlistsLoading=true;app.doXhr(url2,"json",function(e){app.playlistsLoading=false;app.playlists=e.target.response["subsonic-response"].playlists.playlist;app.$.playlistsDialog.open()})}else{app.doToast(chrome.i18n.getMessage("deleteError"))}})};app.closeShuffleOptions=function(){app.$.shuffleOptions.close()};app.shuffleOptions=function(){var url=app.url+"/rest/getGenres.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json";app.closeDrawer(function(){app.doXhr(url,"json",function(e){app.genres=e.target.response["subsonic-response"].genres.genre;app.$.shuffleOptions.open()})})};app.closePodcastDialog=function(){app.$.addPodcast.close()};app.toggleWall=function(){app.dataLoading=true;var wall=app.$.wall;if(wall.listMode==="cover"){wall.listMode="list";chrome.storage.sync.set({listMode:"list"})}else{wall.listMode="cover";chrome.storage.sync.set({listMode:"cover"})}app.tracker.sendEvent("ListMode Changed",wall.listMode)};app.requestSession=function(){chrome.cast.requestSession(onRequestSessionSuccess,onLaunchError)};app.back2List=function(){app.async(function(){app.page=0})};app.nowPlaying=function(){app.async(function(){app.page=1})};app.selectAction=function(event,detail,sender){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){if(wall.sort===sender.attributes.i.value){app.pageLimit=false;if(app.queryMethod==="ID3"){wall.request="getAlbumList2"}else{wall.request="getAlbumList"}wall.post.type=sender.attributes.i.value;wall.refreshContent();wall.showing=app.listMode;wall.$.threshold.clearLower()}wall.sort=sender.attributes.i.value})})})};app.getPodcast=function(){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){wall.getPodcast()})})})};app.getStarred=function(){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){wall.getStarred()})})})};app.getArtist=function(){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){wall.getArtist()})})})};app.gotoSettings=function(){app.closeDrawer(function(){app.page=2})};app.refreshPodcast=function(event,detail,sender){var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();url=app.url+"/rest/refreshPodcasts.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic";app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){animation.cancel();app.$.wall.refreshContent();app.doToast(chrome.i18n.getMessage("podcastCheck"))}})};app.addChannel=function(){if(!app.castURL){app.doToast(app.urlError)}if(!app.invalidURL){app.addingChannel=true;var url=app.url+"/rest/createPodcastChannel.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic&url="+encodeURIComponent(app.castURL);app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){app.addingChannel=false;app.$.addPodcast.close();app.$.wall.refreshContent();app.doToast(chrome.i18n.getMessage("channelAdded"));app.castURL=""}else{app.doToast(chrome.i18n.getMessage("podcastError"))}})}};app.doDelete=function(event,detail,sender){app.$.wall.deleteChannel(sender.attributes.ident.value)};app.deleteEpisode=function(event,detail,sender){app.$.wall.deleteEpisode(sender.attributes.ident.value)};app.getLicense=function(callback){var url=app.url+"/rest/getLicense.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic";app.async(function(){app.doXhr(url,"json",function(e){var response=e.target.response["subsonic-response"];if(response.status==="ok"){app.serverLicense=response.license;app.$.licenseDialog.open();app.async(callback)}})})};app.licenseDialogClose=function(){app.$.licenseDialog.close()};app.userDetails=function(){var url=app.url+"/rest/getUser.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic&username="+app.user;app.async(function(){app.doXhr(url,"json",function(e){var response=e.target.response["subsonic-response"];if(response.status==="ok"){app.activeUser=response.user}else{console.error("Error getting User details")}})})}})();(function(){var g,aa=aa||{},h=this,ba=function(){},ca=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==b&&"undefined"==typeof a.call)return"object";return b},m=function(a){return"array"==ca(a)},da=function(a){var b=ca(a);return"array"==b||"object"==b&&"number"==typeof a.length},n=function(a){return"string"==typeof a},ea=function(a){return"number"==typeof a},p=function(a){return"function"==ca(a)},q=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b},fa=function(a,b,c){return a.call.apply(a.bind,arguments)},ga=function(a,b,c){if(!a)throw Error();if(2b?1:0};var w=Array.prototype,ja=w.indexOf?function(a,b,c){return w.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(n(a))return n(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?null:n(a)?a.charAt(b):a[b]},pa=function(a,b){var c=ja(a,b),d;(d=0<=c)&&w.splice.call(a,c,1);return d},qa=function(a){return w.concat.apply(w,arguments)},ra=function(a,b,c){return 2>=arguments.length?w.slice.call(a,b):w.slice.call(a,b,c)};var sa="StopIteration"in h?h.StopIteration:Error("StopIteration"),ta=function(){};ta.prototype.next=function(){throw sa};ta.prototype.vc=function(){return this};var ua=function(a,b,c){for(var d in a)b.call(c,a[d],d,a)},va=function(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b},wa=function(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b},xa=function(a,b){var c;t:{for(c in a)if(b.call(void 0,a[c],c,a))break t;c=void 0}return c&&a[c]},ya="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),za=function(a,b){for(var c,d,e=1;e2*this.h&&Aa(this),!0):!1};var Aa=function(a){if(a.h!=a.b.length){for(var b=0,c=0;b=c.length)throw sa;var k=c[b++];return a?k:d[k]}};return k};var y=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var Ba,Ca,Da={id:"hitType",name:"t",valueType:"text",maxLength:void 0,defaultValue:void 0},Ea={id:"sessionControl",name:"sc",valueType:"text",maxLength:void 0,defaultValue:void 0},Fa={id:"description",name:"cd",valueType:"text",maxLength:2048,defaultValue:void 0},Ga={id:"eventCategory",name:"ec",valueType:"text",maxLength:150,defaultValue:void 0},Ha={id:"eventAction",name:"ea",valueType:"text",maxLength:500,defaultValue:void 0},Ia={id:"eventLabel",name:"el",valueType:"text",maxLength:500,defaultValue:void 0},Ja={id:"eventValue",name:"ev",valueType:"integer",maxLength:void 0,defaultValue:void 0},Ka={pd:Da,Qc:{id:"anonymizeIp",name:"aip", +app.recommendReload=chrome.i18n.getMessage("recommendReload");app.jumpToLabel=chrome.i18n.getMessage("jumpToLabel");app.closeLabel=chrome.i18n.getMessage("closeLabel");app.moreOptionsLabel=chrome.i18n.getMessage("moreOptionsLabel");app.refreshPodcastLabel=chrome.i18n.getMessage("refreshPodcast");app.registeredEmail=chrome.i18n.getMessage("registeredEmail");app.licenseKey=chrome.i18n.getMessage("licenseKey");app.keyDate=chrome.i18n.getMessage("keyDate");app.validLicense=chrome.i18n.getMessage("validLicense");app.invalidLicense=chrome.i18n.getMessage("invalidLicense");app.adjustVolumeLabel=chrome.i18n.getMessage("adjustVolumeLabel");app.shuffleSizes=[20,40,50,75,100,200];app.sortTypes=[{sort:"newest",name:chrome.i18n.getMessage("newButton")},{sort:"alphabeticalByArtist",name:chrome.i18n.getMessage("byArtistButton")},{sort:"alphabeticalByName",name:chrome.i18n.getMessage("titleButton")},{sort:"frequent",name:chrome.i18n.getMessage("frequentButton")},{sort:"recent",name:chrome.i18n.getMessage("recentButton")}];app.indexedDB=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB;app.IDBTransaction=window.IDBTransaction||window.webkitIDBTransaction||window.OIDBTransaction||window.msIDBTransaction;app.dbVersion=1;app.request=app.indexedDB.open("albumInfo",app.dbVersion);app.request.onerror=function(){console.log("Error creating/accessing IndexedDB database")};app.request.onsuccess=function(){console.log("Success creating/accessing IndexedDB database");app.db=app.request.result;if(app.db.setVersion){if(app.db.version!==app.dbVersion){var setVersion=app.db.setVersion(this.dbVersion);setVersion.onsuccess=function(){app.createObjectStore(this.db)}}}};app.request.onupgradeneeded=function(event){app.createObjectStore(event.target.result)};app.createObjectStore=function(dataBase){console.log("Creating objectStore");dataBase.createObjectStore("albumInfo")};app.dbErrorHandler=function(e){console.error(e)};app.getImageFile=function(url,id,callback){app.doXhr(url,"blob",function(e){var blob=new Blob([e.target.response],{type:"image/jpeg"});app.putInDb(blob,id,callback);console.log("Image Added to indexedDB "+id)})};app.putInDb=function(data,id,callback){var transaction=app.db.transaction(["albumInfo"],"readwrite");if(id){transaction.objectStore("albumInfo").put(data,id);transaction.objectStore("albumInfo").get(id).onsuccess=callback}};app.calculateStorageSize=function(){navigator.webkitTemporaryStorage.queryUsageAndQuota(function(used,remaining){var usedQuota=Math.round(10*(used/1e3/1e3))/10,remainingQuota=Math.round(10*(remaining/1e3/1e3))/10,bytes="MB";if(remainingQuota>1e3){remainingQuota=Math.round(10*(remaining/1e3/1e3/1e3))/10;bytes="GB"}app.storageQuota=app.diskUsed+": "+usedQuota+" MB, "+app.diskRemaining+": "+remainingQuota+" "+bytes},function(e){console.log("Error",e)})};app.getDbItem=function(id,callback){if(id){var transaction=app.db.transaction(["albumInfo"],"readwrite"),request=transaction.objectStore("albumInfo").get(id);request.onsuccess=callback;request.onerror=app.dbErrorHandler}};app.xhrError=function(e){app.dataLoading=false;console.log(e);app.doToast(chrome.i18n.getMessage("connectionError"))};app.doXhr=function(url,dataType,callback){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType=dataType;xhr.onload=callback;xhr.onerror=app.xhrError;xhr.send()};app.playlist=[];app.page=app.page||0;app.pageLimit=false;app.reloadApp=function(){chrome.runtime.reload()};app.minimize=function(){chrome.app.window.current().minimize()};app.maximize=function(){var maximized=chrome.app.window.current().isMaximized(),button=this.$.max;if(maximized){button.icon="check-box-outline-blank";chrome.app.window.current().restore()}else{button.icon="flip-to-back";chrome.app.window.current().maximize()}};app.close=function(){window.close()};app.closeDrawer=function(callback){var panel=app.$.panel;panel.closeDrawer();if(callback){app.async(callback)}};app.openPanel=function(){var panel=app.$.panel;panel.openDrawer()};app.appScroller=function(){return app.$.headerPanel.scroller};app.doToast=function(text){var toast=app.$.toast;toast.text=text;toast.show()};app.getColor=function(image){var colorThief=new ColorThief;return colorThief.getPalette(image,4)};app.getContrast50=function(hexcolor){return parseInt(hexcolor,16)>16777215/2?"black":"white"};app.componentToHex=function(c){var hex=c.toString(16);return hex.length===1?"0"+hex:hex};app.rgbToHex=function(r,g,b){return app.componentToHex(r)+app.componentToHex(g)+app.componentToHex(b)};app.colorThiefHandler=function(imgURL,artId,callback){var imgElement=new Image;imgElement.src=imgURL;imgElement.onload=function(){var color=app.getColor(imgElement),colorArray=[],r=color[1][0],g=color[1][1],b=color[1][2],hex=app.rgbToHex(r,g,b);colorArray[0]="rgb("+r+","+g+","+b+");";colorArray[1]=app.getContrast50(hex);colorArray[2]="rgba("+r+","+g+","+b+",0.4);";if(colorArray[1]!=="white"){colorArray[3]="#444444"}else{colorArray[3]="#c8c8c8"}app.putInDb(colorArray,artId+"-palette",function(){if(callback){callback(colorArray)}console.log("Color palette saved "+artId)})}};app.playAudio=function(artist,title,src,image,id){var audio=app.$.audio,note=app.$.playNotify,time=new Date,now=time.getTime(),url;if(artist===""){app.currentPlaying=title;note.title=title}else{app.currentPlaying=artist+" - "+title;note.title=artist+" - "+title}if(app.activeUser.scrobblingEnabled){url=app.url+"/rest/scrobble.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+id+"&time="+now;app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="failed"){console.log("Last FM submission: "+e.target.response["subsonic-response"].status);app.tracker.sendEvent("Last FM submission","Failed")}})}audio.src=src;audio.play();note.icon=image;note.show();app.tracker.sendEvent("Audio","Playing")};app.playNext=function(next){var audio=app.$.audio;if(app.playlist[next]){app.playing=next}else{audio.pause();app.clearPlaylist()}};app.nextTrack=function(){var next=app.playing+1;app.playNext(next)};app.lastTrack=function(){var next=app.playing-1;app.playNext(next)};app.playThis=function(){app.setFabColor(this.playlist[this.playing]);var url;if(app.playlist[app.playing].artist===""){url=this.url+"/rest/stream.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&format=raw&estimateContentLength=true&id="+app.playlist[this.playing].id}else{url=this.url+"/rest/stream.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&maxBitRate="+app.bitRate+"&id="+app.playlist[this.playing].id}app.playAudio(app.playlist[app.playing].artist,app.playlist[app.playing].title,url,app.playlist[app.playing].cover,app.playlist[app.playing].id);if(app.playlist[app.playing].cover){app.getImageForPlayer(app.playlist[app.playing].cover)}else{app.defaultPlayImage()}};app.playPause=function(){var audio=app.$.audio;if(!audio.paused){audio.pause()}else{audio.play()}};app.playPlaylist=function(event,detail,sender){var url=app.url+"/rest/getPlaylist.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+sender.attributes.ident.value,tracks,mins,seconds,artId,obj,timeString,i=0;app.dataLoading=true;app.playlist=null;app.playlist=[];app.$.audio.pause();app.doXhr(url,"json",function(e){tracks=e.target.response["subsonic-response"].playlist.entry;Array.prototype.forEach.call(tracks,function(item){mins=Math.floor(item.duration/60);seconds=Math.floor(item.duration-mins*60);timeString=mins+":"+("0"+seconds).slice(-2);artId="al-"+item.albumId;obj={id:item.id,artist:item.artist,title:item.title,duration:timeString,cover:artId};app.fixCoverArtForShuffle(obj,function(){i=i+1;if(i===tracks.length){app.doShufflePlayback();app.dataLoading=false;app.closePlaylists()}})})})};app.shufflePlay=function(){app.dataLoading=true;app.shuffleLoading=true;app.playlist=null;app.playlist=[];var url,imgURL,artId,obj,mins,seconds,timeString,i=0;if(!app.startYearInvalid&&!app.endYearInvalid){app.$.audio.pause();if(app.endingYear&&app.startingYear&&app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)+"&fromYear="+app.startingYear+"&toYear="+app.endingYear}else if(app.endingYear&&app.startingYear){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&fromYear="+app.startingYear+"&toYear="+app.endingYear}else if(app.endingYear&&app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)+"&toYear="+app.endingYear}else if(app.startingYear&&app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)+"&fromYear="+app.startingYear}else if(app.genreFilter){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&genre="+encodeURIComponent(app.genreFilter)}else if(app.startingYear){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&fromYear="+app.startingYear}else if(app.endingYear){url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize+"&toYear="+app.endingYear}else{url=app.url+"/rest/getRandomSongs.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&size="+app.shuffleSize}app.doXhr(url,"json",function(event){var data=event.target.response["subsonic-response"];if(data.randomSongs.song){Array.prototype.forEach.call(data.randomSongs.song,function(item){mins=Math.floor(item.duration/60);seconds=Math.floor(item.duration-mins*60);timeString=mins+":"+("0"+seconds).slice(-2);artId="al-"+item.albumId;obj={id:item.id,artist:item.artist,title:item.title,duration:timeString,cover:artId};app.fixCoverArtForShuffle(obj,function(){i=i+1;if(i===data.randomSongs.song.length){app.doShufflePlayback();app.dataLoading=false}})})}else{app.doToast(chrome.i18n.getMessage("noMatch"));app.shuffleLoading=false}})}else{app.shuffleLoading=false;app.doToast(chrome.i18n.getMessage("invalidEntry"))}};app.doShufflePlayback=function(){if(app.$.audio.paused){var art=app.url+"/rest/stream.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&maxBitRate="+app.bitRate+"&id="+app.playlist[0].id;app.playing=0;app.playAudio(app.playlist[0].artist,app.playlist[0].title,art,app.playlist[0].cover,app.playlist[0].id);app.getImageForPlayer(app.playlist[0].cover,function(){app.page=1;app.setFabColor(app.playlist[0]);app.$.shuffleOptions.close();app.shuffleLoading=false})}};app.clearPlaylist=function(){app.$.audio.pause();app.$.playlistDialog.close();app.page=0;app.playlist=null;app.playlist=[]};app.toggleVolume=function(){var dialog=app.$.volumeDialog;dialog.open()};app.closeVolume=function(){var dialog=app.$.volumeDialog;dialog.close()};app.volUp=function(){if(app.volume<100){app.volume=app.volume+2}};app.volDown=function(){if(app.volume>0){app.volume=app.volume-2}};app.getImageForPlayer=function(url,callback){var art=app.$.coverArt,note=app.$.playNotify;art.style.backgroundImage="url('"+url+"')";note.icon=url;if(callback){app.async(callback)}};app.defaultPlayImage=function(){var art=app.$.coverArt,note=app.$.playNotify;art.style.backgroundImage="url('images/default-cover-art.png')";note.icon="images/default-cover-art.png"};app.playerProgress=function(e){var audio,button,progress,currentMins,currentSecs,totalMins,totalSecs;if(e){if(e.type==="waiting"){app.waitingToPlay=true}else if(e.type==="timeupdate"){app.waitingToPlay=false}audio=e.srcElement}else{audio=app.$.audio}button=app.$.avIcon;progress=Math.round(audio.currentTime/audio.duration*100*100)/100;currentMins=Math.floor(audio.currentTime/60);currentSecs=Math.floor(audio.currentTime-currentMins*60);totalMins=Math.floor(audio.duration/60);totalSecs=Math.floor(audio.duration-totalMins*60);if(audio.duration){app.buffer=Math.floor(audio.buffered.end(0)/audio.duration*100)}else{app.buffer=0}if(!audio.paused){button.icon="av:pause";app.isNowPlaying=true;if(!audio.duration){app.playTime=currentMins+":"+("0"+currentSecs).slice(-2)+" / ?:??";app.progress=0}else{app.playTime=currentMins+":"+("0"+currentSecs).slice(-2)+" / "+totalMins+":"+("0"+totalSecs).slice(-2);app.progress=progress}}else{app.isNowPlaying=false;button.icon="av:play-arrow"}};app.showApp=function(){var loader=document.getElementById("loader"),visible=loader.classList.contains("hide"),box=document.getElementById("box");if(!visible){loader.classList.add("hide");box.classList.add("hide");box.classList.add("hide");app.askAnalistics()}};app.sizePlayer=function(){var height=window.innerHeight-256+"px",width=window.innerWidth+"px",art=app.$.coverArt;art.style.width=width;art.style.height=height;art.style.backgroundSize=width};app.askAnalistics=function(){chrome.storage.sync.get(function(result){app.service.getConfig().addCallback(function(config){if(result.analistics===undefined){app.$.analistics.open()}else{config.setTrackingPermitted(result.analistics);app.analisticsEnabled=result.analistics}app.allowAnalistics=function(){app.analisticsEnabled=true;config.setTrackingPermitted(true);chrome.storage.sync.set({analistics:true})};app.disAllowAnalistics=function(){app.analisticsEnabled=false;config.setTrackingPermitted(false);chrome.storage.sync.set({analistics:false})}})})};app.jumpTo=function(event,detail,sender){app.$.wall.jumpToLetter(sender.attributes.it.value)};app.setFolder=function(event,detail,sender){var value=parseInt(sender.attributes.i.value,10);app.folder=value;chrome.storage.sync.set({mediaFolder:value})};app.fixCoverArtForShuffle=function(obj,callback){var artId=obj.cover,img=app.url+"/rest/getCoverArt.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+artId;app.getDbItem(artId,function(ev){if(ev.target.result){var raw=ev.target.result,imgURL=window.URL.createObjectURL(raw);obj.cover=imgURL;app.getDbItem(artId+"-palette",function(ev){obj.palette=ev.target.result;app.playlist.push(obj);app.async(callback)})}else{app.getImageFile(img,artId,function(ev){var raw=ev.target.result,imgURL=window.URL.createObjectURL(raw);obj.cover=imgURL;app.colorThiefHandler(imgURL,artId,function(colorArray){obj.palette=colorArray;app.playlist.push(obj);app.async(callback)})})}})};app.setFabColor=function(array){if(app.colorThiefEnabled&&array.palette){app.colorThiefFab=array.palette[0];app.colorThiefFabOff=array.palette[1];app.colorThiefBuffered=array.palette[2];app.colorThiefProgBg=array.palette[3]}};app.progressClick=function(event){var audio=app.$.audio,clicked=event.x/window.innerWidth,sum=audio.duration-(audio.duration-audio.duration*clicked),bar=app.$.progress;bar.value=clicked*100;audio.currentTime=sum};app.savePlayQueue=function(){app.$.playlistDialog.close();app.$.createPlaylist.open();app.defaultName=new Date};app.savePlayQueue2Playlist=function(){var url=app.url+"/rest/createPlaylist.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&name="+encodeURIComponent(app.defaultName),hasRun=false,i=0;app.savingPlaylist=true;Array.prototype.forEach.call(app.playlist,function(item){url=url+"&songId="+item.id;i=i+1;if(i===app.playlist.length){app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){app.doToast(chrome.i18n.getMessage("playlistCreated"));app.$.createPlaylist.close();app.savingPlaylist=false}else{app.doToast(chrome.i18n.getMessage("playlistError"));app.savingPlaylist=false}})}})};app.closePlaylistSaver=function(){app.$.createPlaylist.close()};app.loadData=function(){chrome.storage.sync.get(function(result){if(result.url===undefined){app.$.firstRun.open()}app.url=result.url;app.user=result.user;app.pass=result.pass;app.listMode="cover";app.bitRate=result.bitRate||320;app.shuffleSize=app.shuffleSize||"50";app.version="1.11.0";app.querySize=40;app.volume=result.volume||100;app.queryMethod=result.queryMethod||"ID3";app.colorThiefEnabled=true;app.dataLoading=false;app.sizePlayer();app.calculateStorageSize();if(app.url&&app.user&&app.pass&&app.version){var url=app.url+"/rest/ping.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json",url2;app.doXhr(url,"json",function(e){if(e.target.status===200){app.version=e.target.response["subsonic-response"].version;url2=app.url+"/rest/getMusicFolders.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic";if(e.target.response["subsonic-response"].status==="ok"){app.userDetails();console.log("Connected to Subconic loading data");app.doXhr(url2,"json",function(e){app.mediaFolders=e.target.response["subsonic-response"].musicFolders.musicFolder;app.folder=result.mediaFolder||0;if(!e.target.response["subsonic-response"].musicFolders.musicFolder[1]){app.$.sortBox.style.display="none"}app.tracker.sendAppView("Album Wall")})}else{app.tracker.sendEvent("Connection Error",e.target.response["subsonic-response"].error.meessage);app.$.firstRun.toggle();app.doToast(e.target.response["subsonic-response"].error.meessage)}}else{app.tracker.sendEvent("Connection Error",e.target.response["subsonic-response"].error.meessage);app.$.firstRun.toggle();app.doToast(e.target.response["subsonic-response"].error.meessage)}})}});var scroller=app.appScroller(),audio=app.$.audio,maximized=chrome.app.window.current().isMaximized(),button=app.$.max,timer;if(maximized){button.icon="check-box-outline-blank"}else{button.icon="flip-to-back"}scroller.onscroll=function(){var fab=app.$.fab,wall=app.$.wall;if(app.page===0&&fab.state!=="off"&&scroller.scrollTopapp.position&&wall.showing!=="podcast"){fab.state="bottom"}app.position=scroller.scrollTop};audio.onwaiting=app.playerProgress;audio.onstalled=function(e){if(timer){clearInterval(timer)}timer=setInterval(function(){app.playerProgress()},250)};audio.onplay=function(e){if(timer){clearInterval(timer)}};audio.onpause=function(e){if(timer){clearInterval(timer)}timer=setInterval(function(){app.playerProgress()},250)};audio.ontimeupdate=app.playerProgress;audio.onended=app.nextTrack;audio.onerror=function(e){app.page=0;console.error("audio playback error ",e);app.doToast("Audio Playback Error");app.tracker.sendEvent("Audio Playback Error",e.target)}};app.doAction=function(event,detail,sender){var scroller=app.appScroller(),wall=app.$.wall,animation=new CoreAnimation;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;if(app.page===0&&scroller.scrollTop!==0&&wall.showing!=="podcast"&&app.$.fab.state==="bottom"){scroller.scrollTop=0}if(app.page===0&&wall.showing==="podcast"){app.$.addPodcast.open()}if(app.page===1){app.showPlaylist()}if(app.page===0&&app.$.fab.state==="mid"){animation.play();app.$.wall.playSomething(sender.ident,function(){animation.cancel()})}if(app.page===3){animation.play();app.$.aDetails.playSomething(sender.ident,function(){animation.cancel()})}};app.fixScroller=function(event,detail,sender){};app.doSearch=function(){if(app.searchQuery){app.async(function(){app.closeDrawer(function(){var url=app.url+"/rest/search3.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&query="+encodeURIComponent(app.searchQuery);app.async(function(){app.doXhr(url,"json",function(e){app.dataLoading=true;if(e.target.response["subsonic-response"].status==="ok"){app.searchQuery="";var response=e.target.response;if(response["subsonic-response"].searchResult3.album){app.async(function(){app.$.wall.clearData(function(){app.async(function(){app.$.wall.response=response;app.showing=app.listMode})})})}else{app.dataLoading=false;app.doToast(chrome.i18n.getMessage("noResults"))}}})})})})}else{app.doToast(chrome.i18n.getMessage("noSearch"))}};app.showPlaylist=function(){var dialog=app.$.playlistDialog;app.async(function(){dialog.toggle()})};app.closePlaylist=function(){var dialog=app.$.playlistDialog;app.async(function(){dialog.close()})};app.openPlaylists=function(){app.closeDrawer(function(){app.playlistsLoading=true;var url=app.url+"/rest/getPlaylists.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json";app.doXhr(url,"json",function(e){app.playlistsLoading=false;app.playlists=e.target.response["subsonic-response"].playlists.playlist;app.$.playlistsDialog.open()})})};app.closePlaylists=function(){app.$.playlistsDialog.close()};app.reallyDelete=function(event,detail,sender){app.delID=sender.attributes.ident.value;app.$.playlistsDialog.close();app.$.playlistConfirm.open()};app.deletePlaylist=function(event,detail,sender){var url=app.url+"/rest/deletePlaylist.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json&id="+sender.attributes.ident.value,url2=app.url+"/rest/getPlaylists.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json";app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){app.playlistsLoading=true;app.doXhr(url2,"json",function(e){app.playlistsLoading=false;app.playlists=e.target.response["subsonic-response"].playlists.playlist;app.$.playlistsDialog.open()})}else{app.doToast(chrome.i18n.getMessage("deleteError"))}})};app.closeShuffleOptions=function(){app.$.shuffleOptions.close()};app.shuffleOptions=function(){var url=app.url+"/rest/getGenres.view?u="+app.user+"&p="+app.pass+"&v="+app.version+"&c=PolySonic&f=json";app.closeDrawer(function(){app.doXhr(url,"json",function(e){app.genres=e.target.response["subsonic-response"].genres.genre;app.$.shuffleOptions.open()})})};app.closePodcastDialog=function(){app.$.addPodcast.close()};app.toggleWall=function(){app.dataLoading=true;var wall=app.$.wall;if(wall.listMode==="cover"){wall.listMode="list";chrome.storage.sync.set({listMode:"list"})}else{wall.listMode="cover";chrome.storage.sync.set({listMode:"cover"})}app.tracker.sendEvent("ListMode Changed",wall.listMode)};app.requestSession=function(){chrome.cast.requestSession(onRequestSessionSuccess,onLaunchError)};app.back2List=function(){app.async(function(){app.page=0})};app.nowPlaying=function(){app.async(function(){app.page=1})};app.selectAction=function(event,detail,sender){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){if(wall.sort===sender.attributes.i.value){app.pageLimit=false;if(app.queryMethod==="ID3"){wall.request="getAlbumList2"}else{wall.request="getAlbumList"}wall.post.type=sender.attributes.i.value;wall.refreshContent();wall.showing=app.listMode;wall.$.threshold.clearLower()}wall.sort=sender.attributes.i.value})})})};app.getPodcast=function(){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){wall.getPodcast()})})})};app.getStarred=function(){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){wall.getStarred()})})})};app.getArtist=function(){var wall=app.$.wall;app.async(function(){app.closeDrawer(function(){app.async(function(){wall.getArtist()})})})};app.gotoSettings=function(){app.closeDrawer(function(){app.page=2})};app.refreshPodcast=function(event,detail,sender){var animation=new CoreAnimation,url;animation.duration=1e3;animation.iterations="Infinity";animation.keyframes=[{opacity:1},{opacity:0}];animation.target=sender;animation.play();url=app.url+"/rest/refreshPodcasts.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic";app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){animation.cancel();app.$.wall.refreshContent();app.doToast(chrome.i18n.getMessage("podcastCheck"))}})};app.addChannel=function(){if(!app.castURL){app.doToast(app.urlError)}if(!app.invalidURL){app.addingChannel=true;var url=app.url+"/rest/createPodcastChannel.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic&url="+encodeURIComponent(app.castURL);app.doXhr(url,"json",function(e){if(e.target.response["subsonic-response"].status==="ok"){app.addingChannel=false;app.$.addPodcast.close();app.$.wall.refreshContent();app.doToast(chrome.i18n.getMessage("channelAdded"));app.castURL=""}else{app.doToast(chrome.i18n.getMessage("podcastError"))}})}};app.doDelete=function(event,detail,sender){app.$.wall.deleteChannel(sender.attributes.ident.value)};app.deleteEpisode=function(event,detail,sender){app.$.wall.deleteEpisode(sender.attributes.ident.value)};app.getLicense=function(callback){var url=app.url+"/rest/getLicense.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic";app.async(function(){app.doXhr(url,"json",function(e){var response=e.target.response["subsonic-response"];if(response.status==="ok"){app.serverLicense=response.license;app.$.licenseDialog.open();app.async(callback)}})})};app.licenseDialogClose=function(){app.$.licenseDialog.close()};app.userDetails=function(){var url=app.url+"/rest/getUser.view?u="+app.user+"&p="+app.pass+"&f=json&v="+app.version+"&c=PolySonic&username="+app.user;app.async(function(){app.doXhr(url,"json",function(e){var response=e.target.response["subsonic-response"];if(response.status==="ok"){app.activeUser=response.user}else{console.error("Error getting User details")}})})}})();(function(){var g,aa=aa||{},h=this,ba=function(){},ca=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==b&&"undefined"==typeof a.call)return"object";return b},m=function(a){return"array"==ca(a)},da=function(a){var b=ca(a);return"array"==b||"object"==b&&"number"==typeof a.length},n=function(a){return"string"==typeof a},ea=function(a){return"number"==typeof a},p=function(a){return"function"==ca(a)},q=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b},fa=function(a,b,c){return a.call.apply(a.bind,arguments)},ga=function(a,b,c){if(!a)throw Error();if(2b?1:0};var w=Array.prototype,ja=w.indexOf?function(a,b,c){return w.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(n(a))return n(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?null:n(a)?a.charAt(b):a[b]},pa=function(a,b){var c=ja(a,b),d;(d=0<=c)&&w.splice.call(a,c,1);return d},qa=function(a){return w.concat.apply(w,arguments)},ra=function(a,b,c){return 2>=arguments.length?w.slice.call(a,b):w.slice.call(a,b,c)};var sa="StopIteration"in h?h.StopIteration:Error("StopIteration"),ta=function(){};ta.prototype.next=function(){throw sa};ta.prototype.vc=function(){return this};var ua=function(a,b,c){for(var d in a)b.call(c,a[d],d,a)},va=function(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b},wa=function(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b},xa=function(a,b){var c;t:{for(c in a)if(b.call(void 0,a[c],c,a))break t;c=void 0}return c&&a[c]},ya="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),za=function(a,b){for(var c,d,e=1;e2*this.h&&Aa(this),!0):!1};var Aa=function(a){if(a.h!=a.b.length){for(var b=0,c=0;b=c.length)throw sa;var k=c[b++];return a?k:d[k]}};return k};var y=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var Ba,Ca,Da={id:"hitType",name:"t",valueType:"text",maxLength:void 0,defaultValue:void 0},Ea={id:"sessionControl",name:"sc",valueType:"text",maxLength:void 0,defaultValue:void 0},Fa={id:"description",name:"cd",valueType:"text",maxLength:2048,defaultValue:void 0},Ga={id:"eventCategory",name:"ec",valueType:"text",maxLength:150,defaultValue:void 0},Ha={id:"eventAction",name:"ea",valueType:"text",maxLength:500,defaultValue:void 0},Ia={id:"eventLabel",name:"el",valueType:"text",maxLength:500,defaultValue:void 0},Ja={id:"eventValue",name:"ev",valueType:"integer",maxLength:void 0,defaultValue:void 0},Ka={pd:Da,Qc:{id:"anonymizeIp",name:"aip", valueType:"boolean",maxLength:void 0,defaultValue:void 0},Ad:{id:"queueTime",name:"qt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Wc:{id:"cacheBuster",name:"z",valueType:"text",maxLength:void 0,defaultValue:void 0},Gd:Ea,Wd:{id:"userId",name:"uid",valueType:"text",maxLength:void 0,defaultValue:void 0},xd:{id:"nonInteraction",name:"ni",valueType:"boolean",maxLength:void 0,defaultValue:void 0},fd:Fa,Pd:{id:"title",name:"dt",valueType:"text",maxLength:1500,defaultValue:void 0},Sc:{id:"appId",name:"aid",valueType:"text",maxLength:150,defaultValue:void 0},Tc:{id:"appInstallerId",name:"aiid",valueType:"text",maxLength:150,defaultValue:void 0},jd:Ga,hd:Ha,kd:Ia,ld:Ja,Id:{id:"socialNetwork",name:"sn",valueType:"text",maxLength:50,defaultValue:void 0},Hd:{id:"socialAction",name:"sa",valueType:"text",maxLength:50,defaultValue:void 0},Jd:{id:"socialTarget",name:"st",valueType:"text",maxLength:2048,defaultValue:void 0},Sd:{id:"transactionId",name:"ti",valueType:"text",maxLength:500,defaultValue:void 0},Rd:{id:"transactionAffiliation",name:"ta",valueType:"text",maxLength:500,defaultValue:void 0},Td:{id:"transactionRevenue",name:"tr",valueType:"currency",maxLength:void 0,defaultValue:void 0},Ud:{id:"transactionShipping",name:"ts",valueType:"currency",maxLength:void 0,defaultValue:void 0},Vd:{id:"transactionTax",name:"tt",valueType:"currency",maxLength:void 0,defaultValue:void 0},dd:{id:"currencyCode",name:"cu",valueType:"text",maxLength:10,defaultValue:void 0},td:{id:"itemPrice",name:"ip",valueType:"currency",maxLength:void 0,defaultValue:void 0},ud:{id:"itemQuantity",name:"iq",valueType:"integer",maxLength:void 0,defaultValue:void 0},rd:{id:"itemCode",name:"ic",valueType:"text",maxLength:500,defaultValue:void 0},sd:{id:"itemName",name:"in",valueType:"text",maxLength:500,defaultValue:void 0},qd:{id:"itemCategory",name:"iv",valueType:"text",maxLength:500,defaultValue:void 0},bd:{id:"campaignSource",name:"cs",valueType:"text",maxLength:100,defaultValue:void 0},$c:{id:"campaignMedium",name:"cm",valueType:"text",maxLength:50,defaultValue:void 0},ad:{id:"campaignName",name:"cn",valueType:"text",maxLength:100,defaultValue:void 0},Zc:{id:"campaignKeyword",name:"ck",valueType:"text",maxLength:500,defaultValue:void 0},Xc:{id:"campaignContent",name:"cc",valueType:"text",maxLength:500,defaultValue:void 0},Yc:{id:"campaignId",name:"ci",valueType:"text",maxLength:100,defaultValue:void 0},od:{id:"gclid",name:"gclid",valueType:"text",maxLength:void 0,defaultValue:void 0},ed:{id:"dclid",name:"dclid",valueType:"text",maxLength:void 0,defaultValue:void 0},zd:{id:"pageLoadTime",name:"plt",valueType:"integer",maxLength:void 0,defaultValue:void 0},gd:{id:"dnsTime",name:"dns",valueType:"integer",maxLength:void 0,defaultValue:void 0},Kd:{id:"tcpConnectTime",name:"tcp",valueType:"integer",maxLength:void 0,defaultValue:void 0},Fd:{id:"serverResponseTime",name:"srt",valueType:"integer",maxLength:void 0,defaultValue:void 0},yd:{id:"pageDownloadTime",name:"pdt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Bd:{id:"redirectResponseTime",name:"rrt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Ld:{id:"timingCategory",name:"utc",valueType:"text",maxLength:150,defaultValue:void 0},Od:{id:"timingVar",name:"utv",valueType:"text",maxLength:500,defaultValue:void 0},Nd:{id:"timingValue",name:"utt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Md:{id:"timingLabel",name:"utl",valueType:"text",maxLength:500,defaultValue:void 0},md:{id:"exDescription",name:"exd",valueType:"text",maxLength:150,defaultValue:void 0},nd:{id:"exFatal",name:"exf",valueType:"boolean",maxLength:void 0,defaultValue:"1"}},La=function(a){if(1>a||200a||200a)return"0";if(3>a)return"1-2";a=Math.floor(Math.log(a-1)/Math.log(2));return Math.pow(2,a)+1+"-"+Math.pow(2,a+1)},Oa=function(a,b){for(var c=0,d=a.length-1,e=0;c<=d;){var f=Math.floor((c+d)/2),e=a[f];if(b<=e){d=0==f?0:a[f-1];if(b>d)return(d+1).toString()+"-"+e.toString();d=f-1}else if(b>e){if(f>=a.length-1)return(a[a.length-1]+1).toString()+"+";c=f+1}}return"<= 0"};var z=function(){this.ab=[]},Pa=function(){return new z};g=z.prototype;g.when=function(a){this.ab.push(a);return this};g.zb=function(a){var b=arguments;this.when(function(a){return 0<=ja(b,a.Gb())});return this};g.Oc=function(a,b){var c=ra(arguments,1);this.when(function(b){b=b.T().get(a);return 0<=ja(c,b)});return this};g.xb=function(a,b){if(q(this.e))throw Error("Filter has already been set.");this.e=q(b)?r(a,b):a;return this};g.Ca=function(){if(0==this.ab.length)throw Error("Must specify at least one predicate using #when or a helper method.");if(!q(this.e))throw Error("Must specify a delegate filter using #applyFilter.");return r(function(a){ma(this.ab,function(b){return b(a)})&&this.e(a)},this)};var A=function(){this.Ab=!1;this.Bb="";this.qb=!1;this.za=null};A.prototype.wc=function(a){this.Ab=!0;this.Bb=a||" - ";return this};A.prototype.Nc=function(){this.qb=!0;return this};A.prototype.Ec=function(){return Qa(this,Na)};A.prototype.Fc=function(a){return Qa(this,ha(Oa,a))};var Qa=function(a,b){if(null!=a.za)throw Error("LabelerBuilder: Only one labeling strategy may be used.");a.za=r(function(a){var d=a.T().get(Ja),e=a.T().get(Ia);ea(d)&&(d=b(d),null!=e&&this.Ab&&(d=e+this.Bb+d),a.T().set(Ia,d))},a);return a};A.prototype.Ca=function(){if(null==this.za)throw Error("LabelerBuilder: a labeling strategy must be specified prior to calling build().");return Pa().zb("event").xb(r(function(a){this.za(a);this.qb&&a.T().remove(Ja)},this)).Ca()};var Ra=function(a,b){var c=Array.prototype.slice.call(arguments),d=c.shift();if("undefined"==typeof d)throw Error("[goog.string.format] Template required");return d.replace(/%([0\-\ \+]*)(\d+)?(\.(\d+))?([%sfdiu])/g,function(a,b,d,l,N,J,U,V){if("%"==J)return"%";var Db=c.shift();if("undefined"==typeof Db)throw Error("[goog.string.format] Not enough arguments");arguments[0]=Db;return B[J].apply(null,arguments)})},B={s:function(a,b,c){return isNaN(c)||""==c||a.length>=c?a:a=-1a?"-":0<=b.indexOf("+")?"+":0<=b.indexOf(" ")?" ":"";0<=a&&(d=f+d);if(isNaN(c)||d.length>=c)return d;d=isNaN(e)?Math.abs(a).toString():Math.abs(a).toFixed(e);a=c-d.length-f.length;return d=0<=b.indexOf("-",0)?f+d+Array(a+1).join(" "):f+Array(a+1).join(0<=b.indexOf("0",0)?"0":" ")+d},d:function(a,b,c,d,e,f,k,l){return B.f(parseInt(a,10),b,c,d,0,f,k,l)}};B.i=B.d;B.u=B.d;var Sa=function(a){if("function"==typeof a.t)return a.t();if(n(a))return a.split("");if(da(a)){for(var b=[],c=a.length,d=0;dparseFloat(a))?String(b):a}(),bb={},M=function(a){var b;if(!(b=bb[a])){b=0;for(var c=String(ab).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=Math.max(c.length,d.length),f=0;0==b&&f=a.keyCode)a.keyCode=-1}catch(b){}};O.prototype.l=function(){};var jb="closure_listenable_"+(1e6*Math.random()|0),kb=function(a){return!(!a||!a[jb])},lb=0;var mb=function(a,b,c,d,e){this.O=a;this.proxy=null;this.src=b;this.type=c;this.pa=!!d;this.sa=e;this.key=++lb;this.removed=this.qa=!1},nb=function(a){a.removed=!0;a.O=null;a.proxy=null;a.src=null;a.sa=null};var P=function(a){this.src=a;this.j={};this.Z=0};P.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.j[f];a||(a=this.j[f]=[],this.Z++);var k=ob(a,b,d,e);-1e.keyCode||void 0!=e.returnValue)){t:{var f=!1;if(0==e.keyCode)try{e.keyCode=-1;break t}catch(k){f=!0}if(f||void 0==e.returnValue)e.returnValue=!0}e=[];for(f=c.currentTarget;f;f=f.parentNode)e.push(f);for(var f=a.type,l=e.length-1;!c.U&&0<=l;l--)c.currentTarget=e[l],d&=Fb(e[l],f,!0,c);for(l=0;!c.U&&l>>0),ub=function(a){if(p(a))return a;a[Gb]||(a[Gb]=function(b){return a.handleEvent(b)});return a[Gb]};var Q=function(){E.call(this);this.A=new P(this);this.kc=this;this.Qa=null};u(Q,E);Q.prototype[jb]=!0;g=Q.prototype;g.addEventListener=function(a,b,c,d){tb(this,a,b,c,d)};g.removeEventListener=function(a,b,c,d){Bb(this,a,b,c,d)};g.dispatchEvent=function(a){var b,c=this.Qa;if(c){b=[];for(var d=1;c;c=c.Qa)b.push(c),++d}c=this.kc;d=a.type||a;if(n(a))a=new F(a,c);else if(a instanceof F)a.target=a.target||c;else{var e=a;a=new F(d,c);za(a,e)}var e=!0,f;if(b)for(var k=b.length-1;!a.U&&0<=k;k--)f=a.currentTarget=b[k],e=Hb(f,d,!0,a)&&e;a.U||(f=a.currentTarget=c,e=Hb(f,d,!0,a)&&e,a.U||(e=Hb(f,d,!1,a)&&e));if(b)for(k=0;!a.U&&k=b.Ia&&b.cancel())}this.hb?this.hb.call(this.gb,this):this.Ka=!0;this.C||this.w(new dc)}};S.prototype.ib=function(a,b){this.Ja=!1;ec(this,a,b)};var ec=function(a,b,c){a.C=!0;a.v=c;a.W=!b;fc(a)},hc=function(a){if(a.C){if(!a.Ka)throw new gc;a.Ka=!1}};S.prototype.G=function(a){hc(this);ec(this,!0,a)};S.prototype.w=function(a){hc(this);ec(this,!1,a)};S.prototype.J=function(a,b){return ic(this,a,null,b)};var ic=function(a,b,c,d){a.ja.push([b,c,d]);a.C&&fc(a);return a};S.prototype.then=function(a,b,c){var d,e,f=new R(function(a,b){d=a;e=b});ic(this,d,function(a){a instanceof dc?f.cancel():e(a)});return f.then(a,b,c)};Sb(S);var jc=function(a){var b=new S;ic(a,b.G,b.w,b);return b},kc=function(a){return la(a.ja,function(a){return p(a[1])})},fc=function(a){if(a.ka&&a.C&&kc(a)){var b=a.ka,c=lc[b];c&&(h.clearTimeout(c.ma),delete lc[b]);a.ka=0}a.o&&(a.o.Ia--,delete a.o);for(var b=a.v,d=c=!1;a.ja.length&&!a.Ja;){var e=a.ja.shift(),f=e[0],k=e[1],e=e[2];if(f=a.W?k:f)try{var l=f.call(e||a.gb,b);void 0!==l&&(a.W=a.W&&(l==b||l instanceof Error),a.v=b=l);Tb(b)&&(d=!0,a.Ja=!0)}catch(N){b=N,a.W=!0,kc(a)||(c=!0)}}a.v=b;d&&(l=r(a.ib,a,!0),d=r(a.ib,a,!1),b instanceof S?(ic(b,l,d),b.Lb=!0):b.then(l,d));c&&(b=new mc(b),lc[b.ma]=b,a.ka=b.ma)},nc=function(a){var b=new S;b.G(a);return b},pc=function(){var a=oc,b=new S;b.w(a);return b},gc=function(){v.call(this)};u(gc,v);gc.prototype.message="Deferred has already fired";gc.prototype.name="AlreadyCalledError";var dc=function(){v.call(this)};u(dc,v);dc.prototype.message="Deferred was canceled";dc.prototype.name="CanceledError";var mc=function(a){this.ma=h.setTimeout(r(this.pc,this),0);this.ga=a};mc.prototype.pc=function(){delete lc[this.ma];throw this.ga};var lc={};var qc=function(a){this.$a=[];this.e=a};qc.prototype.S=function(a){if(!p(a))throw Error("Invalid filter. Must be a function.");this.$a.push(a)};qc.prototype.send=function(a,b){for(var c=new T(a,b),d=0;db.maxLength&&a.set(b,c.substring(0,b.maxLength))})},ed=function(a){Ua(a,function(b,c){void 0!==b.defaultValue&&c==b.defaultValue&&a.remove(b)})};var oc={status:"device-offline",Ba:void 0},fd={status:"rate-limited",Ba:void 0},gd={status:"sampled-out",Ba:void 0},hd={status:"sent",Ba:void 0};var id=function(a,b){this.Wb=a;this.e=b};id.prototype.send=function(a,b){var c;c=this.Wb;var d=c.pb(),e=Math.floor((d-c.ob)*c.Sb);0c.$?c=!1:(c.$-=1,c=!0);return c||"item"==a||"transaction"==a?this.e.send(a,b):nc(fd)};var jd=function(){this.$=60;this.Tb=500;this.Sb=5e-4;this.pb=function(){return(new Date).getTime()};this.ob=this.pb()};var kd=function(a,b){this.k=a;this.e=b};kd.prototype.send=function(a,b){var c=b.get(vc),c=parseInt(c.split("-")[1],16),d;"timing"!=a?d=this.k.V:((d=b.get(yc))&&b.remove(yc),d||(d=this.k.V));return c<655.36*d?this.e.send(a,b):nc(gd)};var ld=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#(.*))?$/,md=L,nd=function(a,b){if(md){md=!1;var c=h.location;if(c){var d=c.href;if(d&&(d=(d=nd(3,d))?decodeURI(d):d)&&d!=c.hostname)throw md=!0,Error()}}return b.match(ld)[a]||null};var od=function(){};od.prototype.Eb=null;var qd=function(a){var b;(b=a.Eb)||(b={},pd(a)&&(b[0]=!0,b[1]=!0),b=a.Eb=b);return b};var rd,sd=function(){};u(sd,od);var td=function(a){return(a=pd(a))?new ActiveXObject(a):new XMLHttpRequest},pd=function(a){if(!a.Hb&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var b=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],c=0;cthis.na?c.w({status:"payload-too-big",Ba:Ra("Encoded hit length == %s, but should be <= %s.",d.length,this.na)}):xd(this.$b,function(){c.G(hd)},d);return c};var Jd=function(a,b){var c=new Fd;c.add(Da.name,a);Ua(b,function(a,b){c.add(a.name,b.toString())});return c.toString()};var Kd=function(a,b,c){this.k=a;this.Qb=b;this.na=c};Kd.prototype.Sa=function(){if(!this.q){var a=this.k;if(!jc(a.ha).C)throw Error("Cannot construct shared channel prior to settings being ready.");new ad;var b=new cd(new Id(this.Qb,this.na)),c=new jd;this.q=new bd(a,new kd(a,new id(c,b)))}return this.q};var Ld=new x,Md=function(){if(!Ba){var a=new Tc("google-analytics");Ba=new X(a)}return Ba};t("goog.async.Deferred",S);t("goog.async.Deferred.prototype.addCallback",S.prototype.J);t("goog.events.EventTarget",Q);t("goog.events.EventTarget.prototype.listen",Q.prototype.listen);t("analytics.getService",function(a){var b=Ld.get(a,null);if(null===b){var b=chrome.runtime.getManifest().version,c=Md();if(!Ca){var d=Md();Ca=new Wc(d,new Kd(d,"https://www.google-analytics.com/collect",8192))}b=new Hc("ca1.5.2",a,b,c,Ca);Ld.set(a,b)}return b});t("analytics.internal.GoogleAnalyticsService",Hc);t("analytics.internal.GoogleAnalyticsService.prototype.getTracker",Hc.prototype.Cc);t("analytics.internal.GoogleAnalyticsService.prototype.getConfig",Hc.prototype.Bc);t("analytics.internal.ServiceSettings",X);t("analytics.internal.ServiceSettings.prototype.setTrackingPermitted",X.prototype.Lc);t("analytics.internal.ServiceSettings.prototype.isTrackingPermitted",X.prototype.va);t("analytics.internal.ServiceSettings.prototype.setSampleRate",X.prototype.Kc);t("analytics.internal.ServiceTracker",W);t("analytics.internal.ServiceTracker.prototype.send",W.prototype.send);t("analytics.internal.ServiceTracker.prototype.sendAppView",W.prototype.Gc);t("analytics.internal.ServiceTracker.prototype.sendEvent",W.prototype.Hc);t("analytics.internal.ServiceTracker.prototype.sendSocial",W.prototype.Jc);t("analytics.internal.ServiceTracker.prototype.sendException",W.prototype.Ic);t("analytics.internal.ServiceTracker.prototype.sendTiming",W.prototype.Cb);t("analytics.internal.ServiceTracker.prototype.startTiming",W.prototype.Mc);t("analytics.internal.ServiceTracker.Timing",Gc);t("analytics.internal.ServiceTracker.Timing.prototype.send",Gc.prototype.send);t("analytics.internal.ServiceTracker.prototype.forceSessionStart",W.prototype.Ac);t("analytics.internal.ServiceTracker.prototype.addFilter",W.prototype.S);t("analytics.internal.FilterChannel.Hit",T);t("analytics.internal.FilterChannel.Hit.prototype.getHitType",T.prototype.Gb);t("analytics.internal.FilterChannel.Hit.prototype.getParameters",T.prototype.T);t("analytics.internal.FilterChannel.Hit.prototype.cancel",T.prototype.cancel);t("analytics.ParameterMap",C);t("analytics.ParameterMap.Entry",C.Entry);t("analytics.ParameterMap.prototype.set",C.prototype.set);t("analytics.ParameterMap.prototype.get",C.prototype.get);t("analytics.ParameterMap.prototype.remove",C.prototype.remove);t("analytics.ParameterMap.prototype.toObject",C.prototype.Jb);t("analytics.HitTypes.APPVIEW","appview");t("analytics.HitTypes.EVENT","event");t("analytics.HitTypes.SOCIAL","social");t("analytics.HitTypes.TRANSACTION","transaction");t("analytics.HitTypes.ITEM","item");t("analytics.HitTypes.TIMING","timing");t("analytics.HitTypes.EXCEPTION","exception");ua(Ka,function(a){var b=a.id.replace(/[A-Z]/,"_$&").toUpperCase();t("analytics.Parameters."+b,a)});t("analytics.filters.EventLabelerBuilder",A);t("analytics.filters.EventLabelerBuilder.prototype.appendToExistingLabel",A.prototype.wc);t("analytics.filters.EventLabelerBuilder.prototype.stripValue",A.prototype.Nc);t("analytics.filters.EventLabelerBuilder.prototype.powersOfTwo",A.prototype.Ec);t("analytics.filters.EventLabelerBuilder.prototype.rangeBounds",A.prototype.Fc);t("analytics.filters.EventLabelerBuilder.prototype.build",A.prototype.Ca);t("analytics.filters.FilterBuilder",z);t("analytics.filters.FilterBuilder.builder",Pa);t("analytics.filters.FilterBuilder.prototype.when",z.prototype.when);t("analytics.filters.FilterBuilder.prototype.whenHitType",z.prototype.zb);t("analytics.filters.FilterBuilder.prototype.whenValue",z.prototype.Oc);t("analytics.filters.FilterBuilder.prototype.applyFilter",z.prototype.xb);t("analytics.filters.FilterBuilder.prototype.build",z.prototype.Ca);t("analytics.EventBuilder",D);t("analytics.EventBuilder.builder",function(){return Va});t("analytics.EventBuilder.prototype.category",D.prototype.xc);t("analytics.EventBuilder.prototype.action",D.prototype.action);t("analytics.EventBuilder.prototype.label",D.prototype.label);t("analytics.EventBuilder.prototype.value",D.prototype.value);t("analytics.EventBuilder.prototype.dimension",D.prototype.yc);t("analytics.EventBuilder.prototype.metric",D.prototype.Dc);t("analytics.EventBuilder.prototype.send",D.prototype.send)})();var CanvasImage=function(a){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),document.body.appendChild(this.canvas),this.width=this.canvas.width=a.width,this.height=this.canvas.height=a.height,this.context.drawImage(a,0,0,this.width,this.height)};CanvasImage.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},CanvasImage.prototype.update=function(a){this.context.putImageData(a,0,0)},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.canvas.parentNode.removeChild(this.canvas)};var ColorThief=function(){};if(ColorThief.prototype.getColor=function(a,b){var c=this.getPalette(a,5,b),d=c[0];return d},ColorThief.prototype.getPalette=function(a,b,c){"undefined"==typeof b&&(b=10),"undefined"==typeof c&&(c=10);for(var d,e,f,g,h,i=new CanvasImage(a),j=i.getImageData(),k=j.data,l=i.getPixelCount(),m=[],n=0;l>n;n+=c)d=4*n,e=k[d+0],f=k[d+1],g=k[d+2],h=k[d+3],h>=125&&(e>250&&f>250&&g>250||m.push([e,f,g]));var o=MMCQ.quantize(m,b),p=o.palette();return i.removeCanvas(),p},!pv)var pv={map:function(a,b){var c={};return b?a.map(function(a,d){return c.index=d,b.call(c,a)}):a.slice()},naturalOrder:function(a,b){return b>a?-1:a>b?1:0},sum:function(a,b){var c={};return a.reduce(b?function(a,d,e){return c.index=e,a+b.call(c,d)}:function(a,b){return a+b},0)},max:function(a,b){return Math.max.apply(null,b?pv.map(a,b):a)}};var MMCQ=function(){function a(a,b,c){return(a<<2*i)+(b<>j,e=b[1]>>j,f=b[2]>>j,c=a(d,e,f),h[c]=(h[c]||0)+1}),h}function f(a,b){var d,e,f,g=1e6,h=0,i=1e6,k=0,l=1e6,m=0;return a.forEach(function(a){d=a[0]>>j,e=a[1]>>j,f=a[2]>>j,g>d?g=d:d>h&&(h=d),i>e?i=e:e>k&&(k=e),l>f?l=f:f>m&&(m=f)}),new c(g,h,i,k,l,m,b)}function g(b,c){function d(a){var b,d,e,f,g,h=a+"1",j=a+"2",k=0;for(i=c[h];i<=c[j];i++)if(o[i]>n/2){for(e=c.copy(),f=c.copy(),b=i-c[h],d=c[j]-i,g=d>=b?Math.min(c[j]-1,~~(i+d/2)):Math.max(c[h],~~(i-1-b/2));!o[g];)g++;for(k=p[g];!k&&o[g-1];)k=p[--g];return e[j]=g,f[h]=e[j]+1,[e,f]}}if(c.count()){var e=c.r2-c.r1+1,f=c.g2-c.g1+1,g=c.b2-c.b1+1,h=pv.max([e,f,g]);if(1==c.count())return[c.copy()];var i,j,k,l,m,n=0,o=[],p=[];if(h==e)for(i=c.r1;i<=c.r2;i++){for(l=0,j=c.g1;j<=c.g2;j++)for(k=c.b1;k<=c.b2;k++)m=a(i,j,k),l+=b[m]||0;n+=l,o[i]=n}else if(h==f)for(i=c.g1;i<=c.g2;i++){for(l=0,j=c.r1;j<=c.r2;j++)for(k=c.b1;k<=c.b2;k++)m=a(j,i,k),l+=b[m]||0;n+=l,o[i]=n}else for(i=c.b1;i<=c.b2;i++){for(l=0,j=c.r1;j<=c.r2;j++)for(k=c.g1;k<=c.g2;k++)m=a(j,k,i),l+=b[m]||0;n+=l,o[i]=n}return o.forEach(function(a,b){p[b]=n-a}),d(h==e?"r":h==f?"g":"b")}}function h(a,c){function h(a,b){for(var c,d=1,e=0;k>e;)if(c=a.pop(),c.count()){var f=g(i,c),h=f[0],j=f[1];if(!h)return;if(a.push(h),j&&(a.push(j),d++),d>=b)return;if(e++>k)return}else a.push(c),e++}if(!a.length||2>c||c>256)return!1;var i=e(a),j=0;i.forEach(function(){j++});var m=f(a,i),n=new b(function(a,b){return pv.naturalOrder(a.count(),b.count())});n.push(m),h(n,l*c);for(var o=new b(function(a,b){return pv.naturalOrder(a.count()*a.volume(),b.count()*b.volume())});n.size();)o.push(n.pop());h(o,c-o.size());for(var p=new d;o.size();)p.push(o.pop());return p}var i=5,j=8-i,k=1e3,l=.75;return c.prototype={volume:function(a){var b=this;return(!b._volume||a)&&(b._volume=(b.r2-b.r1+1)*(b.g2-b.g1+1)*(b.b2-b.b1+1)),b._volume},count:function(b){var c=this,d=c.histo;if(!c._count_set||b){var e,f,g,h=0;for(e=c.r1;e<=c.r2;e++)for(f=c.g1;f<=c.g2;f++)for(g=c.b1;g<=c.b2;g++)index=a(e,f,g),h+=d[index]||0;c._count=h,c._count_set=!0}return c._count},copy:function(){var a=this;return new c(a.r1,a.r2,a.g1,a.g2,a.b1,a.b2,a.histo)},avg:function(b){var c=this,d=c.histo;if(!c._avg||b){var e,f,g,h,j,k=0,l=1<<8-i,m=0,n=0,o=0;for(f=c.r1;f<=c.r2;f++)for(g=c.g1;g<=c.g2;g++)for(h=c.b1;h<=c.b2;h++)j=a(f,g,h),e=d[j]||0,k+=e,m+=e*(f+.5)*l,n+=e*(g+.5)*l,o+=e*(h+.5)*l;c._avg=k?[~~(m/k),~~(n/k),~~(o/k)]:[~~(l*(c.r1+c.r2+1)/2),~~(l*(c.g1+c.g2+1)/2),~~(l*(c.b1+c.b2+1)/2)]}return c._avg},contains:function(a){var b=this,c=a[0]>>j;return gval=a[1]>>j,bval=a[2]>>j,c>=b.r1&&c<=b.r2&&gval>=b.g1&&gval<=b.g2&&bval>=b.b1&&bval<=b.b2}},d.prototype={push:function(a){this.vboxes.push({vbox:a,color:a.avg()})},palette:function(){return this.vboxes.map(function(a){return a.color})},size:function(){return this.vboxes.size()},map:function(a){for(var b=this.vboxes,c=0;cc||void 0===b)&&(b=c,d=e.peek(f).color);return d},forcebw:function(){var a=this.vboxes;a.sort(function(a,b){return pv.naturalOrder(pv.sum(a.color),pv.sum(b.color))});var b=a[0].color;b[0]<5&&b[1]<5&&b[2]<5&&(a[0].color=[0,0,0]);var c=a.length-1,d=a[c].color;d[0]>251&&d[1]>251&&d[2]>251&&(a[c].color=[255,255,255])}},{quantize:h}}(); diff --git a/src/elements/subsonic/album-art.html.0.js b/src/elements/subsonic/album-art.html.0.js index 55ac3c4..47732f9 100755 --- a/src/elements/subsonic/album-art.html.0.js +++ b/src/elements/subsonic/album-art.html.0.js @@ -355,7 +355,7 @@ Polymer('album-art', { this.playlist.push(obj); i = i + 1; if (i === this.tracks.length) { - this.async(callback); + callback(); } }.bind(this)); }); @@ -378,22 +378,18 @@ Polymer('album-art', { /* get the data from subsonic server */ - this.async(function () { - this.app.doXhr(url, 'json', function (e) { - this.trackResponse = e.target.response; - /* - place json in indexeddb - */ - this.async(function () { - this.app.putInDb(this.trackResponse, this.item, function () { - this.async(function () { - this.processJSON(callback); - }); - console.log('JSON Data Added to indexedDB ' + this.item); - }.bind(this)); - }); - }.bind(this)); - }); + this.app.doXhr(url, 'json', function (e) { + this.trackResponse = e.target.response; + /* + place json in indexeddb + */ + this.async(function () { + this.processJSON(callback); + this.app.putInDb(this.trackResponse, this.item, function () { + console.log('JSON Data Added to indexedDB ' + this.item); + }.bind(this)); + }); + }.bind(this)); } }.bind(this)); }); @@ -417,15 +413,13 @@ Polymer('album-art', { /* get image from subsonic server */ - this.async(function () { - this.app.getImageFile(url, artId, function (event) { - this.setImage(event, function (imgURL) { - this.async(function () { - this.app.colorThiefHandler(imgURL, artId); - }); - }.bind(this)); + this.app.getImageFile(url, artId, function (event) { + this.setImage(event, function (imgURL) { + this.async(function () { + this.app.colorThiefHandler(imgURL, artId); + }); }.bind(this)); - }); + }.bind(this)); } }.bind(this)); }); @@ -446,9 +440,9 @@ Polymer('album-art', { /* to be run @ end of loop */ callback = function () { this.app.getImageForPlayer(this.app.playlist[0].cover, function () { - this.app.setFabColor(this.playlist[0]); - var playURL = this.url + '/rest/stream.view?u=' + this.user + '&p=' + this.pass + '&v=' + this.version + '&c=PolySonic&maxBitRate=' + this.bitRate + '&id=' + this.app.playlist[0].id; this.app.playing = 0; + var playURL = this.url + '/rest/stream.view?u=' + this.user + '&p=' + this.pass + '&v=' + this.version + '&c=PolySonic&maxBitRate=' + this.bitRate + '&id=' + this.app.playlist[0].id; + this.app.setFabColor(this.app.playlist[0]); this.app.playAudio(this.app.playlist[0].artist, this.app.playlist[0].title, playURL, this.app.playlist[0].cover, this.app.playlist[0].id); this.app.dataLoading = false; this.app.page = 1; diff --git a/src/elements/subsonic/album-wall.html.0.js b/src/elements/subsonic/album-wall.html.0.js index dfd9e26..124f742 100755 --- a/src/elements/subsonic/album-wall.html.0.js +++ b/src/elements/subsonic/album-wall.html.0.js @@ -87,18 +87,16 @@ Polymer('album-wall', { clearData: function (callback) { 'use strict'; - this.async(function () { - this.isLoading = true; - this.app.dataLoading = true; - this.artist = null; - this.podcast = null; - this.wall = null; - this.artists = []; - this.wall = []; - this.podcast = []; - this.resizeLists(); - this.async(callback); - }); + this.isLoading = true; + this.app.dataLoading = true; + this.artist = null; + this.podcast = null; + this.wall = null; + this.artists = []; + this.wall = []; + this.podcast = []; + this.resizeLists(); + this.async(callback); }, buildObject: function (e) { @@ -223,6 +221,7 @@ Polymer('album-wall', { getPodcast: function () { 'use strict'; + this.showing = 'podcast'; this.clearData(function () { this.app.pageLimit = false; this.request = 'getPodcasts'; @@ -233,15 +232,13 @@ Polymer('album-wall', { 'request': this.request, 'mediaFolder': this.mediaFolder }); - this.showing = 'podcast'; - this.async(function () { - this.$.ajax.go(); - }); + this.$.ajax.go(); }.bind(this)); }, getStarred: function () { 'use strict'; + this.showing = this.listMode; this.clearData(function () { this.app.pageLimit = false; if (this.queryMethod === 'ID3') { @@ -256,10 +253,7 @@ Polymer('album-wall', { 'request': this.request, 'mediaFolder': this.mediaFolder }); - this.showing = this.listMode; - this.async(function () { - this.$.ajax.go(); - }); + this.$.ajax.go(); }.bind(this)); }, @@ -276,14 +270,13 @@ Polymer('album-wall', { 'mediaFolder': this.mediaFolder }); this.showing = 'artists'; - this.async(function () { - this.$.ajax.go(); - }); + this.$.ajax.go(); }.bind(this)); }, sortChanged: function () { 'use strict'; + this.showing = this.listMode; this.clearData(function () { this.app.pageLimit = false; if (this.queryMethod === 'ID3') { @@ -298,10 +291,7 @@ Polymer('album-wall', { 'request': this.request, 'mediaFolder': this.mediaFolder }); - this.showing = this.listMode; - this.async(function () { - this.$.ajax.go(); - }); + this.$.ajax.go(); }.bind(this)); }, diff --git a/src/js/PolySonic.js b/src/js/PolySonic.js index 487d1f8..c0322bf 100755 --- a/src/js/PolySonic.js +++ b/src/js/PolySonic.js @@ -764,7 +764,7 @@ app.bitRate = result.bitRate || 320; app.shuffleSize = app.shuffleSize || '50'; app.version = '1.11.0'; - app.querySize = 30; + app.querySize = 40; app.volume = result.volume || 100; app.queryMethod = result.queryMethod || 'ID3'; app.colorThiefEnabled = true;