adding stuff

This commit is contained in:
Chris Cochrun 2025-06-27 09:43:33 -05:00
parent e0b4c55364
commit a94eb03a40
47 changed files with 852 additions and 575 deletions

View file

@ -43,7 +43,7 @@ impl From<&CampForm> for HashMap<&str, String> {
fn from(form: &CampForm) -> Self {
let mut map = HashMap::new();
map.insert(
"Full_Name",
"Student_Name",
format!("{} {}", form.first_name.0, form.last_name.0),
);
map.insert(
@ -52,15 +52,15 @@ impl From<&CampForm> for HashMap<&str, String> {
);
map.insert("Parent_Phone", form.parent_phone.0.clone());
map.insert("Parent_Email", form.parent_email.0.clone().clone());
map.insert("Birth_Date", form.birthdate.0.clone());
map.insert("Birthdate", form.birthdate.0.clone());
map.insert("Gender", form.gender.0.clone());
map.insert("Street_Address", form.street.0.clone());
map.insert("Street", form.street.0.clone());
map.insert("City", form.city.0.clone());
map.insert("State", form.state.0.clone());
map.insert("Zipcode", form.zip.0.clone().to_string());
map.insert("Zip", form.zip.0.clone().to_string());
map.insert("Grade", form.grade.0.clone());
map.insert("Week_Chosen", form.week.0.clone());
map.insert("Shirt_Size", form.shirt.0.clone());
map.insert("Week", form.week.0.clone());
map.insert("Shirt", form.shirt.0.clone());
map.insert("Registration", form.registration.0.clone());
map.insert("Health_Form", form.health_form.0.clone());
map
@ -302,7 +302,7 @@ async fn store_camp_form(map: HashMap<&str, String>) -> Result<Response> {
fields.insert("fields", map);
json.insert("records", vec![fields]);
let response = request
.post("https://table.tfcconnection.org/api/docs/opaHfFbgoZzdPYXhrUt2S8/tables/Camp_Data/records")
.post("https://table.tfcconnection.org/api/docs/opaHfFbgoZzdPYXhrUt2S8/tables/Camp_Process/records")
.bearer_auth("b8189d1b315548aa610db2fd3a43177a967cd41f")
.header("Content-Type", "application/json")
.json(&json)

View file

@ -1,76 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
h1 {
@apply text-2xl;
}
h2 {
@apply text-xl;
}
p {
@apply pb-4;
}
ul, ol {
@apply list-outside;
@apply pl-6; /* Indent the list elements. */
@apply mb-4; /* The bottom of the list should have a margin, like the paragraphs. */
/* Lists within a list, however, should not have a bottom margin. */
ul, ol {
@apply mb-0;
}
}
ul {
@apply list-disc;
}
ol {
@apply list-decimal;
}
blockquote {
p {
@apply py-0;
}
@apply italic;
@apply border-l-2;
@apply border-neutral-500;
@apply pl-4;
@apply mb-4;
@apply text-neutral-600;
@apply dark:text-neutral-400;
}
img {
@apply py-0;
@apply rounded-lg;
@apply shadow-xl;
@apply object-cover;
}
}
/* Global default styles */
html {
scroll-behavior: smooth;
}
/* Default Pages content styles */
#page-content a {
@apply underline;
}
#page-content p, h2 {
@apply py-4;
}
#page-content :is(h1, h2, h3, h4, h5, h6) {
@apply underline;
}
#page-content pre {
@apply p-4 my-4 overflow-x-auto;
}

View file

@ -1,7 +0,0 @@
document.addEventListener("DOMContentLoaded", function() {
document.getElementById('switch-lang')?.addEventListener('click', switchLang);
})
function switchLang(event) {
document.getElementById('switch-lang-panel').classList.toggle('hidden')
}

View file

@ -1,78 +0,0 @@
document.addEventListener("DOMContentLoaded", function() {
// ---------------- Selected Navbar Link -------------------------
let navbar_links = document.querySelectorAll('.nav-links a');
let trim_last_slash = window.location.href.replace(/\/$/, '');
let selected_navbar_link = [...navbar_links].filter((item) => {
return ((item.href === trim_last_slash) || (item.href === window.location.href))
})
if (selected_navbar_link.length !== 0) {
for (let element of selected_navbar_link) {
element.className = "bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium"
}
}
// ---------------- Switch Theme -------------------------
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
document.getElementById('dark').classList.add('hidden');
document.getElementById("syntax_highlight").href = "/syntax-dark.css";
} else {
document.documentElement.classList.remove('dark')
document.getElementById('light').classList.add('hidden');
document.getElementById("syntax_highlight").href = "/syntax-light.css";
}
// Switch theme action
document.getElementById('switch-theme')?.addEventListener('click', switchTheme);
// ---------------- Toggle Sidebar -------------------------
document.getElementById('toggle-sidebar')?.addEventListener('click', toggleSidebar);
// ---------------- Toggle Mobile menu -------------------------
document.getElementById('toggle-mobile-menu')?.addEventListener('click', toggleMobileMenu);
});
function switchTheme() {
let current_theme = ([...document.documentElement.classList].includes('dark')) ? 'dark' : 'light';
if (current_theme === 'dark') {
localStorage.theme = 'light';
document.documentElement.classList.remove('dark');
document.getElementById('light').classList.add('hidden');
document.getElementById('dark').classList.remove('hidden');
document.getElementById("syntax_highlight").href = "/syntax-light.css";
} else {
localStorage.theme = 'dark';
document.documentElement.classList.add('dark');
document.getElementById('dark').classList.add('hidden');
document.getElementById('light').classList.remove('hidden');
document.getElementById("syntax_highlight").href = "/syntax-dark.css";
}
}
function toggleSidebar() {
let sidebar = document.getElementById('sidebar');
if ([...sidebar.classList].includes('translate-x-0')) {
document.body.style.removeProperty("overflow")
sidebar.classList.remove('translate-x-0')
sidebar.classList.add('-translate-x-full')
} else {
document.body.style.setProperty("overflow", "hidden")
sidebar.classList.remove('-translate-x-full')
sidebar.classList.add('translate-x-0')
}
}
function toggleMobileMenu() {
let menu = document.querySelector('#mobile-menu div.nav-links');
if ([...menu.classList].includes('h-screen')) {
document.body.classList.remove("overflow-hidden", "relative")
document.documentElement.classList.remove("overscroll-none",)
menu.classList.remove('h-screen')
menu.classList.add('h-0')
} else {
document.body.classList.add("overflow-hidden", "relative")
document.documentElement.classList.add("overscroll-none",)
menu.classList.remove('h-0')
menu.classList.add('h-screen')
}
}

View file

@ -1,38 +0,0 @@
document.addEventListener("DOMContentLoaded", function() {
// ---------------- TOC Scrollspy --------------------
if (document.getElementById('toc') !== null) {
const table_of_content_links = document.querySelectorAll('#toc li a')
let page_titles_ids = [];
[...table_of_content_links].forEach((item)=> {
page_titles_ids.push(item.href.substring(item.href.indexOf("#")))
})
const page_titles_elements = document.querySelectorAll(page_titles_ids.join(','));
let reversed_title_elements = [...page_titles_elements].reverse();
let elem = getActiveTocElement(reversed_title_elements) || page_titles_elements[0]; //If no element has gone outside of viewport on y axis
findCorrespondingTocTitle(elem).classList.add('bg-blue-700') //page load
var previous_elem = elem
window.addEventListener('scroll', () => {
let element = getActiveTocElement(reversed_title_elements) || page_titles_elements[0];
if (element !== previous_elem) {
findCorrespondingTocTitle(previous_elem).classList.remove('bg-blue-700')
findCorrespondingTocTitle(element).classList.add('bg-blue-700')
previous_elem = element
}
})
}
});
function getActiveTocElement(elements) {
return [...elements].find((item) => {
return (item.getBoundingClientRect().y <= 0)
})
}
function findCorrespondingTocTitle(element) {
return [...document.querySelectorAll('#toc li a')].find((item) => {
return item.href.substring(item.href.indexOf("#")) === `#${element.id}`
})
}

View file

@ -1,121 +0,0 @@
document.addEventListener("DOMContentLoaded", function() {
// let search_input = document.getElementById('search').addEventListener('click', openSearch)
// var openmodal = document.querySelectorAll('.modal-open')
// for (var i = 0; i < openmodal.length; i++) {
// openmodal[i].addEventListener('click', function(event){
// event.preventDefault()
// toggleSearchModal()
// })
// }
let nav_search_input = document.getElementById('search');
nav_search_input.addEventListener('click', function(event){
event.preventDefault()
toggleSearchModal()
})
const overlay = document.querySelector('.modal-overlay')
overlay.addEventListener('click', toggleSearchModal)
let closemodal = document.querySelectorAll('.modal-close')
// closemodal.addEventListener('click', toggleSearchModal)
for (var i = 0; i < closemodal.length; i++) {
closemodal[i].addEventListener('click', toggleSearchModal)
}
document.onkeydown = function(evt) {
evt = evt || window.event
let isEscape = false
let isCmdK = false
if ("key" in evt) {
isEscape = (evt.key === "Escape" || evt.key === "Esc")
isCmdK = (evt.key === "k" && evt.metaKey === true)
} else {
isCmdK = (evt.keyCode === 75 && evt.metaKey)
isEscape = (evt.keyCode === 27)
}
if (isCmdK) { evt.preventDefault() }
if ((isEscape && document.body.classList.contains('search-active')) || isCmdK) {
toggleSearchModal();
}
};
let search_index = elasticlunr.Index.load(window.searchIndex);
let elasticlunr_options = {
bool: "AND",
fields: {
title: {boost: 2},
body: {boost: 1},
}
};
let search_term = "";
let search_results = "";
let search_input = document.getElementById('search-input');
let search_results_container = document.getElementById('search-results');
search_input.addEventListener('keyup', function(event) {
// Trigger search
if ([...document.body.classList].includes('search-active') && search_input.value.trim().length > 3) {
// console.log('search')
search_term = search_input.value.trim();
// console.log(search_term)
search_results = search_index.search(search_term, elasticlunr_options);
// console.log(search_results)
if (Array.isArray(search_results) && search_results.length > 0) {
let result_list = document.getElementById('results-list');
result_list.replaceChildren();
let item = "";
for (i = 0; i < search_results.length; i++) {
let item = formatResultItem(search_results[i]);
result_list.appendChild(item);
}
}
// if (results.length === 0) {
// $searchResults.style.display = "none";
// return;
// }
}
})
});
function toggleSearchModal () {
const modal = document.getElementById('search-modal')
modal.classList.toggle('opacity-0')
modal.classList.toggle('pointer-events-none')
document.body.classList.toggle('search-active')
if ([...document.body.classList].includes('search-active')) {
// window.setTimeout(function() {
document.getElementById('search-input').value = ""
document.getElementById('search-input').focus()
// }, 500);
}
}
function formatResultItem(search_result) {
console.log(search_result)
let formatted_result = `<li class="flex hover:bg-gray-200 dark:hover:bg-gray-600 text-black dark:text-gray-200 p-2 rounded-lg border border-black dark:border-gray-200 bg-gray-200 dark:bg-gray-500 rounded-lg hover:shadow-xl mb-2">
<a href="${search_result.doc.path}">
<span class="text-xl text-bold">${search_result.doc.title}</span>
<span class="text-lg">${search_result.doc.description}</span>
</a>
</li>`
return htmlToElement(formatted_result)
}
// Credits : https://stackoverflow.com/a/35385518/7098666
function htmlToElement(html) {
let template = document.createElement('template');
html = html.trim();
template.innerHTML = html;
return template.content.firstChild;
}
// function openSearch() {
// console.log("open modal");
// let search_modal = document.getElementById('search-modal');
// search_modal.classList.remove('hidden');
// console.log(search_modal);
// }
// function search() {
// let index = elasticlunr.Index.load(window.searchIndex);
// }