window.onload = SaveLocalStrage(); function SaveLocalStrage() { var ar_sno = ar_sname = ar_add = ar_tel = ar_timestamp = ar_photo_url = []; var json_ar_sno = localStorage.getItem('ar_sno'); var json_ar_sname = localStorage.getItem('ar_sname'); var json_ar_add = localStorage.getItem('ar_add'); var json_ar_tel = localStorage.getItem('ar_tel'); var json_ar_photo_url = localStorage.getItem('ar_photo_url'); var json_ar_timestamp = localStorage.getItem('ar_timestamp'); ar_sno = JSON.parse(json_ar_sno); ar_sname = JSON.parse(json_ar_sname); ar_add = JSON.parse(json_ar_add); ar_tel = JSON.parse(json_ar_tel); ar_photo_url = JSON.parse(json_ar_photo_url); ar_timestamp = JSON.parse(json_ar_timestamp); if(ar_sno){ var length = ar_sno.length; } if(length > 0){ if(!json_ar_sno.includes('18845')){ var i = length; ar_sno[i] = 18845; ar_sname[i] = "洋風居酒屋 花"; ar_add[i] = "松戸市上本郷2675-1 鳥海ビル1F"; ar_tel[i] = "047-710-9186"; ar_photo_url[i] = "18845-0-1729750424.webp,,"; ar_timestamp[i] = "1730442725"; } } else { ar_sno = [18845]; ar_sname = ["洋風居酒屋 花"]; ar_add = ["松戸市上本郷2675-1 鳥海ビル1F"]; ar_tel = ["047-710-9186"]; ar_photo_url = ["18845-0-1729750424.webp,,"]; ar_timestamp = ["1730442725"]; } json_ar_sno = JSON.stringify(ar_sno); json_ar_sname = JSON.stringify(ar_sname); json_ar_add = JSON.stringify(ar_add); json_ar_tel = JSON.stringify(ar_tel); json_ar_photo_url = JSON.stringify(ar_photo_url); json_ar_timestamp = JSON.stringify(ar_timestamp); localStorage.setItem('ar_sno', json_ar_sno); localStorage.setItem('ar_sname', json_ar_sname); localStorage.setItem('ar_add', json_ar_add); localStorage.setItem('ar_tel', json_ar_tel); localStorage.setItem('ar_photo_url', json_ar_photo_url); localStorage.setItem('ar_timestamp', json_ar_timestamp); } function show_result() { var result = ""; if(!length){ $('#dustbox_box').css('display', 'none'); } else { document.getElementById("show_result").innerHTML = result; } } function remove() { var txt = document.getElementById("keyin").value; localStorage.removeItem(txt); // 指定key に対応するデータを削除 ?> show_result(); } function balse(){ const v = confirm('履歴データをすべて削除します。削除したデータは取り消せません。よろしいですか?'); if(v === true){ localStorage.clear(); document.getElementById("show_result").innerHTML = "削除しました。"; $('#dustbox_box').css('display', 'none'); } }