Ubuntu

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ "use strict";window.setImmediate||(window.setImmediate=window.msSetImmediate||window.webkitSetImmediate||window.mozSetImmediate||window.oSetImmediate||function(){if(!window.postMessage||!window.addEventListener)return null;var t=[void 0],e="zero-timeout-message";return window.addEventListener("message",function(r){if("string"==typeof r.data&&r.data.substr(0,e.length)===e){r.stopImmediatePropagation();var a=parseInt(r.data.substr(e.length),36);t[a]&&(t[a](),t[a]=void 0)}},!0),window.clearImmediate=function(e){t[e]&&(t[e]=void 0)},function(r){var a=t.length;return t.push(r),window.postMessage(e+a.toString(36),"*"),a}}()||function(t){window.setTimeout(t,0)}),window.clearImmediate||(window.clearImmediate=window.msClearImmediate||window.webkitClearImmediate||window.mozClearImmediate||window.oClearImmediate||function(t){window.clearTimeout(t)}),function(t){var e=function(){var t=document.createElement("canvas");if(!t||!t.getContext)return!1;var e=t.getContext("2d");return!!e&&(!!e.getImageData&&(!!e.fillText&&(!!Array.prototype.some&&!!Array.prototype.push)))}(),r=function(){if(e){for(var t,r,a=document.createElement("canvas").getContext("2d"),o=20;o;){if(a.font=o.toString(10)+"px sans-serif",a.measureText("W").width===t&&a.measureText("m").width===r)return o+1;t=a.measureText("W").width,r=a.measureText("m").width,o--}return 0}}(),a=function(t){for(var e,r,a=t.length;a;)e=Math.floor(Math.random()*a),r=t[--a],t[a]=t[e],t[e]=r;return t},o={},i=function(t,i){if(e){var n=Math.floor(Math.random()*Date.now());Array.isArray(t)||(t=[t]),t.forEach(function(e,r){if("string"==typeof e){if(t[r]=document.getElementById(e),!t[r])throw new Error("The element id specified is not found.")}else if(!e.tagName&&!e.appendChild)throw new Error("You must pass valid HTML elements, or ID of the element.")});var s={list:[],fontFamily:'"Trebuchet MS", "Heiti TC", "微軟正黑體", "Arial Unicode MS", "Droid Fallback Sans", sans-serif',fontWeight:"normal",color:"random-dark",minSize:0,weightFactor:1,clearCanvas:!0,backgroundColor:"#fff",gridSize:8,drawOutOfBound:!1,shrinkToFit:!1,origin:null,wordsColors:[],drawMask:!1,maskColor:"rgba(255,0,0,0.3)",maskGapWidth:.3,wait:0,abortThreshold:0,abort:function(){},minRotation:-Math.PI/2,maxRotation:Math.PI/2,rotationSteps:0,shuffle:!0,rotateRatio:.1,shape:"circle",ellipticity:.65,classes:null,hover:null,click:null};if(i)for(var l in i)l in s&&(s[l]=i[l]);if("function"!=typeof s.weightFactor){var f=s.weightFactor;s.weightFactor=function(t){return t*f}}if("function"!=typeof s.shape)switch(s.shape){case"circle":default:s.shape="circle";break;case"cardioid":s.shape=function(t){return 1-Math.sin(t)};break;case"diamond":s.shape=function(t){var e=t%(2*Math.PI/4);return 1/(Math.cos(e)+Math.sin(e))};break;case"square":s.shape=function(t){return Math.min(1/Math.abs(Math.cos(t)),1/Math.abs(Math.sin(t)))};break;case"triangle-forward":s.shape=function(t){var e=t%(2*Math.PI/3);return 1/(Math.cos(e)+Math.sqrt(3)*Math.sin(e))};break;case"triangle":case"triangle-upright":s.shape=function(t){var e=(t+3*Math.PI/2)%(2*Math.PI/3);return 1/(Math.cos(e)+Math.sqrt(3)*Math.sin(e))};break;case"pentagon":s.shape=function(t){var e=(t+.955)%(2*Math.PI/5);return 1/(Math.cos(e)+.726543*Math.sin(e))};break;case"star":s.shape=function(t){var e=(t+.955)%(2*Math.PI/10);return(t+.955)%(2*Math.PI/5)-2*Math.PI/10>=0?1/(Math.cos(2*Math.PI/10-e)+3.07768*Math.sin(2*Math.PI/10-e)):1/(Math.cos(e)+3.07768*Math.sin(e))}}s.gridSize=Math.max(Math.floor(s.gridSize),4);var d,c,u,h,m,w,g,v,M=s.gridSize,p=M-s.maskGapWidth,x=Math.abs(s.maxRotation-s.minRotation),b=Math.abs(Math.floor(s.rotationSteps)),T=Math.min(s.maxRotation,s.minRotation);switch(s.color){case"custom":g=function(){var t=Math.floor(Math.random()*s.wordsColors.length);return t=s.wordsColors[t]};break;case"random-dark":g=function(){return L(10,50)};break;case"random-light":g=function(){return L(50,90)};break;default:"function"==typeof s.color&&(g=s.color)}"function"==typeof s.fontWeight&&(v=s.fontWeight);var C=null;"function"==typeof s.classes&&(C=s.classes);var k,y=!1,I=[],S=function(t){var e,r,a=t.currentTarget,o=a.getBoundingClientRect();t.touches?(e=t.touches[0].clientX,r=t.touches[0].clientY):(e=t.clientX,r=t.clientY);var i=e-o.left,n=r-o.top,s=Math.floor(i*(a.width/o.width||1)/M),l=Math.floor(n*(a.height/o.height||1)/M);return I[s]?I[s][l]:null},E=function(t){var e=S(t);k!==e&&(k=e,e?s.hover(e.item,e.dimension,t):s.hover(void 0,void 0,t))},F=function(t){var e=S(t);e&&(s.click(e.item,e.dimension,t),t.preventDefault())},P=[],R=function(t){if(P[t])return P[t];var e=8*t,r=e,a=[];for(0===t&&a.push([h[0],h[1],0]);r--;){var o=1;"circle"!==s.shape&&(o=s.shape(r/e*2*Math.PI)),a.push([h[0]+t*o*Math.cos(-r/e*2*Math.PI),h[1]+t*o*Math.sin(-r/e*2*Math.PI)*s.ellipticity,r/e*2*Math.PI])}return P[t]=a,a},O=function(){return s.abortThreshold>0&&(new Date).getTime()-w>s.abortThreshold},A=function(e,r,a,o,i){if(!(e>=c||r>=u||e<0||r<0)){if(d[e][r]=!1,a)t[0].getContext("2d").fillRect(e*M,r*M,p,p);y&&(I[e][r]={item:i,dimension:o})}},z=function e(o){var i,n,l;Array.isArray(o)?(i=o[0],n=o[1]):(i=o.word,n=o.weight,l=o.attributes);var f=0===s.rotateRatio?0:Math.random()>s.rotateRatio?0:0===x?T:b>0?T+Math.floor(Math.random()*b)*x/(b-1):T+Math.random()*x,h=function(t){if(Array.isArray(t)){var e=t.slice();return e.splice(0,2),e}return[]}(o),w=function(t,e,a,o){var i=s.weightFactor(e);if(i<=s.minSize)return!1;var n,l=1;iR[1]&&(R[1]=P),IR[2]&&(R[2]=I);break t}}return{mu:l,occupied:F,bounds:R,gw:T,gh:b,fillTextOffsetX:p,fillTextOffsetY:x,fillTextWidth:c,fillTextHeight:u,fontSize:i}}(i,n,f,h);if(!w)return!1;if(O())return!1;if(!s.drawOutOfBound&&!s.shrinkToFit){var p=w.bounds;if(p[1]-p[3]+1>c||p[2]-p[0]+1>u)return!1}for(var k=m+1,I=function(e){var r=Math.floor(e[0]-w.gw/2),a=Math.floor(e[1]-w.gh/2);w.gw,w.gh;return!!function(t,e,r,a,o){for(var i=o.length;i--;){var n=t+o[i][0],l=e+o[i][1];if(n>=c||l>=u||n<0||l<0){if(!s.drawOutOfBound)return!1}else if(!d[n][l])return!1}return!0}(r,a,0,0,w.occupied)&&(function(e,r,a,o,i,n,l,f,d,c){var u,h,m,w=a.fontSize;u=g?g(o,i,w,n,l,c):s.color,h=v?v(o,i,w,c):s.fontWeight,m=C?C(o,i,w,c):s.classes,t.forEach(function(t){if(t.getContext){var i=t.getContext("2d"),n=a.mu;i.save(),i.scale(1/n,1/n),i.font=h+" "+(w*n).toString(10)+"px "+s.fontFamily,i.fillStyle=u,i.translate((e+a.gw/2)*M*n,(r+a.gh/2)*M*n),0!==f&&i.rotate(-f),i.textBaseline="middle",i.fillText(o,a.fillTextOffsetX*n,(a.fillTextOffsetY+.5*w)*n),i.restore()}else{var l=document.createElement("span"),c="";c="rotate("+-f/Math.PI*180+"deg) ",1!==a.mu&&(c+="translateX(-"+a.fillTextWidth/4+"px) scale("+1/a.mu+")");var g={position:"absolute",display:"block",font:h+" "+w*a.mu+"px "+s.fontFamily,left:(e+a.gw/2)*M+a.fillTextOffsetX+"px",top:(r+a.gh/2)*M+a.fillTextOffsetY+"px",width:a.fillTextWidth+"px",height:a.fillTextHeight+"px",lineHeight:w+"px",whiteSpace:"nowrap",transform:c,webkitTransform:c,msTransform:c,transformOrigin:"50% 40%",webkitTransformOrigin:"50% 40%",msTransformOrigin:"50% 40%"};for(var v in u&&(g.color=u),l.textContent=o,g)l.style[v]=g[v];if(d)for(var p in d)l.setAttribute(p,d[p]);m&&(l.className+=m),t.appendChild(l)}})}(r,a,w,i,n,m-k,e[2],f,l,h),function(e,r,a,o,i,n){var l,f,d=i.occupied,h=s.drawMask;if(h&&((l=t[0].getContext("2d")).save(),l.fillStyle=s.maskColor),y){var m=i.bounds;f={x:(e+m[3])*M,y:(r+m[0])*M,w:(m[1]-m[3]+1)*M,h:(m[2]-m[0]+1)*M}}for(var w=d.length;w--;){var g=e+d[w][0],v=r+d[w][1];g>=c||v>=u||g<0||v<0||A(g,v,h,f,n)}h&&l.restore()}(r,a,0,0,w,o),!0)};k--;){var S=R(m-k);if(s.shuffle&&(S=[].concat(S),a(S)),S.some(I))return!0}return!!s.shrinkToFit&&(Array.isArray(o)?o[1]=3*o[1]/4:o.weight=3*o.weight/4,e(o))},W=function(e,r,a){if(r)return!t.some(function(t){var r=new CustomEvent(e,{detail:a||{}});return!t.dispatchEvent(r)},this);t.forEach(function(t){var r=new CustomEvent(e,{detail:a||{}});t.dispatchEvent(r)},this)};!function(){var e=t[0];if(e.getContext)c=Math.ceil(e.width/M),u=Math.ceil(e.height/M);else{var r=e.getBoundingClientRect();c=Math.ceil(r.width/M),u=Math.ceil(r.height/M)}if(W("wordcloudstart",!0)){var a,i,l,f,g;if(h=s.origin?[s.origin[0]/M,s.origin[1]/M]:[c/2,u/2],m=Math.floor(Math.sqrt(c*c+u*u)),d=[],!e.getContext||s.clearCanvas)for(t.forEach(function(t){if(t.getContext){var e=t.getContext("2d");e.fillStyle=s.backgroundColor,e.clearRect(0,0,c*(M+1),u*(M+1)),e.fillRect(0,0,c*(M+1),u*(M+1))}else t.textContent="",t.style.backgroundColor=s.backgroundColor,t.style.position="relative"}),a=c;a--;)for(d[a]=[],i=u;i--;)d[a][i]=!0;else{var v=document.createElement("canvas").getContext("2d");v.fillStyle=s.backgroundColor,v.fillRect(0,0,1,1);var p,x,b=v.getImageData(0,0,1,1).data,T=e.getContext("2d").getImageData(0,0,c*M,u*M).data;for(a=c;a--;)for(d[a]=[],i=u;i--;){x=M;t:for(;x--;)for(p=M;p--;)for(l=4;l--;)if(T[4*((i*M+x)*c*M+(a*M+p))+l]!==b[l]){d[a][i]=!1;break t}!1!==d[a][i]&&(d[a][i]=!0)}T=v=b=void 0}if(s.hover||s.click){for(y=!0,a=c+1;a--;)I[a]=[];s.hover&&e.addEventListener("mousemove",E),s.click&&(e.addEventListener("click",F),e.style.webkitTapHighlightColor="rgba(0, 0, 0, 0)"),e.addEventListener("wordcloudstart",function t(){e.removeEventListener("wordcloudstart",t),e.removeEventListener("mousemove",E),e.removeEventListener("click",F),k=void 0})}l=0,0!==s.wait?(f=window.setTimeout,g=window.clearTimeout):(f=window.setImmediate,g=window.clearImmediate);var C=function(e,r){t.forEach(function(t){t.removeEventListener(e,r)},this)},S=function t(){C("wordcloudstart",t),g(o[n])};!function(e,r){t.forEach(function(t){t.addEventListener(e,r)},this)}("wordcloudstart",S),z(["",1]),setTimeout(function(){o[n]=f(function t(){if(l>=s.list.length)return g(o[n]),W("wordcloudstop",!1),C("wordcloudstart",S),void delete o[n];w=(new Date).getTime();var e=z(s.list[l]),r=!W("wordclouddrawn",!0,{item:s.list[l],drawn:e});if(O()||r)return g(o[n]),s.abort(),W("wordcloudabort",!1),W("wordcloudstop",!1),C("wordcloudstart",S),void delete o[n];l++,o[n]=f(t,s.wait)},s.wait)},120)}}()}function L(t,e){return"hsl("+(360*Math.random()).toFixed()+","+(30*Math.random()+70).toFixed()+"%,"+(Math.random()*(e-t)+t).toFixed()+"%)"}};i.isSupported=e,i.minFontSize=r,i.stop=function(){if(o)for(var t in o)window.clearImmediate(o[t])},"function"==typeof define&&define.amd?(t.WordCloud=i,define("wordcloud",[],function(){return i})):"undefined"!=typeof module&&module.exports?module.exports=i:t.WordCloud=i}(this);