Cooper

Vail Logo
PROJECT ESTIMATE

Bathrooms and Showers 

$2,700,000 

Cabin Upgrades

$1,400,000 

TOTAL $4,100,000
PROJECT ESTIMATE

ADA Pathway from parking 

$400,000

TOTAL $400,000
students studing cactus
* The projected costs provided here are estimates based on information available as of June 2023. Final estimates are determined when each project is designed for the specific site and the district enters into a contract. Actual costs are determined at the completion of work.
< script type = "module" defer> // JavaScript Document import { fetchData } from "https://district.tusd1.org/_theme/js/util-fetch-data.js"; import { ensureSchoolData } from 'https://district.tusd1.org/_theme/js/util-whoami.js'; // Function to fetch bond project data from the external JSON file async function fetchBondProjectData() { const data = await fetchData(`https://district.tusd1.org/_theme/json/bond-progress.json`); return data; } // BondProject constructor function BondProject(strSchoolId, strStatus, strProject, strEstimate, strCost) { this.id = strSchoolId; this.status = strStatus; this.project = strProject; this.estimate = strEstimate; this.cost = strCost; } // Convert string to dollar format function convertStringToDollar(strValue) { let strResult = ""; if (strValue.length < 1) { return strResult; } return Number(strValue).toLocaleString("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 }); } // Write table rows for progress function writeProgressTableRows(arrayBondProjectObjs) { console.log(`Writing Progress Rows for ${arrayBondProjectObjs.length} projects`); let strRows = ""; arrayBondProjectObjs.forEach((project) => { strRows += ` ${project.status} ${project.project} ${convertStringToDollar(project.estimate)} ${convertStringToDollar(project.cost)} `; }); return strRows; } // Write full progress table function writeProgressTable(arrayBondProjectObjs) { console.log(`Writing Progress Table for ${arrayBondProjectObjs.length} projects`); const htmlTableRows = writeProgressTableRows(arrayBondProjectObjs); return ` ${htmlTableRows}
Status Project Final Estimate Actual Cost
`; } // Write progress update panel function writeProgressUpdate(strProjectContent, strProgressTitle) { return `

${strProgressTitle}

${strProjectContent}
`; } // Create a separate async function for your main logic async function initializeBondProgress() { // Ensure the school data is available await ensureSchoolData(); console.log("Initializing Bond 2023 Project Progress"); const STR_SELECTOR_PROGRESS = "main .SectionContent .panel-group"; const STR_ID_PROGRESS_CONTAINER = "progressTableContainer"; const STR_PROGRESS_HEADER = "Project Progress"; const STR_PROGRESS_TITLE = `Current ${STR_PROGRESS_HEADER}`; const STR_PROPOSED_TITLE = "Project Proposals"; let json_bond_project; const noSchoolId = document.querySelector("body").dataset.schoolid; if (noSchoolId) { console.log(`School ID: ${noSchoolId}`); // This should now log the School ID // Fetch the bond project data try { json_bond_project = await fetchBondProjectData(); } catch (error) { console.error("Error fetching bond progress:", error); return; } console.log(`Fetched ${json_bond_project.length} bond projects.`); // Filter the JSON data for projects matching the School ID, then map to BondProject objects const filteredProjects = json_bond_project .filter(project => project.SchNo === noSchoolId) .map(project => new BondProject( project.SchNo, project.Status, project.Description, project["Final_Est"], project.ActualCost )); // Log the count of created projects console.log(`Created ${filteredProjects.length} projects for School ID: ${noSchoolId}`); // Generate content based on the filtered projects const strProgressContent = filteredProjects.length > 0 ? writeProgressTable(filteredProjects) : `

No project update available for this site.

`; // Update the DOM with progress and proposed project sections const progressContainer = document.createElement('div'); progressContainer.id = STR_ID_PROGRESS_CONTAINER; progressContainer.innerHTML = `

${STR_PROGRESS_HEADER}

${writeProgressUpdate(strProgressContent, STR_PROGRESS_TITLE)} `; // Prepend progress container to the parent element const progressParent = document.querySelector(STR_SELECTOR_PROGRESS); if (progressParent) { progressParent.insertBefore(progressContainer, progressParent.firstChild); } // Append proposed project title const proposedTitle = document.createElement('h2'); proposedTitle.textContent = STR_PROPOSED_TITLE; progressContainer.appendChild(proposedTitle); // Fix page title const pageTitle = document.querySelector('.PageTitle'); if (pageTitle) { pageTitle.textContent = pageTitle.textContent.replace("Proposed", ""); } } else { console.log("No SchoolId found for the page."); } console.log("Bond Progress Update complete."); } initializeBondProgress(); < /script>