3v324v23 commited on
Commit
7d35120
·
1 Parent(s): f7a587c

Refactor code structure for improved readability and maintainability

Browse files
static/assets/arabic-calligraphy-path.webp ADDED
static/index.html CHANGED
@@ -116,7 +116,8 @@ body.home:not(.manage) #toNow{bottom:76px} body.home:not(.manage) #logoutBtn{bot
116
  /* the way back to the path, at the head of the daily videos' screen (no tab of the foot's bar is lit there) */
117
  #vids button.back{display:inline-flex;align-self:flex-start;gap:6px;padding:6px 12px;border-radius:10px;background:var(--olive);border-color:var(--olive);color:var(--on-olive);font:700 15px var(--f-body)}
118
  #dailyDlg{width:min(92vw,380px)}
119
- .path{--track:color-mix(in srgb,var(--muted) 75%,var(--bg));position:relative;width:100%;max-width:460px;margin:4px auto 72px}
 
120
  .road{position:absolute;left:50%;top:0;width:1px;height:100%;overflow:visible;pointer-events:none}
121
  .road path{fill:none;stroke:var(--line);stroke-width:12;stroke-linecap:round}
122
  .road .went{stroke:var(--olive)}
@@ -302,6 +303,11 @@ body:not(.manage) #manage,body.manage #wrap>header,body.manage #path,body.manage
302
  .tab small{font-weight:600;color:var(--muted);margin-inline-start:6px;font-variant-numeric:tabular-nums}
303
  .tab[aria-selected=true]{background:var(--olive);border-color:var(--olive);color:var(--on-olive)}
304
  .tab[aria-selected=true] small{color:inherit;opacity:.8}
 
 
 
 
 
305
  .chead{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
306
  .chead h2{flex:1;margin:0;font:400 24px/1.1 var(--f-display);overflow-wrap:anywhere}
307
  .chead p{flex:0 0 100%;margin:0;color:var(--muted);font-size:14px}
@@ -583,7 +589,7 @@ body.driving .card.storymode .prompt{display:block}
583
  .bubble-score b{min-width:1.5ch;font:800 30px/1 var(--f-display);text-align:center}
584
  .bubble-score.tick b{animation:score-pop .38s cubic-bezier(.2,1.8,.4,1)}
585
  .bubble-score small{display:block;margin-top:3px;color:#527254;font:700 12px/1 var(--f-body)}
586
- .bubble-misses{display:flex;position:absolute;top:18px;left:145px;right:12px;z-index:3;align-items:flex-start;gap:3px;direction:ltr;pointer-events:none}
587
  .bubble-misses[hidden]{display:none}
588
  .mini-balloon{position:relative;flex:0 0 18px;width:18px;height:22px;border:1px solid #2e782a;border-radius:50% 50% 48% 52%/46% 46% 54% 54%;background:radial-gradient(ellipse at 29% 22%,rgb(255 255 255/.85) 0 8%,transparent 16%),radial-gradient(ellipse at 36% 29%,#9ce98a 0%,#69c956 38%,#287823 100%);box-shadow:inset -3px -4px 5px rgb(15 76 17/.25),0 2px 3px rgb(37 90 42/.22)}
589
  .mini-balloon::after{content:"";position:absolute;left:50%;top:calc(100% - 1px);width:6px;height:5px;background:#348e30;clip-path:polygon(50% 0,100% 100%,0 100%);transform:translateX(-50%)}
@@ -1493,7 +1499,7 @@ function showBubbleHint(){
1493
  function showBubblePast(){
1494
  if(!bubbleCat()||home||bubblePastShown) return;
1495
  showBubbleHint(); bubblePastShown=true; const p=phraseOf(cur.id);
1496
- $("bubblePastText").textContent=(p.tr||"").split(",",1)[0].trim();
1497
  $("bubblePastAr").textContent=(p.ar||"").split("،",1)[0].trim(); $("bubblePast").hidden=false;
1498
  }
1499
  function pauseBubble(){
@@ -2582,7 +2588,11 @@ async function showMode(mode){
2582
  if(mode==="flags"&&!flagsLoaded){ await loadFlags(); drawManage(); }
2583
  }
2584
  for(const b of $("mModes").children) b.onclick=()=>showMode(b.dataset.mode);
2585
- setInterval(()=>{ if(mMode==="flags"&&document.body.classList.contains("manage")&&!document.hidden) loadActivity().then(()=>drawActivityOnly()); },60000);
 
 
 
 
2586
 
2587
  const FLAG_CATEGORIES={recognition:"המודל לא זיהה הגייה תקינה",valid_variant:"וריאנט הגייה תקין",alternative_answer:"תשובה חלופית נכונה",noise:"רעש או הקלטה בעייתית",other:"אחר"};
2588
  const PHONE_NAMES={"ħ":"ח (ح)","ʕ":"ע (ع)","x":"ח׳ (خ)","χ":"ח׳ (خ)","ɣ":"ע׳ (غ)","r":"ר (ر)","q":"ק (ق)","ʔ":"��/ק (ء/ق)","h":"ה (ه)","sˤ":"צ (ص)","tˤ":"ט (ط)","dˤ":"ד׳ (ض)","ðˤ":"ט׳ (ظ)","k":"כ (ك)","s":"ס (س)","t":"ת (ت)","d":"ד (د)","z":"ז (ز)","ʃ":"ש (ش)","dʒ":"ג׳ (ج)","b":"ב (ب)","f":"פ (ف)","m":"מ (م)","n":"נ (ن)","l":"ל (ل)","w":"ו (و)","j":"י (ي)","g":"ג (ج)","_":"לא נשמע"};
@@ -2972,10 +2982,12 @@ function drawTabs(classes){
2972
  tabs.append(all);
2973
  const classTabs=mark("class-tabs","");
2974
  for(const c of classes){
2975
- const t=mark("tab","","button"), name=document.createElement("bdi"); t.setAttribute("role","tab");
 
2976
  name.textContent=c.name; t.append(name); // isolated, so the count does not join a year in the name
2977
  t.setAttribute("aria-selected",c.name===shownClass);
2978
  t.append(mark("",c.emails.length,"small"));
 
2979
  t.onclick=()=>{ shownClass=c.name; shownStudent=""; store.set("ihki.mstudentClass",c.name); drawManage(); };
2980
  classTabs.append(t);
2981
  }
 
116
  /* the way back to the path, at the head of the daily videos' screen (no tab of the foot's bar is lit there) */
117
  #vids button.back{display:inline-flex;align-self:flex-start;gap:6px;padding:6px 12px;border-radius:10px;background:var(--olive);border-color:var(--olive);color:var(--on-olive);font:700 15px var(--f-body)}
118
  #dailyDlg{width:min(92vw,380px)}
119
+ .path{--track:color-mix(in srgb,var(--muted) 75%,var(--bg));position:relative;isolation:isolate;width:100%;max-width:460px;margin:4px auto 72px;background:#101510}
120
+ .path::before{content:"";position:absolute;z-index:-1;inset:0;background:url("/static/assets/arabic-calligraphy-path.webp") top center/100% auto repeat-y;mix-blend-mode:screen;filter:brightness(1.9) saturate(.55);opacity:.24;pointer-events:none}
121
  .road{position:absolute;left:50%;top:0;width:1px;height:100%;overflow:visible;pointer-events:none}
122
  .road path{fill:none;stroke:var(--line);stroke-width:12;stroke-linecap:round}
123
  .road .went{stroke:var(--olive)}
 
303
  .tab small{font-weight:600;color:var(--muted);margin-inline-start:6px;font-variant-numeric:tabular-nums}
304
  .tab[aria-selected=true]{background:var(--olive);border-color:var(--olive);color:var(--on-olive)}
305
  .tab[aria-selected=true] small{color:inherit;opacity:.8}
306
+ .tab .live-now{display:inline-flex;align-items:center;gap:4px;color:var(--ok);font-weight:700}
307
+ .tab .live-now::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor;box-shadow:0 0 0 0 color-mix(in srgb,var(--ok) 45%,transparent);animation:live-class 1.8s ease-out infinite}
308
+ .tab[aria-selected=true] .live-now{color:var(--on-olive);opacity:1}
309
+ @keyframes live-class{60%,100%{box-shadow:0 0 0 7px color-mix(in srgb,var(--ok) 0%,transparent)}}
310
+ @media (prefers-reduced-motion:reduce){.tab .live-now::before{animation:none}}
311
  .chead{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
312
  .chead h2{flex:1;margin:0;font:400 24px/1.1 var(--f-display);overflow-wrap:anywhere}
313
  .chead p{flex:0 0 100%;margin:0;color:var(--muted);font-size:14px}
 
589
  .bubble-score b{min-width:1.5ch;font:800 30px/1 var(--f-display);text-align:center}
590
  .bubble-score.tick b{animation:score-pop .38s cubic-bezier(.2,1.8,.4,1)}
591
  .bubble-score small{display:block;margin-top:3px;color:#527254;font:700 12px/1 var(--f-body)}
592
+ .bubble-misses{display:grid;position:absolute;top:18px;left:145px;z-index:3;grid-template-columns:repeat(5,18px);grid-auto-rows:22px;gap:7px 3px;direction:ltr;pointer-events:none}
593
  .bubble-misses[hidden]{display:none}
594
  .mini-balloon{position:relative;flex:0 0 18px;width:18px;height:22px;border:1px solid #2e782a;border-radius:50% 50% 48% 52%/46% 46% 54% 54%;background:radial-gradient(ellipse at 29% 22%,rgb(255 255 255/.85) 0 8%,transparent 16%),radial-gradient(ellipse at 36% 29%,#9ce98a 0%,#69c956 38%,#287823 100%);box-shadow:inset -3px -4px 5px rgb(15 76 17/.25),0 2px 3px rgb(37 90 42/.22)}
595
  .mini-balloon::after{content:"";position:absolute;left:50%;top:calc(100% - 1px);width:6px;height:5px;background:#348e30;clip-path:polygon(50% 0,100% 100%,0 100%);transform:translateX(-50%)}
 
1499
  function showBubblePast(){
1500
  if(!bubbleCat()||home||bubblePastShown) return;
1501
  showBubbleHint(); bubblePastShown=true; const p=phraseOf(cur.id);
1502
+ setTr($("bubblePastText"),(p.tr||"").split(",",1)[0].trim());
1503
  $("bubblePastAr").textContent=(p.ar||"").split("،",1)[0].trim(); $("bubblePast").hidden=false;
1504
  }
1505
  function pauseBubble(){
 
2588
  if(mode==="flags"&&!flagsLoaded){ await loadFlags(); drawManage(); }
2589
  }
2590
  for(const b of $("mModes").children) b.onclick=()=>showMode(b.dataset.mode);
2591
+ setInterval(()=>{
2592
+ if(!document.body.classList.contains("manage")||document.hidden) return;
2593
+ if(mMode==="flags") loadActivity().then(()=>drawActivityOnly());
2594
+ if(mMode==="students"&&CLASS) drawTabs(CLASS.classes||[]); // let the "active now" hint expire without a page refresh
2595
+ },60000);
2596
 
2597
  const FLAG_CATEGORIES={recognition:"המודל לא זיהה הגייה תקינה",valid_variant:"וריאנט הגייה תקין",alternative_answer:"תשובה חלופית נכונה",noise:"רעש או הקלטה בעייתית",other:"אחר"};
2598
  const PHONE_NAMES={"ħ":"ח (ح)","ʕ":"ע (ع)","x":"ח׳ (خ)","χ":"ח׳ (خ)","ɣ":"ע׳ (غ)","r":"ר (ر)","q":"ק (ق)","ʔ":"��/ק (ء/ق)","h":"ה (ه)","sˤ":"צ (ص)","tˤ":"ט (ط)","dˤ":"ד׳ (ض)","ðˤ":"ט׳ (ظ)","k":"כ (ك)","s":"ס (س)","t":"ת (ت)","d":"ד (د)","z":"ז (ز)","ʃ":"ש (ش)","dʒ":"ג׳ (ج)","b":"ב (ب)","f":"פ (ف)","m":"מ (م)","n":"נ (ن)","l":"ל (ل)","w":"ו (و)","j":"י (ي)","g":"ג (ج)","_":"לא נשמע"};
 
2982
  tabs.append(all);
2983
  const classTabs=mark("class-tabs","");
2984
  for(const c of classes){
2985
+ const active=CLASS.students.some(s=>{ const last=((s.since||{})[c.name]||{}).last, time=last&&Date.parse(last); return time&&Date.now()-time<15*60*1000; });
2986
+ const t=mark("tab"+(active?" live":""),"","button"), name=document.createElement("bdi"); t.setAttribute("role","tab");
2987
  name.textContent=c.name; t.append(name); // isolated, so the count does not join a year in the name
2988
  t.setAttribute("aria-selected",c.name===shownClass);
2989
  t.append(mark("",c.emails.length,"small"));
2990
+ if(active){ t.append(mark("live-now","פעילה עכשיו","small")); t.title="לפחות תלמיד אחד תרגל ב־15 הדקות האחרונות"; }
2991
  t.onclick=()=>{ shownClass=c.name; shownStudent=""; store.set("ihki.mstudentClass",c.name); drawManage(); };
2992
  classTabs.append(t);
2993
  }