platypush/platypush/backend/http/webapp/dist/static/js/1798.2ea76630.js

2 lines
12 KiB
JavaScript

"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1798],{1798:function(e,t,n){n.r(t),n.d(t,{default:function(){return S}});var i=n(6252),a=n(3577);const o={class:"weather"},r={key:1},s=["src","alt","width","height"],h={key:2,class:"temperature"},l=["textContent"];function c(e,t,n,c,u,d){const g=(0,i.up)("Loading"),p=(0,i.up)("skycons");return(0,i.wg)(),(0,i.iD)("div",o,[e.loading?((0,i.wg)(),(0,i.j4)(g,{key:0})):((0,i.wg)(),(0,i.iD)("h1",r,[d._showIcon&&e.weatherIcon&&"weather.darksky"===e.weatherPlugin?((0,i.wg)(),(0,i.j4)(p,{key:0,condition:e.weatherIcon,paused:!n.animate,size:n.iconSize,color:n.iconColor},null,8,["condition","paused","size","color"])):d._showIcon&&e.weatherIcon&&"weather.openweathermap"===e.weatherPlugin?((0,i.wg)(),(0,i.iD)("img",{key:1,src:`/icons/openweathermap/${n.iconColor||"dark"}/${e.weatherIcon}.png`,alt:e.weather?.summary,width:1.5*n.iconSize,height:1.5*n.iconSize,class:"owm-icon"},null,8,s)):(0,i.kq)("",!0),d._showTemperature&&e.weather?((0,i.wg)(),(0,i.iD)("span",h,(0,a.zw)(Math.round(parseFloat(e.weather.temperature))+"°"),1)):(0,i.kq)("",!0)])),d._showSummary&&e.weather&&e.weather.summary?((0,i.wg)(),(0,i.iD)("div",{key:2,class:"summary",textContent:(0,a.zw)(e.weather.summary)},null,8,l)):(0,i.kq)("",!0)])}var u=n(6813);const d=["width","height","data-condition"];function g(e,t,n,a,o,r){return(0,i.wg)(),(0,i.iD)("canvas",{width:r.width,height:r.height,"data-condition":n.condition},null,8,d)}var p=n(6452),f=n.n(p);function m(e){const t={};return t.paused=!e.interval,t.play=()=>{e.play(),t.paused=!1},t.pause=()=>{e.pause(),t.paused=!0},t}var w={props:{condition:{type:String,required:!0},size:{type:[Number,String],default:64},color:{type:String,default:"black"},paused:{type:Boolean,default:!1},speed:{type:[Number,String],default:1}},computed:{width(){return""+this.size},height(){return""+this.size},icon(){return this.condition.toUpperCase().replace(/[\s.-]/g,"_")}},mounted(){const e=new(f())({color:this.color,speed:this.speed});e.set(this.$el,f()[this.icon]),this.paused||e.play(),this.$emit("load",m(e))}},v=n(3744);const y=(0,v.Z)(w,[["render",g]]);var M=y,C=M,k=n(1232),b={name:"Weather",mixins:[u.Z],components:{Loading:k.Z,Skycons:C},props:{animate:{required:!1,default:!0},iconSize:{type:Number,required:!1,default:50},iconColor:{type:String,required:!1},showIcon:{required:!1,default:!0},showSummary:{required:!1,default:!0},showTemperature:{required:!1,default:!0},refreshSeconds:{type:Number,required:!1,default:900}},data:function(){return{weather:void 0,weatherIcon:void 0,weatherPlugin:void 0,loading:!1,weatherPlugins:["weather.openweathermap","weather.darksky"]}},computed:{_showSummary(){return this.parseBoolean(this.showSummary)},_showIcon(){return this.parseBoolean(this.showIcon)},_showTemperature(){return this.parseBoolean(this.showTemperature)}},methods:{async refresh(){this.loading=!0;try{const e=await this.request(`${this.weatherPlugin}.get_current_weather`);this.onWeatherChange(e)}finally{this.loading=!1}},onWeatherChange(e){this.weather||(this.weather={}),this.weather={...this.weather,...e},this.weatherIcon=this.weather.icon},initWeatherPlugin(){for(const e of this.weatherPlugins)if(this.$root.config[e]){this.weatherPlugin=e,console.debug(`Initialized weather UI - plugin: ${e}`);break}this.weatherPlugin||console.warn(`No weather plugins configured. Compatible plugins: ${this.weatherPlugins}`)}},mounted:function(){this.initWeatherPlugin(),this.refresh(),this.subscribe(this.onWeatherChange,null,"platypush.message.event.weather.NewWeatherConditionEvent"),setInterval(this.refresh,parseInt((1e3*this.refreshSeconds).toFixed(0)))}};const I=(0,v.Z)(b,[["render",c],["__scopeId","data-v-150b6d72"]]);var S=I},6452:function(e,t,n){var i,a;(function(){var e=n.g.requestAnimationFrame||n.g.webkitRequestAnimationFrame||n.g.mozRequestAnimationFrame||n.g.oRequestAnimationFrame||n.g.msRequestAnimationFrame,t=n.g.cancelAnimationFrame||n.g.webkitCancelAnimationFrame||n.g.mozCancelAnimationFrame||n.g.oCancelAnimationFrame||n.g.msCancelAnimationFrame;e&&t?(i=function(t){var n={value:null};function i(){n.value=e(i),t()}return i(),n},a=function(e){t(e.value)}):(i=setInterval,a=clearInterval)})();var o=500,r=.08,s=2*Math.PI,h=2/Math.sqrt(2);function l(e,t,n,i){e.beginPath(),e.arc(t,n,i,0,s,!1),e.fill()}function c(e,t,n,i,a){e.beginPath(),e.moveTo(t,n),e.lineTo(i,a),e.stroke()}function u(e,t,n,i,a,o,r,h){var c=Math.cos(t*s),u=Math.sin(t*s);h-=r,l(e,n-u*a,i+c*o+.5*h,r+(1-.5*c)*h)}function d(e,t,n,i,a,o,r,s){var h;for(h=5;h--;)u(e,t+h/5,n,i,a,o,r,s)}function g(e,t,n,i,a,o,r){t/=3e4;var s=.21*a,h=.12*a,l=.24*a,c=.28*a;e.fillStyle=r,d(e,t,n,i,s,h,l,c),e.globalCompositeOperation="destination-out",d(e,t,n,i,s,h,l-o,c-o),e.globalCompositeOperation="source-over"}function p(e,t,n,i,a,o,r){t/=12e4;var h,l,u,d,g=.25*a-.5*o,p=.32*a+.5*o,f=.5*a-.5*o;for(e.strokeStyle=r,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.arc(n,i,g,0,s,!1),e.stroke(),h=8;h--;)l=(t+h/8)*s,u=Math.cos(l),d=Math.sin(l),c(e,n+u*p,i+d*p,n+u*f,i+d*f)}function f(e,t,n,i,a,o,r){t/=15e3;var l=.29*a-.5*o,c=.05*a,u=Math.cos(t*s),d=u*s/-16;e.strokeStyle=r,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",n+=u*c,e.beginPath(),e.arc(n,i,l,d+s/8,d+7*s/8,!1),e.arc(n+Math.cos(d)*l*h,i+Math.sin(d)*l*h,l,d+5*s/8,d+3*s/8,!0),e.closePath(),e.stroke()}function m(e,t,n,i,a,o,r){t/=1350;var h,l,c,u,d=.16*a,g=11*s/12,p=7*s/12;for(e.fillStyle=r,h=4;h--;)l=(t+h/4)%1,c=n+(h-1.5)/1.5*(1===h||2===h?-1:1)*d,u=i+l*l*a,e.beginPath(),e.moveTo(c,u-1.5*o),e.arc(c,u,.75*o,g,p,!1),e.fill()}function w(e,t,n,i,a,o,r){t/=750;var s,h,l,u,d=.1875*a;for(e.strokeStyle=r,e.lineWidth=.5*o,e.lineCap="round",e.lineJoin="round",s=4;s--;)h=(t+s/4)%1,l=Math.floor(n+(s-1.5)/1.5*(1===s||2===s?-1:1)*d)+.5,u=i+h*a,c(e,l,u-1.5*o,l,u+1.5*o)}function v(e,t,n,i,a,o,r){t/=3e3;var h,l,u,d,g=.16*a,p=.75*o,f=t*s*.7,m=Math.cos(f)*p,w=Math.sin(f)*p,v=f+s/3,y=Math.cos(v)*p,M=Math.sin(v)*p,C=f+2*s/3,k=Math.cos(C)*p,b=Math.sin(C)*p;for(e.strokeStyle=r,e.lineWidth=.5*o,e.lineCap="round",e.lineJoin="round",h=4;h--;)l=(t+h/4)%1,u=n+Math.sin((l+h/4)*s)*g,d=i+l*a,c(e,u-m,d-w,u+m,d+w),c(e,u-y,d-M,u+y,d+M),c(e,u-k,d-b,u+k,d+b)}function y(e,t,n,i,a,o,r){t/=3e4;var s=.21*a,h=.06*a,l=.21*a,c=.28*a;e.fillStyle=r,d(e,t,n,i,s,h,l,c),e.globalCompositeOperation="destination-out",d(e,t,n,i,s,h,l-o,c-o),e.globalCompositeOperation="source-over"}var M=[[-.75,-.18,-.7219,-.1527,-.6971,-.1225,-.6739,-.091,-.6516,-.0588,-.6298,-.0262,-.6083,.0065,-.5868,.0396,-.5643,.0731,-.5372,.1041,-.5033,.1259,-.4662,.1406,-.4275,.1493,-.3881,.153,-.3487,.1526,-.3095,.1488,-.2708,.1421,-.2319,.1342,-.1943,.1217,-.16,.1025,-.129,.0785,-.1012,.0509,-.0764,.0206,-.0547,-.012,-.0378,-.0472,-.0324,-.0857,-.0389,-.1241,-.0546,-.1599,-.0814,-.1876,-.1193,-.1964,-.1582,-.1935,-.1931,-.1769,-.2157,-.1453,-.229,-.1085,-.2327,-.0697,-.224,-.0317,-.2064,.0033,-.1853,.0362,-.1613,.0672,-.135,.0961,-.1051,.1213,-.0706,.1397,-.0332,.1512,.0053,.158,.0442,.1624,.0833,.1636,.1224,.1615,.1613,.1565,.1999,.15,.2378,.1402,.2749,.1279,.3118,.1147,.3487,.1015,.3858,.0892,.4236,.0787,.4621,.0715,.5012,.0702,.5398,.0766,.5768,.089,.6123,.1055,.6466,.1244,.6805,.144,.7147,.163,.75,.18],[-.75,0,-.7033,.0195,-.6569,.0399,-.6104,.06,-.5634,.0789,-.5155,.0954,-.4667,.1089,-.4174,.1206,-.3676,.1299,-.3174,.1365,-.2669,.1398,-.2162,.1391,-.1658,.1347,-.1157,.1271,-.0661,.1169,-.017,.1046,.0316,.0903,.0791,.0728,.1259,.0534,.1723,.0331,.2188,.0129,.2656,-.0064,.3122,-.0263,.3586,-.0466,.4052,-.0665,.4525,-.0847,.5007,-.1002,.5497,-.113,.5991,-.124,.6491,-.1325,.6994,-.138,.75,-.14]],C=[{start:.36,end:.11},{start:.56,end:.16}];function k(e,t,n,i,a,o,r){var h=a/8,l=h/3,c=2*l,u=t%1*s,d=Math.cos(u),g=Math.sin(u);e.fillStyle=r,e.strokeStyle=r,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.arc(n,i,h,u,u+Math.PI,!1),e.arc(n-l*d,i-l*g,c,u+Math.PI,u,!1),e.arc(n+c*d,i+c*g,l,u+Math.PI,u,!0),e.globalCompositeOperation="destination-out",e.fill(),e.globalCompositeOperation="source-over",e.stroke()}function b(e,t,n,i,a,o,r,s,h){t/=2500;var l,c,u,d,g=M[r],p=(t+r-C[r].start)%s,f=(t+r-C[r].end)%s,m=(t+r)%s;if(e.strokeStyle=h,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",p<1){if(e.beginPath(),p*=g.length/2-1,l=Math.floor(p),p-=l,l*=2,l+=2,e.moveTo(n+(g[l-2]*(1-p)+g[l]*p)*a,i+(g[l-1]*(1-p)+g[l+1]*p)*a),f<1){for(f*=g.length/2-1,c=Math.floor(f),f-=c,c*=2,c+=2,d=l;d!==c;d+=2)e.lineTo(n+g[d]*a,i+g[d+1]*a);e.lineTo(n+(g[c-2]*(1-f)+g[c]*f)*a,i+(g[c-1]*(1-f)+g[c+1]*f)*a)}else for(d=l;d!==g.length;d+=2)e.lineTo(n+g[d]*a,i+g[d+1]*a);e.stroke()}else if(f<1){for(e.beginPath(),f*=g.length/2-1,c=Math.floor(f),f-=c,c*=2,c+=2,e.moveTo(n+g[0]*a,i+g[1]*a),d=2;d!==c;d+=2)e.lineTo(n+g[d]*a,i+g[d+1]*a);e.lineTo(n+(g[c-2]*(1-f)+g[c]*f)*a,i+(g[c-1]*(1-f)+g[c+1]*f)*a),e.stroke()}m<1&&(m*=g.length/2-1,u=Math.floor(m),m-=u,u*=2,u+=2,k(e,t,n+(g[u-2]*(1-m)+g[u]*m)*a,i+(g[u-1]*(1-m)+g[u+1]*m)*a,a,o,h))}var I=function(e){this.list=[],this.interval=null,this.color=e&&e.color?e.color:"black",this.resizeClear=!(!e||!e.resizeClear),this.speed=Number(e&&e.speed)||1,this.speed<0&&(this.speed=1)};I.CLEAR_DAY=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);p(e,t,.5*i,.5*a,o,o*r,n)},I.CLEAR_NIGHT=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);f(e,t,.5*i,.5*a,o,o*r,n)},I.PARTLY_CLOUDY_DAY=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);p(e,t,.625*i,.375*a,.75*o,o*r,n),g(e,t,.375*i,.625*a,.75*o,o*r,n)},I.PARTLY_CLOUDY_NIGHT=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);f(e,t,.667*i,.375*a,.75*o,o*r,n),g(e,t,.375*i,.625*a,.75*o,o*r,n)},I.CLOUDY=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);g(e,t,.5*i,.5*a,o,o*r,n)},I.RAIN=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);m(e,t,.5*i,.37*a,.9*o,o*r,n),g(e,t,.5*i,.37*a,.9*o,o*r,n)},I.SLEET=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);w(e,t,.5*i,.37*a,.9*o,o*r,n),g(e,t,.5*i,.37*a,.9*o,o*r,n)},I.SNOW=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);v(e,t,.5*i,.37*a,.9*o,o*r,n),g(e,t,.5*i,.37*a,.9*o,o*r,n)},I.WIND=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a);b(e,t,.5*i,.5*a,o,o*r,0,2,n),b(e,t,.5*i,.5*a,o,o*r,1,2,n)},I.FOG=function(e,t,n){var i=e.canvas.width,a=e.canvas.height,o=Math.min(i,a),h=o*r;y(e,t,.5*i,.32*a,.75*o,h,n),t/=5e3;var l=Math.cos(t*s)*o*.02,u=Math.cos((t+.25)*s)*o*.02,d=Math.cos((t+.5)*s)*o*.02,g=Math.cos((t+.75)*s)*o*.02,p=.936*a,f=Math.floor(p-.5*h)+.5,m=Math.floor(p-2.5*h)+.5;e.strokeStyle=n,e.lineWidth=h,e.lineCap="round",e.lineJoin="round",c(e,l+.2*i+.5*h,f,u+.8*i-.5*h,f),c(e,d+.2*i+.5*h,m,g+.8*i-.5*h,m)},I.prototype={_determineDrawingFunction:function(e){return"string"===typeof e&&(e=I[e.toUpperCase().replace(/-/g,"_")]||null),e},add:function(e,t){var n;"string"===typeof e&&(e=document.getElementById(e)),null!==e&&void 0!==e&&(t=this._determineDrawingFunction(t),"function"===typeof t&&(n={element:e,context:e.getContext("2d"),drawing:t},this.list.push(n),this.draw(n,o)))},set:function(e,t){var n;for("string"===typeof e&&(e=document.getElementById(e)),n=this.list.length;n--;)if(this.list[n].element===e)return this.list[n].drawing=this._determineDrawingFunction(t),void this.draw(this.list[n],o);this.add(e,t)},remove:function(e){var t;for("string"===typeof e&&(e=document.getElementById(e)),t=this.list.length;t--;)if(this.list[t].element===e)return void this.list.splice(t,1)},draw:function(e,t){var n=e.context.canvas;this.resizeClear?n.width=n.width:e.context.clearRect(0,0,n.width,n.height),e.drawing(e.context,t,this.color)},play:function(){var e=this;this.pause(),this.interval=i((function(){for(var t=Date.now()*e.speed,n=e.list.length;n--;)e.draw(e.list[n],t)}),1e3/60)},pause:function(){this.interval&&(a(this.interval),this.interval=null)}},e.exports=I}}]);
//# sourceMappingURL=1798.2ea76630.js.map