1$(".js-birthday").each(function () { 2 var $year = $(".js-birthyear"); 3 var $month = $(".js-birthmonth"); 4 var $day = $(".js-birthday"); 5 var $ageInput = $(".js-age"); 6 7 function toHalfWidth(str) { 8 return str.replace(/[\uFF10-\uFF19]/g, function (s) { 9 return String.fromCharCode(s.charCodeAt(0) - 0xFEE0); 10 }); 11 } 12 var updateAge = function () { 13 var yRaw = toHalfWidth($year.val()); 14 var y = parseInt(yRaw,10); 15 var m = parseInt(toHalfWidth($month.val()),10); 16 var d = parseInt(toHalfWidth($day.val()),10); 17 if (yRaw.length === 1 || yRaw.length === 2 || yRaw.length === 3) { 18 $ageInput.val(""); 19 return; 20 } 21 if (Number.isNaN(y) || Number.isNaN(m) || Number.isNaN(d)) { 22 $ageInput.val(""); 23 return; 24 } 25 var birthDate = new Date(y, m - 1, d); 26 var today = new Date(); 27 var age = today.getFullYear() - birthDate.getFullYear(); 28 var hasBirthdayPassed = 29 today.getMonth() > birthDate.getMonth() || 30 (today.getMonth() === birthDate.getMonth() && today.getDate() >= birthDate.getDate()); 31 if (!hasBirthdayPassed) { 32 age--; 33 } 34 if (Number.isNaN(y) || Number.isNaN(m) || Number.isNaN(d)) { 35 $ageInput.val(""); 36 return; 37 } 38 $ageInput.val(age); 39 }; 40 $year.on("change", updateAge); 41 $month.on("change", updateAge); 42 $day.on("change", updateAge); 43}); 44//# sourceMappingURL=test_autoage.min.js.map
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.