···22We can create a new web handler like. /day/3/{did} and it downloads the car file.
33Inside the car export is just one record with the verficiation code
4455-TODO: detect not-logged-in and if not, don't render this button:
66-77-<a id="download-car" href="#" class="btn btn-primary">Download your CAR file</a>
55+<a id="download-car" href="" class="btn btn-primary btn-disabled">Loading (JS required) …</a>
8697<script>
88+(function() {
99+ const button = document.getElementById('download-car');
1010 const carData = atob("{{car_base64}}");
1111+1212+ if (carData.length === 0) {
1313+ button.textContent = 'Log in to download';
1414+ return;
1515+ }
1616+1717+ button.classList.remove('btn-disabled');
1818+ button.textContent = 'Download your CAR file';
1919+1120 const bytes = new Uint8Array(carData.length);
1221 for (let i = 0; i < carData.length; i++) bytes[i] = carData.charCodeAt(i);
1313- document.getElementById('download-car').addEventListener('click', (e) => {
2222+ button.addEventListener('click', (e) => {
1423 e.preventDefault();
1524 const blob = new Blob([bytes], {type: 'application/vnd.ipld.car'});
1625 const url = URL.createObjectURL(blob);
···1827 a.href = url; a.download = 'day3.car'; a.click();
1928 URL.revokeObjectURL(url);
2029 });
3030+})();
2131</script>