-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
a4b6ae4
commit e85b585
Showing
5 changed files
with
100 additions
and
45 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
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,49 @@ | ||
import { collection, getDocs } from "https://www.gstatic.com/firebasejs/9.22.1/firebase-firestore.js"; | ||
import { db } from "./firebase.js"; | ||
|
||
"use strict"; | ||
(function () { | ||
|
||
window.addEventListener("load", init); | ||
|
||
/** | ||
* Initialization function that should handle anything that needs to occur | ||
* on page load (include changing from one page to another). | ||
*/ | ||
function init() { | ||
setUpToastContent(); | ||
setUpToastOnClick(); | ||
} | ||
|
||
function setUpToastOnClick() { | ||
const toast = document.getElementById("toast"); | ||
if (!toast) return; | ||
|
||
toast.addEventListener("click", (evt) => { | ||
evt.preventDefault(); | ||
toast.classList.add("hide"); | ||
setTimeout(() => { | ||
const link = toast.getAttribute("href"); | ||
window.open(link, "_blank"); | ||
}, 500); // match to toast hide animation | ||
}); | ||
} | ||
|
||
async function getEventContent() { | ||
console.log("Loading event from server..."); | ||
const querySnapshot = await getDocs(collection(db, "posts")); | ||
|
||
const posts = []; | ||
querySnapshot.forEach((doc) => { | ||
posts.push(doc.data()); // doc.data() is never undefined for query doc snapshots | ||
}); | ||
posts.reverse(); | ||
blogPosts = posts; | ||
|
||
localStorage.setItem("cachedPosts", JSON.stringify(posts)); | ||
localStorage.setItem("cachedTime", new Date().toISOString()); | ||
window.dispatchEvent(new Event("posts-loaded")); | ||
console.log(`Loaded ${blogPosts.length} posts from server.`); | ||
} | ||
|
||
})(); |
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,15 @@ | ||
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.1/firebase-app.js" | ||
import { getFirestore } from "https://www.gstatic.com/firebasejs/9.22.1/firebase-firestore.js" | ||
|
||
export const firebaseConfig = { | ||
apiKey: "AIzaSyDtv_mjLaZQImF4KoKy6s-moer6TtOVJiI", | ||
authDomain: "geosmart-uw.firebaseapp.com", | ||
projectId: "geosmart-uw", | ||
storageBucket: "geosmart-uw.appspot.com", | ||
messagingSenderId: "244030791746", | ||
appId: "1:244030791746:web:f6c34ef4b145ab7d1a8ddb", | ||
measurementId: "G-9L9TCCS7HD" | ||
} | ||
|
||
export const app = initializeApp(firebaseConfig); | ||
export const db = getFirestore(app); |
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