diff --git a/src/appellate/appellate.js b/src/appellate/appellate.js index 85e660a1..9d1e9a61 100644 --- a/src/appellate/appellate.js +++ b/src/appellate/appellate.js @@ -1181,25 +1181,30 @@ AppellateDelegate.prototype.onDocumentViewSubmit = async function (event) { let form = document.getElementById(event.data.id); let title = document.querySelectorAll('strong')[1].innerHTML; - let dataFromTitle = APPELLATE.parseReceiptPageTitle(title); + let pdfData = APPELLATE.parseReceiptPageTitle(title); - if ( - dataFromTitle.att_number == 0 && - this.queryParameters.get('recapAttNum') - ) { - dataFromTitle.att_number = this.queryParameters.get('recapAttNum'); + // For multi-document pages, the title alone doesn't provide sufficient + // information. Therefore, we need to extract additional data from the + // receipt table to accurately identify the PDF. + // Attempt to parse the necessary data from the receipt table. + if (!pdfData) pdfData = APPELLATE.parseDataFromReceiptTable(); + + // If we still don't have enough data after parsing the receipt table, + // submit the form without retrieving the file. + if (!pdfData) { + form.submit(); + return; } - if (dataFromTitle.doc_number.length > 9) { + if (pdfData.att_number == 0 && this.queryParameters.get('recapAttNum')) + pdfData.att_number = this.queryParameters.get('recapAttNum'); + + if (pdfData.doc_number.length > 9) { // If the number is really big, it's probably a court that uses // pacer_doc_id instead of regular docket entry numbering. - dataFromTitle.doc_number = PACER.cleanPacerDocId(dataFromTitle.doc_number); + pdfData.doc_number = PACER.cleanPacerDocId(dataFromTitle.doc_number); } - if (!dataFromTitle) { - form.submit(); - return; - } $('body').css('cursor', 'wait'); let query_string = new URLSearchParams(new FormData(form)).toString(); const resp = await window.fetch(form.action, { @@ -1215,7 +1220,7 @@ AppellateDelegate.prototype.onDocumentViewSubmit = async function (event) { await resp.blob(), null, previousPageHtml, - dataFromTitle + pdfData ); }; diff --git a/src/appellate/utils.js b/src/appellate/utils.js index 8d1ee35c..d6d54147 100644 --- a/src/appellate/utils.js +++ b/src/appellate/utils.js @@ -374,6 +374,24 @@ let APPELLATE = { return r; }, + // returns data from the table of the Receipt Page as an object + parseDataFromReceiptTable: () => { + // this method uses regex expressions to match that information from the + // receipt table and returns an object with the following attributes: + // - docket_number + // - doc_number + // - att_number (if applicable). + let search_string = $('td:contains(Case)').text(); + let regex = + /Case: (?[^']*), Document: (?\d+)(-(?\d+))?/; + let matches = regex.exec(search_string); + // If no matches were found, return null. + if (!matches) return null; + // If an attachment number was not found, set it to 0. + if (!matches.groups.att_number) matches.groups.att_number = 0; + return matches.groups; + }, + // Returns an object with the court Id and docket number core extracted from a link to district court getDatafromDistrictLinkUrl: (url) => { // Converts links to district courts like: