Changed around line 1
- document.addEventListener('DOMContentLoaded', () => {
- const canvas = document.getElementById('pca-plot');
- const ctx = canvas.getContext('2d');
- const compareButton = document.getElementById('compare-button');
- const matchResult = document.getElementById('match-result');
+ document.addEventListener("DOMContentLoaded", () => {
+ const canvas = document.getElementById("pca-plot");
+ const ctx = canvas.getContext("2d");
+ const compareButton = document.getElementById("compare-button");
+ const matchResult = document.getElementById("match-result");
- // Generate random PCA data points
- const points = Array.from({length: 200}, () => ({
- x: Math.random() * canvas.width,
- y: Math.random() * canvas.height,
- label: ''
- }));
+ // Generate random PCA data points
+ const points = Array.from({ length: 200 }, () => ({
+ x: Math.random() * canvas.width,
+ y: Math.random() * canvas.height,
+ label: "",
+ }));
- function drawPlot() {
- ctx.clearRect(0, 0, canvas.width, canvas.height);
-
- // Draw axes
- ctx.strokeStyle = '#475569';
- ctx.beginPath();
- ctx.moveTo(canvas.width/2, 0);
- ctx.lineTo(canvas.width/2, canvas.height);
- ctx.moveTo(0, canvas.height/2);
- ctx.lineTo(canvas.width, canvas.height/2);
- ctx.stroke();
+ function drawPlot() {
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
- // Draw points
- points.forEach(point => {
- ctx.beginPath();
- ctx.arc(point.x, point.y, 3, 0, Math.PI * 2);
- ctx.fillStyle = '#6366f1';
- ctx.fill();
- });
- }
+ // Draw axes
+ ctx.strokeStyle = "#475569";
+ ctx.beginPath();
+ ctx.moveTo(canvas.width / 2, 0);
+ ctx.lineTo(canvas.width / 2, canvas.height);
+ ctx.moveTo(0, canvas.height / 2);
+ ctx.lineTo(canvas.width, canvas.height / 2);
+ ctx.stroke();
- function animatePoint(x, y) {
- ctx.beginPath();
- ctx.arc(x, y, 6, 0, Math.PI * 2);
- ctx.fillStyle = '#a855f7';
- ctx.fill();
- ctx.strokeStyle = '#ffffff';
- ctx.stroke();
- }
+ // Draw points
+ points.forEach((point) => {
+ ctx.beginPath();
+ ctx.arc(point.x, point.y, 3, 0, Math.PI * 2);
+ ctx.fillStyle = "#6366f1";
+ ctx.fill();
+ });
+ }
- compareButton.addEventListener('click', () => {
- const input = document.getElementById('leader-input').value;
- if (!input) return;
+ function animatePoint(x, y) {
+ ctx.beginPath();
+ ctx.arc(x, y, 6, 0, Math.PI * 2);
+ ctx.fillStyle = "#a855f7";
+ ctx.fill();
+ ctx.strokeStyle = "#ffffff";
+ ctx.stroke();
+ }
- // Simulate analysis
- const randomPoint = points[Math.floor(Math.random() * points.length)];
-
- // Animate result
- drawPlot();
- animatePoint(randomPoint.x, randomPoint.y);
-
- // Show result
- matchResult.classList.remove('hidden');
-
- // Fictional leaders for demo
- const leaders = ['Napoleon Bonaparte', 'Julius Caesar', 'Alexander the Great', 'Genghis Khan'];
- matchResult.textContent = `Your leader most closely matches: ${leaders[Math.floor(Math.random() * leaders.length)]}`;
- });
+ compareButton.addEventListener("click", () => {
+ const input = document.getElementById("leader-input").value;
+ if (!input) return;
+
+ // Simulate analysis
+ const randomPoint = points[Math.floor(Math.random() * points.length)];
- // Initial plot
+ // Animate result
- });
+ animatePoint(randomPoint.x, randomPoint.y);
+
+ // Show result
+ matchResult.classList.remove("hidden");
+
+ // Fictional leaders for demo
+ const leaders = ["Hitler"];
+ matchResult.textContent = `Your leader most closely matches: ${leaders[Math.floor(Math.random() * leaders.length)]}`;
+ });
+
+ // Initial plot
+ drawPlot();
+ });