-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodedost.html
More file actions
659 lines (599 loc) · 35.1 KB
/
codedost.html
File metadata and controls
659 lines (599 loc) · 35.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>CodeDost — Your AI Coding Tutor</title>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" integrity="sha512-2SwdPD6INVrV/lHTZbO2nodKhrnDdJK9/kg2XD1r9uGqPo1cUbujc+IYdlYdEErWNu69gVcYgdx..." crossorigin="anonymous" referrerpolicy="no-referrer" />
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Syne:wght@400;500;700;800&display=swap" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css"/>
<link rel="stylesheet" href="codedost.css"/>
<link rel="stylesheet" href="codedost/css/codedost-1024px.css"/>
<link rel="stylesheet" href="codedost/css/codedost-768px.css"/>
<link rel="stylesheet" href="codedost/css/codedost-900px.css"/>
<link rel="stylesheet" href="codedost/css/codedost-480px.css"/>
<link rel="manifest" href="manifest.json"/>
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
<!-- Vercel Web Analytics -->
<script>
window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
</script>
<script defer src="/_vercel/insights/script.js"></script>
<!-- Vercel Speed Insights -->
<script>
window.si = window.si || function () { (window.siq = window.siq || []).push(arguments); };
</script>
<script defer src="/_vercel/speed-insights/script.js"></script>
</head>
<body>
<!-- PILOT BANNER -->
<div class="pilot-banner" id="pilot-banner" >
<a href="https://sherazramzan.gumroad.com/l/cfevjo" target="_blank">Upgrade to Pro — $0.99/mo ↗</a>
</div>
<!-- ═══════════════════════════════════════════
HEADER
════════════════════════════════════════════ -->
<header class="header h-normal">
<a class="logo" id="logo" href="#">
<div style="display: flex; align-items: center; justify-content: center; gap: 0 6px;">
<div class="logo-icon">{}</div>
<span class="logo-text">Code<span>Dost</span></span>
</div>
<div class="streak-badge" id="streak-badge" title="Your daily learning streak">
<span class="streak-fire">🔥</span>
<span class="streak-count streak-num">0</span>
</div>
</a>
<div class="hamburger">
<i class="fa-solid fa-bars" style="display: none;"></i>
<i class="fa-solid fa-xmark none" ></i>
</div>
<div class="header-right none">
<div class="streak-badge" id="streak-badge" title="Your daily learning streak">
<span class="streak-fire">🔥</span>
<span class="streak-count streak-num">0</span>
<span style="font-size:11px;color:var(--text-muted)">day streak</span>
</div>
<div class="usage-counter-pill" title="Total bugs explained worldwide">
<div class="usage-pulse"></div>
<span id="usage-count" style="font-family:var(--font-code);font-weight:700;color:var(--green)">...</span>
<span style="color:var(--text-muted)">bugs fixed</span>
</div>
<button class="shortcuts-btn" onclick="openHelpModal()" title="Keyboard shortcuts (?)">
<i class="fa-regular fa-keyboard"></i>
</button>
<button class="api-btn" onclick="openModal()" aria-label="Open API key setup">🔑 Free API Key</button>
<!-- AUTH BUTTON -->
<button class="api-btn" id="auth-btn" onclick="openAuthModal()" style="background:var(--purple);color:white;">👤 Login / Sign Up</button>
<!-- QUOTA DISPLAY (shows after login) -->
<div id="quota-pill" style="display:none;font-size:11px;padding:4px 10px;border-radius:20px;background:var(--bg-elevated);border:1px solid var(--border);color:var(--text-muted);">
<span id="quota-used">0</span>/<span id="quota-limit">5</span> uses
</div>
<button type="button" id="theme-toggle" class="theme-btn" onclick="toggleTheme()" aria-label="Toggle theme">
🌙
</button>
</div>
</header>
<!-- ═══════════════════════════════════════════
HERO
════════════════════════════════════════════ -->
<section class="hero">
<div class="hero-tagline">AI Coding Tutor — Powered by Groq + Llama 3 (100% Free)</div>
<h1 class="hero-title">Error aa gaya? <em>Koi baat nahi.</em></h1>
<p class="hero-sub">Apna buggy code paste karo. CodeDost Roman Urdu mein explain karega — desi analogy ke saath — aur fix bhi karega.</p>
<div id="cotd-container"></div>
<div class="mode-toggle" role="group" aria-label="Language mode">
<button type="button" class="mode-btn active" data-mode="urdu">🇵🇰 Roman Urdu</button>
<button type="button" class="mode-btn" data-mode="mixed">⚡ Mixed</button>
<button type="button" class="mode-btn" data-mode="english">🇬🇧 Full English</button>
</div>
</section>
<!-- ═══════════════════════════════════════════
MAIN GRID
════════════════════════════════════════════ -->
<main class="main">
<!-- ── LEFT: INPUT PANEL ─────────────────── -->
<div class="panel-left">
<!-- Code Editor -->
<div class="panel-section">
<div class="section-header">
<span class="section-title">Apna Code Yahan Paste Karo</span>
<button type="button" id="clear-code-btn" class="copy-btn">Clear</button>
</div>
<div class="code-editor-wrap">
<div class="editor-toolbar">
<div class="lang-dots">
<span class="dot-red"></span>
<span class="dot-yellow"></span>
<span class="dot-green"></span>
</div>
<select class="lang-picker" id="lang-picker" onchange="updateLang()">
<option value="python">Python</option>
<option value="javascript">JavaScript</option>
<option value="java">Java</option>
<option value="cpp">C++</option>
<option value="html">HTML/CSS</option>
<option value="sql">SQL</option>
</select>
<span class="editor-counter" id="editor-counter">0 lines</span>
<span class="editor-lang-tag" id="lang-tag">script.py</span>
</div>
<textarea id="code-input" spellcheck="false"
placeholder="# Yahan apna code paste karo...
# Example:
def calculate_total(items):
total = 0
for item in items
total += item['price']
return total"></textarea>
</div>
</div>
<!-- Error Message -->
<div class="panel-section">
<div class="section-header">
<span class="section-title">Error Message</span>
<button type="button" class="paste-error-btn" onclick="pasteErrorFromClipboard()" title="Paste from clipboard">📋 Paste</button>
</div>
<div class="error-input-wrap">
<span class="error-icon">⚠</span>
<input type="text" id="error-input"
placeholder="e.g. TypeError: 'NoneType' object is not subscriptable"/>
</div>
</div>
<!-- Quick Examples -->
<div class="panel-section">
<div class="section-header">
<span class="section-title">Quick Examples</span>
</div>
<div class="examples-row" role="group" aria-label="Quick example snippets">
<button type="button" class="example-chip" data-example="syntax">Syntax Error</button>
<button type="button" class="example-chip" data-example="typeerror">TypeError</button>
<button type="button" class="example-chip" data-example="index">IndexError</button>
<button type="button" class="example-chip" data-example="undefined">Undefined Var</button>
<button type="button" class="example-chip" data-example="async">Async Bug</button>
<button type="button" class="example-chip" data-example="null">Null Reference</button>
</div>
</div>
<!-- Submit -->
<div class="panel-section">
<button class="submit-btn" id="submit-btn" onclick="analyzeCode()">
<span class="btn-text">🚀 Explain Karo — Samjha Do!</span>
<div class="btn-spinner"></div>
</button>
<p style="font-size:11px;color:var(--text-muted);text-align:center;margin-top:8px;">
Groq (Free) se powered · Roman Urdu mein jawab milega · Ctrl+Enter
</p>
<div class="rate-limit-bar" id="rate-limit-bar">
<span>⏳ Rate limit — ready in</span>
<span class="rate-countdown" id="rate-countdown">30</span>
<span>seconds</span>
<div class="rate-progress"><div class="rate-progress-fill" id="rate-progress-fill" style="width:100%"></div></div>
</div>
</div>
</div>
<!-- ── RIGHT: OUTPUT PANEL ───────────────── -->
<div class="panel-right" id="panel-right">
<!-- Empty state -->
<div class="output-empty" id="output-empty">
<div class="output-empty-icon">🤖</div>
<div class="output-empty-title">CodeDost tayaar hai!</div>
<div class="output-empty-sub">Left side mein apna code paste karo, aur main Roman Urdu mein explain kar dunga — desi andaz mein.</div>
<div style="margin-top:16px;display:flex;flex-direction:column;gap:6px;text-align:left;width:100%;max-width:260px">
<div style="font-size:12px;color:var(--text-muted);display:flex;gap:6px;align-items:center;">
<span style="color:var(--green)">✓</span> Error ka cause samjhata hai
</div>
<div style="font-size:12px;color:var(--text-muted);display:flex;gap:6px;align-items:center;">
<span style="color:var(--green)">✓</span> Desi analogy se concept clear hota hai
</div>
<div style="font-size:12px;color:var(--text-muted);display:flex;gap:6px;align-items:center;">
<span style="color:var(--green)">✓</span> Fixed code ke saath line-by-line fix
</div>
<div style="font-size:12px;color:var(--text-muted);display:flex;gap:6px;align-items:center;">
<span style="color:var(--green)">✓</span> Next step batata hai kya seekhna hai
</div>
</div>
</div>
<!-- Output content -->
<div class="output-content" id="output-content" aria-live="polite" aria-atomic="false">
<!-- Repeat error banner -->
<div class="repeat-banner" id="repeat-banner" style="display:none;margin:12px 22px 0;">
<span class="repeat-banner-icon">⚠️</span>
<span id="repeat-banner-text">You have seen this error before — let's go deeper this time.</span>
</div>
<!-- Error Type Badge -->
<div class="result-card" id="card-type">
<div class="card-label" style="color:var(--red)">🔴 Error Identified</div>
<div class="error-badge-row">
<span class="error-type-badge" id="out-error-type">—</span>
<span class="severity-badge" id="out-severity">—</span>
</div>
</div>
<!-- Plain Explanation -->
<div class="result-card" id="card-explain">
<div class="card-label" style="color:var(--amber)">💬 Kya Hua — Roman Urdu Mein</div>
<div class="explanation-text" id="out-explanation">—</div>
</div>
<!-- Understood + Share row -->
<div class="result-card" style="padding:10px 22px;">
<div class="understood-row">
<span class="understood-label">Did you understand this?</span>
<button type="button" class="understood-btn yes" onclick="markUnderstood(true)" id="understood-yes">👍 Yes</button>
<button type="button" class="understood-btn no" onclick="markUnderstood(false)" id="understood-no">👎 No</button>
<button type="button" class="copy-btn" onclick="openShareCard()" style="margin-left:auto">📤 Share</button>
</div>
<div class="understood-stats" id="understood-stats" style="display:none"></div>
</div>
<!-- Desi Analogy -->
<div class="result-card" id="card-analogy">
<div class="card-label" style="color:var(--green)">🫖 Desi Analogy</div>
<div class="analogy-box" id="out-analogy">—</div>
</div>
<!-- Fixed Code -->
<div class="result-card" id="card-fix">
<div class="card-label" style="color:var(--blue)">🔧 Fixed Code</div>
<div class="code-block-wrap">
<div class="code-block-header">
<span class="code-block-title" id="out-fix-lang">fixed_code.py</span>
<div style="display:flex;gap:6px;">
<button class="copy-btn" id="run-code-btn" onclick="runCodeSandbox()" style="background:var(--green);color:white;">▶ Run Code</button>
<button class="copy-btn" id="diff-toggle-btn" onclick="toggleDiffView()">Show Diff</button>
<button class="copy-btn" id="copy-btn" onclick="copyCode()">Copy</button>
<button class="copy-btn" id="download-btn" onclick="downloadCode()">Download</button>
</div>
</div>
<div id="code-diff-view" style="display:none;"></div>
<pre><code id="out-fixed-code" class="language-python"></code></pre>
</div>
</div>
<!-- Code Execution Output -->
<div class="result-card" id="card-execution" style="display:none;">
<div class="card-label" style="color:var(--green)">▶ Code Execution Result</div>
<div class="execution-output" id="execution-output">
<div class="execution-loading" id="execution-loading" style="display:none;">
<div class="spinner"></div>
Running code...
</div>
<pre id="execution-result" style="display:none;"></pre>
</div>
</div>
<!-- Fix Explanation -->
<div class="result-card" id="card-fix-explain">
<div class="card-label" style="color:var(--amber)">📋 Kya Change Kiya — Line by Line</div>
<ul class="fix-list" id="out-fix-list"></ul>
</div>
<!-- Concept to Study -->
<div class="result-card" id="card-concept">
<div class="card-label" style="color:var(--purple)">📚 Aab Yeh Seekho</div>
<div class="concept-card">
<div class="concept-name" id="out-concept-name">—</div>
<div style="font-size:12px;color:var(--text-muted);margin-bottom:8px;" id="out-concept-why">—</div>
<a class="concept-search" id="out-concept-link" href="#" target="_blank">YouTube / Google pe search karo</a>
</div>
</div>
<!-- Similar errors suggestion -->
<div class="result-card" id="card-similar" style="display:none">
<div class="similar-errors-title">📊 Pattern Detected</div>
<div class="similar-errors-card" id="similar-errors-text"></div>
</div>
</div>
</div>
</main>
<!-- ═══════════════════════════════════════════
BOTTOM BAR: HISTORY + PATTERNS
════════════════════════════════════════════ -->
<div class="bottom-bar">
<div class="tabs">
<button class="tab-btn active" onclick="switchTab('history', this)">📋 Session History</button>
<button class="tab-btn" onclick="switchTab('patterns', this)">📊 Tumhare Common Mistakes</button>
<button class="tab-btn" onclick="switchTab('tips', this)">💡 Tips</button>
</div>
<div class="tab-panel active" id="tab-history">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;">
<span style="font-size:12px;color:var(--text-muted);">History ke saath wapas swipe kar sakte ho.</span>
<button type="button" id="clear-history-btn" class="copy-btn" style="font-size:11px;">Clear History</button>
</div>
<div class="history-empty" id="history-empty">Abhi koi query nahi. Pehle koi code analyze karo!</div>
<div class="history-list hidden" id="history-list"></div>
</div>
<div class="tab-panel" id="tab-patterns">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
<div style="display:flex;gap:8px;align-items:center;">
<span style="font-size:12px;color:var(--text-muted);">Filter by date:</span>
<input type="date" id="pattern-date-filter" style="font-size:11px;padding:4px 8px;border:1px solid var(--border);border-radius:4px;background:var(--bg-surface);color:var(--text-primary);">
<button type="button" onclick="clearDateFilter()" class="copy-btn" style="font-size:11px;">Clear</button>
</div>
<button type="button" onclick="exportPatterns()" class="copy-btn" style="font-size:11px;">Export CSV</button>
</div>
<div id="no-patterns" class="no-patterns">Patterns track hone ke liye pehle kuch errors analyze karo.</div>
<div class="pattern-grid hidden" id="pattern-grid"></div>
</div>
<div class="tab-panel" id="tab-tips">
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:10px">
<div style="background:var(--bg-elevated);border-radius:var(--radius-sm);padding:12px;border:1px solid var(--border)">
<div style="font-size:11px;font-weight:700;color:var(--amber);margin-bottom:5px">PRO TIP #1</div>
<div style="font-size:12px;color:var(--text-secondary);line-height:1.6">Error message copy karo puri — sirf code se zyada helpful hota hai diagnosis mein.</div>
</div>
<div style="background:var(--bg-elevated);border-radius:var(--radius-sm);padding:12px;border:1px solid var(--border)">
<div style="font-size:11px;font-weight:700;color:var(--green);margin-bottom:5px">PRO TIP #2</div>
<div style="font-size:12px;color:var(--text-secondary);line-height:1.6">Fix blindly mat karo — pehle "Kya Hua" wali explanation padhna. Understanding zaroori hai.</div>
</div>
<div style="background:var(--bg-elevated);border-radius:var(--radius-sm);padding:12px;border:1px solid var(--border)">
<div style="font-size:11px;font-weight:700;color:var(--purple);margin-bottom:5px">PRO TIP #3</div>
<div style="font-size:12px;color:var(--text-secondary);line-height:1.6">"Aab Yeh Seekho" section ignore mat karo — woh tumhara actual weak point hai.</div>
</div>
<div style="background:var(--bg-elevated);border-radius:var(--radius-sm);padding:12px;border:1px solid var(--border)">
<div style="font-size:11px;font-weight:700;color:var(--blue);margin-bottom:5px">PRO TIP #4</div>
<div style="font-size:12px;color:var(--text-secondary);line-height:1.6">Pattern tab dekho regularly — agar ek hi type ka error baar baar ho raha hai, toh concept gap hai.</div>
</div>
</div>
</div>
<!-- Waitlist + Referral -->
<div class="waitlist-section">
<div class="waitlist-section-child">
<div class="waitlist-label">⭐ Get Pro free — join early access waitlist</div>
<div class="waitlist-row">
<input type="email" class="waitlist-input" id="waitlist-email" placeholder="your@email.com"/>
<button type="button" class="waitlist-btn" onclick="joinWaitlist()">Join Waitlist</button>
</div>
<button type="button" class="referral-btn" onclick="shareOnWhatsApp()">📱 Share CodeDost on WhatsApp</button>
</div>
</div>
</div>
<!-- ═══════════════════════════════════════════
FOOTER
════════════════════════════════════════════ -->
<footer class="footer">
Built with <span>❤</span> for Pakistani CS students · CodeDost v1.0 · Powered by Groq (Free) + Llama 3
</footer>
<!-- ═══════════════════════════════════════════
API KEY MODAL
════════════════════════════════════════════ -->
<div class="modal-overlay" id="modal-overlay" onclick="closeModalOutside(event)">
<div class="modal">
<h2>🔑 Free API Key Setup</h2>
<p>Neeche se koi bhi ek provider choose karo — sab free hain, credit card nahi chahiye.</p>
<!-- Provider tabs -->
<div style="display:flex;gap:4px;background:var(--bg-surface);border:1px solid var(--border);border-radius:8px;padding:3px;margin-bottom:16px">
<button id="ptab-groq" class="provider-tab active-tab" onclick="setProvider('groq')">⚡ Groq (Best)</button>
<button id="ptab-gemini" class="provider-tab" onclick="setProvider('gemini')">💎 Gemini</button>
<button id="ptab-openrouter" class="provider-tab" onclick="setProvider('openrouter')">🔀 OpenRouter</button>
</div>
<!-- Groq -->
<div id="provider-groq" class="provider-info">
<div style="background:rgba(16,185,129,0.08);border:1px solid rgba(16,185,129,0.2);border-radius:8px;padding:10px 12px;margin-bottom:12px">
<div style="font-size:11px;font-weight:700;color:#10b981;margin-bottom:4px">✓ 100% FREE · No credit card · Fastest response</div>
<div style="font-size:12px;color:var(--text-secondary);line-height:1.6">
1. <a href="https://console.groq.com" target="_blank" style="color:var(--amber)">console.groq.com</a> pe jao<br>
2. Sign up (Google se bhi ho sakta hai)<br>
3. "API Keys" → "Create API Key" click karo<br>
4. Key copy karo aur yahan paste karo
</div>
</div>
<input class="modal-input" type="password" id="key-groq" placeholder="gsk_..." autocomplete="off"/>
</div>
<!-- Gemini -->
<div id="provider-gemini" class="provider-info" style="display:none">
<div style="background:rgba(96,165,250,0.08);border:1px solid rgba(96,165,250,0.2);border-radius:8px;padding:10px 12px;margin-bottom:12px">
<div style="font-size:11px;font-weight:700;color:#60a5fa;margin-bottom:4px">✓ 100% FREE · Google ka product · Reliable</div>
<div style="font-size:12px;color:var(--text-secondary);line-height:1.6">
1. <a href="https://aistudio.google.com/apikey" target="_blank" style="color:var(--amber)">aistudio.google.com/apikey</a> pe jao<br>
2. Google account se login karo<br>
3. "Create API Key" click karo<br>
4. Key copy karo aur yahan paste karo
</div>
</div>
<input class="modal-input" type="password" id="key-gemini" placeholder="AIza..." autocomplete="off"/>
</div>
<!-- OpenRouter -->
<div id="provider-openrouter" class="provider-info" style="display:none">
<div style="background:rgba(167,139,250,0.08);border:1px solid rgba(167,139,250,0.2);border-radius:8px;padding:10px 12px;margin-bottom:12px">
<div style="font-size:11px;font-weight:700;color:#a78bfa;margin-bottom:4px">✓ Free models available · Multiple AI models</div>
<div style="font-size:12px;color:var(--text-secondary);line-height:1.6">
1. <a href="https://openrouter.ai/keys" target="_blank" style="color:var(--amber)">openrouter.ai/keys</a> pe jao<br>
2. Sign up karo (free)<br>
3. "Create Key" click karo<br>
4. Key copy karo aur yahan paste karo
</div>
</div>
<input class="modal-input" type="password" id="key-openrouter" placeholder="sk-or-..." autocomplete="off"/>
</div>
<button class="modal-save" onclick="saveApiKey()">Key Save Karo ✓</button>
<div class="modal-note" style="margin-top:10px">Key sirf tumhare browser mein save hoti hai · Kahi send nahi hoti</div>
</div>
</div>
<!-- SHARE CARD MODAL -->
<div class="share-card-modal" id="share-card-modal" onclick="closeShareCard(event)">
<div class="share-card-preview" id="share-card-dom">
<div class="sc-header">
<div class="sc-logo-box">{}</div>
<div class="sc-brand">CodeDost — AI Coding Tutor</div>
</div>
<div class="sc-body">
<div class="sc-error-row">
<span class="error-type-badge" id="sc-error-type">—</span>
<span class="severity-badge" id="sc-severity">—</span>
</div>
<div class="sc-explain" id="sc-explanation">—</div>
<div class="sc-analogy" id="sc-analogy">—</div>
</div>
<div class="sc-footer">
<span class="sc-url">code-dost.vercel.app</span>
<span class="sc-cta">Free · Roman Urdu · No Login</span>
</div>
</div>
<div class="share-modal-btns">
<button class="share-dl-btn" onclick="downloadShareCard()">⬇ Download Image</button>
<button class="share-close-btn" onclick="closeShareCard()">Close</button>
</div>
</div>
<!-- HELP / SHORTCUTS MODAL -->
<div class="help-modal" id="help-modal" onclick="closeHelpModal(event)">
<div class="help-modal-inner">
<div class="help-modal-header">
<span class="help-modal-title">⌨️ Keyboard Shortcuts</span>
<button class="help-modal-close" onclick="closeHelpModal()">✕</button>
</div>
<table class="shortcuts-table">
<tr><td>Ctrl + Enter</td><td>Submit code for analysis</td></tr>
<tr><td>Escape</td><td>Close any modal</td></tr>
<tr><td>Tab (in editor)</td><td>Insert 2 spaces</td></tr>
<tr><td>? (this button)</td><td>Open shortcuts help</td></tr>
</table>
<div style="margin-top:14px;padding-top:14px;border-top:1px solid var(--border)">
<div style="font-size:11px;font-weight:700;color:var(--amber);margin-bottom:8px">QUICK LINKS</div>
<div style="display:flex;flex-direction:column;gap:6px">
<a href="https://code-dost.vercel.app" target="_blank" style="font-size:12px;color:var(--blue);text-decoration:none">🌐 code-dost.vercel.app ↗</a>
<a href="https://github.com/sheraz91-ops/CodeDost" target="_blank" style="font-size:12px;color:var(--blue);text-decoration:none">⭐ GitHub Repository ↗</a>
<a href="https://sherazramzan.gumroad.com/l/cfevjo" target="_blank" style="font-size:12px;color:var(--amber);text-decoration:none">💳 Pro Plan — $0.99/month ↗</a>
<a href="glossary.html" target="_blank" style="font-size:12px;color:var(--green);text-decoration:none">📚 Error Glossary ↗</a>
</div>
</div>
</div>
</div>
<!-- ═══════════════════════════════════════════
AUTH MODAL (Complete: Login, Register, Forgot, Reset)
════════════════════════════════════════════ -->
<div class="modal-overlay" id="auth-modal-overlay" onclick="closeAuthModalOutside(event)" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.7);z-index:1000;display:flex;align-items:center;justify-content:center;">
<div class="modal" style="max-width:380px;width:90%;">
<h2 id="auth-modal-title">👤 Login to CodeDost</h2>
<!-- TABS: Login / Register / Forgot -->
<div style="display:flex;gap:4px;background:var(--bg-surface);border:1px solid var(--border);border-radius:8px;padding:3px;margin-bottom:16px;">
<button id="auth-tab-login" class="provider-tab active-tab" onclick="switchAuthTab('login')">Login</button>
<button id="auth-tab-register" class="provider-tab" onclick="switchAuthTab('register')">Sign Up</button>
<button id="auth-tab-forgot" class="provider-tab" onclick="switchAuthTab('forgot')">Forgot?</button>
</div>
<!-- ── LOGIN FORM ────────────────────── -->
<div id="auth-form-login">
<input class="modal-input" type="email" id="auth-email-login" placeholder="Email address" style="margin-bottom:8px;"/>
<input class="modal-input" type="password" id="auth-pass-login" placeholder="Password" style="margin-bottom:8px;"/>
<div style="text-align: right; font-size: 11px;">
<a onclick="switchAuthTab('forgot')" style="color:var(--blue); cursor:pointer; text-decoration:none;">
Forgot password?
</a>
</div>
</div>
<!-- ── REGISTER FORM ────────────────── -->
<div id="auth-form-register" style="display:none;">
<input class="modal-input" type="text" id="auth-name-register" placeholder="Your name" style="margin-bottom:8px;"/>
<input class="modal-input" type="email" id="auth-email-register" placeholder="Email address" style="margin-bottom:8px;"/>
<input class="modal-input" type="password" id="auth-pass-register" placeholder="Password (min 8 chars)" style="margin-bottom:8px;"/>
<input class="modal-input" type="text" id="auth-university-register" placeholder="University name (optional)"/>
</div>
<!-- ── FORGOT PASSWORD FORM ─────────── -->
<div id="auth-form-forgot" style="display:none;">
<input class="modal-input" type="email" id="auth-email-forgot" placeholder="Enter your email address" style="margin-bottom:8px;"/>
<div style="font-size:12px;color:var(--text-muted);text-align:center;">
We'll send you a reset link via email.
</div>
</div>
<!-- ── RESET PASSWORD FORM ──────────── -->
<div id="auth-form-reset" style="display:none;">
<input class="modal-input" type="password" id="auth-pass-reset-new" placeholder="New password" style="margin-bottom:8px;"/>
<input class="modal-input" type="password" id="auth-pass-reset-confirm" placeholder="Confirm password" style="margin-bottom:8px;"/>
<div style="font-size:11px;color:var(--text-muted);" id="password-strength">
Strength: <span id="strength-text">Weak</span>
</div>
</div>
<!-- ERROR MESSAGE -->
<div class="modal-note" id="auth-error-msg" style="color:var(--red);margin-top:8px;display:none;"></div>
<!-- SUCCESS MESSAGE -->
<div class="modal-note" id="auth-success-msg" style="color:var(--green);margin-top:8px;display:none;"></div>
<!-- SUBMIT BUTTON -->
<button class="modal-save" id="auth-submit-btn" onclick="submitAuth()" style="margin-top:12px;">Login</button>
<div class="modal-note" style="margin-top:8px;">Data secure · Encrypted connection</div>
</div>
</div>
<!-- ═════════════════════════════��═════════════
TOAST
════���═══════════════════════════════════════ -->
<div class="toast" id="toast" role="status" aria-live="polite" aria-atomic="true">
<div class="toast-dot"></div>
<span id="toast-msg">—</span>
</div>
<!-- ════════���══════════════════════════════════
SCRIPTS
════════════════════════════════════════════ -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-javascript.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-java.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-c.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-cpp.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-sql.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/diff@5.1.0/dist/diff.min.js"></script>
<script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script>
<script src="codedost.js"></script>
<script src="/codedost/js/hamburger.js"></script>
<!-- AUTH MODAL -->
<!-- <div class="modal-overlay" id="auth-modal-overlay" onclick="closeAuthModalOutside(event)" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.7);z-index:1000;display:flex;align-items:center;justify-content:center;">
<div class="modal" style="max-width:380px;width:90%;">
<h2 id="auth-modal-title">👤 Login to CodeDost</h2>
<div style="display:flex;gap:4px;background:var(--bg-surface);border:1px solid var(--border);border-radius:8px;padding:3px;margin-bottom:16px">
<button id="auth-tab-login" class="provider-tab active-tab" onclick="switchAuthTab('login')">Login</button>
<button id="auth-tab-register" class="provider-tab" onclick="switchAuthTab('register')">Sign Up</button>
</div>
<div id="auth-form-login">
<input class="modal-input" type="email" id="auth-email-login" placeholder="Email address" style="margin-bottom:8px;"/>
<input class="modal-input" type="password" id="auth-pass-login" placeholder="Password"/>
</div>
<div id="auth-form-register" style="display:none;">
<input class="modal-input" type="text" id="auth-name-register" placeholder="Your name" style="margin-bottom:8px;"/>
<input class="modal-input" type="email" id="auth-email-register" placeholder="Email address" style="margin-bottom:8px;"/>
<input class="modal-input" type="password" id="auth-pass-register" placeholder="Password (min 6 chars)"/>
</div>
<button class="modal-save" id="auth-submit-btn" onclick="submitAuth()" style="margin-top:12px;">Login</button>
<div class="modal-note" id="auth-error-msg" style="color:var(--red);margin-top:8px;display:none;"></div>
<div class="modal-note" style="margin-top:8px;">Data secure hai · Sirf quota track karne ke liye</div>
</div>
</div> -->
<!-- AUTO VERIFY EMAIL ON PAGE LOAD -->
<script>
(function checkEmailVerification() {
const params = new URLSearchParams(window.location.search);
const verifyToken = params.get('verify_token') || params.get('token');
console.log(verifyToken);
if (verifyToken) {
verifyEmailToken(verifyToken);
}
})();
async function verifyEmailToken(token) {
const BACKEND_URL = 'https://codedost-backend-production.up.railway.app';
try {
const res = await fetch(`${BACKEND_URL}/api/auth/verify-email?token=${token}`, {
method: 'GET',
credentials: 'include'
});
const data = await res.json();
console.log(data)
if (data.success) {
authToken = data.accessToken || data.token || authToken;
currentUser = data.user;
localStorage.setItem('cd_auth_token', authToken);
localStorage.setItem('cd_user', JSON.stringify(currentUser));
updateAuthUI();
showToast('success', '✅ Email verified! Welcome to CodeDost!');
// Clean URL
window.history.replaceState({}, document.title, 'codedost.html');
} else {
showToast('error', '❌ Email verification failed: ' + data.message);
}
} catch (error) {
console.error('Verification error:', error);
showToast('error', 'Email verification error');
}
}
// AUTO OPEN RESET PASSWORD ON PAGE LOAD
(function checkPasswordReset() {
const params = new URLSearchParams(window.location.search);
const resetToken = params.get('reset_token');
if (resetToken) {
openAuthModal();
setTimeout(() => {
switchAuthTab('reset');
}, 100);
}
})();
</script>
</body>
</html>