-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
635 lines (555 loc) · 35.8 KB
/
Copy pathindex.html
File metadata and controls
635 lines (555 loc) · 35.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Coding to Image Generator</title>
<!-- PWA Meta Tags -->
<meta name="description" content="Transform your code snippets into beautiful, shareable images with syntax highlighting">
<meta name="theme-color" content="#6366f1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="CodeSnap">
<meta name="mobile-web-app-capable" content="yes">
<!-- PWA Manifest -->
<link rel="manifest" href="manifest.json">
<!-- Apple Touch Icon -->
<link rel="apple-touch-icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><rect fill='%236366f1' width='512' height='512' rx='100'/><text x='50%25' y='50%25' font-size='280' fill='white' text-anchor='middle' dy='.35em' font-family='monospace'></></text></svg>">
<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><rect fill='%236366f1' width='512' height='512' rx='100'/><text x='50%25' y='50%25' font-size='280' fill='white' text-anchor='middle' dy='.35em' font-family='monospace'></></text></svg>">
<script src="https://cdn.tailwindcss.com"></script>
<!-- Prism.js Base and Themes -->
<link id="prism-theme" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet" />
<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/plugins/autoloader/prism-autoloader.min.js"></script>
<!-- html2canvas -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<style>
/* Loading 10 Professional Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=JetBrains+Mono:wght@400;500&family=Plus+Jakarta+Sans:wght@400;600;800&family=Source+Code+Pro:wght@400;500&family=Space+Mono&family=Roboto+Mono&family=Ubuntu+Mono&family=Inconsolata&family=IBM+Plex+Mono&family=Cascadia+Code&display=swap');
body {
font-family: 'Plus Jakarta Sans', sans-serif;
background: #020202;
color: #fff;
overflow-x: hidden;
}
#export-container {
display: inline-block;
background: linear-gradient(135deg, #6366f1, #a855f7);
padding: 60px;
border-radius: 4px;
transition: padding 0.2s ease;
}
.code-window {
background: #1e1e2e;
border-radius: 12px;
box-shadow: 0 40px 120px rgba(0,0,0,0.7);
overflow: hidden;
min-width: 450px;
border: 1px solid rgba(255,255,255,0.08);
display: flex;
flex-direction: column;
}
.window-header {
height: 48px;
padding: 0 20px;
display: flex;
align-items: center;
justify-content: space-between;
background: rgba(0,0,0,0.15);
border-bottom: 1px solid rgba(255,255,255,0.03);
}
.dots { display: flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
#lang-tag {
font-size: 11px;
font-weight: 900;
text-transform: uppercase;
letter-spacing: 0.15em;
padding: 0;
background: transparent;
border: none;
white-space: nowrap;
display: inline-block;
line-height: 1;
}
pre[class*="language-"] {
margin: 0 !important;
padding: 24px !important;
background: transparent !important;
line-height: 1.6;
}
#toast {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%) translateY(200%);
z-index: 9999;
background: #4f46e5;
color: white;
padding: 12px 32px;
border-radius: 100px;
font-weight: 800;
box-shadow: 0 10px 25px rgba(0,0,0,0.5);
transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#toast.visible { transform: translateX(-50%) translateY(0); }
input[type="range"] { accent-color: #a855f7; }
.grad-btn { transition: transform 0.2s; cursor: pointer; border: 2px solid transparent; width: 100%; height: 32px; border-radius: 8px; }
.grad-btn:hover { transform: scale(1.05); }
.color-input-wrapper {
position: relative;
width: 100%;
height: 36px;
border-radius: 10px;
overflow: hidden;
border: 1px solid rgba(255,255,255,0.15);
}
.color-input-wrapper input[type="color"] {
position: absolute;
top: -5px;
left: -5px;
width: calc(100% + 10px);
height: calc(100% + 10px);
cursor: pointer;
background: transparent;
border: none;
}
/* Sidebar custom scrollbar */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }
/* PWA Install Banner */
#install-banner {
display: none;
position: fixed;
bottom: 80px;
left: 50%;
transform: translateX(-50%);
background: linear-gradient(135deg, #6366f1, #a855f7);
padding: 12px 24px;
border-radius: 16px;
box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
z-index: 9998;
animation: slideUp 0.5s ease-out;
}
@keyframes slideUp {
from { transform: translateX(-50%) translateY(100%); opacity: 0; }
to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
#install-banner.show { display: flex; align-items: center; gap: 16px; }
/* Offline indicator */
#offline-indicator {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
background: #ef4444;
color: white;
text-align: center;
padding: 8px;
font-size: 12px;
font-weight: bold;
z-index: 10000;
}
#offline-indicator.show { display: block; }
</style>
</head>
<body class="min-h-screen flex flex-col lg:flex-row">
<!-- Offline Indicator -->
<div id="offline-indicator">📡 You're offline - Changes may not be saved</div>
<!-- PWA Install Banner -->
<div id="install-banner">
<span class="text-sm font-bold">📱 Install CodeSnap</span>
<button onclick="installPWA()" class="bg-white text-indigo-600 px-4 py-2 rounded-lg text-xs font-bold hover:bg-gray-100">Install</button>
<button onclick="hideInstallBanner()" class="text-white/70 hover:text-white text-lg">×</button>
</div>
<!-- Mobile Header -->
<div class="lg:hidden p-4 bg-zinc-900 border-b border-white/5 flex justify-between items-center sticky top-0 z-[60]">
<h1 class="text-lg font-black bg-gradient-to-r from-indigo-400 to-purple-500 bg-clip-text text-transparent uppercase tracking-tighter">Code Snap</h1>
<button onclick="toggleSidebar()" class="p-2 bg-zinc-800 rounded-lg">⚙️</button>
</div>
<!-- SIDEBAR -->
<aside id="sidebar" class="fixed inset-y-0 left-0 z-50 w-full lg:w-[400px] bg-[#080808] border-r border-white/5 p-6 overflow-y-auto transition-transform -translate-x-full lg:translate-x-0 lg:static">
<div class="mb-8">
<h1 class="text-xl font-black bg-gradient-to-r from-indigo-400 to-purple-500 bg-clip-text text-transparent uppercase tracking-tighter">Code to Image</h1>
<p class="text-[9px] text-zinc-500 font-bold tracking-[0.2em] uppercase">V2 Professional Suite • PWA</p>
</div>
<div class="space-y-6">
<!-- Language and Font Selection -->
<div class="grid grid-cols-2 gap-4">
<div class="space-y-1">
<label class="text-[10px] font-bold text-zinc-500 uppercase">Language</label>
<select id="lang-select" onchange="onLanguageChange()" class="w-full bg-zinc-900 border border-white/10 rounded-xl p-3 text-xs outline-none focus:border-indigo-500">
<option value="javascript">JavaScript</option>
<option value="typescript">TypeScript</option>
<option value="python">Python</option>
<option value="rust">Rust</option>
<option value="go">Go</option>
<option value="cpp">C++</option>
<option value="java">Java</option>
<option value="swift">Swift</option>
<option value="kotlin">Kotlin</option>
<option value="php">PHP</option>
<option value="sql">SQL</option>
<option value="css">CSS</option>
<option value="markup">HTML</option>
</select>
</div>
<div class="space-y-1">
<label class="text-[10px] font-bold text-zinc-500 uppercase">Font Family (10)</label>
<select id="font-select" onchange="updateStyle()" class="w-full bg-zinc-900 border border-white/10 rounded-xl p-3 text-xs outline-none focus:border-indigo-500">
<option value="'JetBrains Mono'">JetBrains Mono</option>
<option value="'Fira Code'">Fira Code</option>
<option value="'Source Code Pro'">Source Code Pro</option>
<option value="'Space Mono'">Space Mono</option>
<option value="'Roboto Mono'">Roboto Mono</option>
<option value="'Ubuntu Mono'">Ubuntu Mono</option>
<option value="'Inconsolata'">Inconsolata</option>
<option value="'IBM Plex Mono'">IBM Plex Mono</option>
<option value="'Cascadia Code'">Cascadia Code</option>
<option value="monospace">System Mono</option>
</select>
</div>
</div>
<!-- Theme Selection -->
<div class="space-y-1">
<label class="text-[10px] font-bold text-zinc-500 uppercase">Syntax Theme (10)</label>
<select id="theme-select" onchange="applyTheme()" class="w-full bg-zinc-900 border border-white/10 rounded-xl p-3 text-xs outline-none focus:border-indigo-500">
<option value="tomorrow">Tomorrow Night</option>
<option value="dracula">Dracula</option>
<option value="okaidia">Okaidia</option>
<option value="nord">Nord</option>
<option value="night-owl">Night Owl</option>
<option value="twilight">Twilight</option>
<option value="vsc-dark-plus">VS Code Dark+</option>
<option value="shades-of-purple">Shades of Purple</option>
<option value="synthwave84">Synthwave '84</option>
<option value="atom-dark">Atom Dark</option>
</select>
</div>
<!-- Sliders -->
<div class="bg-zinc-900/50 p-4 rounded-2xl space-y-5 border border-white/5">
<div>
<div class="flex justify-between text-[10px] font-bold text-zinc-400 mb-2">FONT SIZE <span id="font-val" class="text-indigo-400">15px</span></div>
<input type="range" id="font-size" min="10" max="30" value="15" class="w-full" oninput="updateStyle()">
</div>
<div>
<div class="flex justify-between text-[10px] font-bold text-zinc-400 mb-2">PADDING <span id="pad-val" class="text-indigo-400">60px</span></div>
<input type="range" id="padding-ctrl" min="0" max="150" value="60" class="w-full" oninput="updateStyle()">
</div>
<div>
<div class="flex justify-between text-[10px] font-bold text-zinc-400 mb-2">SHADOW DEPTH <span id="shadow-val" class="text-indigo-400">80px</span></div>
<input type="range" id="shadow-ctrl" min="0" max="200" value="80" class="w-full" oninput="updateStyle()">
</div>
</div>
<!-- Color Pickers -->
<div class="grid grid-cols-2 gap-4">
<div class="space-y-2">
<label class="text-[10px] font-bold text-zinc-500 uppercase">Canvas Color</label>
<div class="color-input-wrapper">
<input type="color" id="bg-color-picker" value="#6366f1" oninput="setBg(this.value)">
</div>
</div>
<div class="space-y-2">
<label class="text-[10px] font-bold text-zinc-500 uppercase">Shadow Color</label>
<div class="color-input-wrapper">
<input type="color" id="shadow-color-picker" value="#000000" oninput="updateStyle()">
</div>
</div>
</div>
<!-- Background Presets -->
<div class="space-y-2">
<label class="text-[10px] font-bold text-zinc-500 uppercase">Canvas Presets</label>
<div class="grid grid-cols-5 gap-2">
<button onclick="setBg('linear-gradient(135deg, #6366f1, #a855f7)')" class="grad-btn bg-gradient-to-br from-indigo-500 to-purple-500"></button>
<button onclick="setBg('linear-gradient(135deg, #f97316, #ef4444)')" class="grad-btn bg-gradient-to-br from-orange-500 to-red-500"></button>
<button onclick="setBg('linear-gradient(135deg, #00f2fe, #4facfe)')" class="grad-btn bg-gradient-to-br from-cyan-400 to-blue-500"></button>
<button onclick="setBg('linear-gradient(135deg, #ee9ca7, #ffdde1)')" class="grad-btn bg-gradient-to-br from-pink-300 to-rose-200"></button>
<button onclick="setBg('linear-gradient(135deg, #2af598, #009efd)')" class="grad-btn bg-gradient-to-br from-emerald-400 to-sky-500"></button>
<button onclick="setBg('linear-gradient(135deg, #131313, #333333)')" class="grad-btn bg-gradient-to-br from-zinc-900 to-zinc-700"></button>
<button onclick="setBg('linear-gradient(135deg, #8e2de2, #4a00e0)')" class="grad-btn bg-gradient-to-br from-purple-600 to-indigo-700"></button>
<button onclick="setBg('linear-gradient(135deg, #f12711, #f5af19)')" class="grad-btn bg-gradient-to-br from-red-600 to-yellow-500"></button>
<button onclick="setBg('#000000')" class="grad-btn bg-black border border-white/10"></button>
<button onclick="setBg('#ffffff')" class="grad-btn bg-white border border-black/10"></button>
</div>
</div>
<div class="space-y-1">
<label class="text-[10px] font-bold text-zinc-500 uppercase">Source Code</label>
<textarea id="code-input" rows="6" class="w-full bg-black border border-white/10 rounded-xl p-3 text-xs font-mono outline-none focus:border-indigo-500" placeholder="Paste your code here..."></textarea>
</div>
<button onclick="updatePreview()" class="w-full bg-indigo-600 hover:bg-indigo-500 py-4 rounded-xl font-bold text-xs uppercase tracking-widest transition-all shadow-lg shadow-indigo-500/20 active:scale-[0.98]">Refresh Preview</button>
<div class="grid grid-cols-2 gap-3">
<button onclick="copyCode()" class="bg-zinc-900 border border-white/5 py-3 rounded-xl text-[10px] font-bold uppercase hover:bg-zinc-800">Copy Code</button>
<button onclick="downloadPNG()" id="dl-btn" class="bg-white text-black py-3 rounded-xl text-[10px] font-bold uppercase hover:bg-zinc-200">Export PNG</button>
</div>
</div>
</aside>
<!-- MAIN VIEW -->
<main class="flex-1 overflow-auto bg-[#050505] flex items-center justify-center p-8 pb-24 min-h-[600px]">
<div id="export-container">
<div class="code-window" id="window-element">
<div class="window-header">
<div class="dots">
<div class="dot bg-[#ff5f56]"></div>
<div class="dot bg-[#ffbd2e]"></div>
<div class="dot bg-[#27c93f]"></div>
</div>
<div id="lang-tag">javascript</div>
</div>
<pre id="pre-tag" class="language-javascript"><code id="code-display">function helloWorld() {
console.log("Ready to capture!");
}</code></pre>
</div>
</div>
</main>
<!-- FOOTER -->
<footer class="fixed bottom-0 left-0 right-0 lg:left-[400px] bg-[#0a0a0a] border-t border-white/5 py-3 px-6 z-40">
<div class="flex flex-col sm:flex-row items-center justify-between gap-3">
<!-- Developer Info -->
<div class="flex items-center gap-2">
<span class="text-zinc-500 text-xs">Made with</span>
<span class="text-red-500 animate-pulse">❤️</span>
<span class="text-xs font-bold bg-gradient-to-r from-indigo-400 to-purple-500 bg-clip-text text-transparent">Sudhir Kumar</span>
</div>
<!-- Social Media Icons -->
<div class="flex items-center gap-4">
<!-- GitHub -->
<a href="https://github.com/SudhirDevOps1" target="_blank" rel="noopener noreferrer" class="group" title="GitHub">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-white transition-colors" viewBox="0 0 24 24">
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
</svg>
</a>
<!-- LinkedIn -->
<a href="https://linkedin.com/in/sudhirkumar" target="_blank" rel="noopener noreferrer" class="group" title="LinkedIn">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-[#0A66C2] transition-colors" viewBox="0 0 24 24">
<path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/>
</svg>
</a>
<!-- Twitter/X -->
<a href="https://twitter.com/SudhirDevOps1" target="_blank" rel="noopener noreferrer" class="group" title="Twitter/X">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-white transition-colors" viewBox="0 0 24 24">
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/>
</svg>
</a>
<!-- Instagram -->
<a href="https://instagram.com/sudhirdevops" target="_blank" rel="noopener noreferrer" class="group" title="Instagram">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-[#E4405F] transition-colors" viewBox="0 0 24 24">
<path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"/>
</svg>
</a>
<!-- YouTube -->
<a href="https://youtube.com/@SudhirDevOps" target="_blank" rel="noopener noreferrer" class="group" title="YouTube">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-[#FF0000] transition-colors" viewBox="0 0 24 24">
<path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/>
</svg>
</a>
<!-- Discord -->
<a href="https://discord.gg/sudhirdevops" target="_blank" rel="noopener noreferrer" class="group" title="Discord">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-[#5865F2] transition-colors" viewBox="0 0 24 24">
<path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/>
</svg>
</a>
<!-- Telegram -->
<a href="https://t.me/SudhirDevOps" target="_blank" rel="noopener noreferrer" class="group" title="Telegram">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-[#26A5E4] transition-colors" viewBox="0 0 24 24">
<path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/>
</svg>
</a>
<!-- Email -->
<a href="mailto:sudhirdevops1@gmail.com" class="group" title="Email">
<svg class="w-5 h-5 fill-zinc-500 group-hover:fill-[#EA4335] transition-colors" viewBox="0 0 24 24">
<path d="M24 5.457v13.909c0 .904-.732 1.636-1.636 1.636h-3.819V11.73L12 16.64l-6.545-4.91v9.273H1.636A1.636 1.636 0 0 1 0 19.366V5.457c0-2.023 2.309-3.178 3.927-1.964L5.455 4.64 12 9.548l6.545-4.91 1.528-1.145C21.69 2.28 24 3.434 24 5.457z"/>
</svg>
</a>
</div>
</div>
</footer>
<div id="toast">Action Complete!</div>
<script>
// PWA Installation
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
setTimeout(() => {
document.getElementById('install-banner').classList.add('show');
}, 3000);
});
function installPWA() {
if (deferredPrompt) {
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
showToast('App installed successfully!');
}
deferredPrompt = null;
hideInstallBanner();
});
}
}
function hideInstallBanner() {
document.getElementById('install-banner').classList.remove('show');
}
// Offline detection
function updateOnlineStatus() {
const indicator = document.getElementById('offline-indicator');
if (navigator.onLine) {
indicator.classList.remove('show');
} else {
indicator.classList.add('show');
}
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
// Service Worker Registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('sw.js')
.then((registration) => {
console.log('SW registered:', registration.scope);
})
.catch((err) => console.log('SW registration failed:', err));
});
}
const LANG_COLORS = {
'javascript': '#F7DF1E', 'typescript': '#3178C6', 'python': '#3776AB',
'rust': '#DEA584', 'go': '#00ADD8', 'cpp': '#00599C',
'java': '#ED8B00', 'php': '#777BB4', 'sql': '#E38C00',
'css': '#1572B6', 'markup': '#E34F26', 'swift': '#F05138', 'kotlin': '#7F52FF'
};
const LANG_EXAMPLES = {
'javascript': 'function greet(name) {\n console.log(`Hello, ${name}!`);\n}\n\ngreet("CodeSnap");',
'typescript': 'interface User {\n id: number;\n name: string;\n}\n\nconst user: User = { id: 1, name: "Snap" };',
'python': 'def greet(name):\n print(f"Hello, {name}!")\n\ngreet("Pythonista")',
'rust': 'fn main() {\n println!("Hello, Rust!");\n}',
'go': 'package main\nimport "fmt"\n\nfunc main() {\n fmt.Println("Hello, Go")\n}',
'cpp': '#include <iostream>\n\nint main() {\n std::cout << "Hello C++" << std::endl;\n return 0;\n}',
'java': 'public class Main {\n public static void main(String[] args) {\n System.out.println("Hello Java");\n }\n}',
'swift': 'import Foundation\n\nlet message = "Hello Swift!"\nprint(message)',
'kotlin': 'fun main() {\n println("Hello Kotlin")\n}',
'php': '<?php\n$message = "Hello PHP";\necho $message;',
'sql': 'SELECT * FROM users\nWHERE status = "active"\nORDER BY created_at DESC;',
'css': '.container {\n display: flex;\n justify-content: center;\n background: #f0f0f0;\n}',
'markup': '<div class="card">\n <h1>Hello HTML</h1>\n <p>Standard markup example.</p>\n</div>'
};
const THEME_URLS = {
'tomorrow': 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css',
'dracula': 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-dracula.min.css',
'okaidia': 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-okaidia.min.css',
'nord': 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-nord.min.css',
'night-owl': 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-night-owl.min.css',
'twilight': 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css',
'vsc-dark-plus': 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-vsc-dark-plus.min.css',
'shades-of-purple': 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-shades-of-purple.min.css',
'synthwave84': 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-synthwave84.min.css',
'atom-dark': 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-atom-dark.min.css'
};
const THEME_BG = {
'tomorrow': '#1e1e2e', 'dracula': '#282a36', 'okaidia': '#272822', 'nord': '#2e3440',
'night-owl': '#011627', 'twilight': '#1f1f1f', 'vsc-dark-plus': '#1e1e1e',
'shades-of-purple': '#2d2b55', 'synthwave84': '#2b213a', 'atom-dark': '#1d1f21'
};
function toggleSidebar() { document.getElementById('sidebar').classList.toggle('-translate-x-full'); }
function showToast(msg) {
const t = document.getElementById('toast');
t.innerText = msg;
t.classList.add('visible');
setTimeout(() => t.classList.remove('visible'), 2000);
}
function hexToRgb(hex) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? `${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)}` : '0, 0, 0';
}
function updateStyle() {
const fs = document.getElementById('font-size').value;
const pad = document.getElementById('padding-ctrl').value;
const shadow = document.getElementById('shadow-ctrl').value;
const shadowColor = document.getElementById('shadow-color-picker').value;
const font = document.getElementById('font-select').value;
document.getElementById('font-val').innerText = fs + 'px';
document.getElementById('pad-val').innerText = pad + 'px';
document.getElementById('shadow-val').innerText = shadow + 'px';
const display = document.getElementById('code-display');
display.style.fontSize = fs + 'px';
display.style.fontFamily = font;
const shadowRgb = hexToRgb(shadowColor);
document.getElementById('export-container').style.padding = pad + 'px';
document.getElementById('window-element').style.boxShadow = `0 ${shadow/3}px ${shadow}px rgba(${shadowRgb}, 0.6)`;
}
function setBg(bg) {
document.getElementById('export-container').style.background = bg;
if(bg.startsWith('#')) document.getElementById('bg-color-picker').value = bg;
}
function applyTheme() {
const theme = document.getElementById('theme-select').value;
const link = document.getElementById('prism-theme');
link.href = THEME_URLS[theme];
document.getElementById('window-element').style.background = THEME_BG[theme];
setTimeout(updatePreview, 150);
}
function onLanguageChange() {
const lang = document.getElementById('lang-select').value;
document.getElementById('code-input').value = LANG_EXAMPLES[lang] || "";
updatePreview();
}
function updatePreview() {
const code = document.getElementById('code-input').value;
const lang = document.getElementById('lang-select').value;
const display = document.getElementById('code-display');
const pre = document.getElementById('pre-tag');
const tag = document.getElementById('lang-tag');
display.textContent = code.trim() ? code : (LANG_EXAMPLES[lang] || "");
tag.innerText = lang === 'markup' ? 'html' : lang;
tag.style.color = LANG_COLORS[lang] || '#fff';
pre.className = `language-${lang}`;
if (typeof Prism !== 'undefined') Prism.highlightElement(display);
updateStyle();
}
async function downloadPNG() {
const btn = document.getElementById('dl-btn');
const container = document.getElementById('export-container');
const originalContent = btn.innerText;
btn.innerText = 'Rendering...';
btn.disabled = true;
try {
await new Promise(r => setTimeout(r, 200));
const canvas = await html2canvas(container, {
scale: 3,
backgroundColor: null,
useCORS: true,
logging: false,
onclone: (clonedDoc) => {
const el = clonedDoc.getElementById('export-container');
el.style.display = 'inline-block';
}
});
const dataUrl = canvas.toDataURL("image/png");
const link = document.createElement('a');
link.download = `codesnap-${Date.now()}.png`;
link.href = dataUrl;
link.click();
showToast("Image Saved!");
} catch (err) {
console.error(err);
showToast("Capture Failed");
} finally {
btn.innerText = originalContent;
btn.disabled = false;
}
}
function copyCode() {
const code = document.getElementById('code-input').value || document.getElementById('code-display').textContent;
navigator.clipboard.writeText(code);
showToast("Code Copied!");
}
window.onload = () => {
const defaultLang = 'javascript';
document.getElementById('code-input').value = LANG_EXAMPLES[defaultLang];
applyTheme();
updatePreview();
updateOnlineStatus();
};
</script>
</body>
</html>