From 0f8593da3e75b8d44399c5f04edf000555b7406a Mon Sep 17 00:00:00 2001
From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>
Date: Thu, 6 Apr 2023 22:17:13 +0530
Subject: Now downloading plot information pdf as well.
---
.../view-khatian/download-document-content.ts | 228 +++++++++++++++++++++
src/scripts/functionality/view-khatian/index.ts | 30 ++-
.../view-khatian/khatian-download-document.ts | 160 ---------------
3 files changed, 250 insertions(+), 168 deletions(-)
create mode 100644 src/scripts/functionality/view-khatian/download-document-content.ts
delete mode 100644 src/scripts/functionality/view-khatian/khatian-download-document.ts
(limited to 'src/scripts/functionality/view-khatian')
diff --git a/src/scripts/functionality/view-khatian/download-document-content.ts b/src/scripts/functionality/view-khatian/download-document-content.ts
new file mode 100644
index 0000000..594db5e
--- /dev/null
+++ b/src/scripts/functionality/view-khatian/download-document-content.ts
@@ -0,0 +1,228 @@
+const sanghaFacilitationCentreBannerUrl = chrome.runtime.getURL("/assets/sangha-facilitation-centre-banner.jpg");
+
+export default (isPlotInformation: boolean, details: string, { district, block, mouza }: { district: string, block: string, mouza: string }) => `
+
+
+
${details}
+
+
+`;
diff --git a/src/scripts/functionality/view-khatian/index.ts b/src/scripts/functionality/view-khatian/index.ts
index baf6d8e..0cb3947 100644
--- a/src/scripts/functionality/view-khatian/index.ts
+++ b/src/scripts/functionality/view-khatian/index.ts
@@ -1,7 +1,7 @@
import { downloadPDF } from "@/shared/download-pdf";
-import getKhatinDetailsPDFPageData from "@/scripts/functionality/view-khatian/khatian-download-document";
+import getDetailsPDFContent from "@/scripts/functionality/view-khatian/download-document-content";
-declare function loadKhatian(): void;
+declare function load(): void;
document.addEventListener("DOMContentLoaded", () => {
const proxiedPost = $.post;
@@ -23,21 +23,33 @@ document.addEventListener("DOMContentLoaded", () => {
return element.options[element.selectedIndex].text;
};
- const downloadKhatianInformationPDF = () => {
- const documentStringContent = getKhatinDetailsPDFPageData(document.querySelector("#khdetails")!.innerHTML, {
+ let isPlotInformation: boolean | null = null;
+
+ const downloadInformationPDF = () => {
+ let contentElement = document.getElementById(isPlotInformation ? "plotdetails" : "khdetails");
+ const documentStringContent = getDetailsPDFContent(!!isPlotInformation, contentElement!.innerHTML, {
district: getValueOfSelectElement("#lstDistrictCode1"),
block: getValueOfSelectElement("#lstBlockCode1"),
mouza: getValueOfSelectElement("#lstMouzaList")
});
- downloadPDF(`${documentStringContent}
`, "khatian-details.pdf");
+ downloadPDF(`${documentStringContent}
`);
};
$.post = function() {
- if (arguments[0].startsWith("khDetailsAction_LandInfo.action")) {
+ if (arguments[0].startsWith("plotDetailsAction_LandInfo.action")) {
+ isPlotInformation = true;
+ } else if (arguments[0].startsWith("khDetailsAction_LandInfo.action")) {
+ isPlotInformation = false;
+ }
+
+ if (isPlotInformation !== null) {
const callback = arguments[2];
arguments[2] = (data: any) => {
callback(data);
- const tableElement = document.querySelector("#khdetails > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table > tbody") as HTMLElement | null;
+ const tableElement = document.querySelector(isPlotInformation
+ ? "#plotdetails > div:nth-child(1) > div:nth-child(4) > table > tbody"
+ : "#khdetails > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table > tbody"
+ ) as HTMLElement | null;
if (tableElement) {
tableElement.style.height = "auto";
@@ -48,11 +60,13 @@ document.addEventListener("DOMContentLoaded", () => {
downloadPDFButton.innerHTML = "Download PDF";
downloadPDFButton.style.cssText = styles;
downloadPDFButton.style.width = "auto";
- downloadPDFButton.addEventListener("click", downloadKhatianInformationPDF);
+ downloadPDFButton.style.marginBottom = "1rem";
+ downloadPDFButton.addEventListener("click", downloadInformationPDF);
formElement.insertBefore(downloadPDFButton, separatorElement);
}
} else if (downloadPDFButton) {
formElement.removeChild(downloadPDFButton);
+ isPlotInformation = null;
downloadPDFButton = null;
}
}
diff --git a/src/scripts/functionality/view-khatian/khatian-download-document.ts b/src/scripts/functionality/view-khatian/khatian-download-document.ts
deleted file mode 100644
index c13d0dd..0000000
--- a/src/scripts/functionality/view-khatian/khatian-download-document.ts
+++ /dev/null
@@ -1,160 +0,0 @@
-// TODO: Use the local static asset
-const sanghaFacilitationCentreBannerUrl = /* chrome.runtime.getURL("/sangha-facilitation-centre-banner.jpg") */ "https://raw.githubusercontent.com/arpitchakladar/banglar-bhumi-utils/master/static/sangha-facilitation-centre-banner.jpg";
-
-export default (khatianDetails: string, { district, block, mouza }: { district: string, block: string, mouza: string }) => `
-
-
-${khatianDetails}
-
-
-`;
--
cgit v1.2.3