/* Read-only access to legacy personal records. Never migrate, normalize or write storage. */ 'use strict'; (() => { const $=id=>document.getElementById(id),plan=JSON.parse($('plan-data').textContent); const keys=[plan.planVersion,...(plan.compatiblePlanVersions||[])].map(v=>'notparsec-plan:'+v+':main'); let original=null; function load(){ original=null;$('legacy-records').hidden=true; try { for(const key of keys){const value=localStorage.getItem(key);if(value!==null){original=value;break;}} }catch{return;} if(original===null)return; $('legacy-records').hidden=false; try { const record=JSON.parse(original); $('legacy-notes').textContent=typeof record?.notes==='string'?record.notes:'저장된 메모가 없습니다.'; $('legacy-status').textContent='이전 선택·진행 상태를 포함한 원본 JSON을 내려받을 수 있습니다.'; }catch{ $('legacy-notes').textContent='기존 기록을 해석하지 못했습니다.'; $('legacy-status').textContent='데이터를 덮어쓰지 않았습니다. 원본 그대로 내려받을 수 있습니다.'; } } $('export-json').addEventListener('click',()=>{ if(original===null)return; const url=URL.createObjectURL(new Blob([original],{type:'application/json;charset=utf-8'})); const anchor=document.createElement('a');anchor.href=url;anchor.download='notparsec-previous-records.json'; anchor.click();setTimeout(()=>URL.revokeObjectURL(url),1000); }); window.addEventListener('storage',event=>{if(event.key===null||keys.includes(event.key))load();}); load(); })();