-
Notifications
You must be signed in to change notification settings - Fork 2
/
dashboard.html
685 lines (613 loc) · 23.9 KB
/
dashboard.html
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
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Editor - Dashboard</title>
<!-- CodeMirror CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">
<!-- Font Awesome (for icons) -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<!-- Add JSZip (for downloading code) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"></script>
<!-- the beautifiers -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.0/beautify.min.js"></script>
<!-- Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<!-- favicon -->
<link rel="apple-touch-icon" sizes="180x180" href="./src/images/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./src/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./src/images/favicon-16x16.png">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap" rel="stylesheet">
<!-- FontAwesome Icons -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<style>
/* Consistent font and background */
body {
font-family: 'Roboto Mono', monospace;
background-color: #f8f9fa;
margin: 0;
}
/* Sticky navigation bar */
header {
position: sticky;
top: 0;
z-index: 1000;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
background-color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
}
.navbar-brand {
font-size: 1.5rem;
font-weight: bold;
color: black;
}
.profile-menu {
position: relative;
}
.profile-icon {
font-size: 2.0rem;
cursor: pointer;
color: #343a40;
}
.profile-dropdown {
position: absolute;
right: 0;
top: 40px;
background-color: white;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
border-radius: 8px;
width: 250px;
display: none;
flex-direction: column;
z-index: 2000;
padding: 10px;
}
.profile-dropdown.active {
display: flex;
}
.profile-dropdown p {
margin: 0;
font-size: 1rem;
color: #343a40;
word-wrap: break-word;
text-align: center;
padding: 10px 0;
border-bottom: 1px solid #ddd;
}
.profile-dropdown button {
padding: 10px;
border: none;
background-color: #007bff;
color: white;
cursor: pointer;
text-align: left;
width: 100%;
border-radius: 5px;
margin-top: 10px;
}
.profile-dropdown button:hover {
background-color: #0056b3;
}
/* Main content */
.dashboard-container {
padding: 20px;
max-width: 1200px;
margin: 0 auto;
}
h1 {
font-size: 2.5rem;
color: #343a40;
text-align: center;
margin-bottom: 20px;
}
.welcome-message {
font-size: 1.25rem;
text-align: center;
margin-bottom: 30px;
color: #6c757d;
}
.editor-container {
margin-bottom: 15px;
}
iframe {
width: 100%;
height: 300px;
border: 2px solid #ddd;
border-radius: 5px;
}
.btn-primary {
background-color: #28a745;
color: white;
}
.btn-primary:hover {
background-color: #218838;
}
.btn-secondary {
margin: 5px;
}
#consoleOutput {
margin-top: 20px;
height: 150px;
border: 1px solid #ddd;
border-radius: 5px;
background: #f5f5f5;
overflow-y: scroll;
padding: 10px;
font-size: 14px;
color: #333;
}
.features {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.feature-card {
background: #fff;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 20px;
border-radius: 8px;
flex: 1 1 calc(33.333% - 20px);
margin: 10px;
text-align: center;
}
.feature-card i {
font-size: 2rem;
color: #28a745;
margin-bottom: 15px;
}
.feature-card h4 {
font-size: 1.25rem;
color: #343a40;
margin-bottom: 10px;
}
.feature-card p {
color: #6c757d;
}
.completed span {
text-decoration: line-through;
color: gray;
}
pre {
background: #f8f9fa;
padding: 10px;
border-radius: 5px;
white-space: pre-wrap;
}
/* Style for Project Cards */
.project-card {
background: #fff;
padding: 15px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
margin-bottom: 15px;
border-radius: 8px;
text-align: center;
}
.project-card h6 {
font-size: 1.1rem;
margin-bottom: 10px;
}
.project-card p {
font-size: 0.9rem;
color: #6c757d;
}
.project-card .btn {
margin-top: 10px;
}
</style>
</head>
<body>
<!-- Sticky Header -->
<header>
<div class="navbar-brand">Code Editor</div>
<div class="profile-menu">
<i class="fas fa-user-circle profile-icon" id="profileIcon"></i>
<div class="profile-dropdown" id="profileDropdown">
<p id="userDetails">Loading...</p>
<button id="updateDetails">Update Details</button>
<button id="logoutButton">Logout</button>
</div>
</div>
</header>
<main class="dashboard-container">
<h1>Welcome to Code Editor</h1>
<p class="welcome-message" id="welcomeMessage">Loading...</p>
<section class="features">
<div class="feature-card">
<i class="fas fa-chart-line"></i>
<h4>Activity Overview</h4>
<p>Track your coding progress and recent activity in one place.</p>
</div>
<div class="feature-card">
<i class="fas fa-project-diagram"></i>
<h4>My Projects</h4>
<p>Access and manage your saved projects seamlessly.</p>
</div>
<div class="feature-card">
<i class="fas fa-user-friends"></i>
<h4>Collaborate</h4>
<p>Invite others to work on projects with you in real time.</p>
</div>
</section>
</br>
<div class="row">
<!-- HTML Editor -->
<div class="col-md-4">
<div class="editor-container">
<label for="htmlCode" class="text-muted">
<i class="fa-brands fa-html5"></i> HTML Code
</label>
<textarea id="htmlCode" class="editor" placeholder="Write HTML code here..."></textarea>
</div>
</div>
<!-- CSS Editor -->
<div class="col-md-4">
<div class="editor-container">
<label for="cssCode" class="text-muted">
<i class="fa-brands fa-css3-alt"></i> CSS Code
</label>
<textarea id="cssCode" class="editor" placeholder="Write CSS code here..."></textarea>
</div>
</div>
<!-- JavaScript Editor -->
<div class="col-md-4">
<div class="editor-container">
<label for="jsCode" class="text-muted">
<i class="fa-brands fa-js"></i> JavaScript Code
</label>
<textarea id="jsCode" class="editor" placeholder="Write JS code here..."></textarea>
</div>
</div>
</div>
<div class="row mt-3">
<!-- Action Buttons -->
<div class="col text-center">
<button class="btn btn-primary" id="runCode">
<i class="fas fa-play"></i> Run Code
</button>
<button class="btn btn-secondary" id="downloadCode">
<i class="fas fa-download"></i> Download Code
</button>
<button class="btn btn-secondary" id="formatCode">
<i class="fas fa-align-left"></i> Format Code
</button>
<button class="btn btn-secondary" id="saveCode">
<i class="fas fa-save"></i> Save Code
</button>
<button class="btn btn-secondary" id="loadCode">
<i class="fas fa-folder-open"></i> Load Code
</button>
</div>
</div>
<div class="row mt-4">
<!-- Live Preview -->
<div class="col-12">
<h3 class="text-center">Live Preview</h3>
<iframe id="preview"></iframe>
</div>
</div>
<!-- Console Output -->
<div class="row mt-3">
<div class="col-12">
<div class="card shadow-sm border-0">
<div class="card-body">
<h4 class="text-center">
<i class="fas fa-terminal" style="color: #28a745; margin-right: 10px;"></i>
Console Output
</h4>
<div id="consoleOutput"
style="background-color: #222; color: white; padding: 20px; border-radius: 8px; min-height: 150px;">
</div>
</div>
</div>
</div>
</div>
<section class="tutorials mt-5">
<h2 class="text-center">Coding Tutorials</h2>
<p class="text-muted mb-3 text-center">
Whether you're a beginner or an experienced developer, explore these tutorials to learn new skills and improve your coding knowledge.
</p>
<div class="row">
<!-- HTML Tutorial -->
<div class="col-md-4">
<div class="card shadow-sm mb-4">
<div class="card-body text-center">
<i class="fab fa-html5 fa-3x" style="color: #e44d26;"></i>
<h5 class="card-title mt-3">HTML Tutorials</h5>
<p class="card-text">
Learn the basics of HTML and create the structure of a website.
</p>
<a href="https://www.w3schools.com/html/" target="_blank" class="btn btn-primary">
Start Learning
</a>
</div>
</div>
</div>
<!-- CSS Tutorial -->
<div class="col-md-4">
<div class="card shadow-sm mb-4">
<div class="card-body text-center">
<i class="fab fa-css3-alt fa-3x" style="color: #2965f1;"></i>
<h5 class="card-title mt-3">CSS Tutorials</h5>
<p class="card-text">
Dive into CSS to style and design your webpages beautifully.
</p>
<a href="https://www.w3schools.com/css/" target="_blank" class="btn btn-primary">
Start Learning
</a>
</div>
</div>
</div>
<!-- JavaScript Tutorial -->
<div class="col-md-4">
<div class="card shadow-sm mb-4">
<div class="card-body text-center">
<i class="fab fa-js-square fa-3x" style="color: #f7df1e;"></i>
<h5 class="card-title mt-3">JavaScript Tutorials</h5>
<p class="card-text">
Master JavaScript and make your website interactive.
</p>
<a href="https://www.w3schools.com/js/" target="_blank" class="btn btn-primary">
Start Learning
</a>
</div>
</div>
</div>
</div>
<div class="row">
<!-- React.js Tutorial -->
<div class="col-md-4">
<div class="card shadow-sm mb-4">
<div class="card-body text-center">
<i class="fab fa-react fa-3x" style="color: #61dafb;"></i>
<h5 class="card-title mt-3">React.js Tutorials</h5>
<p class="card-text">
Learn React, a popular JavaScript library for building user interfaces.
</p>
<a href="https://reactjs.org/docs/getting-started.html" target="_blank" class="btn btn-primary">
Start Learning
</a>
</div>
</div>
</div>
<!-- Git & GitHub Tutorial -->
<div class="col-md-4">
<div class="card shadow-sm mb-4">
<div class="card-body text-center">
<i class="fab fa-git-alt fa-3x" style="color: #f05032;"></i>
<h5 class="card-title mt-3">Git & GitHub</h5>
<p class="card-text">
Understand version control and collaborate with others using Git and GitHub.
</p>
<a href="https://git-scm.com/doc" target="_blank" class="btn btn-primary">
Start Learning
</a>
</div>
</div>
</div>
<!-- Bootstrap Tutorial -->
<div class="col-md-4">
<div class="card shadow-sm mb-4">
<div class="card-body text-center">
<i class="fab fa-bootstrap fa-3x" style="color: #563d7c;"></i>
<h5 class="card-title mt-3">Bootstrap Tutorials</h5>
<p class="card-text">
Learn how to quickly design responsive websites using Bootstrap.
</p>
<a href="https://getbootstrap.com/docs/5.1/getting-started/introduction/" target="_blank" class="btn btn-primary">
Start Learning
</a>
</div>
</div>
</div>
</div>
</section>
<section class="task-list mt-5">
<h2 class="text-center">Coding Task List</h2>
<p class="text-muted mb-3 text-center">
Manage your coding tasks effectively. Add, delete, and keep track of your coding tasks.
</p>
<div class="card shadow-sm">
<div class="card-body">
<div class="input-group mb-3">
<input type="text" id="taskInput" class="form-control" placeholder="Enter a new task...">
<div class="input-group-append">
<button class="btn btn-primary" id="addTaskButton">Add Task</button>
</div>
</div>
<ul class="list-group" id="taskList"></ul>
</div>
</div>
</section>
<section class="snippet-library mt-5">
<h2 class="text-center">Code Snippet Library</h2>
<p class="text-muted mb-3 text-center">
Use the Code Snippet Library to save and manage reusable code snippets.
</p>
<div class="card shadow-sm">
<div class="card-body">
<div class="mb-3">
<textarea id="snippetInput" class="form-control" rows="3" placeholder="Enter your code snippet here..."></textarea>
</div>
<button class="btn btn-primary mb-3" id="addSnippetButton">Save Snippet</button>
<ul class="list-group" id="snippetList"></ul>
</div>
</div>
</section>
</main>
<script type="module">
import { onAuthStateChanged, signOut } from "https://www.gstatic.com/firebasejs/9.6.1/firebase-auth.js";
import { auth } from "./scripts/auth.js";
// Toggle Profile Dropdown
const profileIcon = document.getElementById("profileIcon");
const profileDropdown = document.getElementById("profileDropdown");
profileIcon.addEventListener("click", () => {
profileDropdown.classList.toggle("active");
});
// Fetch User Info
const userDetails = document.getElementById("userDetails");
const welcomeMessage = document.getElementById("welcomeMessage");
onAuthStateChanged(auth, (user) => {
if (user) {
const userEmail = user.email;
// Update both the dropdown and welcome message with the user's email
userDetails.textContent = userEmail || "No user details available";
welcomeMessage.textContent = `Hello👋, ${userEmail}!`;
} else {
window.location.href = "login.html"; // Redirect to login if not authenticated
}
});
// Update Details Button
document.getElementById("updateDetails").addEventListener("click", () => {
alert("Update Details feature coming soon!");
});
// Logout Functionality
document.getElementById("logoutButton").addEventListener("click", async () => {
try {
await signOut(auth);
alert("Logged out successfully!");
window.location.href = "index.html";
} catch (error) {
console.error("Logout Error:", error.message);
alert("An error occurred while logging out.");
}
});
</script>
<script>
// Get references to DOM elements
const taskInput = document.getElementById("taskInput");
const addTaskButton = document.getElementById("addTaskButton");
const taskList = document.getElementById("taskList");
// Load tasks from local storage
function loadTasks() {
const tasks = JSON.parse(localStorage.getItem("tasks")) || [];
tasks.forEach(task => addTaskToDOM(task.text, task.completed));
}
// Save tasks to local storage
function saveTasks() {
const tasks = [];
taskList.querySelectorAll("li").forEach(taskItem => {
tasks.push({
text: taskItem.querySelector("span").textContent,
completed: taskItem.classList.contains("completed")
});
});
localStorage.setItem("tasks", JSON.stringify(tasks));
}
// Add a task to the DOM
function addTaskToDOM(taskText, isCompleted = false) {
const taskItem = document.createElement("li");
taskItem.className = `list-group-item d-flex justify-content-between align-items-center ${
isCompleted ? "completed" : ""
}`;
taskItem.innerHTML = `
<span>${taskText}</span>
<div>
<button class="btn btn-success btn-sm completeTask">✔</button>
<button class="btn btn-danger btn-sm deleteTask">✖</button>
</div>
`;
// Add event listeners for buttons
taskItem.querySelector(".completeTask").addEventListener("click", () => {
taskItem.classList.toggle("completed");
saveTasks();
});
taskItem.querySelector(".deleteTask").addEventListener("click", () => {
taskList.removeChild(taskItem);
saveTasks();
});
taskList.appendChild(taskItem);
}
// Add a new task
addTaskButton.addEventListener("click", () => {
const taskText = taskInput.value.trim();
if (taskText) {
addTaskToDOM(taskText);
saveTasks();
taskInput.value = "";
}
});
// Load tasks on page load
document.addEventListener("DOMContentLoaded", loadTasks);
</script>
<script>
// References to DOM elements
const snippetInput = document.getElementById("snippetInput");
const addSnippetButton = document.getElementById("addSnippetButton");
const snippetList = document.getElementById("snippetList");
// Escape HTML for safe display in the DOM
function escapeHTML(html) {
const div = document.createElement("div");
div.innerText = html;
return div.innerHTML;
}
// Load snippets from local storage and render them
function loadSnippets() {
const snippets = JSON.parse(localStorage.getItem("snippets")) || [];
snippets.forEach(snippet => addSnippetToDOM(snippet));
}
// Save snippets to local storage
function saveSnippetsToLocalStorage() {
const snippets = [];
snippetList.querySelectorAll(".snippet-item").forEach(snippetItem => {
snippets.push(snippetItem.dataset.snippet);
});
localStorage.setItem("snippets", JSON.stringify(snippets));
}
// Add a snippet to the DOM
function addSnippetToDOM(snippet) {
const snippetItem = document.createElement("li");
snippetItem.className = "list-group-item snippet-item d-flex justify-content-between align-items-start";
snippetItem.dataset.snippet = snippet; // Store the raw snippet in the dataset for saving
snippetItem.innerHTML = `
<pre class="mb-0 snippet-content" style="white-space: pre-wrap; word-wrap: break-word;">${escapeHTML(snippet)}</pre>
<button class="btn btn-sm btn-danger delete-snippet">Delete</button>
`;
// Add delete functionality
snippetItem.querySelector(".delete-snippet").addEventListener("click", () => {
snippetList.removeChild(snippetItem);
saveSnippetsToLocalStorage();
});
snippetList.appendChild(snippetItem);
}
// Handle adding a new snippet
addSnippetButton.addEventListener("click", () => {
const snippet = snippetInput.value.trim();
if (snippet) {
addSnippetToDOM(snippet);
saveSnippetsToLocalStorage();
snippetInput.value = ""; // Clear the input after saving
} else {
alert("Please enter a code snippet before saving.");
}
});
// Load snippets when the page is loaded
document.addEventListener("DOMContentLoaded", loadSnippets);
</script>
<!-- Bootstrap JS and custom JavaScript -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!-- CodeMirror JS for syntax highlighting -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/htmlmixed/htmlmixed.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/css/css.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/javascript/javascript.min.js"></script>
<!-- JSZip for download -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<!-- js-beautify for formatting -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.7/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.7/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.7/beautify-html.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script src="./src/app.js"></script>
</body>
</html>