Last active
October 29, 2019 15:16
-
-
Save Getaji/b871e421c7fde20ea415884ec343e6f4 to your computer and use it in GitHub Desktop.
HOME'Sの物件一覧を築年数でフィルタするスクリプト。最大築年数をプロンプトで入力。キャンセルか無効な値で解除。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| const jqMansions = $('.rMansion'); | |
| const maxAge = Number.parseInt(prompt('最大築年数', '38')); | |
| if (Number.isNaN(maxAge)) { | |
| if (confirm('フィルタを解除しますか?')) { | |
| jqMansions.each(function() { this.style.display = 'block'; }); | |
| } | |
| return; | |
| } | |
| jqMansions.each(function() { | |
| const elAgeAndFloor = this.querySelector('.bukkenSpec tr:nth-child(3) td'); | |
| if (!elAgeAndFloor) return; | |
| const mAge = elAgeAndFloor.innerText.match(/(\d+)年/); | |
| const age = mAge ? Number.parseInt(mAge[1]) : -1; | |
| if (age > maxAge) { | |
| this.style.display = 'none'; | |
| } | |
| }) | |
| })() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // minified | |
| (function(){const jqMansions=$('.rMansion');const maxAge=Number.parseInt(prompt('最大築年数','38'));if(Number.isNaN(maxAge)){if(confirm('フィルタを解除しますか?')){jqMansions.each(function(){this.style.display='block'})} | |
| return} | |
| $('.rMansion').each(function(){const elAgeAndFloor=this.querySelector('.bukkenSpec tr:nth-child(3) td');if(!elAgeAndFloor)return;const mAge=elAgeAndFloor.innerText.match(/(\d+)年/);const age=mAge?Number.parseInt(mAge[1]):-1;if(age>maxAge){this.style.display='none'}})})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment