Skip to content

Commit

Permalink
added team details
Browse files Browse the repository at this point in the history
  • Loading branch information
joypan1 committed Feb 27, 2024
1 parent 68d9d80 commit 8cc91c7
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 52 deletions.
83 changes: 81 additions & 2 deletions pages/teamdetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
</head>
<body>



<nav>
<div class = "heading">
<h1> Longmetal 7127 </h1>
Expand Down Expand Up @@ -68,6 +66,87 @@ <h1> Team Details </h1>
<h2> Abilities </h2>

<br>
<!-- Autonomous Survey-->
<label for="Autonomous Starting position"> Autonomous Starting Position: </label>
<input type="text" id="startingpos" name="startingpos" maxlength="1">

<form action="/action_page.php">
<input type="checkbox" id="action1" name="Leaveszone" value="leaves">
<label for="action1"> Leaves zone</label><br>
<input type="checkbox" id="action2.0" name="scores1amp" value="scores1amp">
<label for="action2.0"> Scores 1st in amp</label><br>
<input type="checkbox" id="action2.1" name="scores1speaker" value="scores1speaker">
<label for="action2.1"> Scores 1st in speaker</label><br><br>
<input type="checkbox" id="action3" name="picksup" value="picksup">
<label for="action3"> Picks up new note</label><br><br>
<input type="checkbox" id="action4.0" name="scores2amp" value="scores2amp">
<label for="action4.0"> Scores 2nd in amp</label><br>
<input type="checkbox" id="action4.1" name="scores2speaker" value="scores2speaker">
<label for="action4.1"> Scores 2nd in speaker</label><br><br>

</form>

<br>
<!-- Teleop Survey-->
<form action="/action_page.php">
<p>Preferred scoring method:</p>
<input type="radio" id="amp" name="score" value="amp">
<label for="amp">Amp</label><br>
<input type="radio" id="speaker" name="score" value="speaker">
<label for="css">Speaker</label><br>
<input type="radio" id="either" name="score" value="either">
<label for="either">Either</label>
</form>

<br>

<p>Preferred Intake method:</p>
<input type="radio" id="ground" name="intake" value="ground">
<label for="ground">Ground</label><br>
<input type="radio" id="human" name="intake" value="human">
<label for="human">Human Player</label><br>
<input type="radio" id="" name="intake" value="either">
<label for="either">Either</label>
</form>

<label for="prefintake"> Other: </label>
<input type="text" id="" name="prefintake" maxlength="1">

<br>

<form action="/action_page.php">
<p>Preferred scoring method:</p>
<input type="radio" id="amp" name="score" value="amp">
<label for="amp">Amp</label><br>
<input type="radio" id="speaker" name="score" value="speaker">
<label for="css">Speaker</label><br>
<input type="radio" id="either" name="score" value="either">
<label for="either">Either</label>
</form>

<form action="/action_page.php">
<p>Stage abilities:</p>
<input type="checkbox" id="spotlight" name="spotlight" value="spotlight">
<label for="spotlight"> Enters stage</label><br>
<input type="checkbox" id="trap" name="trap" value="trap">
<label for="trap"> Scores in trapdoor </label><br>
<input type="checkbox" id="alone" name="alone" value="alone">
<label for="alone"> Hangs alone </label><br>
<input type="checkbox" id="another" name="another" value="another">
<label for="another"> Hangs with another </label><br>
</form>

<br>

<!-- Human Player Survey-->
<form action="/action_page.php">
<input type="checkbox" id="spotlight" name="spotlight" value="spotlight">
<label for="spotlight"> Attempts Spotlight</label><br>
<input type="checkbox" id="coop" name="coop" value="coop">
<label for="coop"> Favors coopertition button</label><br>
</form>

<br>

<!-- <h1>Team Details</h1>
<div id="team-details">
Expand Down
100 changes: 50 additions & 50 deletions pages/teamdetails.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
// document.addEventListener('DOMContentLoaded', async () => {
// const urlParams = new URLSearchParams(window.location.search);
// const id = urlParams.get('id');
document.addEventListener('DOMContentLoaded', async () => {
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get('id');

// const nameInput = document.getElementById('teamnumber');
// const emailInput = document.getElementById('email');
const nameInput = document.getElementById('teamnumber');
const emailInput = document.getElementById('email');

// // Check if ID exists, if yes, populate the form fields
// if (id) {
// try {
// const response = await fetch(`/getData?id=${id}`);
// const data = await response.json();
// Check if ID exists, if yes, populate the form fields
if (id) {
try {
const response = await fetch(`/getData?id=${id}`);
const data = await response.json();

// // Populate the form fields with existing data
// nameInput.value = data.teamnumber || '';
// emailInput.value = data.email || '';
// } catch (error) {
// console.error('Error fetching data:', error);
// }
// }
// Populate the form fields with existing data
nameInput.value = data.teamnumber || '';
emailInput.value = data.email || '';
} catch (error) {
console.error('Error fetching data:', error);
}
}

// const form = document.getElementById('dataForm');
// form.addEventListener('submit', async (event) => {
// event.preventDefault();
const form = document.getElementById('dataForm');
form.addEventListener('submit', async (event) => {
event.preventDefault();

// const formData = {
// name: nameInput.value,
// email: emailInput.value
// };
const formData = {
name: nameInput.value,
email: emailInput.value
};

// try {
// // Handle submitting new information
// // Here you can send the formData to your server
// console.log('Submitting data:', formData);
try {
// Handle submitting new information
// Here you can send the formData to your server
console.log('Submitting data:', formData);

// // Optionally, you can also save the submitted data to IndexedDB
// // This ensures that the form is pre-filled the next time it's accessed with the same ID
// await saveDataToIndexedDB(formData, id);
// Optionally, you can also save the submitted data to IndexedDB
// This ensures that the form is pre-filled the next time it's accessed with the same ID
await saveDataToIndexedDB(formData, id);

// // Reset the form after submission
// form.reset();
// } catch (error) {
// console.error('Error submitting data:', error);
// }
// });
// });
// Reset the form after submission
form.reset();
} catch (error) {
console.error('Error submitting data:', error);
}
});
});

// async function saveDataToIndexedDB(data, id) {
// const db = await openDB('myIndexedDB', 1);
// const tx = db.transaction('storeName', 'readwrite');
// const store = tx.objectStore('storeName');
async function saveDataToIndexedDB(data, id) {
const db = await openDB('myIndexedDB', 1);
const tx = db.transaction('storeName', 'readwrite');
const store = tx.objectStore('storeName');

// // If an ID exists, update existing data; otherwise, add new data
// if (id) {
// await store.put(data, id);
// } else {
// await store.add(data);
// }
// If an ID exists, update existing data; otherwise, add new data
if (id) {
await store.put(data, id);
} else {
await store.add(data);
}

// await tx.done;
// }
await tx.done;
}


/* function submitform() {
Expand Down

0 comments on commit 8cc91c7

Please sign in to comment.