PageSourceSearch

https://escritorio-digital.github.io/assets/RandomSpinnerWidget-Df-SA5Sk.js

js escritorio-digital.github.io collected 2026-10-03 09:10:37 UTC 5,203 bytes, 1 lines download raw bytes

1import{u as G,f as U,r as o,j as n,b4 as V,b5 as Z,P as ee,F as te,Q as ne}from"./index-B0QJoaDw.js";import{b6 as he}from"./index-B0QJoaDw.js";import{r as se}from"./openDialog-rcOdLkIk.js";import{r as oe}from"./localJsonStorage-DJvo77WP.js";import{P as re}from"./play-D-jFa-BA.js";import{T as ie}from"./trash-2-qTS7XvHc.js";const I=()=>`hsl(${Math.random()*360}, 70%, 80%)`,me=()=>{const{t:r}=G(),[i,m]=U("spinner-options",[]);o.useEffect(()=>{if(oe("spinner-options")!==null)return;const e=r("widgets.random_spinner.default_options",{returnObjects:!0});Array.isArray(e)&&m(e.map(t=>({...t,color:I()})))},[r,m]);const[_,M]=o.useState(""),[b,z]=o.useState(!1),[C,x]=o.useState(null),[q,w]=o.useState(null),[y,h]=o.useState(""),[g,L]=o.useState(!1),[l,B]=o.useState(300),[S,K]=o.useState(!1),[E,O]=o.useState(null),N=o.useRef(null),k=o.useRef(null),A=o.useRef(i);o.useEffect(()=>{A.current=i},[i]),o.useEffect(()=>{const e=k.current;if(!e)return;const t=new ResizeObserver(()=>{if(e){const s=Math.min(e.offsetWidth,e.offsetHeight);B(s)}});return t.observe(e),()=>t.disconnect()},[]),o.useEffect(()=>{const e=N.current;if(!e)return;const t=e.getContext("2d");if(!t)return;e.width=l,e.height=l;const s=i.length;if(s===0){t.clearRect(0,0,l,l);return}const d=2*Math.PI/s,c=l/2,a=l/2,u=l/2-10;t.clearRect(0,0,l,l),t.font=`bold ${Math.max(10,l*.05)}px sans-serif`,i.forEach((p,j)=>{const f=j*d;t.beginPath(),t.fillStyle=p.color,t.moveTo(c,a),t.arc(c,a,u,f,f+d),t.closePath(),t.fill(),t.save(),t.fillStyle="#333",t.translate(c,a),t.rotate(f+d/2),t.textAlign="right";const v=p.text.length>15?p.text.substring(0,12)+"...":p.text;t.fillText(v,u-10,0),t.restore()})},[i,l]);const F=()=>{_.trim()&&i.length<20&&(m([...i,{text:_.trim(),color:I()}]),M(""))},T=e=>{const t=new FileReader;t.onload=s=>{const c=(s.target?.result??"").split(/\r?\n/).map(a=>a.trim()).filter(Boolean).slice(0,20);m(c.map(a=>({text:a,color:I()}))),x(null),w(null),h("")},t.readAsText(e)},W=async()=>{const e=await se({accept:".txt"});if(!e)return;if(e.source==="local"){const[c]=e.files;c&&T(c);return}const[t]=e.entryIds;if(!t)return;const s=await ne(t);if(!s?.blob)return;const d=new File([s.blob],s.name,{type:s.mime||s.blob.type});T(d)},D=e=>{m(i.filter((t,s)=>s!==e))},H=e=>{w(e),h(i[e].text)},$=e=>{if(y.trim()){const t=[...i];t[e].text=y.trim(),m(t)}w(null),h("")},J=()=>{if(b)return;let e=A.current;if(S&&E){const a=e.findIndex(u=>u.text===E);if(a!==-1){const u=e.filter((p,j)=>j!==a);m(u),e=u}O(null)}if(e.length<2)return;z(!0),x(null);const t=Math.random()*20+20,s=(Math.random()*3+4)*1e3;let d=0;const c=a=>{d||(d=a);const u=a-d,p=Math.min(u/s,1),f=t*(P=>1-Math.pow(1-P,4))(p),v=N.current;if(v&&(v.style.transform=`rotate(${f}rad)`),p<1)requestAnimationFrame(c);else{const P=f%(2*Math.PI),Q=2*Math.PI/e.length,X=((-Math.PI/2-P)%(2*Math.PI)+2*Math.PI)%(2*Math.PI),Y=Math.floor(X/Q)%e.length,R=e[Y]?.text??null;x(R),S&&R&&O(R),z(!1)}};requestAnimationFrame(c)};return n.jsxs("div",{className:`random-spinner-widget ${g?"fullscreen":""}`,children:[n.jsxs("div",{ref:k,className:"spinner-area",children:[n.jsx("canvas",{ref:N,className:"spinner-canvas"}),n.jsx("div",{className:"spinner-pointer"}),n.jsx("button",{onClick:J,disabled:b||i.length<2,className:"spin-button",title:r("widgets.random_spinner.spin"),children:n.jsx(re,{size:32})}),C&&!b&&n.jsxs("div",{className:"spinner-result",onClick:()=>x(null),children:[n.jsx("span",{children:C}),n.jsx("small",{children:r("widgets.random_spinner.result_overlay_text")})]}),n.jsx("button",{onClick:()=>L(!g),className:"fullscreen-button",title:r(g?"widgets.random_spinner.restore_view_button_title":"widgets.random_spinner.fullscreen_button_title"),children:g?n.jsx(V,{size:16}):n.jsx(Z,{size:16})})]}),n.jsxs("div",{className:"options-manager",children:[n.jsx("div",{className:"options-header",children:n.jsx("h3",{children:r("widgets.random_spinner.options_header")})}),n.jsxs("label",{className:"remove-selected",children:[n.jsx("input",{type:"checkbox",checked:S,onChange:e=>{const t=e.target.checked;K(t),t||O(null)}}),r("widgets.random_spinner.remove_after_select")]}),n.jsxs("div",{className:"add-option",children:[n.jsx("input",{type:"text",value:_,onCh
1ange:e=>M(e.target.value),placeholder:r("widgets.random_spinner.add_option_placeholder"),"aria-label":r("widgets.random_spinner.add_option_placeholder"),maxLength:20,onKeyPress:e=>e.key==="Enter"&&F()}),n.jsx("button",{onClick:F,title:r("widgets.random_spinner.add_option"),children:n.jsx(ee,{size:18})})]}),n.jsxs("button",{onClick:W,className:"upload-options-button",children:[n.jsx(te,{size:16})," ",r("widgets.random_spinner.load_from_file")]}),n.jsx("ul",{className:"options-list",children:i.map((e,t)=>n.jsxs("li",{onDoubleClick:()=>H(t),children:[n.jsx("span",{className:"option-color",style:{backgroundColor:e.color}}),q===t?n.jsx("input",{type:"text",value:y,onChange:s=>h(s.target.value),onBlur:()=>$(t),onKeyPress:s=>s.key==="Enter"&&$(t),autoFocus:!0,className:"edit-input"}):n.jsx("span",{className:"option-text",children:e.text}),n.jsx("button",{onClick:()=>D(t),title:r("widgets.random_spinner.remove_option"),children:n.jsx(ie,{size:14})})]},t))})]})]})};export{me as RandomSpinnerWidget,he as widgetConfig};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.