Skip to content

Commit b55fcd8

Browse files
Add files via upload
1 parent c61ea71 commit b55fcd8

41 files changed

Lines changed: 3044 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

addon/admin/add_new_book.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.0.0/firebase-app.js";
2+
import { getFirestore, addDoc, collection } from "https://www.gstatic.com/firebasejs/12.0.0/firebase-firestore.js";
3+
4+
const firebaseConfig = {
5+
apiKey: "AIzaSyANTXAHzFmu5zY6k-KH73dCJwfNumK-Jnc",
6+
authDomain: "papercodeweb-c3423.firebaseapp.com",
7+
projectId: "papercodeweb-c3423",
8+
storageBucket: "papercodeweb-c3423.firebasestorage.app",
9+
messagingSenderId: "1411010921",
10+
appId: "1:1411010921:web:7a8bf23496a1fc46416df8",
11+
measurementId: "G-W9F9MH0PKQ"
12+
};
13+
14+
const app = initializeApp(firebaseConfig);
15+
const db = getFirestore(app);
16+
17+
document.getElementById("sub").addEventListener("click", submitExp);
18+
19+
async function submitExp(event) {
20+
event.preventDefault();
21+
22+
const name = document.getElementById("name").value;
23+
const des = document.getElementById("des").value;
24+
const type = document.getElementById("type").value;
25+
const lvl = document.getElementById("lvl").value;
26+
const link = document.getElementById("link").value;
27+
const file = document.getElementById("img").files[0];
28+
29+
if (!file) {
30+
alert("Please select an image.");
31+
return;
32+
}
33+
34+
const imageBase64 = await convertToBase64(file);
35+
36+
addDoc(collection(db, "books"), {
37+
name: name,
38+
description: des,
39+
type: type,
40+
level: lvl,
41+
link: link,
42+
image: imageBase64,
43+
date: new Date()
44+
}).then(() => {
45+
clearForm();
46+
alert("Book added!");
47+
}).catch((error) => {
48+
alert("Error: " + error.message);
49+
});
50+
}
51+
52+
function convertToBase64(file) {
53+
return new Promise((resolve, reject) => {
54+
const reader = new FileReader();
55+
reader.onload = () => resolve(reader.result); // base64 string
56+
reader.onerror = reject;
57+
reader.readAsDataURL(file); // converts to base64
58+
});
59+
}
60+
61+
function clearForm() {
62+
document.getElementById("name").value = "";
63+
document.getElementById("des").value = "";
64+
document.getElementById("type").value = "";
65+
document.getElementById("lvl").value = "";
66+
document.getElementById("link").value = "";
67+
document.getElementById("img").value = "";
68+
}

addon/admin/add_new_exp.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* ----------------------------------------------
2+
Firebase Initialization
3+
------------------------------------------------*/
4+
5+
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.0.0/firebase-app.js";
6+
import { getFirestore, addDoc, collection} from "https://www.gstatic.com/firebasejs/12.0.0/firebase-firestore.js";
7+
8+
const firebaseConfig = {
9+
apiKey: "AIzaSyANTXAHzFmu5zY6k-KH73dCJwfNumK-Jnc",
10+
authDomain: "papercodeweb-c3423.firebaseapp.com",
11+
projectId: "papercodeweb-c3423",
12+
storageBucket: "papercodeweb-c3423.firebasestorage.app",
13+
messagingSenderId: "1411010921",
14+
appId: "1:1411010921:web:7a8bf23496a1fc46416df8",
15+
measurementId: "G-W9F9MH0PKQ"
16+
};
17+
18+
19+
const app = initializeApp(firebaseConfig);
20+
const db = getFirestore(app);
21+
22+
23+
/* ----------------------------------------------
24+
Upload Logic For Main Data
25+
------------------------------------------------*/
26+
27+
const submitBtn = document.getElementById("sub");
28+
submitBtn.addEventListener('click', submitExp);
29+
30+
function submitExp(){
31+
event.preventDefault();
32+
const name = document.getElementById("heading").value;
33+
const des = document.getElementById("des").value;
34+
const link = document.getElementById("link").value;
35+
addDoc(collection(db, "experiments"), {
36+
name: name,
37+
description: des,
38+
link: link,
39+
date: new Date()
40+
}).then(() => {
41+
document.getElementById("heading").value = "";
42+
document.getElementById("des").value = "";
43+
document.getElementById("link").value = "";
44+
}).catch((error) => {
45+
alert(error.message);
46+
});
47+
}

addon/admin/add_new_tools.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.0.0/firebase-app.js";
2+
import { getFirestore, addDoc, collection } from "https://www.gstatic.com/firebasejs/12.0.0/firebase-firestore.js";
3+
4+
const firebaseConfig = {
5+
apiKey: "AIzaSyANTXAHzFmu5zY6k-KH73dCJwfNumK-Jnc",
6+
authDomain: "papercodeweb-c3423.firebaseapp.com",
7+
projectId: "papercodeweb-c3423",
8+
storageBucket: "papercodeweb-c3423.firebasestorage.app",
9+
messagingSenderId: "1411010921",
10+
appId: "1:1411010921:web:7a8bf23496a1fc46416df8",
11+
measurementId: "G-W9F9MH0PKQ"
12+
};
13+
14+
const app = initializeApp(firebaseConfig);
15+
const db = getFirestore(app);
16+
17+
document.getElementById("sub").addEventListener("click", submitExp);
18+
19+
async function submitExp(event) {
20+
event.preventDefault();
21+
22+
const name = document.getElementById("name").value;
23+
const des = document.getElementById("des").value;
24+
const plat = document.getElementById("plat").value;
25+
const link = document.getElementById("link").value;
26+
const file = document.getElementById("img").files[0];
27+
28+
if (!file) {
29+
alert("Please select an image.");
30+
return;
31+
}
32+
33+
const imageBase64 = await convertToBase64(file);
34+
35+
addDoc(collection(db, "tools"), {
36+
name: name,
37+
description: des,
38+
platform: plat,
39+
link: link,
40+
image: imageBase64,
41+
date: new Date()
42+
}).then(() => {
43+
clearForm();
44+
alert("Book added!");
45+
}).catch((error) => {
46+
alert("Error: " + error.message);
47+
});
48+
}
49+
50+
function convertToBase64(file) {
51+
return new Promise((resolve, reject) => {
52+
const reader = new FileReader();
53+
reader.onload = () => resolve(reader.result); // base64 string
54+
reader.onerror = reject;
55+
reader.readAsDataURL(file); // converts to base64
56+
});
57+
}
58+
59+
function clearForm() {
60+
document.getElementById("name").value = "";
61+
document.getElementById("des").value = "";
62+
document.getElementById("type").value = "";
63+
document.getElementById("lvl").value = "";
64+
document.getElementById("link").value = "";
65+
document.getElementById("img").value = "";
66+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Add New Book</title>
5+
</head>
6+
<body>
7+
8+
<input type="text" id="name" placeholder="name"/>
9+
<input type="text" id="des" placeholder="description"/>
10+
<input type="text" id="type" placeholder="type"/>
11+
<input type="text" id="lvl" placeholder="level"/>
12+
<input type="text" id="link" placeholder="link"/>
13+
14+
<input type="file" id="img" accept="image/*" />
15+
16+
<button id="sub">Submit</button>
17+
18+
<script type="module" src="add_new_book.js" defer></script>
19+
20+
</body>
21+
</html>

addon/admin/admin_add_new_exp.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
3+
<body>
4+
<script src="add_new_exp.js" type="module" defer></script>
5+
<input type="text" id="heading" placeholder="heading">
6+
<input type="des" id="des" placeholder="Des">
7+
<input type="url" id="link" placeholder="lnk">
8+
<button id="sub">Submit</button>
9+
</body>
10+
11+
12+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Add New Book</title>
5+
</head>
6+
<body>
7+
8+
<input type="text" id="name" placeholder="name"/>
9+
<input type="text" id="des" placeholder="description"/>
10+
<input type="text" id="plat" placeholder="plat"/>
11+
<input type="text" id="link" placeholder="link"/>
12+
13+
<input type="file" id="img" accept="image/*" />
14+
15+
<button id="sub">Submit</button>
16+
17+
<script type="module" src="add_new_tools.js" defer></script>
18+
19+
</body>
20+
</html>

addon/books.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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>My Books - Paper Code</title>
7+
<link rel="stylesheet" href="../style/books.css">
8+
<script src="../scripts/books.js" type="module" defer></script>
9+
</head>
10+
<body>
11+
<div class="page-title">
12+
<h1>PaperCode eBooks Collection</h1>
13+
<p>Explore all the books written and curated by me.</p>
14+
<a href="admin/admin_add_new_book.html"><button class="admin_add_books" id="add-btn">Add Books</button></a>
15+
</div>
16+
17+
<div class="books-container" id="booksContainer">
18+
<div class="book-card">
19+
<img src="../assets/paper_code_logo.png" alt="Book 1 Cover">
20+
<div class="book-info">
21+
<h2>The Code Journey</h2>
22+
<p>A beginner-friendly guide into the world of programming, with real-world insights and clear examples.</p>
23+
<button onclick="window.location.href='book1.pdf'">Read Now</button>
24+
</div>
25+
</div>
26+
</div>
27+
</body>
28+
</html>

addon/exp.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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>Experiments - Paper Code</title>
7+
<link rel="stylesheet" href="../style/experiments.css" />
8+
<script defer src="../scripts/experiments.js" type="module"></script>
9+
</head>
10+
<body>
11+
<div class="container">
12+
<header>
13+
<h1>Experiments</h1>
14+
<button class="new-btn" id="new-btn">Add New Experiment</button>
15+
</header>
16+
<div id="loading" class="spinner"></div>
17+
<div class="card-grid">
18+
<div class="experiments-container", id="experiments-container">
19+
20+
</div>
21+
</div>
22+
</div>
23+
24+
<!-- Modal (optional) -->
25+
<div id="experimentModal" class="modal">
26+
<div class="modal-content">
27+
<h2 class="heading">Experiment Details</h2>
28+
<p class="description">Coming soon!</p>
29+
<button id="modal_close_btn">OK</button>
30+
</div>
31+
</div>
32+
</body>
33+
</html>

addon/login.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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>Login - Paper Code</title>
7+
<link rel="stylesheet" href="../style/login.css">
8+
<script type="module" src="../scripts/login.js" defer></script>
9+
</head>
10+
<body>
11+
<div class="main-container">
12+
<div class="login-container">
13+
<h1>Hey!</h1>
14+
<h2>Sign in to your account</h2>
15+
<input type="email" class="email_class" id="username" placeholder="Email" required><br>
16+
17+
<div class="input-wrapper">
18+
<img src="../assets/icons/password_icon.png" class="input-icon-left" />
19+
<input type="password" id="password" placeholder="Enter password" />
20+
<img src="../assets/icons/show_password_icon_close.png" class="input-icon-right" id="togglePassword" />
21+
</div>
22+
<br>
23+
24+
<button id="login_btn">Login</button><br>
25+
26+
<p">Don't have an account? <a href="new.html">Register</a></p>
27+
28+
</div>
29+
<div class="welcome-container">
30+
<h1>Welcome Back</h1>
31+
<p>We are glad to see you again. Let's continue building amazing projects together!</p>
32+
</div>
33+
</div>
34+
35+
<!-- Modal -->
36+
<div id="customModal" class="modal">
37+
<div class="modal-content">
38+
<h2 class="heading">Notice</h2>
39+
<p class="description">This is a custom alert box!</p>
40+
<button id="modal_close_btn">OK</button>
41+
</div>
42+
</div>
43+
44+
45+
</body>
46+
</html>

addon/new.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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>Register - Paper Code</title>
7+
<link rel="stylesheet" href="../style/new.css" />
8+
<script type="module" src="../scripts/new.js" defer></script>
9+
</head>
10+
<body>
11+
<div class="register-container">
12+
<h1>Create Account</h1>
13+
<p class="subtitle">Join The Journey of Building Cool Projects</p>
14+
15+
<div class="input-group-double">
16+
<input type="text" id="firstName" placeholder="First Name" required />
17+
<input type="text" id="lastName" placeholder="Last Name" required />
18+
</div>
19+
20+
<input type="email" id="email" placeholder="Email" required />
21+
22+
<div class="input-wrapper">
23+
<img src="../assets/icons/password_icon.png" class="input-icon-left" />
24+
<input type="password" id="password" placeholder="Create Password" />
25+
<img src="../assets/icons/show_password_icon_close.png" class="input-icon-right" id="togglePassword" />
26+
</div>
27+
28+
<button id="register_btn">Register</button>
29+
30+
<p class="footer-link">Already have an account? <a href="login.html">Login</a></p>
31+
32+
<!-- Modal -->
33+
<div id="customModal" class="modal">
34+
<div class="modal-content">
35+
<h2 class="heading">Notice</h2>
36+
<p class="description">This is a custom alert box!</p>
37+
<button id="modal_close_btn">OK</button>
38+
</div>
39+
</div>
40+
</div>
41+
</body>
42+
</html>

0 commit comments

Comments
 (0)