Marthee commited on
Commit
a8c6dd8
·
verified ·
1 Parent(s): 2f352ee

Update templates/gui.html

Browse files
Files changed (1) hide show
  1. templates/gui.html +18 -9
templates/gui.html CHANGED
@@ -13,16 +13,24 @@
13
 
14
  ///////////////////////////////////////////////BEGIN JS CODE//////////////////////////////////////////////////
15
  // Function to send the Dropbox link and keyword to the server
 
 
 
 
 
 
 
 
 
16
 
17
  function processPdf() {
18
-
19
- const pdfLink = 'https://www.dropbox.com/scl/fi/hnp4mqigb51a5kp89kgfa/00801-ARC-20-ZZ-S-A-0002.pdf?rlkey=45abeoebzqw4qwnslnei6dkd6&st=m4yrcjm2&dl=1'; // Dropbox link
20
- const keyword = ['115 INTEGRATED MRI ROOM LININGS'] ; // Example keyword
21
-
22
  // Create a new FormData object to send the data as form data
23
  const formData = new FormData();
24
- formData.append('pdfLink', pdfLink);
25
- formData.append('keyword', keyword); // Single keyword from URL
26
 
27
  // Send the data to the Flask server
28
  fetch('/api/process-data', {
@@ -32,7 +40,7 @@ function processPdf() {
32
  .then(response => response.json())
33
  .then(data => {
34
  if (data.download_link) {
35
- window.location.href = data.download_link; // Redirect to annotated PDF
36
  } else {
37
  alert('Error: ' + data.error);
38
  }
@@ -42,8 +50,9 @@ function processPdf() {
42
  });
43
  }
44
 
45
-
46
-
47
  // Call the function to process the PDF
48
  processPdf();
 
 
 
49
  </script>
 
13
 
14
  ///////////////////////////////////////////////BEGIN JS CODE//////////////////////////////////////////////////
15
  // Function to send the Dropbox link and keyword to the server
16
+ function getURLParams() {
17
+ const urlParams = new URLSearchParams(window.location.search);
18
+ return {
19
+ pdfLink: urlParams.get('pdfLink'),
20
+ keyword: JSON.parse(decodeURIComponent(urlParams.get('keyword') || "[]")), // Decode and parse
21
+ pageNumber: parseInt(urlParams.get('page')) || 1,
22
+ zoomRect: urlParams.get('zoom') // Expecting format: "x,y,width,height"
23
+ };
24
+ }
25
 
26
  function processPdf() {
27
+ // const pdfLink = 'https://www.dropbox.com/scl/fi/hnp4mqigb51a5kp89kgfa/00801-ARC-20-ZZ-S-A-0002.pdf?rlkey=45abeoebzqw4qwnslnei6dkd6&st=m4yrcjm2&dl=1'; // Dropbox link
28
+ // const keyword = ['115 INTEGRATED MRI ROOM LININGS','710 TRANSPORTATION'] ; // Example keyword
29
+ const { pdfLink, keyword, pageNumber, zoomRect } = getURLParams();
 
30
  // Create a new FormData object to send the data as form data
31
  const formData = new FormData();
32
+ formData.append('pdf_link', pdfLink);
33
+ formData.append('keyword', JSON.stringify(keyword));
34
 
35
  // Send the data to the Flask server
36
  fetch('/api/process-data', {
 
40
  .then(response => response.json())
41
  .then(data => {
42
  if (data.download_link) {
43
+ window.location.href = data.download_link; // This will use the rect info from Flask
44
  } else {
45
  alert('Error: ' + data.error);
46
  }
 
50
  });
51
  }
52
 
 
 
53
  // Call the function to process the PDF
54
  processPdf();
55
+
56
+
57
+
58
  </script>