Skip to content

Commit

Permalink
Merge pull request #399 from freelawproject/366-fix-download-zip-file…
Browse files Browse the repository at this point in the history
…s-with-more-than-30-pages

fix(district): Refine generateFileName method for large documents
  • Loading branch information
mlissner authored Sep 19, 2024
2 parents ef6a852 + 08d3a54 commit 686fb97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ Changes:

Fixes:
- Corrected typo in build script, ensuring correct favicon path for Firefox releases([379](https://github.com/freelawproject/recap/issues/379), [397](https://github.com/freelawproject/recap-chrome/pull/397))
- Refines the generateFileName method to accurately compute zip file names ([366](https://github.com/freelawproject/recap/issues/366), [399](https://github.com/freelawproject/recap-chrome/pull/399)).
- Improves the reliability of PACER case ID retrieval on attachment pages ([369](https://github.com/freelawproject/recap/issues/369), [400](https://github.com/freelawproject/recap-chrome/pull/400)).


For developers:
- Nothing yet

Expand Down
29 changes: 27 additions & 2 deletions src/content_delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,34 @@ ContentDelegate.prototype.onDownloadAllSubmit = async function (event) {
.concat('.zip');
} else if (options.lawyer_style_filenames) {
const firstTable = document.getElementsByTagName('table')[0];
// The download page's tables typically display transaction details.
// However, only certain rows contain relevant information:
//
// 1. Table Title.
// 2. Subtitle.
// 3. Date of Transaction
// 4. Pacer Login Data: Includes the Pacer login username and client code.
// 5. Description and Case Number.
// 6. Billable Pages and Cost.
//
// Additionally, if the document has more than 30 pages, an extra row is
// added to inform the user that they will only be billed for 30 pages.
const firstTableRows = firstTable.querySelectorAll('tr');
// 4th from bottom
const matchedRow = firstTableRows[firstTableRows.length - 4];
// Remove rows from the querySelectorAll result that have no visible
// content.
const rowsWithContent = Array.from(firstTableRows).filter((row) =>
row.hasChildNodes()
);
const lastRow = rowsWithContent[rowsWithContent.length -1];
let matchedRow;
// Find the row containing the Description and Case Number. If the last
// row contains the billing message for documents exceeding 30 pages,
// adjusts the index accordingly.
if (lastRow.innerHTML.includes('You will only be billed for 30 pages')){
matchedRow = rowsWithContent[rowsWithContent.length - 3];
} else {
matchedRow = rowsWithContent[rowsWithContent.length - 2];
}
const cells = matchedRow.querySelectorAll('td');
const document_number = cells[0].innerText.match(/\d+(?=\-)/)[0];
const docket_number = cells[1].innerText;
Expand Down

0 comments on commit 686fb97

Please sign in to comment.