-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (36 loc) · 1.25 KB
/
script.js
File metadata and controls
44 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
document.getElementById("extractBtn").addEventListener("click", () => {
const fileInput = document.getElementById("fileInput");
const resultsDiv = document.getElementById("results");
if (fileInput.files.length === 0) {
resultsDiv.textContent = "⚠️ Please upload a file first.";
return;
}
const file = fileInput.files[0];
// Simulate extraction
const fakeData = {
Name: "John Doe",
Position: "Software Engineer",
Salary: "$80,000",
Department: "IT"
};
// Show results
resultsDiv.textContent = Object.entries(fakeData)
.map(([key, value]) => `${key}: ${value}`)
.join("\n");
// Save for CSV export
window.extractedData = fakeData;
});
document.getElementById("exportCSV").addEventListener("click", () => {
if (!window.extractedData) {
alert("No data to export! Please extract first.");
return;
}
const rows = Object.entries(window.extractedData)
.map(([key, value]) => `${key},${value}`)
.join("\n");
const blob = new Blob([rows], { type: "text/csv" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "extracted_data.csv";
link.click();
});