From 5630eab72b62e55bde156eead06fd76b183465c2 Mon Sep 17 00:00:00 2001 From: ronnyTodgers Date: Tue, 27 Feb 2024 15:05:36 +0000 Subject: [PATCH] Revert "Console warnings" --- src/components/ArrowedPopper.js | 73 +++++++- src/components/MakeMeJSON.js | 6 +- src/components/ResultsOptions.js | 2 +- src/components/Upload.js | 22 ++- src/contexts/DataContext.js | 28 ++- src/utilities/pdf-table-extractor.js | 255 ++++++++++++++------------- 6 files changed, 233 insertions(+), 153 deletions(-) diff --git a/src/components/ArrowedPopper.js b/src/components/ArrowedPopper.js index 13e2c5f..07c739d 100644 --- a/src/components/ArrowedPopper.js +++ b/src/components/ArrowedPopper.js @@ -1,6 +1,55 @@ -import { Popper, Fade, Paper } from "@mui/material"; +import { Popper, Fade, Paper, Box, styled } from "@mui/material"; +import { useState } from "react"; + +const StyledPopper = styled(Popper)(({ theme }) => ({ + // You can replace with `PopperUnstyled` for lower bundle size. + '&[data-popper-placement*="bottom"] .arrow': { + top: 0, + left: 0, + marginTop: "-0.9em", + width: "3em", + height: "1em", + "&::before": { + borderWidth: "0 1em 1em 1em", + borderColor: `transparent transparent ${theme.palette.background.paper} transparent`, + }, + }, + '&[data-popper-placement*="top"] .arrow': { + bottom: 0, + left: 0, + marginBottom: "-0.9em", + width: "3em", + height: "1em", + "&::before": { + borderWidth: "1em 1em 0 1em", + borderColor: `${theme.palette.background.paper} transparent transparent transparent`, + }, + }, + '&[data-popper-placement*="right"] .arrow': { + left: 0, + marginLeft: "-0.9em", + height: "3em", + width: "1em", + "&::before": { + borderWidth: "1em 1em 1em 0", + borderColor: `transparent ${theme.palette.background.paper} transparent transparent`, + }, + }, + '&[data-popper-placement*="left"] .arrow': { + right: 0, + marginRight: "-0.9em", + height: "3em", + width: "1em", + "&::before": { + borderWidth: "1em 0 1em 1em", + borderColor: `transparent transparent transparent ${theme.palette.background.paper}`, + }, + }, +})); function ArrowedPopper({ anchorEl, open, placement, children }) { + const [arrowRef, setArrowRef] = useState(null); + return ( @@ -41,6 +93,25 @@ function ArrowedPopper({ anchorEl, open, placement, children }) { {children} + {/* */} )} diff --git a/src/components/MakeMeJSON.js b/src/components/MakeMeJSON.js index a70115b..d32ccae 100644 --- a/src/components/MakeMeJSON.js +++ b/src/components/MakeMeJSON.js @@ -1,8 +1,9 @@ import React, { useState } from "react"; import DragDrop from "./DragDrop"; import { Paper } from "@mui/material"; +import { useHistory } from "react-router-dom"; import InlineFeedback from "./InlineFeedback"; -import { ToastContainer } from "react-toastify"; +import { ToastContainer, toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import pdfTableExtractor from "../utilities/pdf-table-extractor"; @@ -13,8 +14,11 @@ export default function MakeMeJSON({ existingInstruments, ReactGA, }) { + const [loading, setLoading] = useState(false); const [parseError, setParseError] = useState(false); const [matchError, setMatchError] = useState(false); + const [grouping, setGrouping] = useState(""); + const history = useHistory(); function saveFile(blob, filename) { if (window.navigator.msSaveOrOpenBlob) { diff --git a/src/components/ResultsOptions.js b/src/components/ResultsOptions.js index 9da4991..81ebb66 100644 --- a/src/components/ResultsOptions.js +++ b/src/components/ResultsOptions.js @@ -36,7 +36,7 @@ export default function ResultsOptions({ setSearchTerm(resultsOptions.searchTerm); }, [resultsOptions]); - useMemo((resultsOptions, setResultsOptions) => { + useMemo(() => { let thisOptions = { ...resultsOptions }; thisOptions.searchTerm = debouncedSearchTerm; setResultsOptions(thisOptions); diff --git a/src/components/Upload.js b/src/components/Upload.js index 110a9b7..c056f5c 100644 --- a/src/components/Upload.js +++ b/src/components/Upload.js @@ -21,6 +21,7 @@ import { AddCircleOutline as AddCircleOutlineIcon, Delete as DeleteIcon, ExpandMore as ExpandMoreIcon, + Rowing, } from "@mui/icons-material"; import { useHistory } from "react-router-dom"; import InlineFeedback from "./InlineFeedback"; @@ -40,7 +41,7 @@ export default function Upload({ const [loading, setLoading] = useState(false); const [parseError, setParseError] = useState(false); const [matchError, setMatchError] = useState(false); - const [grouping] = useState(""); + const [grouping, setGrouping] = useState(""); const [expanded, setExpanded] = useState(false); const dirty = useRef(false); const localFileInfos = useRef(); @@ -61,11 +62,20 @@ export default function Upload({ localFileInfos.current = fi; }, []); - const syncFileInfos = useCallback((setAppFileInfos) => { + const syncFileInfos = useCallback(() => { console.log("syncing fileinfo"); setAppFileInfos(localFileInfos.current); dirty.current = false; - }, []); + }); + + const getFileInfo = useCallback( + (instrument_id) => { + return fileInfos.filter((fi) => { + return fi.instrument_id === instrument_id; + })[0]; + }, + [fileInfos] + ); function filesReceiver(fileList) { const files = Array.from(fileList); @@ -172,12 +182,10 @@ export default function Upload({ !existingInstrumentIDs.includes(fi.instrument_id) ) { return fi; - } else { - return null } }) .filter((i) => { - return i !== null; + return i; }); // add in any selected which are not already in there @@ -366,7 +374,7 @@ export default function Upload({ const FileInfo = ({ fi }) => { const instrument_id = fi.instrument_id; const fileInfo = fi; - const [, rerender] = useState(); + const [_, rerender] = useState(); console.log("rendering " + instrument_id + fileInfo.instrument_name); return ( { - harmonisation.apiData.instruments.map((instrument) => ( - instrument.questions.map((question) => ( + harmonisation.apiData.instruments.map((instrument) => { + instrument.questions.map((question) => { //This is a circular reference but can't be stored - delete question["instrument"] - ) - ) - ) - ); + delete question["instrument"]; + }); + }); harmonisation.apiData = JSON.parse(JSON.stringify(harmonisation.apiData)); console.log("prepped"); console.log(harmonisation); return harmonisation; }; const undoPrepForFireStore = (harmonisation) => { - harmonisation.apiData.instruments.map((instrument) => ( - instrument.questions.map((question) => ( + harmonisation.apiData.instruments.map((instrument) => { + instrument.questions.map((question) => { //This is a circular reference but can't be stored - question["instrument"] = instrument - ) - ) - ) - ); + question["instrument"] = instrument; + }); + }); console.log("unprepped"); console.log(harmonisation); return harmonisation; diff --git a/src/utilities/pdf-table-extractor.js b/src/utilities/pdf-table-extractor.js index 8560e70..e0c2abd 100644 --- a/src/utilities/pdf-table-extractor.js +++ b/src/utilities/pdf-table-extractor.js @@ -2,7 +2,7 @@ import * as pdfjs from "pdfjs-dist/webpack.mjs"; // HACK few hacks to let PDF.js be loaded not as a module in global space. function xmlEncode(s) { - let i = 0, + var i = 0, ch; s = String(s); while ( @@ -19,7 +19,7 @@ function xmlEncode(s) { if (i >= s.length) { return s; } - let buf = s.substring(0, i); + var buf = s.substring(0, i); while (i < s.length) { ch = s[i++]; switch (ch) { @@ -50,18 +50,18 @@ function xmlEncode(s) { } global.btoa = function btoa(chars) { - let digits = + var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - let buffer = ""; - let i, n; + var buffer = ""; + var i, n; for (i = 0, n = chars.length; i < n; i += 3) { - let b1 = chars.charCodeAt(i) & 0xff; - let b2 = chars.charCodeAt(i + 1) & 0xff; - let b3 = chars.charCodeAt(i + 2) & 0xff; - let d1 = b1 >> 2, + var b1 = chars.charCodeAt(i) & 0xff; + var b2 = chars.charCodeAt(i + 1) & 0xff; + var b3 = chars.charCodeAt(i + 2) & 0xff; + var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4); - let d3 = i + 1 < n ? ((b2 & 0xf) << 2) | (b3 >> 6) : 64; - let d4 = i + 2 < n ? b3 & 0x3f : 64; + var d3 = i + 1 < n ? ((b2 & 0xf) << 2) | (b3 >> 6) : 64; + var d4 = i + 2 < n ? b3 & 0x3f : 64; buffer += digits.charAt(d1) + digits.charAt(d2) + @@ -95,20 +95,20 @@ DOMElement.prototype = { }, appendChild: function DOMElement_appendChild(element) { - let childNodes = this.childNodes; + var childNodes = this.childNodes; if (childNodes.indexOf(element) === -1) { childNodes.push(element); } }, toString: function DOMElement_toString() { - let attrList = []; - for (let i in this.attributes) { + var attrList = []; + for (var i in this.attributes) { attrList.push(i + '="' + xmlEncode(this.attributes[i]) + '"'); } if (this.nodeName === "svg:tspan" || this.nodeName === "svg:style") { - let encText = xmlEncode(this.textContent); + var encText = xmlEncode(this.textContent); return ( "<" + this.nodeName + @@ -121,7 +121,7 @@ DOMElement.prototype = { ">" ); } else if (this.nodeName === "svg:svg") { - let ns = + var ns = 'xmlns:xlink="http://www.w3.org/1999/xlink" ' + 'xmlns:svg="http://www.w3.org/2000/svg"'; return ( @@ -153,7 +153,7 @@ DOMElement.prototype = { }, cloneNode: function DOMElement_cloneNode() { - let newNode = new DOMElement(this.nodeName); + var newNode = new DOMElement(this.nodeName); newNode.childNodes = this.childNodes; newNode.attributes = this.attributes; newNode.textContent = this.textContent; @@ -169,13 +169,13 @@ const pdf_table_extractor_run = (pdfData) => { const pdf_table_extractor_progress = (result) => {}; const pdf_table_extractor = (doc) => { - let numPages = doc.numPages; - let result = {}; + var numPages = doc.numPages; + var result = {}; result.pageTables = []; result.numPages = numPages; result.currentPages = 0; - let transform_fn = function (m1, m2) { + var transform_fn = function (m1, m2) { return [ m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], @@ -186,45 +186,45 @@ const pdf_table_extractor_run = (pdfData) => { ]; }; - let applyTransform_fn = function (p, m) { - let xt = p[0] * m[0] + p[1] * m[2] + m[4]; - let yt = p[0] * m[1] + p[1] * m[3] + m[5]; + var applyTransform_fn = function (p, m) { + var xt = p[0] * m[0] + p[1] * m[2] + m[4]; + var yt = p[0] * m[1] + p[1] * m[3] + m[5]; return [xt, yt]; }; - let lastPromise = Promise.resolve(); // will be used to chain promises - let loadPage = function (pageNum) { + var lastPromise = Promise.resolve(); // will be used to chain promises + var loadPage = function (pageNum) { return doc.getPage(pageNum).then(function (page) { - let verticles = []; - let horizons = []; - let merges = {}; - let merge_alias = {}; - let transformMatrix = [1, 0, 0, 1, 0, 0]; - let transformStack = []; + var verticles = []; + var horizons = []; + var merges = {}; + var merge_alias = {}; + var transformMatrix = [1, 0, 0, 1, 0, 0]; + var transformStack = []; return page .getOperatorList() .then(function (opList) { // Get rectangle first - let showed = {}; - let REVOPS = []; - for (let op in pdfjs.OPS) { + var showed = {}; + var REVOPS = []; + for (var op in pdfjs.OPS) { REVOPS[pdfjs.OPS[op]] = op; } - // let strokeRGBColor = null; - // let fillRGBColor = null; - let current_x, current_y, lineWidth; - let edges = []; - let line_max_width = 2; + var strokeRGBColor = null; + var fillRGBColor = null; + var current_x, current_y, lineWidth; + var edges = []; + var line_max_width = 2; while (opList.fnArray.length) { - let fn = opList.fnArray.shift(); - let args = opList.argsArray.shift(); - if (pdfjs.OPS.constructPath === fn) { + var fn = opList.fnArray.shift(); + var args = opList.argsArray.shift(); + if (pdfjs.OPS.constructPath == fn) { while (args[0].length) { const op = args[0].shift(); - if (op === pdfjs.OPS.rectangle) { + if (op == pdfjs.OPS.rectangle) { const x = args[1].shift(); const y = args[1].shift(); const width = args[1].shift(); @@ -238,13 +238,13 @@ const pdf_table_extractor_run = (pdfData) => { transform: transformMatrix, }); } - } else if (op === pdfjs.OPS.moveTo) { + } else if (op == pdfjs.OPS.moveTo) { current_x = args[1].shift(); current_y = args[1].shift(); - } else if (op === pdfjs.OPS.lineTo) { + } else if (op == pdfjs.OPS.lineTo) { const x = args[1].shift(); const y = args[1].shift(); - if (current_x === x) { + if (current_x == x) { edges.push({ y: Math.min(y, current_y), x: x - lineWidth / 2, @@ -252,7 +252,7 @@ const pdf_table_extractor_run = (pdfData) => { height: Math.abs(y - current_y), transform: transformMatrix, }); - } else if (current_y === y) { + } else if (current_y == y) { edges.push({ x: Math.min(x, current_x), y: y - lineWidth / 2, @@ -267,17 +267,17 @@ const pdf_table_extractor_run = (pdfData) => { // throw ('constructPath ' + op); } } - } else if (pdfjs.OPS.save === fn) { + } else if (pdfjs.OPS.save == fn) { transformStack.push(transformMatrix); - } else if (pdfjs.OPS.restore === fn) { + } else if (pdfjs.OPS.restore == fn) { transformMatrix = transformStack.pop(); - } else if (pdfjs.OPS.transform === fn) { + } else if (pdfjs.OPS.transform == fn) { transformMatrix = transform_fn(transformMatrix, args); - } else if (pdfjs.OPS.setStrokeRGBColor === fn) { - // strokeRGBColor = args; - } else if (pdfjs.OPS.setFillRGBColor === fn) { - // fillRGBColor = args; - } else if (pdfjs.OPS.setLineWidth === fn) { + } else if (pdfjs.OPS.setStrokeRGBColor == fn) { + strokeRGBColor = args; + } else if (pdfjs.OPS.setFillRGBColor == fn) { + fillRGBColor = args; + } else if (pdfjs.OPS.setLineWidth == fn) { lineWidth = args[0]; } else if (["eoFill"].indexOf(REVOPS[fn]) >= 0) { } else if ("undefined" === typeof showed[fn]) { @@ -287,8 +287,8 @@ const pdf_table_extractor_run = (pdfData) => { } edges = edges.map(function (edge) { - let point1 = applyTransform_fn([edge.x, edge.y], edge.transform); - let point2 = applyTransform_fn( + var point1 = applyTransform_fn([edge.x, edge.y], edge.transform); + var point2 = applyTransform_fn( [edge.x + edge.width, edge.y + edge.height], edge.transform ); @@ -310,11 +310,13 @@ const pdf_table_extractor_run = (pdfData) => { }); // get verticle lines - let current_height = 0; - let lines = []; - let lines_add_verticle = function (lines, top, bottom) { - let hit = false; - for (let i = 0; i < lines.length; i++) { + var current_x = null; + var current_y = null; + var current_height = 0; + var lines = []; + var lines_add_verticle = function (lines, top, bottom) { + var hit = false; + for (var i = 0; i < lines.length; i++) { if (lines[i].bottom < top || lines[i].top > bottom) { continue; } @@ -322,7 +324,7 @@ const pdf_table_extractor_run = (pdfData) => { top = Math.min(lines[i].top, top); bottom = Math.max(lines[i].bottom, bottom); - let new_lines = []; + var new_lines = []; if (i > 1) { new_lines = lines.slice(0, i - 1); } @@ -335,7 +337,7 @@ const pdf_table_extractor_run = (pdfData) => { } return lines; }; - let edge; + var edge; while ((edge = edges1.shift())) { // skip horizon lines if (edge.width > line_max_width) { @@ -383,7 +385,7 @@ const pdf_table_extractor_run = (pdfData) => { } // no table - if (current_x === null || lines.length === 0) { + if (current_x === null || lines.length == 0) { return {}; } verticles.push({ x: current_x, lines: lines }); @@ -391,10 +393,10 @@ const pdf_table_extractor_run = (pdfData) => { // Get horizon lines current_x = null; current_y = null; - let current_width = 0; - let lines_add_horizon = function (lines, left, right) { - let hit = false; - for (let i = 0; i < lines.length; i++) { + var current_width = 0; + var lines_add_horizon = function (lines, left, right) { + var hit = false; + for (var i = 0; i < lines.length; i++) { if (lines[i].right < left || lines[i].left > right) { continue; } @@ -402,7 +404,7 @@ const pdf_table_extractor_run = (pdfData) => { left = Math.min(lines[i].left, left); right = Math.max(lines[i].right, right); - let new_lines = []; + var new_lines = []; if (i > 1) { new_lines = lines.slice(0, i - 1); } @@ -420,7 +422,7 @@ const pdf_table_extractor_run = (pdfData) => { if (edge.height > line_max_width) { continue; } - if (null == current_y || edge.y - current_y > line_max_width) { + if (null === current_y || edge.y - current_y > line_max_width) { if (current_width > line_max_width) { lines = lines_add_horizon( lines, @@ -459,13 +461,13 @@ const pdf_table_extractor_run = (pdfData) => { ); } // no table - if (current_y === null || lines.length === 0) { + if (current_y === null || lines.length == 0) { return {}; } horizons.push({ y: current_y, lines: lines }); - let search_index = function (v, list) { - for (let i = 0; i < list.length; i++) { + var search_index = function (v, list) { + for (var i = 0; i < list.length; i++) { if (Math.abs(list[i] - v) < 5) { return i; } @@ -479,39 +481,39 @@ const pdf_table_extractor_run = (pdfData) => { }); // check top_out and bottom_out - let y_list = horizons + var y_list = horizons .map(function (a) { return a.y; }) .sort(function (a, b) { return b - a; }); - let y_max = verticles + var y_max = verticles .map(function (verticle) { return verticle.lines[0].bottom; }) .sort() .reverse()[0]; - let y_min = verticles + var y_min = verticles .map(function (verticle) { return verticle.lines[verticle.lines.length - 1].top; }) .sort()[0]; - let top_out = search_index(y_min, y_list) === -1 ? 1 : 0; - let bottom_out = search_index(y_max, y_list) === -1 ? 1 : 0; + var top_out = search_index(y_min, y_list) == -1 ? 1 : 0; + var bottom_out = search_index(y_max, y_list) == -1 ? 1 : 0; - let verticle_merges = {}; + var verticle_merges = {}; // skip the 1st lines and final lines for ( - let r = 0; + var r = 0; r < horizons.length - 2 + top_out + bottom_out; r++ ) { const hor = horizons[bottom_out + horizons.length - r - 2]; lines = hor.lines.slice(0); - let col = search_index(lines[0].left, x_list); - if (col !== 0) { - for (let c = 0; c < col; c++) { + var col = search_index(lines[0].left, x_list); + if (col != 0) { + for (var c = 0; c < col; c++) { verticle_merges[[r, c].join("-")] = { row: r, col: c, @@ -520,12 +522,12 @@ const pdf_table_extractor_run = (pdfData) => { }; } } - let line; + var line; while ((line = lines.shift())) { const left_col = search_index(line.left, x_list); const right_col = search_index(line.right, x_list); - if (left_col !== col) { - for (let c = col; c < left_col; c++) { + if (left_col != col) { + for (var c = col; c < left_col; c++) { verticle_merges[[r, c].join("-")] = { row: r, col: c, @@ -536,8 +538,8 @@ const pdf_table_extractor_run = (pdfData) => { } col = right_col; } - if (col !== verticles.length - 1 + top_out) { - for (let c = col; c < verticles.length - 1 + top_out; c++) { + if (col != verticles.length - 1 + top_out) { + for (var c = col; c < verticles.length - 1 + top_out; c++) { verticle_merges[[r, c].join("-")] = { row: r, col: c, @@ -549,10 +551,10 @@ const pdf_table_extractor_run = (pdfData) => { } while (true) { - let merged = false; - for (let r_c in verticle_merges) { - let m = verticle_merges[r_c]; - let final_id = [m.row + m.height - 1, m.col + m.width - 1].join( + var merged = false; + for (var r_c in verticle_merges) { + var m = verticle_merges[r_c]; + var final_id = [m.row + m.height - 1, m.col + m.width - 1].join( "-" ); if ("undefined" !== typeof verticle_merges[final_id]) { @@ -568,14 +570,14 @@ const pdf_table_extractor_run = (pdfData) => { } } - let horizon_merges = {}; + var horizon_merges = {}; - for (let c = 0; c < verticles.length - 2; c++) { + for (var c = 0; c < verticles.length - 2; c++) { const ver = verticles[c + 1]; lines = ver.lines.slice(0); - let row = search_index(lines[0].bottom, y_list) + bottom_out; - if (row !== 0) { - for (let r = 0; r < row; r++) { + var row = search_index(lines[0].bottom, y_list) + bottom_out; + if (row != 0) { + for (var r = 0; r < row; r++) { horizon_merges[[r, c].join("-")] = { row: r, col: c, @@ -584,17 +586,16 @@ const pdf_table_extractor_run = (pdfData) => { }; } } - let line; while ((line = lines.shift())) { let top_row = search_index(line.top, y_list); - if (top_row === -1) { + if (top_row == -1) { top_row = y_list.length + bottom_out; } else { top_row += bottom_out; } let bottom_row = search_index(line.bottom, y_list) + bottom_out; - if (bottom_row !== row) { - for (let r = bottom_row; r < row; r++) { + if (bottom_row != row) { + for (var r = bottom_row; r < row; r++) { horizon_merges[[r, c].join("-")] = { row: r, col: c, @@ -605,9 +606,9 @@ const pdf_table_extractor_run = (pdfData) => { } row = top_row; } - if (row !== horizons.length - 1 + bottom_out + top_out) { + if (row != horizons.length - 1 + bottom_out + top_out) { for ( - let r = row; + var r = row; r < horizons.length - 1 + bottom_out + top_out; r++ ) { @@ -628,10 +629,10 @@ const pdf_table_extractor_run = (pdfData) => { } while (true) { - let merged = false; - for (let r_c in horizon_merges) { - let m = horizon_merges[r_c]; - let final_id = [m.row + m.height - 1, m.col + m.width - 1].join( + var merged = false; + for (var r_c in horizon_merges) { + var m = horizon_merges[r_c]; + var final_id = [m.row + m.height - 1, m.col + m.width - 1].join( "-" ); if ("undefined" !== typeof horizon_merges[final_id]) { @@ -647,17 +648,17 @@ const pdf_table_extractor_run = (pdfData) => { } } merges = verticle_merges; - for (let id in horizon_merges) { + for (var id in horizon_merges) { if ("undefined" !== typeof merges[id]) { merges[id].width = horizon_merges[id].width; } else { merges[id] = horizon_merges[id]; } } - for (let id in merges) { - for (let c = 0; c < merges[id].width; c++) { - for (let r = 0; r < merges[id].height; r++) { - if (c === 0 && r === 0) { + for (var id in merges) { + for (var c = 0; c < merges[id].width; c++) { + for (var r = 0; r < merges[id].height; r++) { + if (c == 0 && r == 0) { continue; } delete merges[ @@ -668,10 +669,10 @@ const pdf_table_extractor_run = (pdfData) => { } merge_alias = {}; - for (let id in merges) { - for (let c = 0; c < merges[id].width; c++) { - for (let r = 0; r < merges[id].height; r++) { - if (r === 0 && c === 0) { + for (var id in merges) { + for (var c = 0; c < merges[id].width; c++) { + for (var r = 0; r < merges[id].height; r++) { + if (r == 0 && c == 0) { continue; } merge_alias[ @@ -685,37 +686,37 @@ const pdf_table_extractor_run = (pdfData) => { return page.getTextContent().then(function (content) { const tables = []; const table_pos = []; - for (let i = 0; i < horizons.length - 1; i++) { + for (var i = 0; i < horizons.length - 1; i++) { tables[i] = []; table_pos[i] = []; - for (let j = 0; j < verticles.length - 1; j++) { + for (var j = 0; j < verticles.length - 1; j++) { tables[i][j] = ""; table_pos[i][j] = null; } } - let item; + var item; while ((item = content.items.shift())) { const x = item.transform[4]; const y = item.transform[5]; - let col = -1; - for (let i = 0; i < verticles.length - 1; i++) { + var col = -1; + for (var i = 0; i < verticles.length - 1; i++) { if (x >= verticles[i].x && x < verticles[i + 1].x) { col = i; break; } } - if (col === -1) { + if (col == -1) { continue; } - let row = -1; - for (let i = 0; i < horizons.length - 1; i++) { + var row = -1; + for (var i = 0; i < horizons.length - 1; i++) { if (y >= horizons[i].y && y < horizons[i + 1].y) { row = horizons.length - i - 2; break; } } - if (row === -1) { + if (row == -1) { continue; } @@ -752,7 +753,7 @@ const pdf_table_extractor_run = (pdfData) => { }); }; - for (let i = 1; i <= numPages; i++) { + for (var i = 1; i <= numPages; i++) { lastPromise = lastPromise.then(loadPage.bind(null, i)); } return lastPromise.then(function () {