-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path0aabff42.js
More file actions
1 lines (1 loc) · 8.8 KB
/
Copy path0aabff42.js
File metadata and controls
1 lines (1 loc) · 8.8 KB
1
let shareButton,startButton,fireworks=[],clicked=!1,userName="",nomorWA="",showModal=!0,confetti=[],candleLightIntensity=0,horns=[],modalY=0,isDragging=!1,startY=0,currentY=0;const wishes=["Semoga panjang umur dan sehat selalu! 🎂","Wish you all the best! May all your dreams come true! 🌟","Selamat ulang tahun! Semoga sukses selalu! 🎉","Happy Birthday! Semoga bahagia selalu! 🎊","Selamat bertambah usia! Tetap semangat! 💪"];class Horn{constructor(t,e,o){this.x=t,this.y=e,this.isLeft=o,this.angle=o?-PI/4:PI/4,this.blowing=!1}draw(){push(),translate(this.x,this.y),rotate(this.angle),fill(218,165,32),rect(0,0,60,20),ellipse(60,10,30,30),this.blowing&&random()>.5&&this.createConfetti(),pop()}createConfetti(){for(let t=0;t<3;t++){let t=p5.Vector.random2D();t.mult(random(2,5)),confetti.push({x:this.x+(this.isLeft?60:-60),y:this.y,vx:t.x,vy:t.y,color:color(random(255),random(255),random(255)),rotation:random(TWO_PI)})}}}function createModal(){if(showModal){const t=createDiv("");t.style("background","rgba(0,0,0,0.8)"),t.style("position","fixed"),t.style("top","0"),t.style("left","0"),t.style("width","100%"),t.style("height","100%"),t.style("display","flex"),t.style("justify-content","center"),t.style("align-items","center"),t.style("z-index","1000"),t.style("transition","transform 0.3s ease"),t.id("modal");const e=createDiv("");e.style("background","radial-gradient(100% 193.51% at 100% 0%, #EDF4F8 0%, #EFF2FA 16.92%, #FAEFF6 34.8%, #FAE6F2 48.8%, #FAF0F7 63.79%, #F1F1FB 81.34%, #F0F4F8 100%);"),e.style("padding","20px"),e.style("border-radius","20px"),e.style("text-align","center"),e.style("width","80%"),e.style("max-width","500px"),e.style("position","relative"),e.style("touch-action","none"),e.style("bottom","0"),e.id("modalContent");const o=createDiv("");o.style("width","40px"),o.style("height","4px"),o.style("background-color","rgb(205 205 205)"),o.style("border-radius","2px"),o.style("margin","0 auto 15px auto");const s=createInput("");s.attribute("placeholder","Masukkan nama yang Ulang Tahun"),s.style("margin","10px"),s.style("padding","10px"),s.style("width","80%"),s.style("border","1px solid #ddd"),s.style("border-radius","5px"),s.style("font-size","16px");const a=createInput("");a.attribute("placeholder","Masukkan nomor WA (+62)"),a.style("margin","10px"),a.style("padding","10px"),a.style("width","80%"),a.style("border","1px solid #ddd"),a.style("border-radius","5px"),a.style("font-size","16px");const n=createButton("OK");n.style("margin","10px"),n.style("padding","10px 30px"),n.style("background-color","#4CAF50"),isDragging||startButton.hide(),n.style("border","none"),n.style("border-radius","5px"),n.style("cursor","pointer"),n.style("font-size","16px"),n.mousePressed((()=>function(){if(userName=s.value(),nomorWA=a.value(),""!==userName.trim()&&nomorWA.startsWith("62")){showModal=!1,clicked=!0,select("#modal").remove(),startButton.remove();let t=new Audio("./hbd.mp3");t.addEventListener("ended",(function(){this.currentTime=0,this.play()}),!1),t.play()}else alert("Pastikan nomor WA dimulai dengan 62.")}())),e.child(o),e.child(createP("Siapa yang ulang tahun?")),e.child(s),e.child(a),e.child(n),t.child(e);let r=select("#modalContent").elt;const l=window.matchMedia("(prefers-color-scheme: dark)").matches;r.addEventListener("touchstart",handleTouchStart,!1),r.addEventListener("touchmove",handleTouchMove,!1),r.addEventListener("touchend",handleTouchEnd,!1),window.innerWidth<=768?(e.style("position","absolute"),e.style("bottom","10px"),o.style("display","block")):o.style("display","none"),l?(t.style("background","rgba(0,0,0,0.8)"),e.style("backgroundColor","#1e1e1e"),e.style("color","#ffffff"),o.style("backgroundColor","#333")):(t.style("background","rgba(255, 246, 246, 0.8)"),e.style("background","radial-gradient(100% 193.51% at 100% 0%, #EDF4F8 0%, #EFF2FA 16.92%, #FAEFF6 34.8%, #FAE6F2 48.8%, #FAF0F7 63.79%, #F1F1FB 81.34%, #F0F4F8 100%)"),e.style("color","#000000"),o.style("backgroundColor","rgb(205 205 205)"))}}function handleTouchStart(t){startY=t.touches[0].clientY,isDragging=!0,currentY=0}function handleTouchMove(t){if(!isDragging)return;currentY=t.touches[0].clientY-startY,currentY<0&&(currentY=0);select("#modalContent").elt.style.transform=`translateY(${currentY}px)`}function handleTouchEnd(){startButton.position(windowWidth/2-100,windowHeight/2-25),startButton.style("width","max-content"),startButton.style("height","max-content"),startButton.style("font-size","16px"),isDragging=!1;const t=select("#modalContent").elt;currentY>150?(showModal=!1,select("#modal").remove(),startButton.show()):t.style.transform="translateY(0)"}function createStartButton(){startButton=createButton("Selamat Ulang Tahun! 🎂"),startButton.style("padding","15px 30px"),startButton.style("background-color","#FF4081"),startButton.style("color","white"),startButton.style("border","none"),startButton.style("border-radius","25px"),startButton.style("cursor","pointer"),startButton.style("font-size","18px"),startButton.style("box-shadow","0 4px 8px rgba(0,0,0,0.2)"),startButton.style("transition","all 0.3s ease"),startButton.style("z-index","999"),startButton.style("position","absolute"),startButton.style("left","50%"),startButton.style("top","50%"),startButton.style("transform","translate(-50%, -50%)"),startButton.hide(),startButton.mousePressed((()=>{startButton.hide(),showModal=!0,createModal()})),startButton.mouseOver((()=>{startButton.style("transform","translate(-50%, -50%) scale(1.05)"),startButton.style("box-shadow","0 6px 12px rgba(0,0,0,0.3)")})),startButton.mouseOut((()=>{startButton.style("transform","translate(-50%, -50%) scale(1)"),startButton.style("box-shadow","0 4px 8px rgba(0,0,0,0.2)")}))}function createStartButton(){startButton=createButton("Selamat Ulang Tahun! 🎂"),startButton.position(windowWidth/2-100,windowHeight/2-25),startButton.style("padding","15px 30px"),startButton.style("background-color","#FF4081"),startButton.style("color","white"),startButton.style("border","none"),startButton.style("border-radius","25px"),startButton.style("cursor","pointer"),startButton.style("font-size","18px"),startButton.style("box-shadow","0 4px 8px rgba(0,0,0,0.2)"),startButton.style("transition","all 0.3s ease"),startButton.style("z-index","999"),startButton.style("transform","translateX(-5%)"),startButton.hide(),startButton.mousePressed((()=>{startButton.hide(),showModal=!0,createModal()})),startButton.mouseOver((()=>{startButton.style("transform","scale(1.05)"),startButton.style("box-shadow","0 6px 12px rgba(0,0,0,0.3)")})),startButton.mouseOut((()=>{startButton.style("transform","scale(1)"),startButton.style("box-shadow","0 4px 8px rgba(0,0,0,0.2)")}))}function shareToWhatsApp(){const t=wishes[Math.floor(Math.random()*wishes.length)],e=encodeURIComponent(`${t}\nUcapkan selamat ulang tahun untuk ${userName}!`),o=`https://wa.me/${nomorWA}?text=${e}%0A${encodeURIComponent("https://4211421036.github.io/hbd/")}`;window.open(o,"_blank")}function createShareButton(){shareButton=createButton("Download & Share to WhatsApp 📱"),shareButton.style("padding","10px 20px"),shareButton.style("background-color","#25D366"),shareButton.style("color","white"),shareButton.style("border","none"),shareButton.style("border-radius","5px"),shareButton.style("cursor","pointer"),shareButton.style("font-size","16px"),shareButton.style("z-index","1000"),shareButton.style("position","absolute"),shareButton.style("left","50%"),shareButton.style("bottom","10px"),shareButton.style("transform","translateX(-50%)"),shareButton.hide(),shareButton.mousePressed(shareToWhatsApp)}function setup(){createCanvas(windowWidth,windowHeight),rectMode(CENTER),createStartButton(),createModal(),horns.push(new Horn(50,50,!0)),horns.push(new Horn(width-50,50,!1)),createShareButton()}function windowResized(){resizeCanvas(windowWidth,windowHeight),shareButton&&(shareButton.style("left","50%"),shareButton.style("transform","translateX(-50%)")),startButton&&(startButton.style("left","50%"),startButton.style("top","50%"),startButton.style("transform","translate(-50%, -50%)"))}function draw(){background(0,0,0,25);let t=window.innerWidth<=768,e=t?30:50,o=t?15:20;if(clicked){horns.forEach((t=>{t.blowing=!0,t.draw()}));for(let t=confetti.length-1;t>=0;t--){let e=confetti[t];e.x+=e.vx,e.y+=e.vy,e.vy+=.1,e.rotation+=.1,push(),translate(e.x,e.y),rotate(e.rotation),fill(e.color),rect(0,0,5,5),pop(),e.y>height&&confetti.splice(t,1)}candleLightIntensity=sin(.1*frameCount)*o+50,textSize(e);let s=candleLightIntensity/255;for(let t=20;t>0;t--){fill(255,200,0,s*(t/20)*255),textAlign(CENTER,CENTER),text(`Selamat Ulang Tahun\n${userName}!`,width/2+random(-1,1),height/2+random(-1,1))}fill(255,255,255),text(`Selamat Ulang Tahun\n${userName}!`,width/2,height/2),t&&shareButton.show();for(let t of fireworks)t.step()}else fill(255,255,255,10),noStroke(),textAlign(CENTER,CENTER),text("Klik untuk memulai",width/2,height/2)}function mouseReleased(){if(clicked){let t={x:mouseX,y:mouseY};fireworks.push(new Firework(t))}}