function loadXMLDoc(selectObject) { const xmlFile = new Object(); xmlFile.educator = "https://img1.wsimg.com/blobby/go/0542d7e9-3b6a-4224-a41b-e5f3bdbd03e2/downloads/educator.txt?ver=1643718332907"; xmlFile.firefighter = "https://img1.wsimg.com/blobby/go/0542d7e9-3b6a-4224-a41b-e5f3bdbd03e2/downloads/582c0302-f463-4046-956f-d553077e5a40/firefighter.txt?ver=1737044287601"; xmlFile.law_enforcement = "https://img1.wsimg.com/blobby/go/0542d7e9-3b6a-4224-a41b-e5f3bdbd03e2/downloads/277f9a9c-7790-4efa-9096-6af651218a38/law_enforcement.txt?ver=1737044287601"; xmlFile.medical_professional = "https://img1.wsimg.com/blobby/go/0542d7e9-3b6a-4224-a41b-e5f3bdbd03e2/downloads/medical_professional.txt?ver=1643718332907"; xmlFile.real_estate = "https://img1.wsimg.com/blobby/go/0542d7e9-3b6a-4224-a41b-e5f3bdbd03e2/downloads/real_estate.txt?ver=1643718332907"; xmlFile.self_employed = "https://img1.wsimg.com/blobby/go/0542d7e9-3b6a-4224-a41b-e5f3bdbd03e2/downloads/self_employed.txt?ver=1673617485014"; var occupation = selectObject.value; const fn = eval("xmlFile." + occupation); const xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { showWorksheet(this); } }; xhttp.open("GET", fn, true); xhttp.send(); } function showWorksheet(xml) { var demoTxt, parser, introTxt, printIT, categories, categoryIndex, catDetails, detailIndex, xmlDoc, tabBar, expense , names, catName, divContent, totalContent; var txt =""; parser = new DOMParser(); // work-around because GoDaddy doesn't support XML file extensions, so we used .txt instead xmlDoc = parser.parseFromString(xml.responseText, "text/xml"); // xmlDoc = xml.responseXML; tabBar = ""; divContent = ""; totalContent = ""; printIT = ""; demoTxt = ""; categories = xmlDoc.getElementsByTagName('category'); names = xmlDoc.getElementsByTagName('name'); introTxt = "

Choose from the categories below and enter the amount you've spent for each type of expense. The totals will" + " be automatically calculated. When finished, click on \"Print Worksheet\" and choose to save a PDF from the print window." + " Please then upload the PDF file to the Sea to Sea Tax Client Portal (TaxDome). For help with creating a PDF document, please refer to this HOW-TO article.

" + "

Hint: When calculating qualified mileage deductions, please refer to the official IRS Standard Mileage Rates and use the appropriate tax filing year.

"; for (categoryIndex = 0; categoryIndex < categories.length; categoryIndex++) { catDetails = categories[categoryIndex].children; //outputs array of details catName = names[categoryIndex].childNodes[0].nodeValue; if (categoryIndex == 0) { tabBar += ""; divContent += "
"; } else { tabBar += ""; divContent += "
"; } divContent += "
"; for (detailIndex = 1; detailIndex < catDetails.length; detailIndex++) { expense = catDetails[detailIndex].childNodes[0].nodeValue; divContent += "
"; divContent += "

" + expense + ":

"; divContent += "
"; divContent += "
"; } divContent += "
"; divContent += "

Total " + catName + ":

"; divContent += "
"; divContent += "
"; divContent += "
"; divContent += "
"; } totalContent += "
"; totalContent += "

Grand Total:

"; totalContent += "

"; printIT += ""; document.getElementById("introTxt").innerHTML = introTxt; document.getElementById("tabBar").innerHTML = tabBar; document.getElementById("expenseForms").innerHTML = divContent; document.getElementById("grandTotal").innerHTML = totalContent; document.getElementById("printIT").innerHTML = printIT; } function openCategory(evt, categoryName) { const x = document.getElementsByClassName("category"); const tablinks = document.getElementsByClassName("tablink"); // Hide the div for categories not selected from the bar & add class to be used by generatePDF() for (let i = 0; i < x.length; i++) { x[i].style.display = "none"; x[i].classList.add('unchosen'); } // Change button color for categories not selected from the bar for (let i = 0; i < x.length; i++) { tablinks[i].classList.remove('w3-cyan'); } // show expense category selected from button bar document.getElementById(categoryName).style.display = "block"; document.getElementById(categoryName).classList.remove('unchosen'); evt.currentTarget.classList.add('w3-cyan'); } function calculateTotal(categoryNum, numExpenses) { let i = 0; let subTotal = 0; let grandTotal = 0; let className = "\"cat_" + categoryNum + "\""; let subTotalName = "\"cat_" + categoryNum + "_total\""; let expensesObject = document.getElementsByClassName(eval(className)); let totalsObject = document.getElementsByClassName("total"); // Sum up totals for each category of expenses for (i=0; i < expensesObject.length; i++) { subTotal += Number(expensesObject[i].value); } // Update sub-total on worksheet document.getElementById(eval(subTotalName)).value = numberWithCommas(subTotal.toFixed(2)); // Calculate Grand Total from category totals for (i=0; i< totalsObject.length; i++) { // Remove commas to avoid NaN error in grand total grandTotal += Number(numberWithNoCommas(totalsObject[i].value)); } // Update grand total on worksheet document.getElementById("grand_total").value = numberWithCommas(grandTotal.toFixed(2)); } function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function numberWithNoCommas(x) { return x.toString().replace(/,/g, ''); } function refreshIframe(selectObject) { loadXMLDoc(selectObject); // pause for body.scrollHeight to be updated //const myTimeout = setTimeout(resizeIframe,500); } function unhideCategories() { // unhide expense categories to include on print or PDF export var x = document.getElementsByClassName("unchosen"); var i; for (i = 0; i < x.length; i++) { x[i].style.display = 'block'; } } function hideCategories() { // re-hide the expense categories that aren't chosen from the menu bar var x = document.getElementsByClassName("unchosen"); var i; for (i = 0; i < x.length; i++) { x[i].style.display = 'none'; } } function downloadPDFWithBrowserPrint() { //afterprint method doesn't work if print dialog canceled on Chrome/Edge, but eventlistener does window.addEventListener('afterprint', hideCategories); unhideCategories(); window.print(); window.onafterprint(hideCategories); // needed by IOS window.removeEventListener('afterprint', hideCategories); } function addModals() { // Add allow-modals to sandboxed iFrame provided by GoDaddy parent HTML element so we can save PDF/print let iFrameID = parent.document.getElementsByTagName("iframe").item(0).id; iFrame = parent.document.getElementById(iFrameID); if (iFrame.sandbox.value.search("allow-modals") == -1) { iFrame.sandbox.value += " allow-modals allow-downloads"; iFrame.contentWindow.location.reload(true); } }