diff --git a/CHANGES.md b/CHANGES.md index b881683f..f76340e9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Features: - None yet Changes: - - None yet + - Enhanced logic to retrieve Zip URLs([#352](https://github.com/freelawproject/recap/issues/352)). Fixes: - None yet diff --git a/src/content_delegate.js b/src/content_delegate.js index f6e2fd29..04422842 100644 --- a/src/content_delegate.js +++ b/src/content_delegate.js @@ -545,7 +545,16 @@ ContentDelegate.prototype.onDownloadAllSubmit = async function (event) { const page = document.createElement('html'); page.innerHTML = html; const frames = page.querySelectorAll('iframe'); - return frames[0].src; + if (frames.length) { + return frames[0].src; + } + // Try to extract the PDF URL from the HTML + const showTempURL = html.match(/\/cgi-bin\/show_temp.pl?(.*)/); + if (!showTempURL) { + return null; + } + // Clean the match found in the HTML + return showTempURL[0].replace(';"', ''); }; // helper function - convert string to html document @@ -586,9 +595,32 @@ ContentDelegate.prototype.onDownloadAllSubmit = async function (event) { const browserSpecificFetch = navigator.userAgent.indexOf('Safari') + navigator.userAgent.indexOf('Chrome') < 0 ? content.fetch : window.fetch; + const options = await getItemsFromStorage('options'); + const pacerCaseId = event.data.id.match(/caseid=(\d*)/)[1]; + const filename = generateFileName(options, pacerCaseId); + + // show loading message + let mainDiv = document.getElementById('cmecfMainContent'); + let loadingMessageWrapper = document.createElement('div'); + loadingMessageWrapper.setAttribute('id', 'loading-message'); + loadingMessageWrapper.style.textAlign = 'center'; + + const spinner = document.createElement('i'); + spinner.classList.add('fa', 'fa-spinner', 'fa-spin'); + spinner.setAttribute('id', 'recap-button-spinner'); + + let spanText = document.createElement('span'); + spanText.style.fontFamily = 'helvetica,arial,serif'; + spanText.style.fontSize = '13px'; + spanText.style.padding = '0px 10px'; + spanText.innerHTML = `Download in progress for file ${filename}`; + + loadingMessageWrapper.appendChild(spinner); + loadingMessageWrapper.appendChild(spanText); + mainDiv.append(loadingMessageWrapper); + // fetch the html page which contains the