1/** 2 * é»è®¤è·³è½¬å°æå®è¯è¨ 3 * é»è®¤è°æ´å°è±æ: jumpLang('en'); 4 * 5 */ 6function jumpLang(lang) { 7 // åªæç´æ¥è®¿é®ååæç¨ 8 if (location.pathname === '/') { 9 location.href = '/' + lang; 10 } 11} 12 13/** 14 * ææºç«¯æ¾ç¤ºpc端ç½é¡µ 15 */ 16 function browserRedirect() { 17 var sUserAgent = navigator.userAgent.toLowerCase(); 18 var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; 19 var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; 20 var bIsMidp = sUserAgent.match(/midp/i) == "midp"; 21 var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; 22 var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; 23 var bIsAndroid = sUserAgent.match(/android/i) == "android"; 24 var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; 25 var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; 26 27 if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { 28 // window.location.href = 'm' + location.pathname + location.search; 29 document.querySelector('head').innerHTML += '<meta name="viewport" content="width=1200px, initial-scale=0.3">' 30 } 31} 32 33/** 34 * æ¾ç¤ºæç« ãäº§åæ¨¡åçç§»å¨ç«¯è¯¦æ åæ®µ 35 */ 36function showMContent(m_content_url) { 37 return `${m_content_url ? `<script src="//cdn.xuansiwei.com/${m_content_url}.js"></script>` : ''}`; 38} 39 40/** 41 * æç« ã产å详æ å®ç°å¾ç弿¥å è½½ 42 */ 43function laodLazyPcContent(pc_content_url) { 44 return ` 45 <div class="pc_content"></div> 46 <script> 47 $.ajax({ 48 url: '//cdn.xuansiwei.com/${pc_content_url}.txt', 49 async: false, 50 success: function(txt){ 51 var content = txt.replace(/src="(.+?)"/g, (word, a) => \`src="data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=" data-src="\${a}" style="max-width: 100%; min-height: 200px"\`); 52 $('.pc_content').html(content); 53 } 54 }); 55 </script> 56 ` 57} 58 59/** 60 * ç½ç«æ¯å¦è¢«åµå¨iframeä¸ 61 */ 62function isIframe() { 63 return self !== top; 64} 65 66/** 67 * 301éå®å 68 */ 69function redirectToWWW() { 70 if (location.hostname.split('.').length === 2) { 71 location.href = location.protocol + '//www.' + location.host + location.pathname; 72 } 73} 74 75/** 76 * å±è½ä¸å½ip代ç 77 */ 78function shieldChina() { 79 if (location.host.indexOf('caihongjianzhan.com') === -1) { // åªææ£å¼ååææ§è¡ 80 fetch('//yun-api.sungdell.com/ip-country') 81 .then(res => res.json()) 82 .then(res => { 83 if (res.country === 'CN') { 84 location.href = "cnlogin.html"; 85 } 86 }) 87 } 88} 89 90/** 91 * ç¦æ¢é¡µé¢å¤å¶ 92 */ 93function banCopy() { 94 document.writeln(` 95 <script> 96 document.oncontextmenu=new Function("event.returnValue=false"); 97 document.onselectstart=new Function("event.returnValue=false"); 98 </script> 99 `); 100} 101 102/** 103 * ç¨å¾ç主è²ä½ä¸ºèæ¯æ¸å 104 */ 105 function setSectionsMainColor(imgEle) { 106 imgEle.crossOrigin = "Anonymous"; 107 if (imgEle.naturalWidth === 0) { 108 console.info('naturalWidth is 0'); 109 return; 110 } 111 const canvas = document.createElement('canvas') 112 var ctx = canvas.getContext("2d"); 113 var naturalImgSize = [imgEle.naturalWidth, imgEle.naturalHeight]; 114 canvas.width = naturalImgSize[0]; 115 canvas.height = naturalImgSize[1]; 116 117 //ç»å¶å°canvas 118 ctx.drawImage(imgEle, 0, 0); 119 //è·åimageDataï¼rgbaåç´ ç¹ 120 var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height); 121 const leftSectionData = [] 122 const rightSectionData = [] 123 const onelineImgDataLen = canvas.width * 4; 124 125 imgData.data.forEach((colorVal, i) => { 126 if (i % onelineImgDataLen <= 0.5 * onelineImgDataLen || i % onelineImgDataLen >= 0.6 * onelineImgDataLen) { 127 const inLeft = i % onelineImgDataLen <= 0.5 * onelineImgDataLen 128 if (i % 4 === 0) { 129 // è·årgbåå¼ 130 const curAverageRGB = (imgData.data[i] + imgData.data[i + 1] + imgData.data[i + 2]) / 3; 131 let leftOrRightRef = inLeft ? leftSectionData : rightSectionData; 132 //æ¯ä¸ªæ°ç»éåå个å¼ï¼æ¬é¢è²å¼ä¸çrãgãbçåå¼ï¼ä»¥årãgãbä¸ä¸ªå¼ã 133 //åå¼ä¸æ¹é¢ç¨äºç´¯å è®¡ç®æ¬åºåçæ´ä½åå¼ï¼ç¶ååè·æ¯ä¸ªåå¼å¯¹æ¯æ¿å°ä¸æ´ä½å弿æ¥è¿ç项çç´¢å¼ï¼åå该æ°ç»éçåä¸ä¸ªå¼ï¼rgbï¼å¯¹åºçé¢è² 134 leftOrRightRef[leftOrRightRef.length] = [curAverageRGB, imgData.data[i], imgData.data[i + 1], imgData.data[i + 2]] 135 } 136 } 137 }) 138 //generate average rgb 139 const averageOfLeft = Math.round(leftSectionData.reduce((_cur, item) => { 140 return _cur + item[0] 141 }, 0) / leftSectionData.length) 142 const averageOfRight = Math.round(rightSectionData.reduce((_cur, item) => { 143 return _cur + item[0] 144 }, 0) / rightSectionData.length) 145 //find the most near color
146 const findNearestIndex = (averageVal, arrBox) => { 147 let _gapValue = Math.abs(averageVal - arrBox[0]) 148 let _nearColorIndex = 0 149 arrBox.forEach((item, index) => { 150 const curGapValue = Math.abs(item - averageVal) 151 if (curGapValue < _gapValue) { 152 _gapValue = curGapValue 153 _nearColorIndex = index 154 } 155 }) 156 return _nearColorIndex 157 } 158 159 const leftNearestColor = leftSectionData[findNearestIndex(averageOfLeft, leftSectionData)] 160 const rightNearestColor = rightSectionData[findNearestIndex(averageOfRight, rightSectionData)] 161 console.log(leftNearestColor,rightNearestColor); 162 $(imgEle).parent().css('background-image', 'linear-gradient(90deg,rgba(' + leftNearestColor[1] + ',' + leftNearestColor[2] + ',' + leftNearestColor[3] + ',1) 0%,rgba(' + rightNearestColor[1] + ',' + rightNearestColor[2] + ',' + rightNearestColor[3] + ',1) 100%') 163}
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.