diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-04-06 22:17:13 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-04-06 22:32:09 +0530 |
| commit | 0f8593da3e75b8d44399c5f04edf000555b7406a (patch) | |
| tree | 4e1c5fbbd6a27d35b91a194525c9d5972dcf5cfb /src/scripts/functionality | |
| parent | 26649f83873d9e01d23f2927f64155453918aec7 (diff) | |
| download | banglar-bhumi-utils-0f8593da3e75b8d44399c5f04edf000555b7406a.tar.gz banglar-bhumi-utils-0f8593da3e75b8d44399c5f04edf000555b7406a.zip | |
Now downloading plot information pdf as well.
Diffstat (limited to 'src/scripts/functionality')
3 files changed, 250 insertions, 168 deletions
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 }) => ` +<style> + * { + box-sizing: border-box !important; + text-decoration: none; + margin: 0; + padding: 0; + } + + body { + width: 100%; + margin: 0 !important; + padding: 0 !important; + } + + #content { + width: 100%; + min-height: calc(100vw * 1.4); + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + } + + .banner { + width: 100%; + } + + .details { + padding: 1rem; + } + + #locater-information { + width: 100%; + margin-bottom: 1rem; + } + + #locater-information, + .details#plot-information > div:nth-child(1) > div:nth-child(5) > table { + border-collapse: collapse; + } + + .details#khatian-information > table, + .details#plot-information > div:nth-child(1) { + width: 100% !important; + border-spacing: 0; + border: 1px solid black; + } + + .details#plot-information > div:nth-child(1) > div:nth-child(1) { + text-align: center !important; + } + + .details#plot-information > div:nth-child(1) > div:nth-child(1) { + margin: 0 !important; + } + + .details#plot-information > div > div > table tr { + border-bottom: 1px solid black; + } + + .details#plot-information > div:nth-child(1) > div:nth-child(3) > table > tbody > tr > th:last-child, + .details#plot-information > div:nth-child(1) > div:nth-child(3) > table > tbody > tr > td:last-child, + .details#plot-information > div:nth-child(1) > div:nth-child(3) > table, + .details#plot-information > div:nth-child(1) > div:nth-child(5) > table > tbody > tr > td:last-child, + .details#plot-information #headertitle > tr > th:last-child, + .details#plot-information > div:nth-child(1) > div:nth-child(5) > table > tbody > tr:last-child { + border: none !important; + } + + .details#plot-information > div:nth-child(1) > div { + position: initial !important; + left: 0 !important; + width: 100% !important; + border-left: 0 !important; + border-right: 0 !important; + } + + .details#plot-information > div:nth-child(2) { + display: none; + } + + .details#plot-information > div:nth-child(1) > div:nth-child(5) > table > tbody > tr { + background-color: transparent !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1), + .details#plot-information > div:nth-child(1) > div:nth-child(3) > table { + width: 100% !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(2) { + display: none; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(1), + .details#khatian-information > table > tbody > tr > td:nth-child(1) > p:nth-child(4) { + text-align: center; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) { + width: 100% !important; + position: initial !important; + left: 0 !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table, + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table { + width: 100% !important; + border: none !important; + } + + .details table tbody tr tr, + .details table tbody tr th, + .details table tbody tr td { + border: none !important; + background-color: transparent; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) td, + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) th { + text-align: left; + } + + .details#khatian-information > table > tbody > tr > td > div > table > tbody > tr > th, + .details#khatian-information > table > tbody > tr > td > div > table > tbody > tr > td, + .details#plot-information td { + padding: 0 0.2rem 0 0.2rem; + } + + .details table tbody tr tr, + #locater-information tr { + border-bottom: 1px solid black !important; + } + + .details table tbody tr tr:last-child { + border: none; + } + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1) > th { + font-weight: 500; + } + + .details table tbody tr th, + .details table tbody tr td, + .details#plot-information #headertitle > tr > th { + border-right: 1px solid black !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1), + #headertitle > tr, + .details#plot-information > div:nth-child(1) > div:nth-child(3) > table > tbody > tr.table-text.knwurprpty_tbl_head_txt.ng-scope, + #headertitle, + #locater-information tr:nth-child(1) { + border-top: 1px solid black !important; + border-color: black !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table > tbody > tr:last-child { + border: none !important; + } + + .details#khatian-information > table tbody tr tr th:last-child, .details table tbody tr tr td:last-child, + #locater-information tr > td:last-child { + border-right: none !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > p:nth-child(4) { + margin-top: 1rem !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(5), + .details#plot-information > div:nth-child(1) > div:nth-child(5) { + position: initial !important; + left: 0 !important; + top: 0 !important; + margin: 0 !important; + width: 100% !important; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > p:nth-child(3) { + display: none; + } + + .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1) > th { + width: 50%; + } + + .footer { + width: 100%; + margin-top: auto; + } +</style> +<img class="banner" src="https://banglarbhumi.gov.in/BanglarBhumi/images/bl.png"> +<div class="details" id=${isPlotInformation ? "plot-information" : "khatian-information"}>${details}</div> +<img class="footer" src="${sanghaFacilitationCentreBannerUrl}"> +<script> + let tableBodyElement; + const createTableEntry = (label, value) => { + const tableRowElement = document.createElement("tr"); + const tableLabelColumnElement = document.createElement("td"); + tableLabelColumnElement.innerHTML = label; + const tableValueColumnElement = document.createElement("td"); + tableValueColumnElement.innerHTML = value; + tableRowElement.appendChild(tableLabelColumnElement); + tableRowElement.appendChild(tableValueColumnElement); + tableBodyElement.appendChild(tableRowElement); + }; + ${isPlotInformation + ? ` + const tableElement = document.createElement("table"); + tableElement.setAttribute("id", "locater-information"); + tableBodyElement = document.createElement("tbody"); + tableElement.appendChild(tableBodyElement); + const detailsElement = document.querySelector("#plot-information > div:nth-child(1)"); + console.log(detailsElement.querySelector("div:nth-child(2)")); + detailsElement.insertBefore(tableElement, detailsElement.querySelector("div:nth-child(2)")); + ` + : ` + tableBodyElement = document.querySelector(".details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody"); + ` + } + createTableEntry("\u{99C}\u{9C7}\u{9B2}\u{9BE} (District):", "${district}"); + createTableEntry("\u{9AC}\u{9CD}\u{9B2}\u{995} (Block):", "${block}"); + createTableEntry("\u{9AE}\u{9CC}\u{99C}\u{9BE} (Mouza):", "${mouza}"); +</script> +`; 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(`<div id="content">${documentStringContent}</div>`, "khatian-details.pdf"); + downloadPDF(`<div id="content">${documentStringContent}</div>`); }; $.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 }) => ` -<style> - * { - box-sizing: border-box !important; - text-decoration: none; - margin: 0; - padding: 0; - } - - body { - width: 100%; - height: 100%; - margin: 0 !important; - padding: 0 !important; - } - - #content { - width: 100%; - margin: 0; - padding: 0; - } - - .banner { - width: 100%; - } - - .khatian-details { - padding: 1rem; - } - - .khatian-details > table { - width: 100% !important; - border-spacing: 0; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) { - width: 100% !important; - } - - .khatian-details > table > tbody > tr > td:nth-child(2) { - display: none; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(1), - .khatian-details > table > tbody > tr > td:nth-child(1) > p:nth-child(4) { - text-align: center; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) { - width: 100% !important; - position: initial !important; - left: 0 !important; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table, - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table { - width: 100% !important; - border: none !important; - } - - .khatian-details table tbody tr tr, - .khatian-details table tbody tr th, - .khatian-details table tbody tr td { - border: none !important; - background-color: transparent; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) td, - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) th { - text-align: left; - } - - .khatian-details > table > tbody > tr > td > div > table > tbody > tr > th, - .khatian-details > table > tbody > tr > td > div > table > tbody > tr > td { - padding: 0 0.2rem 0 0.2rem; - } - - .khatian-details table tbody tr tr { - border-bottom: 1px solid #808080 !important; - } - - .khatian-details table tbody tr tr:last-child { - border: none; - } - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1) > th { - font-weight: 500; - } - - .khatian-details table tbody tr th, .khatian-details table tbody tr td { - border-right: 1px solid #808080 !important; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1), - #headertitle > tr { - border-top: 1px solid #808080 !important; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table > tbody > tr:last-child { - border: none !important; - } - - .khatian-details > table tbody tr tr th:last-child, .khatian-details table tbody tr tr td:last-child { - border-right: none !important; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > p:nth-child(4) { - margin-top: 1rem !important; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(5) { - position: initial !important; - left: 0 !important; - top: 0 !important; - margin: 0 !important; - width: 100% !important; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > p:nth-child(3) { - display: none; - } - - .khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1) > th { - width: 50%; - } - - .footer { - width: 100%; - margin-top: 1rem; - } -</style> -<img class="banner" src="https://banglarbhumi.gov.in/BanglarBhumi/images/bl.png"> -<div class="khatian-details">${khatianDetails}</div> -<img class="footer" src="${sanghaFacilitationCentreBannerUrl}"> -<script> - const tableBodyElement = document.querySelector(".khatian-details > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody"); - const headerLabelElement = tableBodyElement.querySelector("tr:nth-child(1) > th:nth-child(1)"); - const headerValueElement = tableBodyElement.querySelector("tr:nth-child(1) > th:nth-child(2)"); - const khatianNumberText = headerLabelElement.innerHTML; - const khatianNumberValue = headerValueElement.innerHTML; - headerLabelElement.innerHTML = "\u{99C}\u{9C7}\u{9B2}\u{9BE} (District):" - headerValueElement.innerHTML = "${district}"; - const nextElement = tableBodyElement.querySelector("tr:nth-child(2)"); - const createTableEntry = (label, value) => { - const tableRowElement = document.createElement("tr"); - const tableLabelColumnElement = document.createElement("td"); - tableLabelColumnElement.innerHTML = label; - const tableValueColumnElement = document.createElement("td"); - tableValueColumnElement.innerHTML = value; - tableRowElement.appendChild(tableLabelColumnElement); - tableRowElement.appendChild(tableValueColumnElement); - tableBodyElement.insertBefore(tableRowElement, nextElement); - } - createTableEntry("\u{9AC}\u{9CD}\u{9B2}\u{995} (Block):", "${block}"); - createTableEntry("\u{9AE}\u{9CC}\u{99C}\u{9BE} (Mouza):", "${mouza}"); - createTableEntry(khatianNumberText, khatianNumberValue); -</script> -`; |
