(file)
| 957 | } |
| 958 | |
| 959 | function readInputFileFile(file) { |
| 960 | const FR = new FileReader(); |
| 961 | currentFileNames.push(file.name); |
| 962 | const fileExtension = file.name.split('.').pop().toLowerCase(); |
| 963 | |
| 964 | FR.addEventListener("load", async function(evt) { |
| 965 | if (fileExtension === 'pdf') { |
| 966 | try { |
| 967 | const content = await extractTextFromPDF(evt.target.result); |
| 968 | fileContents.push({ name: file.name, content: content }); |
| 969 | } catch (error) { |
| 970 | console.error('Error processing PDF:', error); |
| 971 | fileContents.push({ name: file.name, content: "Error processing PDF file" }); |
| 972 | } |
| 973 | } else { |
| 974 | // For text and markdown files |
| 975 | fileContents.push({ name: file.name, content: evt.target.result }); |
| 976 | } |
| 977 | }); |
| 978 | |
| 979 | if (fileExtension === 'pdf') { |
| 980 | FR.readAsArrayBuffer(file); |
| 981 | } else { |
| 982 | FR.readAsText(file); |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | function submitPrompt(event) { |
| 987 | event.preventDefault(); |
no test coverage detected