1document.addEventListener('DOMContentLoaded', function() { 2 /** 3 * æå®ãããã³ã³ããå ã®ãããæ¤ç´¢ããããã¼ã¯ã¼ããã«æ¤ç´¢æ©è½ãè¨å®ãã颿° 4 * @param {HTMLElement} containerElement - 対象ã¨ãªãã³ã³ããè¦ç´ 5 */ 6 function initializeSearchTrend(containerElement) { 7 if (!containerElement) { 8 return; 9 } 10 11 const trendParagraph = containerElement.querySelector('p'); 12 if (!trendParagraph) { 13 return; 14 } 15 16 // â¼â¼â¼ãããããä¿®æ£ãâ¼â¼â¼ 17 // å¦ç対象ã«<a>ã¿ã°ãã¾ã å«ã¾ãã¦ããªãï¼æªå¦çã®ï¼å ´åã®ã¿ãHTMLã®çæå¦çãè¡ã 18 const isAlreadyFormatted = trendParagraph.querySelector('a') !== null; 19 20 if (!isAlreadyFormatted) { 21 const trendAlltext = trendParagraph.innerHTML; 22 const trendArry = trendAlltext.split(/\r\n|\r|\n/).map(line => line.trim()).filter(line => line); 23 24 // HTMLãä¸åº¦ã¯ãªã¢ 25 trendParagraph.innerHTML = ''; 26 27 for (let i = 0; i < trendArry.length; i++) { 28 if (trendArry[i].includes('href')) { 29 trendParagraph.insertAdjacentHTML('beforeend', trendArry[i]); 30 } else { 31 const linkHTML = `<a tabindex="0">${trendArry[i]}</a>`; 32 trendParagraph.insertAdjacentHTML('beforeend', linkHTML); 33 } 34 } 35 } 36 // â²â²â²ãä¿®æ£ã¯ããã¾ã§ãâ²â²â² 37 38 // ã¤ãã³ããªã¹ãã¼ã®è¨å®ã¯ãå¦çæ¸ã¿ãã©ããã«é¢ãããæ¯åå®è¡ãã 39 // (cloneNodeã§è¤è£½ãããè¦ç´ ã«ã¯ãªã¹ãã¼ãå¼ãç¶ãããªããã) 40 const trendLinks = trendParagraph.querySelectorAll('a'); 41 const queryInput = document.querySelector('#tmp_query'); 42 const submitButton = document.querySelector('#submit'); 43 44 if (!queryInput || !submitButton) { 45 return; 46 } 47 48 trendLinks.forEach(link => { 49 // æ¢ã«è¿½å æ¸ã¿ã®ãªã¹ãã¼ãåé¤ãã¦ãã追å ãããã¨ã§ãäºéç»é²ãé²ã 50 link.removeEventListener('click', eventHandler); 51 link.removeEventListener('keypress', keypressHandler); 52 53 link.addEventListener('click', eventHandler); 54 link.addEventListener('keypress', keypressHandler); 55 }); 56 } 57 58 // ã¤ãã³ããã³ãã©ã颿°ã®å¤ã§å®ç¾© 59 function eventHandler() { 60 const queryInput = document.querySelector('#tmp_query'); 61 queryInput.style.backgroundImage = 'none'; 62 queryInput.value = this.textContent; 63 document.querySelector('#submit').click(); 64 } 65 66 function keypressHandler(e) { 67 if (e.key === 'Enter') { 68 eventHandler.call(this); 69 } 70 } 71 72 // å ã®ãããã¼ã«ãããã¼ã¯ã¼ããåæå 73 const originalSearchTrend = document.querySelector('.site-header-top #search_trend_word, .site-header-lower #search_trend_word'); 74 initializeSearchTrend(originalSearchTrend); 75 76 // ã°ãã¼ãã«ã¹ã³ã¼ãã«é¢æ°ãå ¬é 77 window.initializeSearchTrend = initializeSearchTrend; 78});
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.