Spaces:
Running

undefined / index.html
EleutheroiEdge's picture
Enhance the existing TaxWizard Pro interface to work with user accounts and saved portfolios:
249d1fc verified
Raw History Blame Contribute Delete
47.7 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaxWizard Pro: Portfolio Alchemist</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
<script>
// Portfolio management
let currentPortfolio = null;
let portfolios = [
{
id: 'retirement',
name: 'Retirement Portfolio',
lastUpdated: '2023-10-15',
totalValue: 125342,
holdingsCount: 12,
taxSavings: 1245,
description: 'Primary retirement account'
},
{
id: 'taxable',
name: 'Taxable Account',
lastUpdated: '2023-09-28',
totalValue: 87321,
holdingsCount: 8,
taxSavings: 842,
description: 'Brokerage account for active trading'
}
];
// Initialize portfolio dropdown
function updatePortfolioDropdown() {
const select = document.getElementById('portfolioSelect');
select.innerHTML = '<option value="">Select a portfolio...</option><option value="new">+ Create New Portfolio</option>';
portfolios.forEach(portfolio => {
const option = document.createElement('option');
option.value = portfolio.id;
option.textContent = portfolio.name;
select.appendChild(option);
});
}
// Load portfolio data
function loadPortfolio(portfolioId) {
if (!portfolioId || portfolioId === 'new') {
currentPortfolio = null;
document.getElementById('portfolioInfo').classList.add('hidden');
document.getElementById('saveOptions').classList.remove('hidden');
return;
}
const portfolio = portfolios.find(p => p.id === portfolioId);
if (portfolio) {
currentPortfolio = portfolio;
document.getElementById('portfolioName').textContent = portfolio.name;
document.getElementById('lastUpdated').textContent = new Date(portfolio.lastUpdated).toLocaleDateString();
document.getElementById('totalValue').textContent = `${portfolio.totalValue.toLocaleString()}`;
document.getElementById('holdingsCount').textContent = portfolio.holdingsCount;
document.getElementById('taxSavings').textContent = `${portfolio.taxSavings.toLocaleString()}`;
document.getElementById('portfolioInfo').classList.remove('hidden');
document.getElementById('saveOptions').classList.add('hidden');
}
}
// Toggle between upload and load modes
document.getElementById('uploadToggle').addEventListener('click', function() {
this.classList.add('bg-white', 'dark:bg-gray-800', 'shadow-sm');
this.classList.remove('text-gray-500', 'dark:text-gray-400');
document.getElementById('loadToggle').classList.remove('bg-white', 'dark:bg-gray-800', 'shadow-sm');
document.getElementById('loadToggle').classList.add('text-gray-500', 'dark:text-gray-400');
document.getElementById('portfolioSelect').value = '';
loadPortfolio(null);
});
document.getElementById('loadToggle').addEventListener('click', function() {
this.classList.add('bg-white', 'dark:bg-gray-800', 'shadow-sm');
this.classList.remove('text-gray-500', 'dark:text-gray-400');
document.getElementById('uploadToggle').classList.remove('bg-white', 'dark:bg-gray-800', 'shadow-sm');
document.getElementById('uploadToggle').classList.add('text-gray-500', 'dark:text-gray-400');
document.getElementById('portfolioSelect').value = portfolios[0].id;
loadPortfolio(portfolios[0].id);
});
// Portfolio selection handler
document.getElementById('portfolioSelect').addEventListener('change', function() {
loadPortfolio(this.value);
});
// Save portfolio handler
document.getElementById('savePortfolioBtn').addEventListener('click', function() {
const saveStatus = document.getElementById('saveStatus');
saveStatus.innerHTML = '<i data-feather="loader" class="w-3 h-3 mr-1 animate-spin"></i> Saving...';
feather.replace();
// Simulate save
setTimeout(() => {
saveStatus.innerHTML = '<i data-feather="check-circle" class="w-3 h-3 mr-1 text-green-500"></i> Saved';
feather.replace();
// Reset status after 3 seconds
setTimeout(() => {
saveStatus.innerHTML = '<i data-feather="circle" class="w-3 h-3 mr-1 text-gray-400"></i> Saved';
feather.replace();
}, 3000);
}, 1500);
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
updatePortfolioDropdown();
feather.replace();
});
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
primary: {
50: '#f0f9ff',
100: '#e0f2fe',
600: '#2563eb',
700: '#1d4ed8',
900: '#1e3a8a',
}
}
}
}
}
</script>
<style>
.dropzone {
border: 2px dashed #94a3b8;
transition: all 0.3s ease;
}
.dropzone-active {
border-color: #3b82f6;
background-color: rgba(59, 130, 246, 0.05);
}
.dark .dropzone-active {
background-color: rgba(59, 130, 246, 0.1);
}
#vanta-bg {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
opacity: 0.15;
}
.theme-toggle {
transition: all 0.3s ease;
}
.glow-card {
box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.2);
}
.dark .glow-card {
box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.4);
}
</style>
</head>
<body class="bg-gray-50 text-gray-800 dark:bg-gray-900 dark:text-gray-100 min-h-screen transition-colors duration-300">
<div id="vanta-bg" class="dark:opacity-30"></div>
<!-- Theme Toggle -->
<button id="themeToggle" class="fixed top-4 right-4 z-50 p-2 rounded-full bg-white dark:bg-gray-800 shadow-lg theme-toggle">
<i data-feather="moon" class="hidden dark:block text-yellow-300"></i>
<i data-feather="sun" class="dark:hidden text-yellow-500"></i>
</button>
<div class="max-w-6xl mx-auto px-4 py-12 relative z-10">
<!-- Header -->
<header class="mb-12 text-center">
<div class="flex justify-center items-center mb-4">
<div class="bg-primary-100 dark:bg-primary-900 p-3 rounded-full">
<i data-feather="dollar-sign" class="text-primary-600 dark:text-primary-400 w-8 h-8"></i>
</div>
<span class="ml-2 text-xs font-semibold bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200 px-2 py-1 rounded-full">BETA</span>
</div>
<h1 class="text-3xl md:text-4xl font-bold mb-2">Welcome to <span class="text-primary-600 dark:text-primary-400">TaxWizard</span> Pro</h1>
<p class="text-gray-600 dark:text-gray-400 max-w-2xl mx-auto">Upload your brokerage statement to preview lots and generate tax-efficient trades.</p>
</header>
<!-- Main Card -->
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-lg overflow-hidden border border-gray-200 dark:border-gray-700 glow-card">
<div class="md:flex">
<!-- Left Panel -->
<div class="md:w-1/2 p-8 md:p-10" id="uploadPanel">
<!-- Portfolio Selection Dropdown -->
<div class="mb-4 flex items-center justify-between">
<div class="relative w-full mr-2">
<select id="portfolioSelect" class="w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white">
<option value="">Select a portfolio...</option>
<option value="new">+ Create New Portfolio</option>
<option value="retirement">Retirement Portfolio</option>
<option value="taxable">Taxable Account</option>
</select>
<div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
<i data-feather="chevron-down" class="w-4 h-4 text-gray-400"></i>
</div>
</div>
<button id="refreshPortfolios" class="p-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
<i data-feather="refresh-cw" class="w-4 h-4"></i>
</button>
</div>
<div class="mb-8">
<div class="flex items-center mb-4">
<div class="bg-primary-100 dark:bg-primary-900 p-2 rounded-full mr-3">
<i data-feather="bar-chart-2" class="text-primary-600 dark:text-primary-400 w-5 h-5"></i>
</div>
<h2 class="text-xl font-semibold">Tax-Loss Harvesting Optimizer</h2>
</div>
<p class="text-gray-600 dark:text-gray-400">Maximize your portfolio's tax efficiency with intelligent harvesting.</p>
<div class="flex justify-between items-center mt-6 bg-gray-100 dark:bg-gray-700 p-4 rounded-lg">
<div class="flex items-center workflow-step" data-step="upload">
<div class="bg-primary-100 dark:bg-primary-900 p-2 rounded-full mr-3">
<i data-feather="upload" class="text-primary-600 dark:text-primary-400 w-4 h-4"></i>
</div>
<span class="font-medium">Upload</span>
</div>
<i data-feather="arrow-right" class="text-gray-400 dark:text-gray-500 w-5 h-5 mx-2"></i>
<div class="flex items-center workflow-step" data-step="settings">
<div class="bg-gray-200 dark:bg-gray-600 p-2 rounded-full mr-3">
<i data-feather="settings" class="text-gray-500 dark:text-gray-300 w-4 h-4"></i>
</div>
<span class="text-gray-500 dark:text-gray-300">Settings</span>
</div>
<i data-feather="arrow-right" class="text-gray-400 dark:text-gray-500 w-5 h-5 mx-2"></i>
<div class="flex items-center workflow-step" data-step="harvest">
<div class="bg-gray-200 dark:bg-gray-600 p-2 rounded-full mr-3">
<i data-feather="dollar-sign" class="text-gray-500 dark:text-gray-300 w-4 h-4"></i>
</div>
<span class="text-gray-500 dark:text-gray-300">Harvest</span>
</div>
</div>
</div>
<!-- Upload/Load Toggle -->
<div class="flex mb-4 bg-gray-100 dark:bg-gray-700 rounded-lg p-1">
<button id="uploadToggle" class="flex-1 py-2 px-4 rounded-md font-medium text-center bg-white dark:bg-gray-800 shadow-sm">
Upload New
</button>
<button id="loadToggle" class="flex-1 py-2 px-4 rounded-md font-medium text-center text-gray-500 dark:text-gray-400">
Load Saved
</button>
</div>
<!-- Upload Section -->
<div id="dropzone" class="dropzone rounded-lg p-8 text-center cursor-pointer mb-6 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 transition">
<div id="portfolioInfo" class="hidden text-left mb-4 p-4 bg-white dark:bg-gray-800 rounded-lg">
<div class="flex justify-between items-start mb-2">
<h4 class="font-semibold" id="portfolioName">Portfolio Name</h4>
<span class="text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded-full">Active</span>
</div>
<div class="grid grid-cols-2 gap-2 text-sm">
<div>
<p class="text-gray-500 dark:text-gray-400">Last Updated</p>
<p id="lastUpdated">Oct 15, 2023</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Total Value</p>
<p id="totalValue">$125,342</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Holdings</p>
<p id="holdingsCount">12</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Tax Savings</p>
<p id="taxSavings">$1,245</p>
</div>
</div>
</div>
<i data-feather="upload-cloud" class="w-12 h-12 mx-auto text-gray-400 mb-3"></i>
<h3 class="text-lg font-medium mb-1">Upload Statement</h3>
<p class="text-gray-500 dark:text-gray-400 text-sm mb-4">Drag & drop your statement here (PDF, CSV, XLSX)</p>
<button class="bg-primary-600 hover:bg-primary-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition">
Select File
</button>
</div>
<!-- Save Options -->
<div id="saveOptions" class="hidden mb-4 p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
<div class="flex items-center mb-3">
<input type="checkbox" id="savePortfolio" class="mr-2" checked>
<label for="savePortfolio" class="font-medium">Save to Portfolio</label>
</div>
<div id="saveFields" class="space-y-3">
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Portfolio Name</label>
<input type="text" id="portfolioNameInput" class="w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Description</label>
<textarea id="portfolioDescription" rows="2" class="w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg"></textarea>
</div>
<div class="flex items-center">
<input type="radio" id="saveNew" name="saveOption" value="new" class="mr-2" checked>
<label for="saveNew" class="mr-4">Save as new</label>
<input type="radio" id="saveOverwrite" name="saveOption" value="overwrite" class="mr-2">
<label for="saveOverwrite">Overwrite existing</label>
</div>
</div>
</div>
<div class="flex items-start text-sm">
<input type="checkbox" id="privacy" class="mt-1 mr-2 bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600">
<label for="privacy" class="text-gray-600 dark:text-gray-400">I agree to the <a href="#" class="text-primary-600 dark:text-primary-400 hover:underline">Privacy Notice</a></label>
</div>
</div>
<!-- Right Panel -->
<div class="md:w-1/2 bg-gray-50 dark:bg-gray-700 p-8 md:p-10 border-t md:border-t-0 md:border-l border-gray-200 dark:border-gray-600">
<div class="bg-yellow-100/50 dark:bg-yellow-900/50 border-l-4 border-yellow-400 p-4 mb-6">
<div class="flex">
<div class="flex-shrink-0">
<i data-feather="alert-triangle" class="h-5 w-5 text-yellow-500 dark:text-yellow-400"></i>
</div>
<div class="ml-3">
<p class="text-sm text-yellow-800 dark:text-yellow-300">
<span class="font-semibold">BETA MODE</span> - Currently supports Robinhood and Fidelity style files one account at a time.
</p>
</div>
</div>
</div>
<!-- Calculations Estimates Table -->
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4 mb-6">
<h3 class="font-semibold text-lg mb-3 flex items-center">
<i data-feather="calculator" class="w-5 h-5 mr-2 text-primary-600 dark:text-primary-400"></i>
Tax Impact Estimates
</h3>
<div class="grid grid-cols-2 gap-4 text-sm">
<div>
<p class="text-gray-500 dark:text-gray-400">Short-Term Gain/Loss</p>
<p class="font-medium" id="shortTermEstimate">$0.00</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Long-Term Gain/Loss</p>
<p class="font-medium" id="longTermEstimate">$0.00</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Tax Bill Estimate</p>
<p class="font-medium text-red-500" id="taxBillEstimate">$0.00</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Budget Used</p>
<p class="font-medium" id="budgetUsed">$0.00 <span class="text-gray-400">of $3,000</span></p>
</div>
<div class="col-span-2">
<div class="flex justify-between mb-1">
<span class="text-sm font-medium">Tax Savings Progress</span>
<span class="text-sm" id="savingsPercentage">0%</span>
</div>
<div class="w-full bg-gray-200 dark:bg-gray-600 rounded-full h-2.5">
<div class="bg-primary-600 h-2.5 rounded-full" id="savingsProgress" style="width: 0%"></div>
</div>
</div>
</div>
</div>
<!-- Preview Data Panel -->
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm overflow-hidden mb-6">
<div class="flex justify-between items-center p-4 border-b border-gray-200 dark:border-gray-700">
<h3 class="font-semibold text-lg flex items-center">
<i data-feather="eye" class="w-5 h-5 mr-2 text-primary-600 dark:text-primary-400"></i>
Preview Data
</h3>
<button class="text-sm text-primary-600 dark:text-primary-400 hover:underline" id="togglePreview">
<i data-feather="chevron-down" class="w-4 h-4"></i>
</button>
</div>
<div class="p-4 hidden" id="previewDataContent">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
<thead class="bg-gray-50 dark:bg-gray-700">
<tr>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Symbol</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Qty</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Market Value</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Cost Basis</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700" id="previewDataBody">
<!-- Data will be populated here -->
</tbody>
</table>
</div>
<div class="mt-4 text-center text-gray-500 dark:text-gray-400" id="noPreviewData">
No data available. Upload a statement to begin.
</div>
</div>
</div>
<!-- Results Panel -->
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm overflow-hidden">
<div class="flex justify-between items-center p-4 border-b border-gray-200 dark:border-gray-700">
<h3 class="font-semibold text-lg flex items-center">
<i data-feather="bar-chart-2" class="w-5 h-5 mr-2 text-primary-600 dark:text-primary-400"></i>
Harvest Results
</h3>
<button class="text-sm text-primary-600 dark:text-primary-400 hover:underline" id="toggleResults">
<i data-feather="chevron-down" class="w-4 h-4"></i>
</button>
</div>
<div class="p-4 hidden" id="resultsContent">
<div class="flex justify-between items-center mb-4">
<div>
<p class="text-sm text-gray-500 dark:text-gray-400">Generated Trades</p>
<p class="font-medium" id="tradeCount">0 trades</p>
</div>
<button class="flex items-center text-sm bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-lg">
<i data-feather="download" class="w-4 h-4 mr-2"></i>
Export to Excel
</button>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
<thead class="bg-gray-50 dark:bg-gray-700">
<tr>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Action</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Symbol</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Qty</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Est. Gain/Loss</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700" id="resultsDataBody">
<!-- Results will be populated here -->
</tbody>
</table>
</div>
<div class="mt-4 text-center text-gray-500 dark:text-gray-400" id="noResultsData">
No harvest results available. Run the harvest to generate trades.
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bottom Action Bar -->
<div class="fixed bottom-0 left-0 w-full bg-white/90 dark:bg-gray-800/90 backdrop-blur-sm border-t border-gray-200 dark:border-gray-700 p-4 z-50">
<div class="flex items-center justify-between mb-2">
<div class="flex items-center text-sm text-gray-600 dark:text-gray-400">
<span id="saveStatus" class="flex items-center">
<i data-feather="circle" class="w-3 h-3 mr-1 text-gray-400"></i>
Not saved
</span>
<span class="mx-2">•</span>
<span id="autoSaveStatus" class="flex items-center">
<i data-feather="clock" class="w-3 h-3 mr-1 text-gray-400"></i>
Auto-save off
</span>
</div>
<button id="savePortfolioBtn" class="flex items-center text-blue-600 dark:text-blue-400 hover:underline">
<i data-feather="save" class="w-4 h-4 mr-1"></i>
Save Portfolio
</button>
</div>
<div class="max-w-6xl mx-auto flex flex-col md:flex-row items-center gap-4">
<div class="flex-1 min-w-[150px]">
<label class="text-sm text-gray-600 dark:text-gray-400">Max Tax Budget ($)</label>
<input type="number" id="maxBudget" placeholder="e.g., 3000" class="mt-1 w-full bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded px-3 py-2 dark:text-white">
</div>
<div class="flex items-center gap-2">
<label class="text-sm text-gray-600 dark:text-gray-400">Disposition</label>
<select id="dispositionMethod" class="bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded px-2 py-1 text-sm dark:text-white">
<option value="fifo">FIFO</option>
<option value="lifo">LIFO</option>
<option value="highest">Highest Cost</option>
<option value="lowest">Lowest Cost</option>
</select>
</div>
<div class="flex-1">
<label class="text-sm text-gray-600 dark:text-gray-400">Long-Term Rate</label>
<input type="range" id="longTermRate" min="0" max="50" value="15" class="w-full mt-1">
<span class="text-primary-600 dark:text-primary-400 text-sm"><span id="longTermRateValue">15</span>%</span>
</div>
<div class="flex-1">
<label class="text-sm text-gray-600 dark:text-gray-400">Short-Term Rate</label>
<input type="range" id="shortTermRate" min="0" max="50" value="25" class="w-full mt-1">
<span class="text-primary-600 dark:text-primary-400 text-sm"><span id="shortTermRateValue">25</span>%</span>
</div>
<div class="flex-1">
<label class="text-sm text-gray-600 dark:text-gray-400">Raise Cash ($)</label>
<input type="number" id="raiseCash" placeholder="0" class="mt-1 w-full bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded px-3 py-2 dark:text-white">
</div>
<button id="runHarvest" class="bg-primary-600 hover:bg-primary-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition whitespace-nowrap">
<i data-feather="bar-chart-2" class="inline mr-2 w-4 h-4"></i> Run Harvest
</button>
</div>
</div>
</div>
<!-- Toast Notification Container -->
<div id="toastContainer" class="fixed top-4 left-1/2 transform -translate-x-1/2 z-50 space-y-2 w-full max-w-md px-4"></div>
<script>
feather.replace();
// Current step tracking
let currentStep = 'upload';
// Initialize Vanta.js
VANTA.GLOBE({
el: "#vanta-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x3b82f6,
backgroundColor: 0xffffff,
size: 0.8
});
// Theme toggle functionality
const themeToggle = document.getElementById('themeToggle');
const html = document.documentElement;
themeToggle.addEventListener('click', () => {
html.classList.toggle('dark');
localStorage.setItem('theme', html.classList.contains('dark') ? 'dark' : 'light');
// Update Vanta.js background for theme
if (html.classList.contains('dark')) {
VANTA.GLOBE({
el: "#vanta-bg",
color: 0x3b82f6,
backgroundColor: 0x111827
});
} else {
VANTA.GLOBE({
el: "#vanta-bg",
color: 0x3b82f6,
backgroundColor: 0xffffff
});
}
});
// Check for saved theme preference
if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
html.classList.add('dark');
VANTA.GLOBE({
el: "#vanta-bg",
color: 0x3b82f6,
backgroundColor: 0x111827
});
}
// Dropzone functionality
const dropzone = document.getElementById('dropzone');
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
dropzone.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
['dragenter', 'dragover'].forEach(eventName => {
dropzone.addEventListener(eventName, highlight, false);
});
['dragleave', 'drop'].forEach(eventName => {
dropzone.addEventListener(eventName, unhighlight, false);
});
function highlight() {
dropzone.classList.add('dropzone-active');
}
function unhighlight() {
dropzone.classList.remove('dropzone-active');
}
dropzone.addEventListener('drop', handleDrop, false);
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
handleFiles(files);
}
function handleFiles(files) {
([...files]).forEach(uploadFile);
}
function uploadFile(file) {
// Show loading state
showLoading('upload', 'Processing your file...');
// Simulate file processing
setTimeout(() => {
hideLoading('upload');
if (file.name.endsWith('.pdf') || file.name.endsWith('.csv') || file.name.endsWith('.xlsx')) {
showToast('File uploaded successfully!', 'success');
updateFileUploadSuccess(file.name);
enableNextStep('settings');
} else {
showToast('Invalid file type. Please upload PDF, CSV, or XLSX.', 'error');
}
}, 2000);
}
function updateFileUploadSuccess(filename) {
const dropzone = document.getElementById('dropzone');
dropzone.innerHTML = `
<div class="flex flex-col items-center">
<i data-feather="check-circle" class="w-12 h-12 text-green-500 mb-3"></i>
<h3 class="text-lg font-medium mb-1">Upload Complete</h3>
<p class="text-gray-500 dark:text-gray-400 text-sm mb-4">${filename}</p>
<button class="text-primary-600 dark:text-primary-400 text-sm hover:underline" id="changeFile">
Change File
</button>
</div>
`;
feather.replace();
document.getElementById('changeFile').addEventListener('click', resetUploader);
}
function resetUploader() {
const dropzone = document.getElementById('dropzone');
dropzone.innerHTML = `
<i data-feather="upload-cloud" class="w-12 h-12 mx-auto text-gray-400 mb-3"></i>
<h3 class="text-lg font-medium mb-1">Upload Statement</h3>
<p class="text-gray-500 dark:text-gray-400 text-sm mb-4">Drag & drop your statement here (PDF, CSV, XLSX)</p>
<button class="bg-primary-600 hover:bg-primary-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition">
Select File
</button>
`;
feather.replace();
currentStep = 'upload';
updateStepUI();
}
function enableNextStep(nextStep) {
currentStep = nextStep;
updateStepUI();
}
function updateStepUI() {
// Update workflow navigation highlights
document.querySelectorAll('.workflow-step').forEach(step => {
if (step.dataset.step === currentStep) {
step.classList.add('bg-primary-100', 'dark:bg-primary-900', 'text-primary-600', 'dark:text-primary-400');
step.classList.remove('bg-gray-200', 'dark:bg-gray-600', 'text-gray-500', 'dark:text-gray-300');
} else {
step.classList.remove('bg-primary-100', 'dark:bg-primary-900', 'text-primary-600', 'dark:text-primary-400');
step.classList.add('bg-gray-200', 'dark:bg-gray-600', 'text-gray-500', 'dark:text-gray-300');
}
});
// Show/hide panels based on current step
if (currentStep === 'settings') {
document.getElementById('settingsPanel').classList.remove('hidden');
document.getElementById('uploadPanel').classList.add('hidden');
} else {
document.getElementById('settingsPanel').classList.add('hidden');
document.getElementById('uploadPanel').classList.remove('hidden');
}
}
function showLoading(context, message) {
const loaderId = `${context}Loader`;
let loader = document.getElementById(loaderId);
if (!loader) {
loader = document.createElement('div');
loader.id = loaderId;
loader.className = 'fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center z-50';
loader.innerHTML = `
<div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-xl max-w-sm w-full text-center">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600 mx-auto mb-4"></div>
<p class="text-gray-800 dark:text-gray-200">${message}</p>
</div>
`;
document.body.appendChild(loader);
}
}
function hideLoading(context) {
const loaderId = `${context}Loader`;
const loader = document.getElementById(loaderId);
if (loader) {
loader.remove();
}
}
function showToast(message, type = 'info') {
const toast = document.createElement('div');
const types = {
success: 'bg-green-100 border-green-400 text-green-700',
error: 'bg-red-100 border-red-400 text-red-700',
warning: 'bg-yellow-100 border-yellow-400 text-yellow-700',
info: 'bg-blue-100 border-blue-400 text-blue-700'
};
toast.className = `border-l-4 ${types[type]} p-4 rounded shadow-lg mb-2 flex items-start justify-between animate-fade-in`;
toast.innerHTML = `
<div class="flex items-start">
<i data-feather="${type === 'success' ? 'check-circle' : type === 'error' ? 'alert-circle' : 'info'}"
class="w-5 h-5 mr-3 mt-0.5"></i>
<p>${message}</p>
</div>
<button class="ml-4 text-gray-500 hover:text-gray-700" onclick="this.parentElement.remove()">
<i data-feather="x" class="w-4 h-4"></i>
</button>
`;
document.getElementById('toastContainer').appendChild(toast);
feather.replace();
setTimeout(() => {
toast.classList.add('animate-fade-out');
setTimeout(() => toast.remove(), 300);
}, 5000);
}
// Initialize interactive panels
document.getElementById('togglePreview').addEventListener('click', function() {
const content = document.getElementById('previewDataContent');
const icon = this.querySelector('i');
content.classList.toggle('hidden');
icon.setAttribute('data-feather', content.classList.contains('hidden') ? 'chevron-down' : 'chevron-up');
feather.replace();
});
document.getElementById('toggleResults').addEventListener('click', function() {
const content = document.getElementById('resultsContent');
const icon = this.querySelector('i');
content.classList.toggle('hidden');
icon.setAttribute('data-feather', content.classList.contains('hidden') ? 'chevron-down' : 'chevron-up');
feather.replace();
});
// Real-time calculation updates
document.getElementById('maxBudget').addEventListener('input', updateCalculations);
document.getElementById('longTermRate').addEventListener('input', function() {
document.getElementById('longTermRateValue').textContent = this.value;
updateCalculations();
});
document.getElementById('shortTermRate').addEventListener('input', function() {
document.getElementById('shortTermRateValue').textContent = this.value;
updateCalculations();
});
document.getElementById('dispositionMethod').addEventListener('change', updateCalculations);
document.getElementById('raiseCash').addEventListener('input', updateCalculations);
function updateCalculations() {
// Simulate calculations
const budget = parseFloat(document.getElementById('maxBudget').value) || 0;
const longTermRate = parseFloat(document.getElementById('longTermRate').value) || 0;
const shortTermRate = parseFloat(document.getElementById('shortTermRate').value) || 0;
// Update UI with simulated data
document.getElementById('shortTermEstimate').textContent = `${(Math.random() * 1000).toFixed(2)}`;
document.getElementById('longTermEstimate').textContent = `${(Math.random() * 500).toFixed(2)}`;
document.getElementById('taxBillEstimate').textContent = `-${(Math.random() * 300).toFixed(2)}`;
const progress = Math.min(100, (Math.random() * 100));
document.getElementById('savingsProgress').style.width = `${progress}%`;
document.getElementById('savingsPercentage').textContent = `${progress.toFixed(0)}%`;
}
// Form validation
document.getElementById('runHarvest').addEventListener('click', function() {
const budget = document.getElementById('maxBudget').value;
if (!budget || isNaN(budget) || parseFloat(budget) <= 0) {
showToast('Please enter a valid tax budget amount', 'error');
return;
}
showLoading('harvest', 'Calculating optimal trades...');
setTimeout(() => {
hideLoading('harvest');
showToast('Harvest complete! Optimal trades generated.', 'success');
// Simulate results
populateResultsTable();
}, 3000);
});
function populateResultsTable() {
const resultsBody = document.getElementById('resultsDataBody');
resultsBody.innerHTML = '';
// Sample data
const sampleTrades = [
{ action: 'Sell', symbol: 'AAPL', qty: 5, gainLoss: -125.34 },
{ action: 'Sell', symbol: 'TSLA', qty: 2, gainLoss: -87.21 },
{ action: 'Buy', symbol: 'SPY', qty: 3, gainLoss: 0 }
];
sampleTrades.forEach(trade => {
const row = document.createElement('tr');
row.className = 'hover:bg-gray-50 dark:hover:bg-gray-700';
row.innerHTML = `
<td class="px-4 py-2 whitespace-nowrap ${trade.action === 'Sell' ? 'text-red-500' : 'text-green-500'}">${trade.action}</td>
<td class="px-4 py-2 whitespace-nowrap">${trade.symbol}</td>
<td class="px-4 py-2 whitespace-nowrap">${trade.qty}</td>
<td class="px-4 py-2 whitespace-nowrap ${trade.gainLoss < 0 ? 'text-red-500' : 'text-green-500'}">
${Math.abs(trade.gainLoss).toFixed(2)}
</td>
`;
resultsBody.appendChild(row);
});
document.getElementById('tradeCount').textContent = `${sampleTrades.length} trades`;
document.getElementById('resultsContent').classList.remove('hidden');
document.getElementById('noResultsData').classList.add('hidden');
}
// Initialize with sample preview data
document.addEventListener('DOMContentLoaded', function() {
// Sample preview data
const sampleData = [
{ symbol: 'AAPL', qty: 10, marketValue: 1750.00, costBasis: 1500.00 },
{ symbol: 'TSLA', qty: 5, marketValue: 1250.00, costBasis: 1500.00 },
{ symbol: 'SPY', qty: 15, marketValue: 6000.00, costBasis: 5500.00 }
];
const previewBody = document.getElementById('previewDataBody');
sampleData.forEach(item => {
const row = document.createElement('tr');
row.className = 'hover:bg-gray-50 dark:hover:bg-gray-700';
row.innerHTML = `
<td class="px-4 py-2 whitespace-nowrap">${item.symbol}</td>
<td class="px-4 py-2 whitespace-nowrap">${item.qty}</td>
<td class="px-4 py-2 whitespace-nowrap">${item.marketValue.toFixed(2)}</td>
<td class="px-4 py-2 whitespace-nowrap">${item.costBasis.toFixed(2)}</td>
<td class="px-4 py-2 whitespace-nowrap">
<button class="text-primary-600 dark:text-primary-400 hover:underline text-sm">Edit</button>
</td>
`;
previewBody.appendChild(row);
});
document.getElementById('noPreviewData').classList.add('hidden');
// Initialize workflow steps
document.querySelectorAll('.workflow-step').forEach(step => {
step.addEventListener('click', function() {
if (this.dataset.step === 'upload' || currentStep === 'settings') {
enableNextStep(this.dataset.step);
}
});
});
});
</script>
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
from { opacity: 1; transform: translateY(0); }
to { opacity: 0; transform: translateY(10px); }
}
.animate-fade-in {
animation: fadeIn 0.3s ease-out forwards;
}
.animate-fade-out {
animation: fadeOut 0.3s ease-out forwards;
}
/* Responsive adjustments */
@media (max-width: 768px) {
.bottom-action-bar {
flex-direction: column;
gap: 0.5rem;
padding: 0.5rem;
}
.bottom-action-bar > div {
width: 100%;
}
#mainCard {
flex-direction: column;
}
#mainCard > div {
width: 100%;
}
}
</style>
</body>
</html>