1/** 2 * JavaScript for announce.shared.uach.js 3 * @description ãã¡æ©ãå®è¡ããããã¨ãåæã¨ãã¦ããããjqueryä¸ä½¿ç¨ 4 * 5 * @author [email protected] 6 */ 7(function() { 8 'use strict'; 9 window.addEventListener('DOMContentLoaded', function() { 10 const infoArea = document.querySelector('.announceList'); 11 // ãç¥ããã¨ãªã¢ãåå¨ããªãå ´åã¯å¦çãçµäº 12 if (!infoArea) return; 13 const announceList = infoArea.querySelectorAll('[data-uach_announce]'); 14 if ( 15 announceList.length === 0 || // UACHãã§ãã¯æ å ±ããªãå ´å 16 !navigator.userAgentData || // navigator.userAgentDataãåå¨ããªãå ´å 17 typeof navigator.userAgentData.getHighEntropyValues !== 'function' // é«ã¨ã³ãããã¼ã®æ å ±åå¾ãä¸å¯ãªå ´å 18 ) { 19 // UACHã§ã®å¤å®ãä¸è¦ï¼æ å ±åå¾ä¸å¯ï¼ã§ããã°ã以éã®å¦çã¯å®è¡ããªã 20 return; 21 } 22 23 // UACHãã§ã㯠24 (async () => { 25 let highEntropyValues; 26 try { 27 // é«ã¨ã³ãããã¼ã®æ å ±åå¾ 28 highEntropyValues = await navigator.userAgentData.getHighEntropyValues(['platformVersion', 'fullVersionList']); 29 } catch (e) { 30 // é«ã¨ã³ãããã¼ã®æ å ±åå¾ã«å¤±æããå ´åã¯ããã以éå¦çã§ããªãããå¦çãçµäºãã 31 return; 32 } 33 // ãã§ãã¯å¦ç 34 for (let n = 0; n < announceList.length; n++) { 35 // ã¨ã¬ã¡ã³ãæ¯ã«UACHãã§ãã¯ã®å®æ½ 36 const announceUach = JSON.parse(decodeURIComponent(announceList[n].dataset.uach_announce)); 37 let isDevice = true; 38 if (typeof announceUach.device !== 'undefined') { 39 const osVersionRegexp = announceUach.device.map(device => 40 new RegExp(device.version) 41 ); 42 // OSãã¼ã¸ã§ã³ã®æ£è¦è¡¨ç¾ãã§ã㯠43 isDevice = osVersionRegexp.some((osVersionRegexp) => { 44 return osVersionRegexp.test(highEntropyValues.platformVersion); 45 }); 46 } 47 48 let isBrowser = true; 49 if (typeof announceUach.browser !== 'undefined') { 50 // ãã©ã¦ã¶ã®æ£è¦è¡¨ç¾ãã¼ã¿ãããã°ãã§ã㯠51 const browserRegexp = announceUach.browser.map(browser => ({ 52 name: new RegExp(browser.name), 53 version: new RegExp(browser.version) 54 })); 55 // ãã©ã¦ã¶ç¨®å¥ï¼ãã¼ã¸ã§ã³ã®æ£è¦è¡¨ç¾ãã§ã㯠56 isBrowser = browserRegexp.some((browserRegexp) => { 57 return highEntropyValues.fullVersionList.some((fullVersionList) => { 58 return browserRegexp.name.test(fullVersionList.brand) && // ãã©ã¦ã¶åãä¸è´ 59 browserRegexp.version.test(fullVersionList.version) // ãã©ã¦ã¶ãã¼ã¸ã§ã³ãä¸è´ 60 }); 61 }); 62 } 63 64 if (isDevice && isBrowser) { 65 // 表示対象ãªã®ã§è©²å½ã¢ãã¦ã³ã¹ã表示 66 announceList[n].style.display = 'block'; 67 } else { 68 // 表示対象ã§ã¯ãªãã®ã§è©²å½ã¢ãã¦ã³ã¹ãåé¤ 69 announceList[n].remove(); 70 } 71 } 72 73 // ãç¥ãã表示ã¨ãªã¢ã®ç¶æ 夿´ 74 if (infoArea) { 75 // RWDãèæ ®ãã¦è¡¨ç¤ºä¸ã®ãç¥ãããåå¾ãã¦å¤å®ãã 76 const visibleAnnounce = Array.from(infoArea.querySelectorAll('.announceItem')).filter(function(el) { 77 return getComputedStyle(el).display !== 'none'; 78 }); 79 // 表示ä¸ã®ãç¥ãããããã°ä½ãããªã 80 if (visibleAnnounce.length !== 0) return; 81 82 // RWDã®SPãã¥ã¼å°ç¨ã®åºå®ãç¥ããããããç¢ºèª 83 const rwdSpOnlyItems = infoArea.querySelectorAll('.announceItem.cmn-display-tab'); 84 if (rwdSpOnlyItems.length > 0) { 85 // 表示ä¸ã®ãç¥ããããªãããã¤RWDã®SPãã¥ã¼å°ç¨ã®åºå®ãç¥ãããããå ´å㯠86 // RWDã®PCãã¥ã¼ã®ããcmn-display-tabã¯ã©ã¹ãä»ä¸ 87 const addClassTarget = infoArea.querySelector('#addClassTarget'); 88 if (addClassTarget) { 89 addClassTarget.classList.add('cmn-display-tab'); 90 } 91 } else { 92 // 表示ãããç¥ãããåå¨ããªãã®ã§ãç¥ããã¨ãªã¢ãåé¤ 93 infoArea.remove(); 94 } 95 } 96 })(); 97 }); 98})();
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.