aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/pages/view-khatian
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-13 20:49:57 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-13 20:49:57 +0530
commit6f6c263a072c9df4e826d8ebb2035c82a87be7e0 (patch)
treec8b944fe53b660d9d58b5559b10f4c73141e7559 /src/scripts/pages/view-khatian
parentbc4eb3606afbbc4b54fbb3b4ef81badd06cde525 (diff)
downloadbanglar-bhumi-utils-6f6c263a072c9df4e826d8ebb2035c82a87be7e0.tar.gz
banglar-bhumi-utils-6f6c263a072c9df4e826d8ebb2035c82a87be7e0.zip
refactor: organised the scripts into a more well defined structure
now all scripts that are common to all pages lie in src/scripts/common each page gets its own folder in src/pages and different parts of the page's configuration are separated in separated folders which are all finally imported in src/pages/*/index.ts
Diffstat (limited to 'src/scripts/pages/view-khatian')
-rw-r--r--src/scripts/pages/view-khatian/download-information-pdf-page-content.html241
-rw-r--r--src/scripts/pages/view-khatian/index.ts95
2 files changed, 336 insertions, 0 deletions
diff --git a/src/scripts/pages/view-khatian/download-information-pdf-page-content.html b/src/scripts/pages/view-khatian/download-information-pdf-page-content.html
new file mode 100644
index 0000000..129608e
--- /dev/null
+++ b/src/scripts/pages/view-khatian/download-information-pdf-page-content.html
@@ -0,0 +1,241 @@
+<div id="content">
+ <style type="text/css" media="print">
+ @page {
+ size: A4;
+ margin: 0;
+ }
+ </style>
+ <style>
+ * {
+ box-sizing: border-box !important;
+ text-decoration: none;
+ margin: 0;
+ padding: 0;
+ font-size: 16px !important;
+ }
+
+ #content {
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ }
+
+ .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;
+ }
+
+ .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,
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div > table > tbody > tr,
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table > tbody > tr:last-child,
+ #locater-information > tbody > tr {
+ border-bottom: 1px solid black;
+ }
+
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div > table > tbody > tr > th:nth-child(1),
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div > table > tbody > tr > td:nth-child(1),
+ .details#khatian-information #headertitle > tr > th:nth-child(1),
+ #locater-information > tbody > tr > td:nth-child(1),
+ .details#plot-information > div:nth-child(1) > div:nth-child(3) > table > tbody > tr > td:nth-child(1),
+ #headertitle > tr > th:nth-child(1),
+ #plot-information > div:nth-child(1) > div:nth-child(5) > table > tbody > tr > td:nth-child(1) {
+ border-left: 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 td {
+ white-space: normal;
+ }
+
+ .details#plot-information #headertitle > tr > th,
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div > table > tbody > tr > th,
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div > table > tbody > tr > td,
+ .details#khatian-information #headertitle > tr > th,
+ #locater-information > tbody > tr > td,
+ .details#plot-information > div:nth-child(1) > div:nth-child(3) > table > tbody > tr > td,
+ .details#plot-information > div:nth-child(1) > div:nth-child(5) > table > tbody > tr > td,
+ .details#plot-information > div:nth-child(1) > div:nth-child(5) > table > tbody {
+ border-right: 1px solid black !important;
+ }
+
+ .details#plot-information > div:nth-child(1) > div:nth-child(3) > table {
+ border: none !important;
+ }
+
+ .details#plot-information > div:nth-child(1) > div {
+ position: initial !important;
+ left: 0 !important;
+ width: 100% !important;
+ border-left: none !important;
+ border-right: none !important;
+ }
+
+ .details#plot-information > div:nth-child(2),
+ .details#plot-information > div:nth-child(1) > div:nth-child(3) > table > tbody > tr > td:nth-child(4),
+ .details#plot-information > div:nth-child(1) > div:nth-child(3) > table > tbody > tr > th:nth-child(4),
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > p:nth-child(3),
+ .details#khatian-information > table > tbody > tr > td:nth-child(2) {
+ display: none !important;
+ }
+
+ .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(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 {
+ 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#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1) > th {
+ font-weight: 500;
+ }
+
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr > th:nth-child(1),
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr > td:nth-child(1),
+ #locater-information > tbody > tr > td:nth-child(1) {
+ font-weight: bold;
+ }
+
+ .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#plot-information > div:nth-child(1),
+ .details#khatian-information > table,
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) {
+ border: none !important;
+ }
+
+ .details#khatian-information > table > tbody > tr > td:nth-child(1) > div:nth-child(2) > table > tbody > tr:nth-child(1) > th,
+ #locater-information > tbody > tr > td {
+ width: 50%;
+ }
+
+ body {
+ width: 210mm !important;
+ height: 297mm !important;
+ margin: 0 !important;
+ padding: 0 !important;
+ }
+ </style>
+ <img class="banner" src="https://banglarbhumi.gov.in/BanglarBhumi/images/bl.png">
+ <div class="details">$details$</div>
+ <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);
+ };
+
+ if ($isPlotInformation$) {
+ document.querySelector(".details").setAttribute("id", "plot-information");
+ const tableElement = document.createElement("table");
+ tableElement.setAttribute("id", "locater-information");
+ tableBodyElement = document.createElement("tbody");
+ tableElement.appendChild(tableBodyElement);
+ const detailsElement = document.querySelector(".details > div:nth-child(1)");
+ detailsElement.insertBefore(tableElement, detailsElement.querySelector("div:nth-child(2)"));
+ } else {
+ document.querySelector(".details").setAttribute("id", "khatian-information");
+ 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$");
+ Promise.all(
+ Array.from(document.images)
+ .filter(img => !img.complete).map(img => new Promise(resolve => {
+ img.onload = img.onerror = resolve;
+ }))
+ ).then(() => {
+ window.addEventListener("afterprint", window.close);
+ window.print();
+ });
+ </script>
+</div>
diff --git a/src/scripts/pages/view-khatian/index.ts b/src/scripts/pages/view-khatian/index.ts
new file mode 100644
index 0000000..0be0c52
--- /dev/null
+++ b/src/scripts/pages/view-khatian/index.ts
@@ -0,0 +1,95 @@
+import { generateWebPage } from "@/shared/generate-web-page";
+import { interceptPost } from "@/shared/intercept-jquery-ajax";
+import getDownloadInformationPDFPageContent from "@/scripts/pages/view-khatian/download-information-pdf-page-content.html";
+
+const submitButtonElement = $("#khbutton");
+const separatorElement = $("#bodycover > div > form > hr:nth-child(2)");
+const formElement = $("#bodycover > div > form");
+let downloadPDFButton: JQuery<HTMLButtonElement> | null = null;
+
+const submitButtonElementComputedStyles = window.getComputedStyle(submitButtonElement[0]);
+const styles = Array.from(submitButtonElementComputedStyles)
+ .reduce(
+ (str, property) => `${str}${property}:${submitButtonElementComputedStyles.getPropertyValue(property)};`,
+ ""
+ );
+
+/**
+ * Reads the currently selected text from a `<select>` element.
+ *
+ * @param selector - CSS selector for the select element.
+ * @returns The text of the selected option.
+ */
+const getValueOfSelectElement = (selector: string) => {
+ const element = document.querySelector<HTMLSelectElement>(selector)!;
+ return element.options[element.selectedIndex].text;
+};
+
+let isPlotInformation: boolean | null = null;
+
+/**
+ * Opens a new window with a printable PDF view of the current khatian
+ * or plot details, including district/block/mouza info.
+ */
+const downloadInformationPDF = () => {
+ generateWebPage(
+ getDownloadInformationPDFPageContent({
+ isPlotInformation: !!isPlotInformation,
+ details: $(isPlotInformation ? "#plotdetails" : "#khdetails").html(),
+ district: getValueOfSelectElement("#lstDistrictCode1"),
+ block: getValueOfSelectElement("#lstBlockCode1"),
+ mouza: getValueOfSelectElement("#lstMouzaList")
+ }),
+ isPlotInformation
+ ? "Plot Details"
+ : "Khatian Details"
+ );
+};
+
+/**
+ * Intercepts the success callback of a jQuery AJAX call. When a valid
+ * details table is returned, it inserts a "Download PDF" button;
+ * otherwise it removes an existing button.
+ *
+ * @param args - The `arguments` object from the intercepted `$.post` call.
+ */
+const showDownloadButton = (args: any) => {
+ if (isPlotInformation !== null) {
+ const callback = args[2];
+ args[2] = (data: any) => {
+ callback(data);
+ const tableElement = $(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"
+ );
+
+ if (tableElement.length) {
+ tableElement.css("height", "auto");
+ tableElement.css("width", "100%");
+
+ if (!downloadPDFButton) {
+ downloadPDFButton = $(document.createElement("button"));
+ downloadPDFButton.html("Download PDF");
+ downloadPDFButton[0].style.cssText = styles;
+ downloadPDFButton.css("width", "auto");
+ downloadPDFButton.css("margin-bottom", "1rem");
+ downloadPDFButton.on("click", downloadInformationPDF);
+ formElement[0].insertBefore(downloadPDFButton[0], separatorElement[0]);
+ }
+ } else if (downloadPDFButton) {
+ ($(downloadPDFButton as any) as any).remove();
+ isPlotInformation = null;
+ downloadPDFButton = null;
+ }
+ }
+ }
+};
+
+interceptPost("plotDetailsAction_LandInfo.action", args => {
+ isPlotInformation = true;
+ showDownloadButton(args);
+});
+interceptPost("khDetailsAction_LandInfo.action", args => {
+ isPlotInformation = false;
+ showDownloadButton(args);
+});