/* A-LINE v1.0 | Local-only memo. No network requests, cookies, or storage. */ (function(w,d){ 'use strict'; var root=d.getElementById('aln-life'); if(!root || root.dataset.initialized==='true') return; root.dataset.initialized='true'; var error=d.getElementById('aln-memo-error'), result=d.getElementById('aln-memo-result'); var labels={ stage:{start:'\u3053\u308c\u304b\u3089\u8003\u3048\u59cb\u3081\u305f\u3044',search:'\u7269\u4ef6\u3092\u63a2\u3057\u3066\u3044\u308b',compare:'\u5019\u88dc\u306e\u7269\u4ef6\u3092\u6bd4\u8f03\u3057\u305f\u3044'}, protect:{daily:'\u6bce\u65e5\u306e\u3086\u3068\u308a',family:'\u5bb6\u65cf\u3068\u904e\u3054\u3059\u6642\u9593',hobby:'\u8da3\u5473\u3084\u65c5\u884c',education:'\u5b66\u3073\u3084\u6559\u80b2',future:'\u5c06\u6765\u3078\u306e\u5099\u3048',undecided:'\u307e\u3060\u6574\u7406\u3067\u304d\u3066\u3044\u306a\u3044'}, confirm:{budget:'\u6bce\u6708\u306e\u8ca0\u62c5\u3068\u4e88\u7b97',cost:'\u7dad\u6301\u8cbb\u3084\u4fee\u7e55\u8cbb',area:'\u30a8\u30ea\u30a2\u3084\u66ae\u3089\u3057\u3084\u3059\u3055',risk:'\u7269\u4ef6\u306e\u30ea\u30b9\u30af',timing:'\u8cfc\u5165\u306e\u30bf\u30a4\u30df\u30f3\u30b0',undecided:'\u4f55\u304b\u3089\u59cb\u3081\u308b\u304b\u76f8\u8ac7\u3057\u305f\u3044'} }; var next={start:'\u4eca\u306e\u53ce\u5165\u30fb\u652f\u51fa\u3068\u3001\u8cfc\u5165\u5f8c\u3082\u6b8b\u3057\u305f\u3044\u652f\u51fa\u3092\u66f8\u304d\u51fa\u3057\u307e\u3057\u3087\u3046\u3002',search:'\u5019\u88dc\u306e\u8cfc\u5165\u8cbb\u7528\u306b\u52a0\u3048\u3001\u6bce\u6708\u306e\u4f4f\u5c45\u8cbb\u3068\u7dad\u6301\u8cbb\u3092\u4e26\u3079\u3066\u6bd4\u3079\u307e\u3057\u3087\u3046\u3002',compare:'\u5019\u88dc\u3054\u3068\u306b\u3001\u8cfc\u5165\u6642\u306e\u652f\u51fa\u30fb\u8cfc\u5165\u5f8c\u306e\u8cbb\u7528\u30fb\u672a\u78ba\u8a8d\u306e\u6761\u4ef6\u3092\u6574\u7406\u3057\u307e\u3057\u3087\u3046\u3002'}; function chosen(name){return Array.prototype.map.call(root.querySelectorAll('input[name="aln-'+name+'"]:checked'),function(n){return n.value;});} function text(name,values){return values.map(function(v){return labels[name][v] || '';}).filter(Boolean).join(' / ');} function set(id,value){var n=d.getElementById(id); if(n)n.textContent=value;} function emit(event,placement,target){if(w.ALINETracking)w.ALINETracking.track(event,placement,target);} function printDate(){var a=new Date();return '\u8a18\u5165\u65e5\uff1a'+a.getFullYear()+'\u5e74'+(a.getMonth()+1)+'\u6708'+a.getDate()+'\u65e5';} d.getElementById('aln-create-memo').addEventListener('click',function(){ var stage=chosen('stage'), protect=chosen('protect'), confirm=chosen('confirm'); var missing=!stage.length?'stage':(!protect.length?'protect':(!confirm.length?'confirm':null)); if(missing){error.textContent='3\u3064\u306e\u554f\u3044\u306b\u3001\u305d\u308c\u305e\u308c1\u3064\u4ee5\u4e0a\u304a\u7b54\u3048\u304f\u3060\u3055\u3044\u3002\u6c7a\u307e\u3063\u3066\u3044\u306a\u3044\u9805\u76ee\u306f\u3001\u305d\u306e\u9078\u629e\u80a2\u3092\u9078\u3079\u307e\u3059\u3002';error.hidden=false;d.getElementById('aln-'+missing+'-group').querySelector('legend').focus();return;} error.hidden=true; var data={stage:text('stage',stage),protect:text('protect',protect),confirm:text('confirm',confirm),next:next[stage[0]]}; Object.keys(data).forEach(function(k){set('aln-result-'+k,data[k]);set('aln-print-'+k,data[k]);}); set('aln-print-date',printDate());result.hidden=false;result.focus(); emit('aln_memo_complete','memo','memo'); }); // "Undecided" is exclusive within the respective question. ['protect','confirm'].forEach(function(group){ root.querySelectorAll('input[name="aln-'+group+'"]').forEach(function(input){input.addEventListener('change',function(){ if(!input.checked){result.hidden=true;['stage','protect','confirm','next'].forEach(function(k){set('aln-print-'+k,'');});return;} root.querySelectorAll('input[name="aln-'+group+'"]').forEach(function(other){ if(other!==input && (input.value==='undecided'||other.value==='undecided'))other.checked=false; }); if(!result.hidden){result.hidden=true;['stage','protect','confirm','next'].forEach(function(k){set('aln-print-'+k,'\u672a\u4f5c\u6210\uff1a\u9078\u629e\u5f8c\u306b\u300c\u6574\u7406\u30e1\u30e2\u3092\u3064\u304f\u308b\u300d\u3092\u62bc\u3057\u3066\u304f\u3060\u3055\u3044\u3002');});} });}); }); root.querySelectorAll('input[name="aln-stage"]').forEach(function(n){n.addEventListener('change',function(){if(!result.hidden){result.hidden=true;['stage','protect','confirm','next'].forEach(function(k){set('aln-print-'+k,'\u672a\u4f5c\u6210\uff1a\u9078\u629e\u5f8c\u306b\u300c\u6574\u7406\u30e1\u30e2\u3092\u3064\u304f\u308b\u300d\u3092\u62bc\u3057\u3066\u304f\u3060\u3055\u3044\u3002');});}});}); d.getElementById('aln-reset-memo').addEventListener('click',function(){ root.querySelectorAll('.aln-memo-form input').forEach(function(n){n.checked=false;}); error.hidden=true;result.hidden=true;['stage','protect','confirm','next'].forEach(function(k){set('aln-result-'+k,'');set('aln-print-'+k,'\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000');}); set('aln-print-date','\u8a18\u5165\u65e5\uff1a\u3000\u3000\u3000\u5e74\u3000\u3000\u6708\u3000\u3000\u65e5');d.getElementById('aln-stage-group').querySelector('legend').focus(); }); d.getElementById('aln-print-memo').addEventListener('click',function(){emit('aln_memo_print','memo_result','print_dialog');w.print();}); d.getElementById('aln-copy-request').addEventListener('click',function(){ var value='\u66ae\u3089\u3057\u3068\u4e88\u7b97\u306e\u6574\u7406\u76f8\u8ac7\u3092\u5e0c\u671b\u3057\u307e\u3059\u3002'; function fallback(){var t=d.getElementById('aln-copy-fallback');t.hidden=false;t.focus();t.select();set('aln-copy-status','\u30b3\u30d4\u30fc\u3067\u304d\u306a\u3044\u5834\u5408\u306f\u3001\u4e0b\u306e\u6587\u5b57\u3092\u9078\u629e\u3057\u3066\u30b3\u30d4\u30fc\u3057\u3066\u304f\u3060\u3055\u3044\u3002');} if(w.navigator.clipboard && w.isSecureContext){w.navigator.clipboard.writeText(value).then(function(){set('aln-copy-status','\u76f8\u8ac7\u540d\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3057\u305f\u3002\u30d5\u30a9\u30fc\u30e0\u306e\u8a73\u7d30\u6b04\u306b\u8cbc\u308a\u4ed8\u3051\u3066\u304f\u3060\u3055\u3044\u3002');}).catch(fallback);}else fallback(); }); })(window,document);