
Hãy dành thời gian mỗi đêm trong tuần, và ngắm nhìn chòm sao của riêng bạn dần hiện ra. Ghi lại ba đêm, và mặt trăng sẽ tràn ngập điểm số của bạn.
Những vì sao của bạn đang chờ đợi.
Bạn có ngủ trên Sleepm không?
Những cái nào?
Chúng tôi chỉ lưu giữ điểm số của tuần này, các câu trả lời của bạn ở trên và số giờ ngủ trung bình của bạn. Chúng tôi tuyệt đối không lưu giữ tên, địa chỉ email hay thông tin liên lạc của bạn. Chính sách bảo mật
Nhật ký giấc ngủ của bạn chỉ được lưu trữ trên thiết bị này. Chỉ để bạn tham khảo, không phải lời khuyên y tế: chỉ số này dựa trên số giờ ngủ (7 đến 9 giờ là mức khuyến nghị chung dành cho người lớn), mức độ ổn định của giờ đi ngủ và cảm giác của bạn. Nếu bạn thực sự gặp khó khăn trong việc ngủ, hãy tham khảo ý kiến bác sĩ.
(function(){
var root=document.getElementById('ls2');if(!root){return;}
var NS='http://www.w3.org/2000/svg',KEY='sleepm-diary-v1',D={};
try{D=JSON.parse(localStorage.getItem(KEY)||'{}')||{};}catch(e){D={};}
function save(){try{localStorage.setItem(KEY,JSON.stringify(D));}catch(e){}}
function $(s){return root.querySelector(s);}
function iso(d){return d.getFullYear()+'-'+String(d.getMonth()+1).padStart(2,'0')+'-'+String(d.getDate()).padStart(2,'0');}
var DAYS=[];for(var i=6;i>=0;i--){var d=new Date();d.setDate(d.getDate()-i);DAYS.push(d);}
function mins(t){if(!t){return null;}var p=t.split(':');return (+p[0])*60+(+p[1]);}
function dur(b,w){var x=mins(b),y=mins(w);if(x==null||y==null){return null;}var v=y-x;if(v<=0){v+=1440;}return v;}
function fmt(m){return Math.floor(m/60)+'h '+String(Math.round(m%60)).padStart(2,'0')+'m';}
function clock(m){m=((m%1440)+1440)%1440;var h=Math.floor(m/60),mm=Math.round(m%60);if(mm===60){mm=0;h=(h+1)%24;}return (h%12||12)+':'+String(mm).padStart(2,'0')+(h>=12?' PM':' AM');}
var svg=$('.ls2-svg'),starsG=$('.ls2-stars'),line=$('.ls2-line'),fx=$('.ls2-fx'),dayBar=$('.ls2-days');
var dust=$('.ls2-dust');var seed=7;function rnd(){seed=(seed*9301+49297)%233280;return seed/233280;}
for(var k=0;k<46;k++){var c=document.createElementNS(NS,'circle');c.setAttribute('cx',(rnd()*1000).toFixed(1));c.setAttribute('cy',(rnd()*330).toFixed(1));c.setAttribute('r',(0.6+rnd()*1.3).toFixed(2));c.style.animationDelay=(rnd()*3).toFixed(2)+'s';dust.appendChild(c);}
var POS=DAYS.map(function(d,ix){return {x:95+ix*112,y:250-78*Math.sin(Math.PI*ix/6)};});
var sel=6,mood=null,adv=null;
DAYS.forEach(function(d,ix){var p=POS[ix];var g=document.createElementNS(NS,'g');g.setAttribute('class','ls2-star');g.setAttribute('tabindex','0');g.setAttribute('role','button');
g.setAttribute('aria-label','Night of '+d.toLocaleDateString('en-US',{weekday:'long',month:'long',day:'numeric'}));
g.innerHTML='<circle class="hit" cx="'+p.x+'" cy="'+p.y+'" r="34"/><circle class="glow" cx="'+p.x+'" cy="'+p.y+'" r="38" fill="url(#ls2Glow)"/><circle class="ring" cx="'+p.x+'" cy="'+p.y+'" r="19"/><path class="core" d="M'+p.x+' '+(p.y-15)+' L'+(p.x+4)+' '+(p.y-4)+' L'+(p.x+15)+' '+p.y+' L'+(p.x+4)+' '+(p.y+4)+' L'+p.x+' '+(p.y+15)+' L'+(p.x-4)+' '+(p.y+4)+' L'+(p.x-15)+' '+p.y+' L'+(p.x-4)+' '+(p.y-4)+'Z"/><text class="lbl" x="'+p.x+'" y="'+(p.y+42)+'">'+d.toLocaleDateString('en-US',{weekday:'short'})+'</text>';
g.addEventListener('click',function(){pick(ix);});g.addEventListener('keydown',function(e){if(e.key==='Enter'||e.key===' '){e.preventDefault();pick(ix);}});
starsG.appendChild(g);
var b=document.createElement('button');b.type='button';b.className='ls2-day';b.innerHTML='<b></b><span></span><i></i>';b.querySelector('b').textContent=d.toLocaleDateString('en-US',{weekday:'short'});b.querySelector('span').textContent=d.getDate();b.addEventListener('click',function(){pick(ix);});dayBar.appendChild(b);});
var inB=$('.ls2-b'),inW=$('.ls2-w'),moods=root.querySelectorAll('.ls2-mood'),step=1,cur={};
function lab(t){var m=mins(t),h=Math.floor(m/60),mm=m%60;if(h===0&&mm===0){return 'Midnight';}if(h===12&&mm===0){return 'Noon';}return (h%12||12)+(mm?':'+String(mm).padStart(2,'0'):'')+(h>=12?' PM':' AM');}
function opts(from,n){var o=[];for(var q=0;q<n;q++){var m=(from+q*30)%1440;o.push(String(Math.floor(m/60)).padStart(2,'0')+':'+String(m%60).padStart(2,'0'));}return o;}
function grid(el,list,key){list.forEach(function(t){var bt=document.createElement('button');bt.type='button';bt.className='ls2-t';bt.dataset.t=t;bt.textContent=lab(t);bt.addEventListener('click',function(){setT(key,t);});el.appendChild(bt);});}
grid($('.ls2-gb'),opts(20*60,12),'b');grid($('.ls2-gw'),opts(4*60+30,12),'w');
function nm(ix){return ix===6?'Tonight':ix===5?'Last night':DAYS[ix].toLocaleDateString('en-US',{weekday:'long'})+' night';}
function show(n){step=n;[].forEach.call(root.querySelectorAll('.ls2-q'),function(q){q.hidden=+q.dataset.s!==n;});
[].forEach.call(root.querySelectorAll('.ls2-otherbox'),function(x){x.hidden=true;});
$('.ls2-step').textContent=n<4?'Step '+n+' of 3':'';$('.ls2-back').hidden=!(n===2||n===3);
[].forEach.call(root.querySelectorAll('.ls2-gb .ls2-t'),function(x){x.classList.toggle('on',x.dataset.t===cur.b);});
[].forEach.call(root.querySelectorAll('.ls2-gw .ls2-t'),function(x){x.classList.toggle('on',x.dataset.t===cur.w);});
[].forEach.call(moods,function(x){x.classList.toggle('on',x.dataset.q===cur.q);});
if(n===1){var pv=prevNight(sel);var sm=$('.ls2-same');if(pv){sm.hidden=false;sm.dataset.ix=pv.ix;sm.textContent='Same as '+(pv.ix===5?'last night':DAYS[pv.ix].toLocaleDateString('en-US',{weekday:'long'}))+' ('+lab(pv.v.b)+' to '+lab(pv.v.w)+')';}else{sm.hidden=true;}}
if(n===4){doneView();}}
function prevNight(ix){for(var j=ix-1;j>=0;j--){var v=D[iso(DAYS[j])];if(v&&v.b&&v.w){return {ix:j,v:v};}}for(var k=ix+1;k<7;k++){var w=D[iso(DAYS[k])];if(w&&w.b&&w.w){return {ix:k,v:w};}}return null;}
function count(){var n=0;DAYS.forEach(function(d){var v=D[iso(d)];if(v&&v.b&&v.w){n++;}});return n;}
function nextOpen(){for(var j=5;j>=0;j--){var v=D[iso(DAYS[j])];if(!(v&&v.b&&v.w)){return j;}}var t=D[iso(DAYS[6])];return (t&&t.b&&t.w)?-1:6;}
function setT(key,t){cur[key]=t;show(key==='b'?2:3);}
function doneView(){var v=D[iso(DAYS[sel])];var n=count();
$('.ls2-donet').textContent=nm(sel)+' is saved';
$('.ls2-dones').textContent=lab(v.b)+' to '+lab(v.w)+' · '+fmt(dur(v.b,v.w))+' of sleep'+(n<3?' · '+(3-n)+' more night'+(3-n===1?'':'s')+' to see your score':'');
var nx=nextOpen(),nb=$('.ls2-next');if(nx>=0){nb.hidden=false;nb.dataset.ix=nx;nb.textContent='Next: '+nm(nx)+' →';}else{nb.hidden=true;}
$('.ls2-see').hidden=n<3;$('.ls2-see').classList.toggle('ghost',nx>=0);}
[].forEach.call(moods,function(m){m.addEventListener('click',function(){cur.q=m.dataset.q;if(!cur.b||!cur.w){show(cur.b?2:1);return;}
D[iso(DAYS[sel])]={b:cur.b,w:cur.w,q:cur.q};save();paint();burst(sel);show(4);});});
[].forEach.call(root.querySelectorAll('.ls2-other'),function(o){o.addEventListener('click',function(){var bx=o.nextElementSibling;bx.hidden=!bx.hidden;if(!bx.hidden){var i=bx.querySelector('input');i.value=cur[o.dataset.for]||'';i.focus();}});});
[].forEach.call(root.querySelectorAll('.ls2-use'),function(u){u.addEventListener('click',function(){var i=u.previousElementSibling;if(!i.value){i.focus();return;}setT(u.dataset.for,i.value);});});
$('.ls2-same').addEventListener('click',function(){var v=D[iso(DAYS[+this.dataset.ix])];cur.b=v.b;cur.w=v.w;show(3);});
$('.ls2-back').addEventListener('click',function(){show(step-1);});
$('.ls2-next').addEventListener('click',function(){pick(+this.dataset.ix);});
$('.ls2-edit').addEventListener('click',function(){show(1);});
$('.ls2-see').addEventListener('click',function(){var r=$('.ls2-result');r.scrollIntoView({behavior:'smooth',block:'start'});});
function pick(ix){sel=ix;var v=D[iso(DAYS[ix])];cur=v?{b:v.b,w:v.w,q:v.q}:{};
$('.ls2-when').textContent=nm(ix)+' · '+DAYS[ix].toLocaleDateString('en-US',{month:'short',day:'numeric'});paint();show(v&&v.b&&v.w?4:1);}
function burst(ix){var p=POS[ix],r=svg.getBoundingClientRect(),vb=svg.viewBox.baseVal;var sc=Math.max(r.width/vb.width,r.height/vb.height);var ox=(r.width-vb.width*sc)/2,oy=(r.height-vb.height*sc)/2;var x=ox+p.x*sc,y=oy+p.y*sc;
for(var n=0;n<16;n++){var s=document.createElement('i');var a=n/16*Math.PI*2,dd=30+Math.random()*40;s.style.left=x+'px';s.style.top=y+'px';s.style.setProperty('--dx',(Math.cos(a)*dd).toFixed(1)+'px');s.style.setProperty('--dy',(Math.sin(a)*dd).toFixed(1)+'px');fx.appendChild(s);setTimeout(function(el){return function(){el.remove();};}(s),1100);}}
var TITLES=[[90,'Moonkeeper','Your nights run like clockwork'],[75,'Dream Weaver','Most nights end in a good story'],[60,'Star Wanderer','Some nights sparkle, some wander'],[40,'Night Owl in Training','The stars are rooting for you'],[0,'Sleepy Sprout','Every week is a fresh start']];
var last={};
function paint(){var pts=[],lit=[];DAYS.forEach(function(d,ix){var v=D[iso(d)];var g=starsG.children[ix],b=dayBar.children[ix];var on=!!(v&&v.b&&v.w);g.classList.toggle('lit',on);g.classList.toggle('sel',ix===sel);b.classList.toggle('sel',ix===sel);
b.querySelector('i').textContent=on?fmt(dur(v.b,v.w)).replace(' ',''):'';
if(on){var du=dur(v.b,v.w);var k=du>=420&&du<=540?1.25:du>=360?1:.8;if(v.q==='Rested'){k+=.15;}g.querySelector('.glow').setAttribute('r',(34*k).toFixed(1));pts.push(POS[ix].x+','+POS[ix].y);lit.push(v);}});
line.setAttribute('points',pts.length>1?pts.join(' '):'');
var num=$('.ls2-num'),shade=$('.ls2-shade'),mt=$('.ls2-mtxt');
if(lit.length<3){root.classList.remove('has');shade.setAttribute('cx',860);mt.textContent=lit.length?String(3-lit.length):'?';num.textContent='–';$('.ls2-title').textContent=lit.length?(3-lit.length)+' more night'+(3-lit.length===1?'':'s'):'Log three nights';$('.ls2-sub').textContent='to meet your sleep spirit';['.ls2-avg','.ls2-cons','.ls2-bed'].forEach(function(s){$(s).textContent='–';});$('.ls2-tip').textContent=lit.length?'Your constellation is forming.':'Your stars are waiting.';$('.ls2-share').disabled=true;$('.ls2-save').disabled=true;last={};if(typeof svUpdate==='function'){svUpdate();}return;}
var ds=lit.map(function(v){return dur(v.b,v.w);});var avg=ds.reduce(function(a,b){return a+b;},0)/ds.length;
var bts=lit.map(function(v){var m=mins(v.b);return m<720?m+1440:m;});var mb=bts.reduce(function(a,b){return a+b;},0)/bts.length;var sd=Math.sqrt(bts.reduce(function(a,b){return a+(b-mb)*(b-mb);},0)/bts.length);
var durPts=avg>=420&&avg<=540?50:Math.max(0,50-Math.abs(avg-(avg<420?420:540))/3);var conPts=Math.max(0,35-sd/3);var felt=lit.filter(function(v){return v.q;}).length,rest=lit.filter(function(v){return v.q==='Rested';}).length,ok=lit.filter(function(v){return v.q==='Okay';}).length;var feelPts=felt?15*(rest+ok*.5)/felt:7.5;
var s=Math.max(0,Math.min(100,Math.round(durPts+conPts+feelPts)));
root.classList.add('has');shade.setAttribute('cx',(860+Math.min(1,s/90)*118).toFixed(1));mt.textContent=s;
var t=TITLES.filter(function(x){return s>=x[0];})[0];$('.ls2-title').textContent='You are a '+t[1];$('.ls2-sub').textContent=t[2];
var from=+num.dataset.v||0;num.dataset.v=s;var t0=performance.now();(function step(now){var p=Math.min(1,(now-t0)/900);num.textContent=Math.round(from+(s-from)*(1-Math.pow(1-p,3)));if(p<1){requestAnimationFrame(step);}})(t0);
$('.ls2-avg').textContent=fmt(avg);$('.ls2-cons').textContent=sd<=30?'Steady':sd<=60?'Fairly steady':'Wandering';$('.ls2-bed').textContent=clock(mb);
$('.ls2-tip').textContent=avg<420?'Most adults feel best with 7 to 9 hours. Try lights out 15 minutes earlier this week.':sd>60?'Your lights-out time wanders. A steadier bedtime is one of the simplest habits to build.':'A lovely rhythm. Keep the lights low in the last hour before bed.';
last={s:s,t:t,avg:avg,sd:sd,mb:mb};$('.ls2-share').disabled=false;$('.ls2-save').disabled=false;if(typeof svUpdate==='function'){svUpdate();}}
function card(cb){var W=1080,H=1350,c=document.createElement('canvas');c.width=W;c.height=H;var x=c.getContext('2d');
var g=x.createLinearGradient(0,0,0,H);g.addColorStop(0,'#070b24');g.addColorStop(.6,'#1b2360');g.addColorStop(1,'#5a4a93');x.fillStyle=g;x.fillRect(0,0,W,H);
seed=11;for(var n=0;n<160;n++){x.globalAlpha=.25+rnd()*.7;x.fillStyle='#fff';x.beginPath();x.arc(rnd()*W,rnd()*H*.75,.6+rnd()*1.8,0,7);x.fill();}x.globalAlpha=1;
var mx=W/2,my=360,mr=150;var hg=x.createRadialGradient(mx,my,mr*.6,mx,my,mr*2.4);hg.addColorStop(0,'rgba(255,242,198,.45)');hg.addColorStop(1,'rgba(255,242,198,0)');x.fillStyle=hg;x.fillRect(0,0,W,H);
x.save();x.beginPath();x.arc(mx,my,mr,0,7);x.clip();x.fillStyle='#fff3cf';x.fillRect(mx-mr,my-mr,mr*2,mr*2);x.fillStyle='#1b2360';x.beginPath();x.arc(mx+Math.min(1,last.s/90)*mr*2.2,my,mr*1.04,0,7);x.fill();x.restore();
x.strokeStyle='rgba(255,242,198,.4)';x.lineWidth=2;x.beginPath();x.arc(mx,my,mr,0,7);x.stroke();
var sp=DAYS.map(function(d,ix){return {x:140+ix*133,y:760-70*Math.sin(Math.PI*ix/6),on:!!(D[iso(d)]&&D[iso(d)].w)};});
x.strokeStyle='rgba(255,217,138,.6)';x.lineWidth=2.5;x.setLineDash([6,9]);x.beginPath();var st=0;sp.forEach(function(p){if(p.on){if(!st){x.moveTo(p.x,p.y);st=1;}else{x.lineTo(p.x,p.y);}}});x.stroke();x.setLineDash([]);
sp.forEach(function(p){if(p.on){var r=x.createRadialGradient(p.x,p.y,0,p.x,p.y,46);r.addColorStop(0,'rgba(255,246,216,.95)');r.addColorStop(.4,'rgba(255,217,138,.5)');r.addColorStop(1,'rgba(255,217,138,0)');x.fillStyle=r;x.beginPath();x.arc(p.x,p.y,46,0,7);x.fill();}x.fillStyle=p.on?'#fff6d8':'rgba(207,214,255,.4)';x.beginPath();for(var q=0;q<8;q++){var a=q*Math.PI/4-Math.PI/2,rr=q%2?5:16;x.lineTo(p.x+Math.cos(a)*rr,p.y+Math.sin(a)*rr);}x.closePath();x.fill();});
x.fillStyle='#141a44';x.beginPath();x.moveTo(0,1050);x.bezierCurveTo(300,990,650,1040,1080,1000);x.lineTo(1080,H);x.lineTo(0,H);x.fill();
x.textAlign='center';x.fillStyle='#ffd98a';x.font='500 30px Inter, sans-serif';x.fillText('MY SLEEPM WEEK',mx,110);
x.fillStyle='#1b2360';x.font='600 120px "Cormorant Garamond", Georgia, serif';x.fillText(String(last.s),mx,my+42);
x.fillStyle='#ffd98a';x.font='italic 500 76px "Cormorant Garamond", Georgia, serif';x.fillText(last.t[1],mx,620);
x.fillStyle='#e9ecff';x.font='400 34px Inter, sans-serif';x.fillText(fmt(last.avg)+' a night · lights out '+clock(last.mb),mx,1140);
x.fillStyle='rgba(233,236,255,.7)';x.font='400 28px Inter, sans-serif';x.fillText('sleepm.com/sleep-score',mx,1250);
c.toBlob(cb,'image/png');}
$('.ls2-save').addEventListener('click',function(){card(function(b){var a=document.createElement('a');a.href=URL.createObjectURL(b);a.download='my-sleepm-week.png';document.body.appendChild(a);a.click();setTimeout(function(){URL.revokeObjectURL(a.href);a.remove();},2000);$('.ls2-msg').textContent='Saved to your downloads.';});});
$('.ls2-share').addEventListener('click',function(){var txt='I am a '+last.t[1]+' this week: '+last.s+'/100 on my Sleepm sleep score. Light your own stars:';var m=$('.ls2-msg');
card(function(b){var f=null;try{f=new File([b],'my-sleepm-week.png',{type:'image/png'});}catch(e){}
if(navigator.share&&f&&navigator.canShare&&navigator.canShare({files:[f]})){navigator.share({files:[f],text:txt,url:'https://sleepm.com/sleep-score/'}).catch(function(){});}
else if(navigator.share){navigator.share({text:txt,url:'https://sleepm.com/sleep-score/'}).catch(function(){});}
else if(navigator.clipboard){navigator.clipboard.writeText(txt+' https://sleepm.com/sleep-score/').then(function(){m.textContent='Copied. Paste it anywhere.';},function(){m.textContent=txt;});}});});
var sv=$('.ls2-sv'),svOwner=null,svProd=[],svReady=false;
function isoWeek(d){var t=new Date(Date.UTC(d.getFullYear(),d.getMonth(),d.getDate()));var dn=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-dn);var y=new Date(Date.UTC(t.getUTCFullYear(),0,1));var w=Math.ceil(((t-y)/86400000+1)/7);return t.getUTCFullYear()+'-W'+String(w).padStart(2,'0');}
function devId(){var k='sleepm-sv-id',v=null;try{v=localStorage.getItem(k);if(!v){v=(self.crypto&&crypto.randomUUID)?crypto.randomUUID():('d'+Math.random().toString(36).slice(2)+Date.now().toString(36));localStorage.setItem(k,v);}}catch(e){v=null;}return v;}
function svUpdate(){sv.hidden=!(svReady&&last.s!=null&&root.classList.contains('has'));$('.ls2-svgo').disabled=!svOwner;}
fetch('/wp-json/sleepm/v1').then(function(r){return r.ok?r.json():null;}).then(function(j){svReady=!!(j&&j.routes&&j.routes['/sleepm/v1/score']);svUpdate();}).catch(function(){});
[].forEach.call(sv.querySelectorAll('[data-o]'),function(b){b.addEventListener('click',function(){svOwner=b.dataset.o;[].forEach.call(sv.querySelectorAll('[data-o]'),function(x){x.classList.toggle('on',x===b);});$('.ls2-svprod').hidden=svOwner!=='yes';svUpdate();});});
[].forEach.call(sv.querySelectorAll('[data-p]'),function(b){b.addEventListener('click',function(){var p=b.dataset.p,i=svProd.indexOf(p);if(i>=0){svProd.splice(i,1);b.classList.remove('on');}else{svProd.push(p);b.classList.add('on');}});});
$('.ls2-svgo').addEventListener('click',function(){var m=$('.ls2-svmsg'),dv=devId(),btn=this;if(!dv){m.textContent='Your browser is blocking storage, so we cannot count this device.';return;}
var n=0;DAYS.forEach(function(d){var v=D[iso(d)];if(v&&v.b&&v.w){n++;}});btn.disabled=true;m.textContent='Adding…';
fetch('/wp-json/sleepm/v1/score',{method:'POST',headers:{'Content-Type':'application/json'},credentials:'omit',body:JSON.stringify({score:last.s,nights:n,owner:svOwner,products:svOwner==='yes'?svProd:[],dev:dv,week:isoWeek(new Date()),avg:Math.round(last.avg),sd:Math.round(last.sd)})})
.then(function(r){return r.json().then(function(j){return {ok:r.ok,j:j};});}).then(function(x){if(x.ok){m.textContent=x.j.updated?'Updated. Thank you for this week.':'Thank you. Your score is counted for this week.';btn.textContent='Update my entry';try{localStorage.setItem('sleepm-sv-'+isoWeek(new Date()),'1');}catch(e){}}else{m.textContent=(x.j&&x.j.message)||'Something went wrong. Please try again.';}btn.disabled=false;}).catch(function(){m.textContent='Something went wrong. Please try again.';btn.disabled=false;});});
$('.ls2-clear').addEventListener('click',function(){D={};save();pick(5);});
var first=nextOpen();pick(first<0?5:first);
})();
Mỗi chiếc Sleepm đều được giới thiệu qua người thân — một người thân cận với bạn, nói cùng ngôn ngữ với bạn, và cũng đang sử dụng sản phẩm này. Có hỗ trợ trả góp.
(function(){ var cv=document.getElementById('dust'),cx=cv.getContext('2d'),W,H; function size(){W=cv.width=innerWidth;H=cv.height=innerHeight}size();addEventListener('resize',size); var P=[];var GOLD=[255,217,138],PERI=[159,176,255],WHITE=[240,243,255]; function spawn(x,y,opt){opt=opt||{};var c=[GOLD,PERI,WHITE][Math.random()*3|0]; P.push({x:x,y:y,vx:(Math.random()-.5)*(opt.sp||1.2),vy:(Math.random()-.5)*1.2,life:1,decay:.012+Math.random()*.02,s:opt.s||(1+Math.random()*2.2),c:c,tw:Math.random()*6.28});} addEventListener('mousemove',function(e){for(var i=0;i<3;i++)spawn(e.clientX+(Math.random()-.5)*10,e.clientY+(Math.random()-.5)*10,{sp:.9});}); setInterval(function(){spawn(Math.random()*W,Math.random()*H*.6,{sp:.3,s:1});},300); function loop(){cx.clearRect(0,0,W,H);cx.globalCompositeOperation='lighter'; for(var i=P.length-1;i>=0;i--){var p=P[i];p.x+=p.vx;p.y+=p.vy;p.life-=p.decay;p.tw+=.25; if(p.life<=0){P.splice(i,1);continue} var a=p.life*(.55+.45*Math.sin(p.tw)); var g=cx.createRadialGradient(p.x,p.y,0,p.x,p.y,p.s*3.2); g.addColorStop(0,'rgba('+p.c[0]+','+p.c[1]+','+p.c[2]+','+a+')');g.addColorStop(1,'rgba('+p.c[0]+','+p.c[1]+','+p.c[2]+',0)'); cx.fillStyle=g;cx.beginPath();cx.arc(p.x,p.y,p.s*3.2,0,6.28);cx.fill();} requestAnimationFrame(loop);}loop(); var io=new IntersectionObserver(function(es){es.forEach(function(e){if(e.isIntersecting)e.target.classList.add('awake');});},{threshold:.15}); document.querySelectorAll('.awaken').forEach(function(el){io.observe(el)}); })();
(function(){var btn=document.querySelector('.lb-btn');if(btn){btn.addEventListener('click',function(e){e.preventDefault();document.documentElement.classList.toggle('lbopen');});}var menu=document.querySelector('.lb-menu');if(menu){menu.addEventListener('click',function(){document.documentElement.classList.remove('lbopen');});}})();
(function(){var root=document.getElementById('lloydLang');if(!root)return;var btn=root.querySelector('.ll-btn');btn.addEventListener('click',function(e){e.stopPropagation();root.classList.toggle('ll-open');});document.addEventListener('click',function(){root.classList.remove('ll-open');});function sw(code){var done=false;if(window.Weglot){if(Weglot.switchTo){Weglot.switchTo(code);done=true;}}if(!done){var a=document.getElementById('weglot-language-'+code);if(a){a.click();}}}var opts=root.querySelectorAll('.ll-opt');opts.forEach(function(o){o.addEventListener('click',function(e){e.preventDefault();var code=o.getAttribute('data-wg');sw(code);var el=root.querySelector('.ll-cur');if(el){el.textContent=code.toUpperCase();}root.classList.remove('ll-open');});});function setCur(){var cur='';if(window.Weglot){if(Weglot.getCurrentLang){cur=Weglot.getCurrentLang();}}if(cur){var el=root.querySelector('.ll-cur');if(el){el.textContent=(''+cur).toUpperCase();}}}setTimeout(setCur,900);})();
Quét bằng camera điện thoại — Ứng dụng dành cho iPhone đã có mặt trên App Store, còn phiên bản dành cho Android đã có mặt trên Google Play.
Hoặc nhấn vào đây trên điện thoại của bạn →