1// ===================================================== 2// MarsFlag æ¤ç´¢ãã©ã¼ã ããªã㸠3// ===================================================== 4// ãã¶ã¤ã³è¦ä»¶ã§æ®ãã¦ãããã¤ãã£ã <form>+<input> 㨠5// MarsFlag ã®ã«ã¹ã¿ã è¦ç´ <mf-search-box> ãæ©æ¸¡ãããã¹ã¯ãªããã 6// 7// submit ãã¿ã³æ¼ä¸æã«ããEnter ãã¼æ¼ä¸æã¨åã MarsFlag æ¤ç´¢é·ç§»ã 8// çºç«ããããã«ãå é¨ input ã¸å¤ãåæã Enter ãçä¼¼çºç«ãããã 9// 10// 対象: ãã¼ã¸å ã«è¤æ°ãã£ã¦ã OKã<form class="search-form"> ã㤠11// ç´ä¸ã« <mf-search-box> ãå«ããã©ã¼ã å ¨ã¦ã«ä¸åº¦ã ããã¤ã³ãããã 12// 13// 注æ: å ¬å¼ MarsFlag ã©ã¤ãã©ãªã mf-search.js ã¨ããååã§ããã 14// ãã¡ã㯠https://ce.mf.marsflag.com/... ã® CDN ä¸ã®ãã®ã§ããå¥ç©ã§ãã 15 16(function () { 17 'use strict'; 18 19 function findMfInput(mfBox) { 20 if (!mfBox) return null; 21 if (mfBox.shadowRoot) { 22 const inShadow = mfBox.shadowRoot.querySelector('input'); 23 if (inShadow) return inShadow; 24 } 25 return mfBox.querySelector('input'); 26 } 27 28 function dispatchEnter(target) { 29 ['keydown', 'keypress', 'keyup'].forEach((type) => { 30 target.dispatchEvent(new KeyboardEvent(type, { 31 key: 'Enter', 32 code: 'Enter', 33 keyCode: 13, 34 which: 13, 35 bubbles: true, 36 })); 37 }); 38 } 39 40 function bindForm(form) { 41 if (form.dataset.mfBridge === 'bound') return; 42 43 const nativeInput = form.querySelector('input[name="q"]'); 44 const mfBox = form.querySelector('mf-search-box'); 45 if (!nativeInput || !mfBox) return; 46 47 form.dataset.mfBridge = 'bound'; 48 49 form.addEventListener('submit', (e) => { 50 const q = nativeInput.value.trim(); 51 if (!q) { 52 e.preventDefault(); 53 return; 54 } 55 56 const mfInput = findMfInput(mfBox); 57 if (!mfInput) return; // mf-search-box æªåæåæã¯ãã¤ãã£ãéä¿¡ã«ãã©ã¼ã«ãã㯠58 59 e.preventDefault(); 60 mfInput.value = q; 61 mfInput.dispatchEvent(new Event('input', { bubbles: true })); 62 mfInput.dispatchEvent(new Event('change', { bubbles: true })); 63 dispatchEnter(mfInput); 64 }); 65 } 66 67 function initializeMfSearch() { 68 document.querySelectorAll('form.search-form').forEach(bindForm); 69 } 70 71 window.initializeMfSearch = initializeMfSearch; 72})();
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.