mirror of
https://github.com/kevinveenbirkenbach/roulette-wheel.git
synced 2024-11-22 10:11:04 +01:00
1 line
6.5 KiB
JavaScript
1 line
6.5 KiB
JavaScript
|
(()=>{"use strict";var e={583:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Component=void 0,t.Component=class{constructor(e){this.el=e}removeChildren(){if(this.el.childNodes.length>0)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}}},983:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ItemRemoval=void 0;const n=o(583);class a extends n.Component{constructor(e){const t=document.createElement("img");t.src="static/close.png",t.alt="delete",t.className="item-delete",t.id=`${e}-delete`,super(t)}}t.ItemRemoval=a},658:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MenuItem=void 0;const n=o(583),a=o(983);class l extends n.Component{constructor(e,t,o){const n=new a.ItemRemoval(e),l=document.createElement("li");l.className="menu-item",l.id=`${e}-item`,l.textContent=t,l.style.backgroundColor=o,l.appendChild(n.el),super(l),this.deleteItem=n,this.appearAnimation()}appearAnimation(){this.el.animate([{transform:"scale(1.25)"},{transform:"scale(1.00)"}],{duration:500})}}t.MenuItem=l},191:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ItemList=void 0,t.ItemList=class{constructor(e){this.items=[],this.maximumSize=e}add(e){this.items.length<this.maximumSize&&this.items.push(e)}removeById(e){const t=this.items.find((t=>t.id===e));t&&this.remove(t)}remove(e){this.items.splice(this.items.indexOf(e),1)}clear(){this.items=[]}}},418:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Item=void 0,t.Item=class{constructor(e,t,o){this.id=e,this.name=t,this.color=o}}},497:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IdPool=void 0;class o{static initializeIdsPool(e){for(let t=1;t<=e;t++)o.avaliableIds[t]=t}static getAnId(){const e=this.avaliableIds.pop();if(e)return e;alert("Maxiumum number of items!")}static addId(e){this.avaliableIds.push(e)}}t.IdPool=o,o.avaliableIds=[]},617:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LightDarkMode=void 0,t.LightDarkMode=class{}},974:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.avaliableRGBs=void 0,t.avaliableRGBs=["rgba(255, 0, 0, 0.5)","rgba(0, 255, 0, 0.5)","rgba(0, 0, 255, 0.5)","rgba(255, 255, 0, 0.5)","rgba(0, 255, 255, 0.5)","rgba(205, 127, 50, 0.5)","rgba(115, 147, 179, 0.5)","rgba(255, 117, 24, 0.5)","rgba(255, 0, 255, 0.5)","rgba(191, 64, 191, 0.5)","rgba(47, 197, 114, 0.5)","rgba(255, 222, 173, 0.5)","rgba(204, 204, 255, 0.5)","rgba(93, 63, 211, 0.5)","rgba(250, 128, 114, 0.5)","rgba(0, 255, 127, 0.5)"]}},t={};function o(n){var a=t[n];if(void 0!==a)return a.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,o),l.exports}(()=>{const e=o(658),t=o(418),n=o(191),a=o(497),l=o(617),i=o(974),s=document.getElementsByClassName("add-item-button")[0],r=document.querySelector("input"),d=document.getElementsByClassName("menu-item-list")[0],c=document.getElementsByClassName("counter")[0],m=document.getElementsByClassName("remove-all-items-button")[0],h=document.getElementsByClassName("light-dark-mode")[0],u=document.querySelector("canvas"),g=document.querySelector("body"),f=h.querySelector("img"),v=document.getElementsByClassName("winner")[0],b=document.querySelector("footer"),p=document.getElementsByClassName("icons-authors")[0],y=document.getElementsByClassName("roulette-wheel")[0],I=new Audio("/static/roulette-wheel.mp3"),M=u.getContext("2d");u.width=y.offsetWidth,u.height=y.offsetHeight;const C=u.width/2,k=u.height/2,P=u.height/2-5,x=1e3/60,E=new n.ItemList(16),B=[];let w=0;function L(){c.textContent=`${E.items.length}/16`,c.animate([{transform:"scale(1.5)"},{transform:"scale(1.00)"}],{duration:500})}function _(e){const t=360/B.length;let o=t+e;M.clearRect(0,0,u.width,u.height),M.beginPath(),M.save(),M.translate(C+P+50,k),M.lineTo(0,-20),M.lineTo(0,20),M.lineTo(-50,0),M.fillStyle="#C4B454",M.fill(),M.stroke(),M.restore(),M.arc(C,k,P,0,2*Math.PI),M.stroke();for(let n=0;n<B.length;n++){M.beginPath(),M.lineTo(C,k),console.log(outerHeight),console.log(outerWidth),outerWidth<1280?M.font="bold 10px verdana, sans-serif":M.font="bold 24px verdana, sans-serif",M.arc(C,k,P,e*Math.PI/180,o*Math.PI/18
|