Muskan10sharma commited on
Commit
949dc3c
ยท
verified ยท
1 Parent(s): 3474dac

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +762 -0
static/script.js CHANGED
@@ -688,6 +688,767 @@ window.addEventListener('DOMContentLoaded', () => {
688
  showToast(msg);
689
  });
690
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
691
  });
692
  // 1. Sarcastic Messages ka Database
693
  const sarcasticVault = {
@@ -742,6 +1503,7 @@ function popSarcasticNotif() {
742
  // Set to 20s to balance humor without being annoying
743
  setInterval(popSarcasticNotif, 20000);
744
 
 
745
  /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
746
  DEBUG & LOGS
747
  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
 
688
  showToast(msg);
689
  });
690
  }
691
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
692
+ DistractIQ ยท script.js
693
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
694
+ // โ”€โ”€ Interactive Assets โ”€โ”€
695
+ const sounds = {
696
+ pop: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-modern-technology-select-3124.mp3'),
697
+ scan: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-futuristic-robotic-data-601.mp3'),
698
+ levelUp: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-arcade-retro-changing-tab-206.mp3')
699
+ };
700
+ Object.values(sounds).forEach(s => s.volume = 0.2);
701
+
702
+ const trapRoasts = [
703
+ "Isliye tumhare exams clear nahi hote, distraction ki magnet ho tum! ๐Ÿงฒ",
704
+ "Focus focus focus... oh look, a useless button! - You, probably. ๐Ÿคก",
705
+ "Self-control: 0. Button clicking skills: 100. Proud of you. ๐Ÿ™„",
706
+ "Beta, career par dhyan de lo, is button par nahi. ๐Ÿงฌ",
707
+ "Physics wallah se pehle distraction wallah banoge tum. ๐Ÿ“‰"
708
+ ];
709
+ /* โ”€โ”€ State โ”€โ”€ */
710
+ const S = {
711
+ name: '', quizDone: false, quizAnswers: [],
712
+ results: null, history: [], streak: 0,
713
+ xp: 0, darkMode: true,
714
+ inputs: { study:4, phone:3, social:2, sleep:7, notifications:50 }
715
+ };
716
+
717
+ /* โ”€โ”€ Persistence โ”€โ”€ */
718
+ function save(){ try{ localStorage.setItem('diq', JSON.stringify(S)); }catch(e){} }
719
+ function load(){
720
+ try{
721
+ const d = JSON.parse(localStorage.getItem('diq')||'null');
722
+ if(d){ Object.assign(S, d); }
723
+ }catch(e){}
724
+ }
725
+
726
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
727
+ GALAXY CANVAS
728
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
729
+ (function initGalaxy(){
730
+ const cv = document.getElementById('galaxy');
731
+ const ctx = cv.getContext('2d');
732
+ let W, H, stars=[], nebulas=[];
733
+
734
+ function resize(){ W=cv.width=innerWidth; H=cv.height=innerHeight; }
735
+
736
+ function mkStars(){
737
+ stars = Array.from({length:220},()=>({
738
+ x:Math.random()*W, y:Math.random()*H,
739
+ r:Math.random()*1.6+.3,
740
+ a:Math.random(), da:(Math.random()-.5)*.008,
741
+ s:Math.random()*.4+.1
742
+ }));
743
+ nebulas = Array.from({length:5},()=>({
744
+ x:Math.random()*W, y:Math.random()*H,
745
+ r:Math.random()*180+80,
746
+ h:Math.random()*360, a:Math.random()*.18+.04
747
+ }));
748
+ }
749
+
750
+ function draw(){
751
+ ctx.clearRect(0,0,W,H);
752
+ nebulas.forEach(n=>{
753
+ const g=ctx.createRadialGradient(n.x,n.y,0,n.x,n.y,n.r);
754
+ g.addColorStop(0,`hsla(${n.h},80%,55%,${n.a})`);
755
+ g.addColorStop(1,'transparent');
756
+ ctx.fillStyle=g; ctx.fillRect(0,0,W,H);
757
+ });
758
+ stars.forEach(st=>{
759
+ st.a+=st.da;
760
+ if(st.a<0||st.a>1) st.da*=-1;
761
+ st.x-=st.s*.15;
762
+ if(st.x<0) st.x=W;
763
+ ctx.beginPath();
764
+ ctx.arc(st.x,st.y,st.r,0,Math.PI*2);
765
+ ctx.fillStyle=`rgba(255,255,255,${st.a})`;
766
+ ctx.fill();
767
+ });
768
+ requestAnimationFrame(draw);
769
+ }
770
+
771
+ window.addEventListener('resize',()=>{ resize(); mkStars(); });
772
+ resize(); mkStars(); draw();
773
+ })();
774
+
775
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
776
+ SCREEN SWITCHER
777
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
778
+ function showScreen(id){
779
+ document.querySelectorAll('.screen').forEach(s=>s.classList.remove('active'));
780
+ const el = document.getElementById(id);
781
+ el.classList.add('active');
782
+ }
783
+
784
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
785
+ LOGIN
786
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
787
+ function doLogin(){
788
+ const n = document.getElementById('name-in').value.trim();
789
+ if(!n){ showToast('Please enter your name! ๐Ÿ‘€'); return; }
790
+ S.name = n;
791
+ if(!S.quizDone){ showScreen('s-quiz'); initQuiz(); }
792
+ else{ showScreen('s-input'); initInputs(); }
793
+ save();
794
+ }
795
+
796
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
797
+ PERSONALITY QUIZ
798
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
799
+ const QUIZ = [
800
+ { q:'When do you feel most productive?', e:'๐Ÿ•',
801
+ opts:['Early morning (5โ€“9 AM)','Late morning (9โ€“12)','Afternoon vibes','Night owl mode ๐Ÿฆ‰'] },
802
+ { q:'How often do you check your phone while studying?', e:'๐Ÿ“ฑ',
803
+ opts:['Every 5 mins (bad, I know)','Every 30 mins','Only on breaks','I forget phones exist'] },
804
+ { q:'What kills your focus the most?', e:'๐Ÿ’€',
805
+ opts:['Social media notifications','Background noise','Random thoughts','Hunger / boredom'] },
806
+ { q:'How many hours of deep work can you do daily?', e:'๐Ÿ”ฅ',
807
+ opts:['Less than 1 hour','1โ€“2 hours','3โ€“4 hours','5+ hours (beast mode)'] }
808
+ ];
809
+
810
+ let qIdx=0;
811
+ function initQuiz(){
812
+ qIdx=0; S.quizAnswers=[];
813
+ renderQ();
814
+ }
815
+ function renderQ(){
816
+ const q=QUIZ[qIdx];
817
+ document.getElementById('qemoji').textContent=q.e;
818
+ document.getElementById('qtext').textContent=q.q;
819
+ document.getElementById('qlabel').textContent=`Question ${qIdx+1} of ${QUIZ.length}`;
820
+ document.getElementById('qprog').style.width=`${((qIdx)/QUIZ.length)*100}%`;
821
+ const oc=document.getElementById('qopts');
822
+ oc.innerHTML='';
823
+ q.opts.forEach((o,i)=>{
824
+ const b=document.createElement('button');
825
+ b.className='qopt'; b.textContent=o;
826
+ b.onclick=()=>pickQ(i, b);
827
+ oc.appendChild(b);
828
+ });
829
+ // Animate card in
830
+ const card=document.getElementById('qcard');
831
+ card.style.animation='none';
832
+ card.offsetHeight;
833
+ card.style.animation='popIn .4s cubic-bezier(.34,1.56,.64,1)';
834
+ }
835
+ function pickQ(i, btn){
836
+ document.querySelectorAll('.qopt').forEach(b=>b.classList.remove('sel'));
837
+ btn.classList.add('sel');
838
+ S.quizAnswers.push(i);
839
+ setTimeout(()=>{
840
+ qIdx++;
841
+ if(qIdx<QUIZ.length){ renderQ(); }
842
+ else{
843
+ S.quizDone=true; save();
844
+ showScreen('s-input'); initInputs();
845
+ }
846
+ },420);
847
+ }
848
+
849
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
850
+ INPUT SLIDERS
851
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
852
+ const INPUTS_CFG = [
853
+ { key:'study', icon:'๐Ÿ“š', title:'Study Hours Today', desc:'How many hours did you actually study?', min:0, max:16, step:.5, unit:'hrs', def:4 },
854
+ { key:'phone', icon:'๐Ÿ“ฑ', title:'Phone Usage', desc:'Total time on phone today (hours)', min:0, max:16, step:.5, unit:'hrs', def:3 },
855
+ { key:'social', icon:'๐ŸŒ', title:'Social Media Time', desc:'Time spent on Instagram, YouTube, etc.', min:0, max:16, step:.5, unit:'hrs', def:2 },
856
+ { key:'sleep', icon:'๐Ÿ˜ด', title:'Sleep Last Night', desc:'How many hours did you sleep?', min:0, max:12, step:.5, unit:'hrs', def:7 },
857
+ { key:'notifications', icon:'๐Ÿ””', title:'Notifications Today', desc:'How many notifications did you receive?', min:0, max:300, step:5, unit:'notifs',def:50 }
858
+ ];
859
+
860
+ let inpIdx=0;
861
+ function initInputs(){
862
+ inpIdx=0;
863
+ renderInp();
864
+ renderDots();
865
+ }
866
+ function renderInp(){
867
+ const c=INPUTS_CFG[inpIdx];
868
+ document.getElementById('inp-icon').textContent=c.icon;
869
+ document.getElementById('inp-title').textContent=c.title;
870
+ document.getElementById('inp-desc').textContent=c.desc;
871
+ const sl=document.getElementById('inp-slider');
872
+ sl.min=c.min; sl.max=c.max; sl.step=c.step;
873
+ sl.value=S.inputs[c.key]!==undefined ? S.inputs[c.key] : c.def;
874
+ document.getElementById('slid-unit').textContent=c.unit;
875
+ onSlide(sl.value);
876
+ // re-trigger animation
877
+ const card=document.getElementById('inp-card');
878
+ card.style.animation='none'; card.offsetHeight;
879
+ card.style.animation='popIn .4s cubic-bezier(.34,1.56,.64,1)';
880
+ }
881
+ function onSlide(v){
882
+ document.getElementById('slid-val').textContent=v;
883
+ }
884
+ function nextInp(){
885
+ const val=parseFloat(document.getElementById('inp-slider').value);
886
+ S.inputs[INPUTS_CFG[inpIdx].key]=val;
887
+ // Animate card out
888
+ const card=document.getElementById('inp-card');
889
+ card.style.transform='scale(.9) translateY(-30px)';
890
+ card.style.opacity='0';
891
+ setTimeout(()=>{
892
+ card.style.transform=''; card.style.opacity='';
893
+ inpIdx++;
894
+ if(inpIdx<INPUTS_CFG.length){ renderInp(); renderDots(); }
895
+ else{ save(); callAPI(); }
896
+ },350);
897
+ }
898
+ function renderDots(){
899
+ const dc=document.getElementById('inp-dots');
900
+ dc.innerHTML='';
901
+ INPUTS_CFG.forEach((_,i)=>{
902
+ const d=document.createElement('div');
903
+ d.className='dot'+(i===inpIdx?' active':i<inpIdx?' done':'');
904
+ dc.appendChild(d);
905
+ });
906
+ }
907
+
908
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
909
+ API CALL
910
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
911
+ function callAPI() {
912
+ // ๐Ÿ”Š Scanning sound start
913
+ sounds.scan.loop = true;
914
+ sounds.scan.play();
915
+
916
+ showToast('๐Ÿง  Analyzing your focus patternsโ€ฆ');
917
+ const body = {
918
+ study_hours_per_day: S.inputs.study,
919
+ phone_usage_hours: S.inputs.phone,
920
+ social_media_hours: S.inputs.social,
921
+ sleep_hours: S.inputs.sleep,
922
+ notifications: S.inputs.notifications
923
+ };
924
+
925
+ fetch('/predict', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
926
+ .then(r => r.json())
927
+ .then(d => {
928
+ // ๐Ÿ”‡ Scanning sound stop
929
+ sounds.scan.pause();
930
+ sounds.scan.currentTime = 0;
931
+
932
+ if (d.error) { showToast('โš ๏ธ ' + d.error); return; }
933
+
934
+ S.results = d;
935
+ processResults(d);
936
+ showScreen('s-dash');
937
+ showTab('home');
938
+ updateStreak();
939
+ save();
940
+
941
+ // ๐Ÿ† Level Up sound if good performance
942
+ if (d.productivity > 80) {
943
+ sounds.levelUp.play();
944
+ }
945
+
946
+ setTimeout(() => scheduleNotif(d.score), 4000);
947
+ })
948
+ .catch(e => {
949
+ // ๐Ÿ”‡ Error aane par bhi sound stop karein
950
+ sounds.scan.pause();
951
+ showToast('Connection error. Please try again.');
952
+ console.error(e);
953
+ });
954
+ }
955
+
956
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
957
+ PROCESS & RENDER RESULTS
958
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
959
+ function processResults(d){
960
+ const {score, risk, productivity, is_focused} = d;
961
+
962
+ // XP
963
+ const gainedXP = Math.round(productivity * 5);
964
+ S.xp = (S.xp||0) + gainedXP;
965
+ saveHistory(d);
966
+
967
+ // Greeting
968
+ const hour=new Date().getHours();
969
+ const greet=hour<12?'Good Morning โ˜€๏ธ':hour<17?'Good Afternoon ๐ŸŒค':hour<20?'Good Evening ๐ŸŒ†':'Good Night ๐ŸŒ™';
970
+ document.getElementById('greeting').textContent=`${greet}, ${S.name}! ๐Ÿ‘‹`;
971
+
972
+ // Sarcasm
973
+ document.getElementById('sarcasm').textContent=getSarcasm(score, hour);
974
+ document.getElementById('sarcasm').style.borderColor=score>75?'rgba(239,68,68,.4)':score>45?'rgba(245,158,11,.4)':'rgba(16,185,129,.4)';
975
+
976
+ // Animate rings
977
+ animRing('rg-dist', score, score>75?'#ef4444':score>45?'#f59e0b':'#10b981');
978
+ animRing('rg-risk', risk, risk>75?'#ef4444':risk>45?'#f59e0b':'#10b981');
979
+ animRing('rg-prod', productivity, productivity<40?'#ef4444':productivity<70?'#f59e0b':'#10b981');
980
+ animNum('n-dist', score);
981
+ animNum('n-risk', risk);
982
+ animNum('n-prod', productivity);
983
+
984
+ // Persona
985
+ const persona=getPersona(score, productivity, d.inputs||S.inputs);
986
+ document.getElementById('p-icon').textContent=persona.icon;
987
+ document.getElementById('p-name').textContent=persona.name;
988
+ document.getElementById('p-desc').textContent=persona.desc;
989
+
990
+ // Level & XP
991
+ const lv=getLevel(S.xp);
992
+ document.getElementById('lvl-name').textContent=lv.name;
993
+ document.getElementById('lvl-fill').style.width=lv.pct+'%';
994
+ document.getElementById('xp-ct').textContent=S.xp;
995
+ document.getElementById('xp-ct2').textContent=S.xp;
996
+ document.getElementById('xp-max').textContent=lv.max;
997
+
998
+ // Drivers
999
+ renderDrivers(d.inputs||S.inputs, score);
1000
+
1001
+ // Optimizer
1002
+ renderOptimizer(d.inputs||S.inputs, score, productivity);
1003
+
1004
+ // Quote
1005
+ document.getElementById('quote-txt').textContent=getQuote();
1006
+
1007
+ // Profile
1008
+ document.getElementById('prof-name').textContent=S.name;
1009
+ document.getElementById('prof-persona').textContent=persona.name;
1010
+
1011
+ // Stats
1012
+ renderStats(score, productivity, risk);
1013
+
1014
+ // Streak
1015
+ document.getElementById('streak-ct').textContent=S.streak;
1016
+ document.getElementById('s-big').textContent=S.streak;
1017
+
1018
+ // History & breakdown
1019
+ renderHistory();
1020
+ renderBreakdown(d.inputs||S.inputs, score);
1021
+
1022
+ // Streaks calendar
1023
+ renderCal();
1024
+
1025
+ // Achievements
1026
+ renderAch();
1027
+ }
1028
+
1029
+ /* โ”€โ”€ Ring animation โ”€โ”€ */
1030
+ function animRing(id, val, color){
1031
+ const el=document.getElementById(id);
1032
+ el.style.stroke=color;
1033
+ const offset=264-(264*(val/100));
1034
+ requestAnimationFrame(()=>{ el.style.strokeDashoffset=offset; });
1035
+ }
1036
+ function animNum(id, target){
1037
+ const el=document.getElementById(id);
1038
+ let cur=0; const dur=1200; const start=performance.now();
1039
+ function step(now){
1040
+ const p=Math.min((now-start)/dur,1);
1041
+ el.textContent=Math.round(cur+(target-cur)*easeOut(p));
1042
+ if(p<1) requestAnimationFrame(step);
1043
+ }
1044
+ requestAnimationFrame(step);
1045
+ }
1046
+ function easeOut(t){ return 1-Math.pow(1-t,3); }
1047
+
1048
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1049
+ CONTENT GENERATORS
1050
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1051
+ function getSarcasm(score, hour){
1052
+ if(hour>=23||hour<5){
1053
+ const lateArr=['Sleep is optional, regret is guaranteed. ๐Ÿ˜ญ','Why are you awake? Your productivity isn\'t. ๐ŸŒ™','Your brain needs rest, not a late-night doom scroll.','2 AM productivity? Bold strategy. Let us know how it goes.'];
1054
+ return rnd(lateArr);
1055
+ }
1056
+ if(score>75){
1057
+ return rnd(['Focus gaya tel lene ๐Ÿ˜ญ','Productivity just left the chat.','Phone se rishta thoda kam karo. ๐Ÿ“ฑ','Your phone has more screen time than your textbook.','Distraction level: Olympic gold medalist.','Your attention span just filed for bankruptcy.']);
1058
+ }
1059
+ if(score>45){
1060
+ return rnd(['You\'re almost productive. Almost. ๐Ÿค','Some focus detectedโ€ฆ very little.','Mediocre effort detected. Could be worse. Could be better.','The Wi-Fi is testing you and you\'re losing.','Half-focus is like half a parachute. ๐Ÿช‚']);
1061
+ }
1062
+ return rnd(['This is suspiciously impressive. ๐Ÿ‘€','Look at you getting things done! ๐Ÿš€','Productivity unlocked. Who are you?','Your focus game is on another level today.','Deep work mode: ACTIVATED. We stan. ๐Ÿ”ฅ']);
1063
+ }
1064
+
1065
+ function getPersona(score, prod, inp){
1066
+ const ph=inp.phone||S.inputs.phone;
1067
+ const notif=inp.notifications||S.inputs.notifications;
1068
+ if(prod>78) return {icon:'๐Ÿฅท',name:'Deep Work Ninja',desc:'You enter flow states effortlessly. Elite.'};
1069
+ if(ph>7) return {icon:'๐Ÿ“ฑ',name:'Digital Drifter',desc:'Glued to the screen like it owes you money.'};
1070
+ if(notif>140)return {icon:'โšก',name:'Chronic Multitasker',desc:'You juggle 10 things and finish 2. Progress.'};
1071
+ return {icon:'โš–๏ธ',name:'Balanced Performer',desc:'Solid effort. A few tweaks and you\'re elite.'};
1072
+ }
1073
+
1074
+ function getLevel(xp){
1075
+ if(xp<500) return {name:'Beginner', pct:Math.round((xp/500)*100), max:500};
1076
+ if(xp<2000) return {name:'Builder', pct:Math.round(((xp-500)/1500)*100), max:2000};
1077
+ return {name:'Master', pct:Math.round(Math.min(((xp-2000)/3000)*100,100)), max:5000};
1078
+ }
1079
+
1080
+ function renderDrivers(inp, score){
1081
+ const cont=document.getElementById('drivers');
1082
+ const drivers=[];
1083
+ const ph=inp.phone||S.inputs.phone;
1084
+ const sm=inp.social||S.inputs.social;
1085
+ const sl=inp.sleep||S.inputs.sleep;
1086
+ const nt=inp.notifications||S.inputs.notifications;
1087
+ const st=inp.study||S.inputs.study;
1088
+
1089
+ if(ph>5) drivers.push({icon:'๐Ÿ“ฑ',label:'High Phone Usage', pct:Math.min(100,Math.round(ph/16*100)), color:'#ef4444'});
1090
+ if(sm>3) drivers.push({icon:'๐Ÿ“ธ',label:'Social Media', pct:Math.min(100,Math.round(sm/16*100)), color:'#ec4899'});
1091
+ if(sl<6) drivers.push({icon:'๐Ÿ˜ด',label:'Sleep Deficit', pct:Math.min(100,Math.round((6-sl)/6*100)), color:'#f59e0b'});
1092
+ if(nt>80) drivers.push({icon:'๐Ÿ””',label:'Notification Storm',pct:Math.min(100,Math.round(nt/200*100)), color:'#8b5cf6'});
1093
+ if(st<3) drivers.push({icon:'๐Ÿ“š',label:'Low Study Time', pct:Math.min(100,Math.round((3-st)/3*100)), color:'#06b6d4'});
1094
+ if(!drivers.length) drivers.push({icon:'โœ…',label:'No major distractions!',pct:5,color:'#10b981'});
1095
+
1096
+ cont.innerHTML=drivers.map(d=>`
1097
+ <div class="drv">
1098
+ <div class="drv-lft">${d.icon} ${d.label}</div>
1099
+ <div class="drv-bw"><div class="drv-bf" style="width:0%;background:${d.color}" data-w="${d.pct}"></div></div>
1100
+ <div class="drv-pct">${d.pct}%</div>
1101
+ </div>`).join('');
1102
+ // Animate bars
1103
+ setTimeout(()=>{
1104
+ cont.querySelectorAll('.drv-bf').forEach(b=>{ b.style.width=b.dataset.w+'%'; });
1105
+ },200);
1106
+ }
1107
+
1108
+ function renderOptimizer(inp, score, prod){
1109
+ const cont=document.getElementById('optimizer');
1110
+ const tips=[];
1111
+ const sm=inp.social||S.inputs.social;
1112
+ const ph=inp.phone||S.inputs.phone;
1113
+ const sl=inp.sleep||S.inputs.sleep;
1114
+ const nt=inp.notifications||S.inputs.notifications;
1115
+ const st=inp.study||S.inputs.study;
1116
+
1117
+ if(sm>1) tips.push(`๐Ÿ“‰ Cut social media by 1hr โ†’ +${Math.round(sm*4)}% productivity boost`);
1118
+ if(ph>3) tips.push(`๐Ÿ“ต Phone-free study blocks โ†’ reduces distraction score by ~${Math.round(ph*3)} pts`);
1119
+ if(sl<7) tips.push(`๐Ÿ›Œ Sleep 1hr more โ†’ clears mental fog, +${Math.round((7-sl)*8)}% focus`);
1120
+ if(nt>50)tips.push(`๐Ÿ”• Silence notifications during study โ†’ recover ${Math.round(nt*.5)} min of deep work`);
1121
+ if(st<5) tips.push(`๐Ÿ“– Add 1hr of study โ†’ +${Math.round(1*2*5)} productivity XP gained`);
1122
+ if(!tips.length) tips.push('๐Ÿ† You\'re optimized! Keep this up for streak bonuses.');
1123
+
1124
+ cont.innerHTML=tips.map(t=>`<div class="tip"><span class="tip-ic">๐Ÿ’ก</span><span>${t}</span></div>`).join('');
1125
+ }
1126
+
1127
+ const QUOTES=[
1128
+ '"Deep work is the superpower of the 21st century." โ€” Cal Newport',
1129
+ '"Focus is a matter of deciding what things you\'re NOT going to do." โ€” John Carmack',
1130
+ '"Energy, not time, is the fundamental currency of high performance."',
1131
+ '"The successful warrior is the average person with laser-like focus." โ€” Bruce Lee',
1132
+ '"Concentrate all your thoughts upon the work at hand." โ€” Alexander Graham Bell',
1133
+ '"Where focus goes, energy flows." โ€” Tony Robbins',
1134
+ '"Do one thing at a time, and do it well."',
1135
+ '"Your future is created by what you do today, not tomorrow."'
1136
+ ];
1137
+ function getQuote(){ return rnd(QUOTES); }
1138
+
1139
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1140
+ HISTORY
1141
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1142
+ function saveHistory(d){
1143
+ const entry={
1144
+ date: new Date().toLocaleDateString('en-IN',{day:'numeric',month:'short'}),
1145
+ score: d.score, risk: d.risk, productivity: d.productivity,
1146
+ persona: getPersona(d.score, d.productivity, d.inputs||S.inputs).name
1147
+ };
1148
+ S.history = [entry, ...(S.history||[])].slice(0,30);
1149
+ }
1150
+
1151
+ function renderHistory(){
1152
+ const cont=document.getElementById('hist-list');
1153
+ if(!S.history||!S.history.length){
1154
+ cont.innerHTML='<div class="muted" style="font-size:.85rem;padding:8px 0">No history yet. Run your first analysis!</div>';
1155
+ return;
1156
+ }
1157
+ cont.innerHTML=S.history.slice(0,10).map(h=>{
1158
+ const cls=h.score>75?'hi':h.score>45?'md':'lo';
1159
+ return `<div class="hitem">
1160
+ <div class="hdot ${cls}"></div>
1161
+ <div class="hinfo">
1162
+ <div class="hdate">${h.date}</div>
1163
+ <div class="hscore">Score: ${h.score} ยท Risk: ${h.risk}%</div>
1164
+ <div class="hpers">${h.persona}</div>
1165
+ </div>
1166
+ <div style="font-family:var(--fd);font-size:.9rem;color:${h.productivity>70?'#10b981':h.productivity>45?'#f59e0b':'#ef4444'}">${h.productivity}%</div>
1167
+ </div>`;
1168
+ }).join('');
1169
+ }
1170
+
1171
+ function renderBreakdown(inp, score){
1172
+ const cont=document.getElementById('breakdown');
1173
+ const ph=inp.phone||S.inputs.phone;
1174
+ const sm=inp.social||S.inputs.social;
1175
+ const nt=inp.notifications||S.inputs.notifications;
1176
+ const st=inp.study||S.inputs.study;
1177
+ const sl=inp.sleep||S.inputs.sleep;
1178
+
1179
+ const bars=[
1180
+ {label:'Phone', val:Math.min(100,Math.round(ph/16*100)), color:'#ef4444'},
1181
+ {label:'Social', val:Math.min(100,Math.round(sm/16*100)), color:'#ec4899'},
1182
+ {label:'Notifs', val:Math.min(100,Math.round(nt/200*100)), color:'#8b5cf6'},
1183
+ {label:'Study', val:Math.min(100,Math.round(st/16*100)), color:'#10b981'},
1184
+ {label:'Sleep', val:Math.min(100,Math.round(sl/12*100)), color:'#3b82f6'}
1185
+ ];
1186
+ cont.innerHTML=bars.map(b=>`
1187
+ <div class="bki">
1188
+ <div class="bkh"><span>${b.label}</span><span>${b.val}%</span></div>
1189
+ <div class="bkbg"><div class="bkf" style="width:0%;background:${b.color};color:${b.color}" data-w="${b.val}"></div></div>
1190
+ </div>`).join('');
1191
+ setTimeout(()=>{
1192
+ cont.querySelectorAll('.bkf').forEach(b=>{ b.style.width=b.dataset.w+'%'; });
1193
+ },200);
1194
+ }
1195
+
1196
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1197
+ STREAKS & CALENDAR
1198
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1199
+ function updateStreak(){
1200
+ const today=new Date().toDateString();
1201
+ const last=S.lastDay||'';
1202
+ if(last===today) return;
1203
+ const yesterday=new Date(Date.now()-86400000).toDateString();
1204
+ if(last===yesterday){ S.streak=(S.streak||0)+1; }
1205
+ else{ S.streak=1; }
1206
+ S.lastDay=today;
1207
+ S.streakDays=S.streakDays||[];
1208
+ S.streakDays.push(today);
1209
+ save();
1210
+ }
1211
+
1212
+ function renderCal(){
1213
+ const cont=document.getElementById('s-cal');
1214
+ const today=new Date();
1215
+ const year=today.getFullYear();
1216
+ const month=today.getMonth();
1217
+ const daysInMonth=new Date(year,month+1,0).getDate();
1218
+ const firstDay=new Date(year,month,1).getDay();
1219
+ const done=new Set(S.streakDays||[]);
1220
+ let html='';
1221
+ for(let i=0;i<firstDay;i++) html+=`<div class="cday"></div>`;
1222
+ for(let d=1;d<=daysInMonth;d++){
1223
+ const dt=new Date(year,month,d).toDateString();
1224
+ const isToday=d===today.getDate();
1225
+ const isDone=done.has(dt);
1226
+ html+=`<div class="cday${isDone?' done':''}${isToday?' today':''}">${d}</div>`;
1227
+ }
1228
+ cont.innerHTML=html;
1229
+ }
1230
+
1231
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1232
+ ACHIEVEMENTS
1233
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1234
+ const ACHS=[
1235
+ {icon:'๐Ÿš€',name:'First Launch', desc:'Completed first analysis', check:()=>S.history&&S.history.length>=1},
1236
+ {icon:'๐Ÿ”ฅ',name:'3-Day Streak', desc:'3 days in a row', check:()=>(S.streak||0)>=3},
1237
+ {icon:'๐Ÿ’Ž',name:'Focus Diamond', desc:'Productivity > 80%', check:()=>S.results&&S.results.productivity>80},
1238
+ {icon:'๐Ÿง˜',name:'Zen Mode', desc:'Distraction score < 20', check:()=>S.results&&S.results.score<20},
1239
+ {icon:'โšก',name:'500 XP Club', desc:'Earned 500 XP', check:()=>(S.xp||0)>=500},
1240
+ {icon:'๐Ÿ†',name:'Week Warrior', desc:'7-day streak', check:()=>(S.streak||0)>=7},
1241
+ ];
1242
+ function renderAch(){
1243
+ document.getElementById('ach-list').innerHTML=ACHS.map(a=>{
1244
+ const on=a.check();
1245
+ return `<div class="ach ${on?'on':'off'}">
1246
+ <div class="ach-ic">${a.icon}</div>
1247
+ <div><div class="ach-nm">${a.name} ${on?'โœ…':''}</div><div class="ach-ds">${a.desc}</div></div>
1248
+ </div>`;
1249
+ }).join('');
1250
+ }
1251
+
1252
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1253
+ STATS
1254
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1255
+ function renderStats(score, prod, risk){
1256
+ document.getElementById('prof-stats').innerHTML=`
1257
+ <div class="st-row"><span>Total Analyses</span><span class="st-v">${S.history?S.history.length:1}</span></div>
1258
+ <div class="st-row"><span>Current Score</span><span class="st-v">${score}</span></div>
1259
+ <div class="st-row"><span>Productivity</span><span class="st-v">${prod}%</span></div>
1260
+ <div class="st-row"><span>Risk Level</span><span class="st-v">${risk}%</span></div>
1261
+ <div class="st-row"><span>Total XP</span><span class="st-v">${S.xp||0}</span></div>
1262
+ <div class="st-row"><span>Best Streak</span><span class="st-v">${S.streak||0} days</span></div>
1263
+ `;
1264
+ }
1265
+
1266
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1267
+ TABS
1268
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1269
+ function showTab(name){
1270
+ document.querySelectorAll('.tab').forEach(t=>t.classList.remove('active'));
1271
+ document.querySelectorAll('.nb').forEach(b=>b.classList.remove('active'));
1272
+ document.getElementById('tab-'+name).classList.add('active');
1273
+ document.getElementById('nb-'+name).classList.add('active');
1274
+ }
1275
+
1276
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1277
+ TOAST
1278
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1279
+ function showToast(msg, dur=3200){
1280
+ const t = document.getElementById('toast');
1281
+ if(!t) return;
1282
+
1283
+ // Play sound
1284
+ sounds.pop.currentTime = 0;
1285
+ sounds.pop.play();
1286
+
1287
+ t.textContent = msg;
1288
+ t.classList.add('show');
1289
+ setTimeout(() => t.classList.remove('show'), dur);
1290
+ }
1291
+
1292
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1293
+ SARCASTIC NOTIFICATIONS
1294
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1295
+ const NOTIFS=[
1296
+ 'Hey, your phone misses you. Actually no, it doesn\'t. ๐Ÿ“ต',
1297
+ 'Your study notes won\'t read themselves. Or will they? ๐Ÿค”',
1298
+ 'Notification from: Reality. You have work to do.',
1299
+ 'Focus check: still alive? Put the phone down.',
1300
+ 'Your productivity just texted. It\'s lonely.',
1301
+ 'Average Indian student scrolls 3hrs/day. Don\'t be average.',
1302
+ 'Your future self is watching. Don\'t disappoint them. ๐Ÿ‘',
1303
+ ];
1304
+ function scheduleNotif(score){
1305
+ if(!document.getElementById('notif-tog').checked) return;
1306
+ if(score>50) showToast('๐Ÿ”” '+rnd(NOTIFS));
1307
+ }
1308
+
1309
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1310
+ THEME
1311
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1312
+ function toggleTheme(){
1313
+ S.darkMode=!S.darkMode;
1314
+ document.body.classList.toggle('light',!S.darkMode);
1315
+ document.getElementById('theme-toggle' ) && (document.querySelector('.ico-btn').textContent=S.darkMode?'๐ŸŒ™':'โ˜€๏ธ');
1316
+ const tog=document.getElementById('dark-tog');
1317
+ if(tog) tog.checked=S.darkMode;
1318
+ save();
1319
+ }
1320
+ function toggleThemeCheck(el){
1321
+ S.darkMode=el.checked;
1322
+ document.body.classList.toggle('light',!S.darkMode);
1323
+ save();
1324
+ }
1325
+
1326
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1327
+ RESET
1328
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1329
+ function rerun(){
1330
+ inpIdx=0; S.inputs={study:4,phone:3,social:2,sleep:7,notifications:50};
1331
+ showScreen('s-input'); initInputs();
1332
+ }
1333
+ function clearAll(){
1334
+ if(!confirm('Reset all data? This cannot be undone.')) return;
1335
+ localStorage.removeItem('diq');
1336
+ location.reload();
1337
+ }
1338
+
1339
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1340
+ UTILS
1341
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1342
+ function rnd(arr){ return arr[Math.floor(Math.random()*arr.length)]; }
1343
+
1344
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1345
+ INIT
1346
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1347
+ window.addEventListener('DOMContentLoaded', () => {
1348
+ load();
1349
+ if (S.darkMode === false) document.body.classList.add('light');
1350
+ if (S.name) {
1351
+ document.getElementById('name-in').value = S.name;
1352
+ }
1353
+
1354
+ // Enter key on login
1355
+ document.getElementById('name-in').addEventListener('keydown', e => {
1356
+ if (e.key === 'Enter') doLogin();
1357
+ });
1358
+
1359
+ // If returning user with results, go straight to dash
1360
+ if (S.name && S.results && S.quizDone) {
1361
+ document.getElementById('greeting').textContent = `Welcome back, ${S.name}! ๐Ÿ‘‹`;
1362
+ showScreen('s-dash');
1363
+ processResults(S.results);
1364
+ showTab('home');
1365
+ }
1366
+
1367
+ // --- TRAP BUTTON LOGIC (Sabke liye kaam karega) ---
1368
+ const trapBtn = document.getElementById('trap-btn');
1369
+ if (trapBtn) {
1370
+ trapBtn.addEventListener('click', () => {
1371
+ sounds.pop.currentTime = 0;
1372
+ sounds.pop.play();
1373
+
1374
+ document.body.classList.add('trap-flash');
1375
+ setTimeout(() => document.body.classList.remove('trap-flash'), 500);
1376
+
1377
+ const msg = trapRoasts[Math.floor(Math.random() * trapRoasts.length)];
1378
+ showToast(msg);
1379
+ });
1380
+ }
1381
+ });
1382
+ // 1. Sarcastic Messages ka Database
1383
+ const sarcasticVault = {
1384
+ high: ["Focus gaya tel lene ๐Ÿ˜ญ", "Productivity just left the chat.", "เค‡เคคเคจเคพ scrolling? Dedication galat jagah pe hai.", "Phone se relationship strong haiโ€ฆ future se weak."],
1385
+ medium: ["Youโ€™re almost productive. Almost.", "Half focus, half nonsense. Balanced life?", "Scrolling kam, kaam thoda zyada?", "Potential haiโ€ฆ use kab karoge?"],
1386
+ low: ["Who are you and why are you so productive?", "Suspiciously impressive. Character development!", "Focus level: main character energy.", "Is thisโ€ฆ discipline? ๐Ÿ˜ณ"],
1387
+ random: ["เคฌเฅเคฐเฅ‡เค• เคฒเคฟเคฏเคพ เคฅเคพ เคฏเคพ retirement?", "Motivation bufferingโ€ฆ please wait.", "เคซเฅ‹เคจ เคฐเค–เฅ‹. Future เค‰เค เคพเค“.", "เค•เคพเคฎ pending hai, attitude full hai ๐Ÿ˜ญ"]
1388
+ };
1389
+
1390
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1391
+ SMART SARCASTIC NOTIFICATIONS
1392
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1393
+
1394
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1395
+ SMART SARCASTIC NOTIFICATIONS
1396
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1397
+
1398
+ function popSarcasticNotif() {
1399
+ // Only roast if the user is logged in and the dashboard is active
1400
+ const dashActive = document.getElementById('s-dash').classList.contains('active');
1401
+ if (!S.name || !S.quizDone || !dashActive) return;
1402
+
1403
+ const toast = document.getElementById('toast');
1404
+ if(!toast) return;
1405
+
1406
+ // Determine roast category based on the latest distraction score
1407
+ let type = 'random';
1408
+ if (S.results) {
1409
+ const score = S.results.score;
1410
+ type = score > 75 ? 'high' : score > 45 ? 'medium' : 'low';
1411
+ }
1412
+
1413
+ const messages = sarcasticVault[type] || sarcasticVault.random;
1414
+ const msg = messages[Math.floor(Math.random() * messages.length)];
1415
+
1416
+ // Severity-based accent colors
1417
+ const colors = { high: "#ef4444", medium: "#f59e0b", low: "#10b981", random: "#8b5cf6" };
1418
+ const color = colors[type] || colors.random;
1419
+
1420
+ // Audio cue
1421
+ sounds.pop.currentTime = 0;
1422
+ sounds.pop.play();
1423
+
1424
+ toast.innerText = "๐Ÿ”” " + msg;
1425
+ toast.style.borderLeft = `6px solid ${color}`;
1426
+ toast.classList.add('show');
1427
+
1428
+ setTimeout(() => toast.classList.remove('show'), 4000);
1429
+ }
1430
+
1431
+ // Start the roast engine
1432
+ // Set to 20s to balance humor without being annoying
1433
+ setInterval(popSarcasticNotif, 20000);
1434
+ const xpBtn = document.getElementById("xp-btn");
1435
+ const focusBox = document.getElementById("focus-optimizer");
1436
+
1437
+ xpBtn.addEventListener("click", () => {
1438
+ focusBox.classList.add("show");
1439
+
1440
+ clearTimeout(focusBox.hideTimer);
1441
+
1442
+ focusBox.hideTimer = setTimeout(() => {
1443
+ focusBox.classList.remove("show");
1444
+ }, 3000);
1445
+ });
1446
+
1447
+ /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1448
+ DEBUG & LOGS
1449
+ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */
1450
+ console.log("๐Ÿš€ DistractIQ Engine: Active & Ready to Roast.");
1451
+
1452
  });
1453
  // 1. Sarcastic Messages ka Database
1454
  const sarcasticVault = {
 
1503
  // Set to 20s to balance humor without being annoying
1504
  setInterval(popSarcasticNotif, 20000);
1505
 
1506
+
1507
  /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
1508
  DEBUG & LOGS
1509
  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */