1// æ¦è¦: å ±éè¦ç´ ãã¬ã³ããªã³ã°ããããã®ã¹ã¯ãªãããç¨éã«å¿ããHTMLã¿ã°ãé ç½®ãããã¨ã«ãã£ã¦åä½ããã 2// ä½¿ç¨æ¹æ³: headã¿ã°ã§æ¬ã¹ã¯ãªãããèªã¿è¾¼ãã 3// <script src="/js/digima-renderer-v1.js" defer></script> 4// TIPS åçãã¼ã¸ã®å ´å: 5// åçãã¼ã¸ãªã©ã§ã¬ã³ããªã³ã°ãåå以éã«çºçããå ´åãã¬ã³ããªã³ã°å®äºå¾ã« `window.renderDigimaTag();` ãå®è¡ãããããã¯åªçæ§ãããããè¤æ°åå®è¡ãã¦ããã 6 7window.renderDigimaTag = () => { 8 try { 9 // -------- ã¡ã½ããå®ç¾©ãããã -------- 10 const methods = { // { [key: string]: (element: Element) => void } 11 // æ¦è¦: [data-digima="render"]ã®innerHTMLã«å¤ãé©ç¨ããã 12 // 使ç¨ä¾: <span data-digima="render" data-digima-key="reception-time"></span> 13 render: (element) => { 14 const htmlCodes = { // { [key: string]: string | (element: Element) => string } 15 "reception-time": "9:00ï½23:00", 16 "reception-time-note": "忥ã»ç¥æ¥ãåä»ãã¦ããã¾ã", 17 // "header": () => "<header>ãããã¼</header>", // TODO: å°æ¥çã«ã¯ãããã¼ãçæã§ããããã«ãã¦ããããã 18 }; 19 20 // æå®ãããkeyã«å¯¾å¿ããå¤ãinnerHTMLã«é©ç¨ããã 21 const key = element.dataset.digimaKey 22 if (key in htmlCodes) { 23 const isFunction = typeof htmlCodes[key] === "function" 24 element.innerHTML = isFunction ? htmlCodes[key](element) : htmlCodes[key]; 25 26 element.dataset.digimaRendered = "true"; 27 } 28 }, 29 } 30 31 const main = () => { 32 // data-digimaãä»ãã¦ãã¦ãdata-digima-renderedãä»ãã¦ããªã(=é©ç¨ããã¦ããªã)è¦ç´ ãè¿å´ããã 33 const elements = document.querySelectorAll("[data-digima]:not([data-digima-rendered])"); 34 35 elements.forEach(element => { 36 const type = element.dataset.digima 37 if (type in methods) { 38 methods[type](element); 39 } 40 }); 41 } 42 // -------- ã¡ã½ããå®ç¾©ããã¾ã§ -------- 43 44 main(); 45 } 46 catch(e) { 47 console.error("[digima internal error]", e) 48 } 49} 50 51document.addEventListener('DOMContentLoaded', () => { 52 window.renderDigimaTag() 53})
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.