דילוג לתוכן
בס״ד
להיות אדם
נפש
רוח
נשמה
בס״ד
להיות אדם
מערכת לבניה וצמיחה אישית מ״
עַיִר
פרא״ לאדם גדול
העבודה שלי
יומן
השמירה המקומית אינה זמינה בדפדפן הזה. השינויים יישמרו רק עד סגירת הקובץ.
ייצוא עכשיו
חזרה
חזרה ל״להיות אדם״
לניהול הזמן היומי שלי
ניהול הלילה · נשמר בדפדפן הזה, כמו שאר הנתונים
מסך מלא
פותחים את ניהול הלילה…
חזרה ל״להיות אדם״
`;document.body.append(d);d.querySelector(".nh-back").onclick=()=>this.close();d.querySelector(".nh-cancel")?.addEventListener("click",(()=>this.close()));d.querySelector(".nh-full").onclick=()=>Fullscreen.toggle();d.addEventListener("cancel",(e=>{e.preventDefault();this.close()}));d.addEventListener("close",(()=>{document.body.classList.remove("night-open");try{NightPeek.paint()}catch(_){}}));addEventListener("message",(e=>{const m=e.data;if(!m||typeof m!=="object")return;if(m.type==="night:close")this.close();if(m.type==="night:ready"){d.classList.add("is-ready");d.querySelector(".nh-loading")?.remove()}}));return d},open(){if(!this.available()){toast("המערכת לניהול הזמן אינה כלולה בקובץ הזה");return}const d=this.dlg||(this.dlg=this.build()),f=d.querySelector("iframe");this.opener=document.activeElement;document.body.classList.add("night-open");if(!d.open)Opening.show(d);Fullscreen.sync();if(!this.loaded){this.loaded=true;f.srcdoc=this.source()}if(!state.prefs.nightSeen){state.prefs.nightSeen=true;save()}if(!Motion.reduced())d.animate([{opacity:0,transform:"translateY(14px) scale(.985)"},{opacity:1,transform:"none"}],{duration:380,easing:"cubic-bezier(.16,1,.3,1)"});setTimeout((()=>{try{f.contentWindow?.focus()}catch(_){}}),400);Events.emit("NIGHT_OPENED",{});Nav.layer("night",(()=>this.close(true)));setTimeout((()=>safe((()=>NightBridge.hello()))),60)},close(fromHistory=false){const d=this.dlg;if(!d||!d.open)return;if(!fromHistory)Nav.unlayer("night");const done=()=>{Opening.hide(d);document.body.classList.remove("night-open");try{this.opener?.focus()}catch(_){}};if(Motion.reduced()){done();return}const a=d.animate([{opacity:1,transform:"none"},{opacity:0,transform:"translateY(10px) scale(.99)"}],{duration:220,easing:"ease-in"});a.finished.catch((()=>{})).finally(done)}};const NightPeek={KEY:"layla-haadam-v1",read(){let S=null;try{S=JSON.parse(Store.get(this.KEY)||"null")}catch(_){}const now=new Date,boundary=+(S?.settings?.boundary??4),d=new Date(now);if(now.getHours()
`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`;const friday=d.getDay()===5,tasks=(S?.tasks||[]).filter((t=>t.active!==false)),total=(tasks.length||9)+1,levels=S?.levels||{over:100,done:80,little:40,none:0};const answered=k=>{const n=S?.nights?.[k];if(!n)return 0;let c=0;for(const t of tasks)if(n.a?.[t.id]!=null)c++;if(n.f!=null)c++;return c};const score=k=>{const n=S?.nights?.[k];if(!n||n.off)return null;let sw=0,sv=0;for(const t of tasks){const a=n.a?.[t.id];if(a==null)continue;const w=+t.weight||1;sw+=w;sv+=w*(+levels[a]||0)}return sw?sv/sw:null};let run=0;if(S){let x=new Date(d);if(answered(key(x))
=total-1){run++;x.setDate(x.getDate()-1)}else break}}const k=key(d),done=answered(k),[hh,mm]=String(S?.settings?.sleep||"23:00").split(":").map(Number),h=now.getHours()+now.getMinutes()/60,sleep=(hh||23)+(mm||0)/60;const evening=h>=Math.max(18,sleep-4)||h
=total,score:score(k),run:run,evening:evening,off:!!S?.nights?.[k]?.off}},period(start,end){let S=null;try{S=JSON.parse(Store.get(this.KEY)||"null")}catch(_){}if(!S||!S.nights||S.settings&&S.settings.weekly===false)return null;const tasks=(S.tasks||[]).filter((t=>t.active!==false)),levels=S.levels||{over:100,done:80,little:40,none:0},sleep=tasks.find((t=>t.id==="t9"||/שינה בזמן/.test(t.short||""))),keys=Object.keys(S.nights).filter((k=>k>=start&&k<=end&&!S.nights[k].off)),out={nights:0,scores:[],sleepYes:0,sleepAsked:0,feel:[],possible:0};const ck=x=>`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,upto=ck(new Date)
l.length?l.reduce(((a,b)=>a+b),0)/l.length:null;out.score=mean(out.scores);out.feelMean=mean(out.feel);return out},text(p){if(!p.started)return{line:"עשר שאלות קצרות לסיום היום — דקה אחת בערב",badge:""};if(p.friday)return{line:"ליל שבת — אין סיכום הלילה",badge:""};if(p.off)return{line:"הלילה סומן כלילה חופשי",badge:""};if(p.complete)return{line:`הלילה הושלם${p.score!=null?` · ציון ${Math.round(p.score)}%`:""}${p.run>1?` · ${p.run} לילות ברצף`:""}`,badge:"✓"};if(p.done)return{line:`הלילה: ${p.done} מתוך ${p.total} נענו — עוד מעט וסיימת`,badge:`${p.done}/${p.total}`};return{line:p.evening?`הערב: ${p.total} שאלות הלילה מחכות לך${p.run?` · ${p.run} לילות ברצף`:""}`:`הערב — ${p.total} שאלות קצרות${p.run?` · ${p.run} לילות ברצף`:""}`,badge:p.evening?"הערב":""}},paint(){const b=document.getElementById("nightbtn");if(!b)return;const p=this.read(),t=this.text(p),fresh=!state.prefs?.nightSeen;b.classList.toggle("is-evening",p.evening&&!p.complete&&!p.friday&&!p.off);b.classList.toggle("is-complete",p.complete);b.title=`לניהול הזמן היומי שלי — ${t.line}`;b.setAttribute("aria-label",`לניהול הזמן היומי שלי. ${t.line}`);const small=b.querySelector(".rail-copy small");if(small)small.textContent=t.line;let tag=b.querySelector(".nl-tag");const label=fresh?"חדש":t.badge;if(label){if(!tag){tag=document.createElement("span");tag.className="nl-tag";(b.querySelector(".rail-copy strong")||b).append(tag)}tag.textContent=label;tag.dir=/\d/.test(label)?"ltr":"rtl";tag.classList.toggle("is-new",fresh)}else tag?.remove()}};