1document.addEventListener('DOMContentLoaded', function () { 2 const pRecommends = document.querySelector('.p-recommend'); 3 const checkboxes = Array.from(pRecommends.querySelectorAll('.checkbox_recommend_estimate')); 4 const countDisplay = pRecommends.querySelector('.p-recommend__count-number'); 5 const countContainer = pRecommends.querySelector('.p-recommend__count'); 6 let remainRecommendCount = parseInt(countDisplay.textContent); 7 8 // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤Îdisabled°À¤ò¹¹¿· 9 function updateCheckboxState(remain) { 10 countDisplay.textContent = remain; 11 12 // ²Äǽ·ï¿ô¤¬0·ï¤Î¾ì¹ç¡¢ÇØ·Ê¿§¤ò¥Ô¥ó¥¯¤ËÊѹ¹ 13 if (remain === 0) { 14 countContainer.classList.add('zero-available'); 15 } else { 16 countContainer.classList.remove('zero-available'); 17 } 18 19 // ³Æ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤Îdisabled¾õÂÖ¤ò¹¹¿·¡ÊPCÈǤδû¸CSS¤Ç¥°¥ì¡¼¥¢¥¦¥È¡Ë 20 checkboxes.forEach(checkboxe => { 21 checkboxe.disabled = remain === 0 && !checkboxe.checked; 22 }); 23 } 24 25 // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤´¤È¤Ë¥í¥Ã¥¯Â°À¤òÄɲà 26 let checkboxesLocked = false; 27 checkboxes.forEach(checkbox => { 28 checkbox.addEventListener('change', function () { 29 const self = this; 30 const value = self.value; 31 32 let jsonValue; 33 try { 34 jsonValue = JSON.parse(value); 35 } catch (err) { 36 console.error('Invalid JSON in checkbox value:', err); 37 self.checked = !self.checked; 38 checkboxesLocked = false; 39 return; 40 } 41 42 jsonValue['action'] = self.checked ? 'add' : 'remove'; 43 self.checked = !self.checked; // ¥Á¥§¥Ã¥¯¾õÂÖ¤òȿž 44 45 // ¥¯¥ê¥Ã¥¯¤ò̵»ë¤¹¤ë¾ì¹ç 46 if (checkboxesLocked) return; 47 checkboxesLocked = true; 48 49 // Ajax¥ê¥¯¥¨¥¹¥È¤òÁ÷¿® 50 $.ajax({ 51 url: "/goonet/php/estimate/ajax_cart_manager.php", 52 type: "post", 53 data: jsonValue, 54 dataType: "json", 55 success: function (data) { 56 if (data.status === 'success') { 57 if (jsonValue['action'] === 'add') { 58 self.checked = true; 59 remainRecommendCount--; 60 } else { 61 self.checked = false; 62 remainRecommendCount++; 63 } 64 // ¤ª¤¹¤¹¤á¤Î»Ä¤ê¿ô¤ò¹¹¿· 65 updateCheckboxState(remainRecommendCount); 66 } else { 67 console.error('Error:', data.message); 68 } 69 checkboxesLocked = false; 70 }, 71 error: function (xhr, status, error) { 72 checkboxesLocked = false; 73 console.error('Ajax Error:', status, error); 74 } 75 }); 76 }); 77 }); 78 // ½é´ü¾õÂ֤DzÄǽ·ï¿ô¤¬0·ï¤Î¾ì¹ç¤Ë¤âÂбþ 79 updateCheckboxState(remainRecommendCount); 80});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.