-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben Sanderson
committed
Nov 14, 2024
1 parent
da7c7f3
commit b2485ff
Showing
4 changed files
with
117 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.2/firebase-app.js"; | ||
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.13.2/firebase-analytics.js"; | ||
import { getFirestore, collection, orderBy, getDoc, addDoc, getDocs, doc, query, where } from 'https://www.gstatic.com/firebasejs/10.13.2/firebase-firestore.js'; | ||
import { getAuth, | ||
createUserWithEmailAndPassword, | ||
signOut, | ||
signInWithEmailAndPassword, | ||
onAuthStateChanged | ||
} | ||
|
||
from "https://www.gstatic.com/firebasejs/10.13.2/firebase-auth.js"; | ||
// TODO: Add SDKs for Firebase products that you want to use | ||
// https://firebase.google.com/docs/web/setup#available-libraries | ||
|
||
// Your web app's Firebase configuration | ||
// For Firebase JS SDK v7.20.0 and later, measurementId is optional | ||
const firebaseConfig = { | ||
apiKey: "AIzaSyAt-SInlPaL2FzwtXrRltIEiV5l8k5HMjg", | ||
authDomain: "pageturners-a831a.firebaseapp.com", | ||
projectId: "pageturners-a831a", | ||
storageBucket: "pageturners-a831a.appspot.com", | ||
messagingSenderId: "304224952392", | ||
appId: "1:304224952392:web:f33dbc84b481e39a44787d", | ||
measurementId: "G-C6DKQSJ1R8" | ||
}; | ||
|
||
// Initialize Firebase | ||
const app = initializeApp(firebaseConfig); | ||
const analytics = getAnalytics(app); | ||
const auth = getAuth(); | ||
const db = getFirestore(app); | ||
|
||
const queryParams = new URLSearchParams(window.location.search); | ||
let userUID = ""; | ||
let userEmail = ""; | ||
auth.onAuthStateChanged(function(user){ | ||
if (user) { | ||
userUID = user.uid; | ||
userEmail = user.email; | ||
} | ||
}) | ||
|
||
const postform = document.getElementById("reply-form"); | ||
|
||
postform.addEventListener("submit", async function (e) { | ||
|
||
e.preventDefault(); | ||
|
||
let title = postform["title"].value; | ||
let body = postform["text"].value; | ||
|
||
//let docRef2 = doc(db,"BookClubs", queryParams.get("id")); | ||
const discRef = collection(db,"BookClubs",queryParams.get("id"),"DiscussionPosts"); | ||
|
||
let docref = await addDoc(discRef, { | ||
Author: userEmail, | ||
Body: body, | ||
Title: title, | ||
postDate: new Date() | ||
}).then((e)=>{ | ||
window.location.href = "./clubhomepage.html?id=" + queryParams.get("id"); | ||
}) | ||
|
||
|
||
|
||
|
||
|
||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Discussion Thread</title> | ||
<link rel="stylesheet" href="../css/loginreg.css"> | ||
</head> | ||
<body> | ||
<main> | ||
<section class="discussion-thread"> | ||
<h2 id="discussion-title"></h2> | ||
<div id="discussion-container"></div> | ||
|
||
<!-- Form to submit a new reply --> | ||
<form id="reply-form"> | ||
<input type="text" id="title" placeholder="Title" required> | ||
<textarea id="text" rows="4" placeholder="Write your Post here..." required></textarea> | ||
<button type="submit">Post</button> | ||
</form> | ||
</section> | ||
</main> | ||
<script type="module" src="../../scripts/post.js"></script> | ||
</body> | ||
</html> |