Multimedix commited on
Commit
a8dbaca
·
verified ·
1 Parent(s): ec54781

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +784 -19
index.html CHANGED
@@ -1,19 +1,784 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>GoLang Nexus | Developer Dashboard</title>
7
+ <!-- Importing Inter Font and Fira Code for that IDE look -->
8
+ <link rel="preconnect" href="https://fonts.googleapis.com">
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
11
+ <!-- Font Awesome for Icons -->
12
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
13
+
14
+ <style>
15
+ :root {
16
+ /* Go Brand Colors & Dark Theme Palette */
17
+ --go-cyan: #00ADD8;
18
+ --go-cyan-dim: #008bae;
19
+ --bg-dark: #0f1115;
20
+ --bg-panel: #161b22;
21
+ --bg-panel-hover: #21262d;
22
+ --border-color: #30363d;
23
+ --text-main: #c9d1d9;
24
+ --text-muted: #8b949e;
25
+ --success: #2ea043;
26
+ --code-bg: #0d1117;
27
+
28
+ /* Syntax Highlighting Colors */
29
+ --syntax-keyword: #ff7b72;
30
+ --syntax-func: #d2a8ff;
31
+ --syntax-string: #a5d6ff;
32
+ --syntax-comment: #8b949e;
33
+ --syntax-type: #79c0ff;
34
+
35
+ --sidebar-width: 260px;
36
+ --header-height: 60px;
37
+ --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
38
+ }
39
+
40
+ * {
41
+ margin: 0;
42
+ padding: 0;
43
+ box-sizing: border-box;
44
+ }
45
+
46
+ body {
47
+ font-family: 'Inter', sans-serif;
48
+ background-color: var(--bg-dark);
49
+ color: var(--text-main);
50
+ height: 100vh;
51
+ overflow: hidden;
52
+ display: flex;
53
+ flex-direction: column;
54
+ }
55
+
56
+ /* --- Scrollbar Styling --- */
57
+ ::-webkit-scrollbar {
58
+ width: 8px;
59
+ height: 8px;
60
+ }
61
+ ::-webkit-scrollbar-track {
62
+ background: var(--bg-dark);
63
+ }
64
+ ::-webkit-scrollbar-thumb {
65
+ background: var(--border-color);
66
+ border-radius: 4px;
67
+ }
68
+ ::-webkit-scrollbar-thumb:hover {
69
+ background: var(--text-muted);
70
+ }
71
+
72
+ /* --- Header --- */
73
+ header {
74
+ height: var(--header-height);
75
+ background-color: var(--bg-panel);
76
+ border-bottom: 1px solid var(--border-color);
77
+ display: flex;
78
+ align-items: center;
79
+ justify-content: space-between;
80
+ padding: 0 20px;
81
+ z-index: 100;
82
+ }
83
+
84
+ .brand {
85
+ display: flex;
86
+ align-items: center;
87
+ gap: 12px;
88
+ font-weight: 700;
89
+ font-size: 1.2rem;
90
+ color: #fff;
91
+ text-decoration: none;
92
+ }
93
+
94
+ .brand i {
95
+ color: var(--go-cyan);
96
+ font-size: 1.4rem;
97
+ }
98
+
99
+ .anycoder-link {
100
+ font-size: 0.8rem;
101
+ color: var(--text-muted);
102
+ text-decoration: none;
103
+ background: rgba(0, 173, 216, 0.1);
104
+ padding: 4px 8px;
105
+ border-radius: 4px;
106
+ transition: var(--transition);
107
+ border: 1px solid transparent;
108
+ }
109
+
110
+ .anycoder-link:hover {
111
+ color: var(--go-cyan);
112
+ border-color: var(--go-cyan);
113
+ background: rgba(0, 173, 216, 0.15);
114
+ }
115
+
116
+ .header-actions {
117
+ display: flex;
118
+ align-items: center;
119
+ gap: 15px;
120
+ }
121
+
122
+ .search-bar {
123
+ position: relative;
124
+ display: none; /* Hidden on small mobile */
125
+ }
126
+
127
+ @media (min-width: 768px) {
128
+ .search-bar { display: block; }
129
+ }
130
+
131
+ .search-bar input {
132
+ background: var(--bg-dark);
133
+ border: 1px solid var(--border-color);
134
+ padding: 8px 12px 8px 35px;
135
+ border-radius: 6px;
136
+ color: var(--text-main);
137
+ font-family: 'Inter', sans-serif;
138
+ font-size: 0.9rem;
139
+ width: 250px;
140
+ transition: var(--transition);
141
+ }
142
+
143
+ .search-bar input:focus {
144
+ outline: none;
145
+ border-color: var(--go-cyan);
146
+ width: 300px;
147
+ }
148
+
149
+ .search-bar i {
150
+ position: absolute;
151
+ left: 10px;
152
+ top: 50%;
153
+ transform: translateY(-50%);
154
+ color: var(--text-muted);
155
+ font-size: 0.8rem;
156
+ }
157
+
158
+ .user-avatar {
159
+ width: 32px;
160
+ height: 32px;
161
+ border-radius: 50%;
162
+ background: linear-gradient(45deg, var(--go-cyan), #4facfe);
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: center;
166
+ font-weight: bold;
167
+ color: #fff;
168
+ cursor: pointer;
169
+ }
170
+
171
+ /* --- Main Layout --- */
172
+ .layout {
173
+ display: flex;
174
+ flex: 1;
175
+ overflow: hidden;
176
+ }
177
+
178
+ /* --- Sidebar --- */
179
+ aside {
180
+ width: var(--sidebar-width);
181
+ background-color: var(--bg-panel);
182
+ border-right: 1px solid var(--border-color);
183
+ display: flex;
184
+ flex-direction: column;
185
+ padding: 20px 0;
186
+ transition: var(--transition);
187
+ }
188
+
189
+ .nav-group {
190
+ margin-bottom: 25px;
191
+ }
192
+
193
+ .nav-title {
194
+ padding: 0 20px;
195
+ font-size: 0.75rem;
196
+ text-transform: uppercase;
197
+ letter-spacing: 1px;
198
+ color: var(--text-muted);
199
+ margin-bottom: 10px;
200
+ font-weight: 600;
201
+ }
202
+
203
+ .nav-item {
204
+ display: flex;
205
+ align-items: center;
206
+ gap: 12px;
207
+ padding: 10px 20px;
208
+ color: var(--text-main);
209
+ text-decoration: none;
210
+ transition: var(--transition);
211
+ border-left: 3px solid transparent;
212
+ cursor: pointer;
213
+ }
214
+
215
+ .nav-item:hover {
216
+ background-color: var(--bg-panel-hover);
217
+ color: #fff;
218
+ }
219
+
220
+ .nav-item.active {
221
+ background-color: rgba(0, 173, 216, 0.1);
222
+ color: var(--go-cyan);
223
+ border-left-color: var(--go-cyan);
224
+ }
225
+
226
+ .nav-item i {
227
+ width: 20px;
228
+ text-align: center;
229
+ }
230
+
231
+ /* --- Content Area --- */
232
+ main {
233
+ flex: 1;
234
+ display: flex;
235
+ flex-direction: column;
236
+ position: relative;
237
+ background-color: var(--bg-dark);
238
+ }
239
+
240
+ .toolbar {
241
+ height: 50px;
242
+ border-bottom: 1px solid var(--border-color);
243
+ display: flex;
244
+ align-items: center;
245
+ justify-content: space-between;
246
+ padding: 0 20px;
247
+ background: var(--bg-dark);
248
+ }
249
+
250
+ .file-info {
251
+ display: flex;
252
+ align-items: center;
253
+ gap: 10px;
254
+ font-family: 'Fira Code', monospace;
255
+ font-size: 0.9rem;
256
+ color: var(--text-muted);
257
+ }
258
+
259
+ .file-info i { color: var(--go-cyan); }
260
+
261
+ .run-btn {
262
+ background-color: var(--success);
263
+ color: white;
264
+ border: none;
265
+ padding: 8px 16px;
266
+ border-radius: 6px;
267
+ font-weight: 600;
268
+ cursor: pointer;
269
+ display: flex;
270
+ align-items: center;
271
+ gap: 8px;
272
+ transition: var(--transition);
273
+ box-shadow: 0 4px 12px rgba(46, 160, 67, 0.3);
274
+ }
275
+
276
+ .run-btn:hover {
277
+ background-color: #2c974b;
278
+ transform: translateY(-1px);
279
+ }
280
+
281
+ .run-btn:active {
282
+ transform: translateY(1px);
283
+ }
284
+
285
+ /* --- Editor & Output Split --- */
286
+ .workspace {
287
+ display: flex;
288
+ flex: 1;
289
+ overflow: hidden;
290
+ }
291
+
292
+ .editor-pane, .output-pane {
293
+ flex: 1;
294
+ display: flex;
295
+ flex-direction: column;
296
+ overflow: hidden;
297
+ position: relative;
298
+ }
299
+
300
+ .editor-pane {
301
+ border-right: 1px solid var(--border-color);
302
+ }
303
+
304
+ .pane-header {
305
+ padding: 10px 20px;
306
+ background: var(--bg-panel);
307
+ font-size: 0.8rem;
308
+ color: var(--text-muted);
309
+ border-bottom: 1px solid var(--border-color);
310
+ display: flex;
311
+ justify-content: space-between;
312
+ }
313
+
314
+ /* Code Editor Simulation */
315
+ .code-container {
316
+ flex: 1;
317
+ position: relative;
318
+ overflow: auto;
319
+ background-color: var(--code-bg);
320
+ }
321
+
322
+ #code-editor {
323
+ position: absolute;
324
+ top: 0;
325
+ left: 0;
326
+ width: 100%;
327
+ height: 100%;
328
+ padding: 20px;
329
+ border: none;
330
+ background: transparent;
331
+ color: transparent; /* Text is transparent, caret is visible */
332
+ caret-color: white;
333
+ font-family: 'Fira Code', monospace;
334
+ font-size: 14px;
335
+ line-height: 1.6;
336
+ resize: none;
337
+ outline: none;
338
+ white-space: pre;
339
+ z-index: 2;
340
+ }
341
+
342
+ #code-highlight {
343
+ position: absolute;
344
+ top: 0;
345
+ left: 0;
346
+ width: 100%;
347
+ height: 100%;
348
+ padding: 20px;
349
+ font-family: 'Fira Code', monospace;
350
+ font-size: 14px;
351
+ line-height: 1.6;
352
+ pointer-events: none; /* Let clicks pass through to textarea */
353
+ z-index: 1;
354
+ white-space: pre;
355
+ color: var(--text-main);
356
+ }
357
+
358
+ /* Output Console */
359
+ .output-content {
360
+ flex: 1;
361
+ padding: 20px;
362
+ font-family: 'Fira Code', monospace;
363
+ font-size: 14px;
364
+ color: var(--text-main);
365
+ overflow-y: auto;
366
+ }
367
+
368
+ .log-entry {
369
+ margin-bottom: 5px;
370
+ opacity: 0;
371
+ animation: fadeIn 0.3s forwards;
372
+ }
373
+
374
+ .log-entry.error { color: #ff7b72; }
375
+ .log-entry.success { color: #79c0ff; }
376
+ .log-entry.info { color: var(--text-muted); }
377
+
378
+ @keyframes fadeIn {
379
+ to { opacity: 1; }
380
+ }
381
+
382
+ /* Gopher Animation Area */
383
+ .gopher-stage {
384
+ height: 150px;
385
+ background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-dark) 100%);
386
+ display: flex;
387
+ align-items: center;
388
+ justify-content: center;
389
+ border-bottom: 1px solid var(--border-color);
390
+ position: relative;
391
+ overflow: hidden;
392
+ }
393
+
394
+ .gopher-svg {
395
+ height: 100px;
396
+ transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
397
+ }
398
+
399
+ .gopher-svg.running {
400
+ animation: bounce 0.6s infinite alternate;
401
+ }
402
+
403
+ @keyframes bounce {
404
+ from { transform: translateY(0); }
405
+ to { transform: translateY(-20px); }
406
+ }
407
+
408
+ /* Mobile Responsive */
409
+ .mobile-toggle {
410
+ display: none;
411
+ background: none;
412
+ border: none;
413
+ color: var(--text-main);
414
+ font-size: 1.2rem;
415
+ cursor: pointer;
416
+ }
417
+
418
+ @media (max-width: 768px) {
419
+ .mobile-toggle { display: block; margin-right: 15px; }
420
+ aside {
421
+ position: absolute;
422
+ left: -100%;
423
+ height: 100%;
424
+ z-index: 200;
425
+ box-shadow: 10px 0 20px rgba(0,0,0,0.5);
426
+ }
427
+ aside.open { left: 0; }
428
+ .workspace { flex-direction: column; }
429
+ .editor-pane { border-right: none; border-bottom: 1px solid var(--border-color); height: 60%; }
430
+ .output-pane { height: 40%; }
431
+ .search-bar { display: none; }
432
+ }
433
+
434
+ /* Syntax Highlighting Classes */
435
+ .kw { color: var(--syntax-keyword); font-weight: bold; }
436
+ .fn { color: var(--syntax-func); }
437
+ .str { color: var(--syntax-string); }
438
+ .com { color: var(--syntax-comment); font-style: italic; }
439
+ .typ { color: var(--syntax-type); }
440
+ .num { color: #bd93f9; }
441
+
442
+ </style>
443
+ </head>
444
+ <body>
445
+
446
+ <!-- Header -->
447
+ <header>
448
+ <div class="brand">
449
+ <button class="mobile-toggle" onclick="toggleSidebar()"><i class="fas fa-bars"></i></button>
450
+ <i class="fab fa-golang"></i>
451
+ <span>GoNexus</span>
452
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">Built with anycoder</a>
453
+ </div>
454
+
455
+ <div class="header-actions">
456
+ <div class="search-bar">
457
+ <i class="fas fa-search"></i>
458
+ <input type="text" placeholder="Search packages (e.g. fmt, http)...">
459
+ </div>
460
+ <div class="user-avatar" title="User Profile">GD</div>
461
+ </div>
462
+ </header>
463
+
464
+ <div class="layout">
465
+ <!-- Sidebar -->
466
+ <aside id="sidebar">
467
+ <div class="nav-group">
468
+ <div class="nav-title">Workspace</div>
469
+ <a href="#" class="nav-item active" onclick="switchTab(this, 'playground')">
470
+ <i class="fas fa-terminal"></i> Playground
471
+ </a>
472
+ <a href="#" class="nav-item" onclick="switchTab(this, 'docs')">
473
+ <i class="fas fa-book"></i> Documentation
474
+ </a>
475
+ <a href="#" class="nav-item" onclick="switchTab(this, 'packages')">
476
+ <i class="fas fa-box-open"></i> Packages
477
+ </a>
478
+ </div>
479
+
480
+ <div class="nav-group">
481
+ <div class="nav-title">Examples</div>
482
+ <a href="#" class="nav-item" onclick="loadExample('hello')">
483
+ <i class="fas fa-code"></i> Hello World
484
+ </a>
485
+ <a href="#" class="nav-item" onclick="loadExample('loop')">
486
+ <i class="fas fa-sync"></i> Loops & Switch
487
+ </a>
488
+ <a href="#" class="nav-item" onclick="loadExample('struct')">
489
+ <i class="fas fa-cubes"></i> Structs
490
+ </a>
491
+ </div>
492
+
493
+ <div style="margin-top: auto; padding: 20px;">
494
+ <div style="font-size: 0.8rem; color: var(--text-muted);">
495
+ Go Version: <span style="color: var(--go-cyan);">1.21.0</span>
496
+ </div>
497
+ </div>
498
+ </aside>
499
+
500
+ <!-- Main Content -->
501
+ <main>
502
+ <!-- Toolbar -->
503
+ <div class="toolbar">
504
+ <div class="file-info">
505
+ <i class="far fa-file-code"></i>
506
+ <span>main.go</span>
507
+ </div>
508
+ <button class="run-btn" onclick="runCode()">
509
+ <i class="fas fa-play"></i> Run
510
+ </button>
511
+ </div>
512
+
513
+ <div class="workspace">
514
+ <!-- Editor -->
515
+ <div class="editor-pane">
516
+ <div class="code-container">
517
+ <!-- Highlight Layer -->
518
+ <div id="code-highlight"></div>
519
+ <!-- Input Layer -->
520
+ <textarea id="code-editor" spellcheck="false" oninput="updateHighlight()" onscroll="syncScroll()"></textarea>
521
+ </div>
522
+ </div>
523
+
524
+ <!-- Output -->
525
+ <div class="output-pane">
526
+ <div class="gopher-stage">
527
+ <!-- Inline SVG Go Gopher -->
528
+ <svg class="gopher-svg" id="gopher" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
529
+ <g fill="#00ADD8">
530
+ <path d="M100,40 C70,40 50,60 50,90 C50,110 60,120 60,120 L60,140 C60,140 40,140 40,160 C40,175 60,180 80,180 L120,180 C140,180 160,175 160,160 C160,140 140,140 140,140 L140,120 C140,120 150,110 150,90 C150,60 130,40 100,40 Z"/>
531
+ <circle cx="85" cy="80" r="8" fill="#fff"/>
532
+ <circle cx="115" cy="80" r="8" fill="#fff"/>
533
+ <circle cx="85" cy="80" r="3" fill="#000"/>
534
+ <circle cx="115" cy="80" r="3" fill="#000"/>
535
+ <path d="M90,100 Q100,110 110,100" stroke="#fff" stroke-width="3" fill="none" stroke-linecap="round"/>
536
+ </g>
537
+ <g fill="#fff">
538
+ <path d="M40,100 L20,90 L25,110 Z"/>
539
+ <path d="M160,100 L180,90 L175,110 Z"/>
540
+ </g>
541
+ </svg>
542
+ </div>
543
+ <div class="pane-header">
544
+ <span>Console Output</span>
545
+ <i class="fas fa-trash" style="cursor:pointer" onclick="clearConsole()" title="Clear Console"></i>
546
+ </div>
547
+ <div class="output-content" id="console-output">
548
+ <div class="log-entry info">// Ready to compile...</div>
549
+ </div>
550
+ </div>
551
+ </div>
552
+ </main>
553
+ </div>
554
+
555
+ <script>
556
+ // --- Data & State ---
557
+ const examples = {
558
+ hello: `package main
559
+
560
+ import "fmt"
561
+
562
+ func main() {
563
+ fmt.Println("Hello, Go Developer!")
564
+ fmt.Println("Welcome to GoNexus.")
565
+ }`,
566
+ loop: `package main
567
+
568
+ import "fmt"
569
+
570
+ func main() {
571
+ i := 1
572
+ for i <= 3 {
573
+ fmt.Println(i)
574
+ i = i + 1
575
+ }
576
+
577
+ switch 2 {
578
+ case 1:
579
+ fmt.Println("One")
580
+ case 2:
581
+ fmt.Println("Two")
582
+ default:
583
+ fmt.Println("Other")
584
+ }
585
+ }`,
586
+ struct: `package main
587
+
588
+ import "fmt"
589
+
590
+ type Vertex struct {
591
+ X int
592
+ Y int
593
+ }
594
+
595
+ func main() {
596
+ v := Vertex{1, 2}
597
+ fmt.Println(v)
598
+ fmt.Println(v.X)
599
+
600
+ // Modifying fields
601
+ v.X = 10
602
+ fmt.Println("Updated:", v)
603
+ }`
604
+ };
605
+
606
+ // --- Core Functions ---
607
+
608
+ function init() {
609
+ loadExample('hello');
610
+ setupEditorEvents();
611
+ }
612
+
613
+ function toggleSidebar() {
614
+ document.getElementById('sidebar').classList.toggle('open');
615
+ }
616
+
617
+ function switchTab(element, tabName) {
618
+ // Remove active class from all nav items
619
+ document.querySelectorAll('.nav-item').forEach(el => el.classList.remove('active'));
620
+ // Add active to clicked
621
+ element.classList.add('active');
622
+
623
+ // Close sidebar on mobile after click
624
+ if(window.innerWidth <= 768) {
625
+ document.getElementById('sidebar').classList.remove('open');
626
+ }
627
+
628
+ if(tabName !== 'playground') {
629
+ logToConsole(`[System] Navigated to ${tabName} view (Demo only)`, 'info');
630
+ }
631
+ }
632
+
633
+ function loadExample(key) {
634
+ const code = examples[key];
635
+ const editor = document.getElementById('code-editor');
636
+ editor.value = code;
637
+ updateHighlight();
638
+ clearConsole();
639
+ logToConsole(`[System] Loaded example: ${key}.go`, 'info');
640
+ }
641
+
642
+ // --- Syntax Highlighting Logic (Simple Regex) ---
643
+ function updateHighlight() {
644
+ const editor = document.getElementById('code-editor');
645
+ const highlight = document.getElementById('code-highlight');
646
+ let text = editor.value;
647
+
648
+ // Escape HTML
649
+ text = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
650
+
651
+ // Simple Go Syntax Highlighting Rules
652
+ // Keywords
653
+ text = text.replace(/\b(package|import|func|return|var|const|type|struct|interface|map|chan|go|defer|if|else|for|switch|case|default|break|continue)\b/g, '<span class="kw">$1</span>');
654
+ // Built-in types
655
+ text = text.replace(/\b(int|string|bool|float64|byte|rune|error|nil)\b/g, '<span class="typ">$1</span>');
656
+ // Functions (rough approximation)
657
+ text = text.replace(/\b(fmt|Println|Printf|Sprintf|make|len|cap|new|append|copy|close|delete|complex|real|imag|panic|recover)\b/g, '<span class="fn">$1</span>');
658
+ // Strings
659
+ text = text.replace(/(".*?")/g, '<span class="str">$1</span>');
660
+ // Comments
661
+ text = text.replace(/(\/\/.*)/g, '<span class="com">$1</span>');
662
+ // Numbers
663
+ text = text.replace(/\b(\d+)\b/g, '<span class="num">$1</span>');
664
+
665
+ // Handle trailing newline for visual consistency
666
+ if (text[text.length - 1] === "\n") {
667
+ text += " ";
668
+ }
669
+
670
+ highlight.innerHTML = text;
671
+ }
672
+
673
+ function syncScroll() {
674
+ const editor = document.getElementById('code-editor');
675
+ const highlight = document.getElementById('code-highlight');
676
+ highlight.scrollTop = editor.scrollTop;
677
+ highlight.scrollLeft = editor.scrollLeft;
678
+ }
679
+
680
+ function setupEditorEvents() {
681
+ const editor = document.getElementById('code-editor');
682
+
683
+ // Handle Tab key to insert spaces instead of changing focus
684
+ editor.addEventListener('keydown', function(e) {
685
+ if (e.key == 'Tab') {
686
+ e.preventDefault();
687
+ var start = this.selectionStart;
688
+ var end = this.selectionEnd;
689
+
690
+ // Set textarea value to: text before caret + tab + text after caret
691
+ this.value = this.value.substring(0, start) +
692
+ " " + this.value.substring(end);
693
+
694
+ // Put caret at right position again
695
+ this.selectionStart = this.selectionEnd = start + 4;
696
+ updateHighlight();
697
+ }
698
+ });
699
+ }
700
+
701
+ // --- Simulation Logic ---
702
+
703
+ function runCode() {
704
+ const code = document.getElementById('code-editor').value;
705
+ const gopher = document.getElementById('gopher');
706
+ const outputDiv = document.getElementById('console-output');
707
+
708
+ // UI Feedback
709
+ gopher.classList.add('running');
710
+ logToConsole("> go run main.go", 'info');
711
+
712
+ // Simulate processing time
713
+ setTimeout(() => {
714
+ gopher.classList.remove('running');
715
+
716
+ // Very basic parser to simulate output based on input text
717
+ // This is a mock interpreter for the UI demo
718
+ const lines = code.split('\n');
719
+ let hasOutput = false;
720
+
721
+ lines.forEach(line => {
722
+ // Clean line
723
+ const cleanLine = line.trim();
724
+
725
+ if (cleanLine.includes('fmt.Println')) {
726
+ // Extract string inside quotes
727
+ const match = cleanLine.match(/fmt\.Println\((.*)\)/);
728
+ if (match && match[1]) {
729
+ let content = match[1].replace(/"/g, '');
730
+ // Handle variables roughly
731
+ if(content.includes('+') || content.includes('v')) {
732
+ // Mock dynamic content
733
+ if(content.includes('v')) content = "{10 2}";
734
+ else content = "Calculated Value";
735
+ }
736
+ logToConsole(content, 'success');
737
+ hasOutput = true;
738
+ }
739
+ } else if (cleanLine.includes('fmt.Printf')) {
740
+ logToConsole("[Formatted Output Simulation]", 'success');
741
+ hasOutput = true;
742
+ }
743
+ });
744
+
745
+ if (!hasOutput) {
746
+ // Check for basic logic simulation
747
+ if(code.includes('i <= 3')) {
748
+ logToConsole("1", 'success');
749
+ logToConsole("2", 'success');
750
+ logToConsole("3", 'success');
751
+ logToConsole("Two", 'success');
752
+ hasOutput = true;
753
+ }
754
+ }
755
+
756
+ if (!hasOutput) {
757
+ logToConsole("Program exited with code 0", 'info');
758
+ } else {
759
+ logToConsole("Program exited with code 0", 'info');
760
+ }
761
+
762
+ }, 800);
763
+ }
764
+
765
+ function logToConsole(message, type = 'normal') {
766
+ const outputDiv = document.getElementById('console-output');
767
+ const entry = document.createElement('div');
768
+ entry.className = `log-entry ${type}`;
769
+ entry.textContent = message;
770
+ outputDiv.appendChild(entry);
771
+ outputDiv.scrollTop = outputDiv.scrollHeight;
772
+ }
773
+
774
+ function clearConsole() {
775
+ const outputDiv = document.getElementById('console-output');
776
+ outputDiv.innerHTML = '';
777
+ }
778
+
779
+ // Initialize on load
780
+ window.addEventListener('DOMContentLoaded', init);
781
+
782
+ </script>
783
+ </body>
784
+ </html>