Skip to content

Commit

Permalink
Update cranach_pairwise_comparison.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Argyris36 authored Aug 16, 2024
1 parent ce7b262 commit 330c56f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions cranach_pairwise_comparison.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,20 @@ <h1>Lucas Cranach Painting Pairwise Comparison</h1>
renderPair(pairs[currentPair]); // Start with the first pair

document.getElementById('export-results').addEventListener('click', () => {
let csvContent = "data:text/csv;charset=utf-8,Pair,Choice\\n";
results.forEach(result => {
csvContent += `${result.pair.img1} vs ${result.pair.img2},${result.choice}\\n`;
});
const encodedUri = encodeURI(csvContent);
const link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "cranach_results.csv");
document.body.appendChild(link);
link.click();
});
let csvContent = "Pair,Choice\n"; // Ensure proper CSV headers
results.forEach(result => {
csvContent += `${result.pair.img1} vs ${result.pair.img2},${result.choice}\n`;
});

const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement("a");
const url = URL.createObjectURL(blob);
link.setAttribute("href", url);
link.setAttribute("download", "cranach_results.csv");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
</script>
</body>
</html>

0 comments on commit 330c56f

Please sign in to comment.