From 26649f83873d9e01d23f2927f64155453918aec7 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Thu, 6 Apr 2023 18:40:24 +0530 Subject: Improved the functionality of the Download PDF button and reduced bundle size manyfold. --- src/scripts/functionality/view-khatian/index.ts | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/scripts/functionality/view-khatian/index.ts (limited to 'src/scripts/functionality/view-khatian/index.ts') diff --git a/src/scripts/functionality/view-khatian/index.ts b/src/scripts/functionality/view-khatian/index.ts new file mode 100644 index 0000000..baf6d8e --- /dev/null +++ b/src/scripts/functionality/view-khatian/index.ts @@ -0,0 +1,63 @@ +import { downloadPDF } from "@/shared/download-pdf"; +import getKhatinDetailsPDFPageData from "@/scripts/functionality/view-khatian/khatian-download-document"; + +declare function loadKhatian(): void; + +document.addEventListener("DOMContentLoaded", () => { + const proxiedPost = $.post; + + const submitButtonElement = document.querySelector("#khbutton") as HTMLButtonElement; + const separatorElement = document.querySelector("#bodycover > div > form > hr:nth-child(2)") as HTMLElement; + const formElement = document.querySelector("#bodycover > div > form") as HTMLElement; + let downloadPDFButton: HTMLButtonElement | null = null; + + const submitButtonElementComputedStyles = window.getComputedStyle(submitButtonElement); + const styles = Array.from(submitButtonElementComputedStyles) + .reduce( + (str, property) => `${str}${property}:${submitButtonElementComputedStyles.getPropertyValue(property)};`, + "" + ); + + const getValueOfSelectElement = (selector: string) => { + const element = document.querySelector(selector) as HTMLSelectElement; + return element.options[element.selectedIndex].text; + }; + + const downloadKhatianInformationPDF = () => { + const documentStringContent = getKhatinDetailsPDFPageData(document.querySelector("#khdetails")!.innerHTML, { + district: getValueOfSelectElement("#lstDistrictCode1"), + block: getValueOfSelectElement("#lstBlockCode1"), + mouza: getValueOfSelectElement("#lstMouzaList") + }); + downloadPDF(`