1// BUILD_DATE: 2025-04-10 2var str_css = 3 '@keyframes loadingAnimate{from {-webkit-transform: rotateY(0deg) scale(0.8);-o-transform: rotateY(0deg) scale(0.8);-ms-transform: rotateY(0deg) scale(0.8);-moz-transform: rotateY(0deg) scale(0.8);transform: rotateY(0deg) scale(0.8);}to {-webkit-transform: rotateY(-180deg) scale(0.8);-o-transform: rotateY(-180deg) scale(0.8);-ms-transform: rotateY(-180deg) scale(0.8);-moz-transform: rotateY(-180deg) scale(0.8);transform: rotateY(-180deg) scale(0.8);}}' + 4 '@-webkit-keyframes loadingAnimate{from {-webkit-transform: rotateY(0deg) scale(0.8);-o-transform: rotateY(0deg) scale(0.8);-ms-transform: rotateY(0deg) scale(0.8);-moz-transform: rotateY(0deg) scale(0.8);transform: rotateY(0deg) scale(0.8);}to {-webkit-transform: rotateY(-180deg) scale(0.8);-o-transform: rotateY(-180deg) scale(0.8);-ms-transform: rotateY(-180deg) scale(0.8);-moz-transform: rotateY(-180deg) scale(0.8);transform: rotateY(-180deg) scale(0.8);}}' + 5 '.loadingRun{-webkit-animation : loadingAnimate 1.2s infinite;animation : loadingAnimate 1.2s infinite;}' + 6 '.loader,.loader:after {border-radius: 50%;width: 60px;height: 60px;}' + 7 '.loader {margin: 60px auto;font-size: 10px;position: relative;text-indent: -9999em;border-top: 1.1em solid rgba(255, 255, 255, 0.2);border-right: 1.1em solid rgba(255, 255, 255, 0.2);border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);' + 8 'border-left: 1.1em solid #ffffff;-webkit-transform: translateZ(0);-ms-transform: translateZ(0);transform: translateZ(0);-webkit-animation: load8 1.1s infinite linear;animation: load8 1.1s infinite linear;}' + 9 '@-webkit-keyframes load8 {0% {-webkit-transform: rotate(0deg);transform: rotate(0deg);}100% {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}' + 10 '@keyframes load8 {0% {-webkit-transform: rotate(0deg);transform: rotate(0deg);}100% {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}'; 11 12const boolMap = { 13 no: false, 14 hide: false, 15 false: false, 16 0: false, 17 yes: true, 18 show: true, 19 true: true, 20 1: true, 21 enable: true, 22 disable: false 23}; 24 25function add_css(str_css) { 26 try { 27 //IEä¸å¯è¡ 28 var style = document.createStyleSheet(); 29 style.cssText = str_css; 30 } catch (e) { 31 //Firefox,Opera,Safari,Chromeä¸å¯è¡ 32 var style = document.createElement('style'); 33 style.type = 'text/css'; 34 style.textContent = str_css; 35 document.getElementsByTagName('HEAD').item(0).appendChild(style); 36 } 37} 38 39add_css(str_css); 40 41var loadingIconBase64 = 42 'data:image/svg+xml;base64,PHN2ZyB0PSIxNTI1OTE2MjIyMjk5IiBjbGFzcz0iaWNvbiIgc3R5bGU9IiIgdmlld0JveD0iMTMwIDAgODAwIDEwMjQiIHZlcnNpb249IjEuMSINCiAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwLWlkPSIyNDc4IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayINCiAgd2lkdGg9IjQ5IiBoZWlnaHQ9IjU2Ij4NCiAgPGRlZnM+DQogICAgPHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPg0KICA8L2RlZnM+DQogIDxwYXRoDQogICAgZD0iTTgzNS41NTAyNyA0OC43NjE5MDVDODc2LjgwNTEyMiA0OC43NjE5MDUgOTEwLjIyMjIyMyA4MS40NDExNTggOTEwLjIyMjIyMyAxMjEuNzUzNjA0TDkxMC4yMjIyMjMgOTAyLjA5NUM5MTAuMjIyMjIzIDkwMi4wOTUgOTEwLjIyMjIyMyA5NDIuNDA5MDExIDg3Ni44MDUgOTc1LjIzODA5NUwxMTMuNzc3Nzc4IDk3NS4yMzgwOTUgMTEzLjc3Nzc3OCAyNC4zODA5NTIgODguODg4ODg5IDQ4Ljc2MTkwNSA4MzUuNTUwMjcgNDguNzYxOTA1Wk02NCAwIDY0IDI0LjM4MDk1MiA2NCAxMDI0TDk2MC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Ayx1uzgDQnxILptvAClSBiDrRkeqv7VFvPdraBlf1uvZcN3AVvfgABY6TPLX9M6KZ2cwcXoCaI2XZgbYArup5GjY1PDbnvJHq5m46FLiiIVPDY/N/u3pcq/cp2hTEg9Vnn9fGO4FwBfT6DkFSYLi17OyEfwGiWm1shbv/BgAAAABJRU5ErkJggg=='; 48var parseBool = function (value, defaultValue) { 49 if (value === true || value === false) return value; 50 if (value == undefined || value == null) return false; 51 defaultValue = !!defaultValue; 52 53 if (typeof value == 'number') return value != 0; 54 if (typeof value != 'string') return false; 55 56 if (value == '') return false; 57 58 var trueArr = ['true', 'yes', 'show', 'enable'], 59 falseArr = ['false', 'no', 'hide', 'disable'], 60 value = value.toLowerCase(); 61 62 if (trueArr.indexOf(value) < 0 && falseArr.indexOf(value) < 0) { 63 return defaultValue; 64 } else { 65 return trueArr.indexOf(value) >= 0; 66 } 67}; 68 69var isIphone = function () { 70 var userAgent = navigator.userAgent.toLowerCase(); 71 return userAgent.indexOf('iphone') > 0; 72}; 73 74var isIphoneXor11 = function () { 75 return ( 76 isIphone() && 77 ((screen.height == 812 && screen.width == 375) || (screen.height == 896 && screen.width == 414)) 78 ); 79}; 80 81// 夿æ¡ä»¶: æ ¹æ®ä¸»è²è°ç hsl 82// hçåºé´ï¼[0,49],[50,190],[191,360] 83// s ä¸ç¨å¤æ 84// lçåºé´ï¼[0,39],[40,60],[61,100] 85function getTitleColor(mainHsl) { 86 let [h, s, l] = mainHsl; 87 let temp = l; 88 temp = 95; 89 if (h > 49 && h < 191) { 90 if (l > 39 && l < 101) temp = 20; 91 } else { 92 if (l > 60 && l < 101) temp = 20; 93 } 94 // if (l > 60 && l < 101) { 95 // if (h < 50 || h > 190) temp = 20; 96 // } 97 return [h, s, temp]; 98} 99function hexToRgba(hex, opacity = 1) { 100 if (!hex) hex = '#0076fe'; 101 // å¤çrgbaæ ¼å¼ 102 if (hex.startsWith('rgba(')) { 103 const rgba = hex.match(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/); 104 if (rgba) { 105 return [parseInt(rgba[1]), parseInt(rgba[2]), parseInt(rgba[3]), parseFloat(rgba[4])]; 106 } 107 } 108 // å¤çhexæ ¼å¼ 109 let r = parseInt('0x' + hex.slice(1, 3)); 110 let g = parseInt('0x' + hex.slice(3, 5)); 111 let b = parseInt('0x' + hex.slice(5, 7)); 112 return [r, g, b, opacity]; 113} 114function rgbtohsl(r, g, b) { 115 r = r / 255; 116 g = g / 255; 117 b = b / 255; 118 119 var min = Math.min(r, g, b); 120 var max = Math.max(r, g, b); 121 var l = (min + max) / 2; 122 var difference = max - min; 123 var h, s, l; 124 if (max == min) { 125 h = 0; 126 s = 0; 127 } else { 128 s = l > 0.5 ? difference / (2.0 - max - min) : difference / (max + min); 129 switch (max) { 130 case r: 131 h = (g - b) / difference + (g < b ? 6 : 0); 132 break; 133 case g: 134 h = 2.0 + (b - r) / difference; 135 break; 136 case b: 137 h = 4.0 + (r - g) / difference; 138 break; 139 } 140 h = Math.round(h * 60); 141 } 142 s = Math.round(s * 100); //è½¬æ¢æç¾åæ¯çå½¢å¼ 143 l = Math.round(l * 100); 144 return [h, s, l]; 145} 146function hsltorgb(h, s, l) {
147 var h = h / 360; 148 var s = s / 100; 149 var l = l / 100; 150 var rgb = []; 151 152 if (s == 0) { 153 rgb = [Math.round(l * 255), Math.round(l * 255), Math.round(l * 255)]; 154 } else { 155 var q = l >= 0.5 ? l + s - l * s : l * (1 + s); 156 var p = 2 * l - q; 157 var tr = (rgb[0] = h + 1 / 3); 158 var tg = (rgb[1] = h); 159 var tb = (rgb[2] = h - 1 / 3); 160 for (var i = 0; i < rgb.length; i++) { 161 var tc = rgb[i]; 162 if (tc < 0) { 163 tc = tc + 1; 164 } else if (tc > 1) { 165 tc = tc - 1; 166 } 167 switch (true) { 168 case tc < 1 / 6: 169 tc = p + (q - p) * 6 * tc; 170 break; 171 case 1 / 6 <= tc && tc < 0.5: 172 tc = q; 173 break; 174 case 0.5 <= tc && tc < 2 / 3: 175 tc = p + (q - p) * (4 - 6 * tc); 176 break; 177 default: 178 tc = p; 179 break; 180 } 181 rgb[i] = Math.round(tc * 255); 182 } 183 } 184 return rgb; 185} 186function rgbToStr(r, g, b) { 187 let rr = '00' + r.toString(16); 188 let gg = '00' + g.toString(16); 189 let bb = '00' + b.toString(16); 190 191 rr = rr.substr(rr.length - 2, 2); 192 gg = gg.substr(gg.length - 2, 2); 193 bb = bb.substr(bb.length - 2, 2); 194 return '#' + rr + gg + bb; 195} 196 197function toAbsURL(url) { 198 var a = document.createElement('a'); 199 a.href = url; 200 return a.href; 201} 202 203function changeBookResourceBaseURL(url) { 204 const bookResourceBaseURL = 205 (htmlConfig.loadingConfig && htmlConfig.loadingConfig.bookResourceBaseURL) || 206 window.bookResourceBaseURL || 207 ''; 208 209 const useTheFliphtml5Service = parseBool( 210 htmlConfig.loadingConfig.useTheFliphtml5Service || 'false' 211 ); 212 213 if (!bookResourceBaseURL) return url; 214 if (useTheFliphtml5Service) return url; 215 if (url.indexOf('http') >= 0) return url; 216 if (url.indexOf('file:///') >= 0) return url; 217 218 url = url.replace('../', '').replace('./', ''); 219 220 var absUrl = toAbsURL(bookResourceBaseURL + url); 221 return absUrl; 222} 223 224window.waitForLoading = true; 225var LoadingJS = function () { 226 this.initConfig(); 227 228 this.initHtml(); 229 this.initCss(); 230 231 this.startLoading(); 232 this.onResize(); 233 234 var self = this; 235 window.onresize = function () { 236 self.onResize(); 237 }; 238 239 window.setTimeout(function () { 240 window.waitForLoading = false; 241 }, 250); 242}; 243 244LoadingJS.prototype = { 245 initConfig: function () { 246 if (!window.loadingConfig && window.bookConfig && typeof window.bookConfig != 'string') { 247 window.loadingConfig = window.bookConfig; 248 } 249 if ( 250 !window.loadingConfig && 251 window.htmlConfig && 252 window.htmlConfig.bookConfig && 253 typeof window.htmlConfig.bookConfig != 'string' 254 ) { 255 window.loadingConfig = window.htmlConfig.bookConfig; 256 } 257 if (window.htmlConfig && window.htmlConfig.loadingConfig) { 258 window.loadingConfig = window.htmlConfig.loadingConfig; 259 } 260 try { 261 this.loadingVideoObjectFit = loadingConfig.loadingVideoObjectFit || 'fill'; 262 this.loadingBackgroundColorType = loadingConfig.loadingBackgroundColorType || '1'; 263 this.loadingCaptionColor = loadingConfig.loadingCaptionColor || '#DDDDDD'; 264 this.loadingBackground = loadingConfig.loadingBackground || '#1F2232'; 265 this.loadingMainColor = loadingConfig.loadingMainColor || loadingConfig.loadingBackground; 266 let [mainR, mainG, mainB, mainA] = hexToRgba(this.loadingMainColor); 267 if (this.loadingBackgroundColorType == 0) { 268 let [mainH, mainS, mainL] = rgbtohsl(mainR, mainG, mainB); 269 let [titleH, titleS, titleL] = getTitleColor([mainH, mainS, mainL]); 270 this.loadingBackground = `hsla(${mainH},${mainS}%,${mainL}%,${mainA})`; 271 this.loadingCaptionColor = `hsla(${titleH},${titleS}%,${titleL}%,${mainA})`; 272 loadingConfig.loadingCaptionColor = this.loadingCaptionColor; 273 } 274 this.loadingCaption = loadingConfig.loadingCaption || document.title; 275 this.loadingCaptionFontSize = !isNaN(loadingConfig.loadingCaptionFontSize) 276 ? parseInt(loadingConfig.loadingCaptionFontSize) 277 : 28; 278 this.loadingCaptionFontSize = Math.min(100, this.loadingCaptionFontSize); 279 this.loadingCaptionFontSize = Math.max(0, this.loadingCaptionFontSize); 280 this.loadingPicture = loadingConfig.loadingPicture 281 ? changeBookResourceBaseURL(loadingConfig.loadingPicture) + '?' + new Date().getTime() 282 : ''; 283 // this.loadingPictureWidth = !isNaN(loadingConfig.loadingPictureWidth) ? parseInt(loadingConfig.loadingPictureWidth) : 80; 284 this.loadingPictureHeight = !isNaN(loadingConfig.loadingPictureHeight) 285 ? parseInt(loadingConfig.loadingPictureHeight) 286 : 150; 287 this.loadingDisplayTime = !isNaN(loadingConfig.loadingDisplayTime) 288 ? parseInt(loadingConfig.loadingDisplayTime) 289 : 0; 290 this.loadingSpacing = !isNaN(loadingConfig.loadingSpacing) 291 ? parseInt(loadingConfig.loadingSpacing) 292 : 20; 293 this.showLoadingGif = 294 loadingConfig.showLoadingGif != undefined 295 ? parseBool(loadingConfig.showLoadingGif, true) 296 : true; 297 this.loadingVideo = loadingConfig.loadingVideo 298 ? changeBookResourceBaseURL(loadingConfig.loadingVideo) + '?' + new Date().getTime() 299 : ''; 300 if (this.loadingVideo) this.showLoadingGif = false;
301 this.isCloseVideoButtonVisible = loadingConfig.isCloseVideoButtonVisible 302 ? parseBool(loadingConfig.isCloseVideoButtonVisible, false) 303 : false; 304 this.loadingVideoCover = loadingConfig.loadingVideoCover 305 ? changeBookResourceBaseURL(loadingConfig.loadingVideoCover) + '?' + new Date().getTime() 306 : ''; 307 this.alwaysDoublePageOnMobile = loadingConfig.alwaysDoublePageOnMobile 308 ? parseBool(loadingConfig.alwaysDoublePageOnMobile, false) 309 : false; 310 } catch (err) { 311 this.loadingCaption = document.title; 312 this.loadingCaptionFontSize = 28; 313 this.loadingCaptionColor = '#DDDDDD'; 314 this.loadingBackground = '#1F2232'; 315 this.loadingPicture = ''; 316 this.showLoadingGif = true; 317 // this.loadingPictureWidth = 80; 318 this.loadingPictureHeight = 150; 319 this.loadingDisplayTime = 0; 320 this.loadingSpacing = 20; 321 this.loadingVideo = ''; 322 this.loadingVideoObjectFit = 'fill'; 323 this.isCloseVideoButtonVisible = false; 324 this.loadingVideoCover = ''; 325 this.alwaysDoublePageOnMobile = false; 326 } 327 328 if (document.querySelector('#tmpLoading')) { 329 document.querySelector('#tmpLoading').style.background = this.loadingBackground; 330 } 331 }, 332 get upsideOnMobile() { 333 if (this.alwaysDoublePageOnMobile && window.innerHeight > window.innerWidth) return true; 334 return false; 335 }, 336 initHtml: function () { 337 this.stop = false; 338 339 this.instance = document.createElement('div'); 340 this.title = document.createElement('p'); 341 this.title.innerHTML = this.loadingCaption; 342 this.copyright = document.createElement('p'); 343 this.copyright.setAttribute( 344 'style', 345 'position:absolute;bottom:5%;font-size:1.1rem;width:100%;text-align:center;' 346 ); 347 if (window.userInfo && window.userInfo.copyright) 348 this.copyright.innerHTML = window.userInfo.copyright; 349 350 this.bg = document.createElement('div'); 351 this.bg.setAttribute('style', 'transform:scale(1);'); 352 353 this.loadingAnimation = true; 354 if (this.showLoadingGif) this.initAnimationHtml(); 355 356 if (this.loadingVideo) { 357 this.initVideo(); 358 } 359 360 if (this.loadingPicture) { 361 this.image = document.createElement('img'); 362 this.image.src = this.loadingPicture; 363 this.instance.appendChild(this.image); 364 } 365 this.instance.appendChild(this.title); 366 this.instance.appendChild(this.copyright); 367 this.bg.appendChild(this.instance); 368 document.body.appendChild(this.bg); 369 370 try { 371 if (document.getElementById('bacgradient_image')) 372 document.getElementById('bacgradient_image').style.visibility = 'visible'; 373 } catch (error) {} 374 }, 375 376 initVideo: function () { 377 this.videoImage = document.createElement('img'); 378 this.videoImage.src = videoImage; 379 this.videoImage.setAttribute( 380 'style', 381 'position: absolute; top: 0px; right: 0px;left:0;bottom:0;margin:auto; z-index: 4;' 382 ); 383 this.videoImage.addEventListener( 384 'click', 385 function () { 386 this.video.style.display = 'block'; 387 this.instance.style.display = 'none'; 388 this.video.play(); 389 }.bind(this) 390 ); 391 392 this.videoLoadImage = document.createElement('div'); 393 this.videoLoadImage.setAttribute( 394 'style', 395 'position: absolute; top: auto; right: 0px;left:0;bottom:50%;margin:auto; z-index: 4;' 396 ); 397 this.videoLoadImage.setAttribute('class', 'loader'); 398 399 this.video = document.createElement('video'); 400 this.video.src = this.loadingVideo; 401 // this.video.setAttribute("webkit-playsinline", "true"); 402 // this.video.setAttribute("x5-playsinline", "true"); 403 // this.video.setAttribute("playsinline", ""); 404 this.video.setAttribute('preload', 'auto'); 405 if (this.loadingVideoCover) this.video.setAttribute('poster', this.loadingVideoCover); 406 // this.video.setAttribute("controls", "controls"); 407 // this.video.setAttribute("muted", ""); 408 // this.video.setAttribute("x-webkit-airplay", "allow"); 409 this.video.setAttribute( 410 'style', 411 'width: 100%; height: 100%; object-fit: ' + 412 this.loadingVideoObjectFit + 413 '; position: absolute; top: 0px; right: 0px; z-index: 3;' 414 ); 415 this.video.addEventListener('play', () => { 416 if (this.isCloseVideoButtonVisible) this.createCloseBtn(); 417 }); 418 419 this.bg.appendChild(this.video); 420 this.instance.appendChild(this.videoImage); 421 this.instance.appendChild(this.videoLoadImage); 422 this.video.load(); 423 }, 424 425 createCloseBtn: function () { 426 this.videoCloseBtn = document.createElement('div'); 427 const closeImg = document.createElement('img'); 428 closeImg.src = closeIcon; 429 closeImg.setAttribute('style', 'width: 16px; height: 16px;'); 430 431 this.videoCloseBtn.appendChild(closeImg); 432 this.videoCloseBtn.setAttribute( 433 'style', 434 'position: absolute; top: 10px; right: 40px; z-index: 999;background: rgba(0, 0, 0, 0.5); border-radius: 50%;height: 30px; width: 30px;cursor: pointer;box-sizing: border-box;display:flex;justify-content:center;align-items:center;' 435 ); 436 this.videoCloseBtn.addEventListener('click', () => this.video.pause()); 437 this.bg.appendChild(this.videoCloseBtn); 438 }, 439 440 showVideo: function () { 441 try { 442 this.videoImage.style.display = 'block'; 443 this.videoLoadImage.style.display = 'none'; 444 } catch (error) {} 445 }, 446 447 loadingSvg: function () { 448 // this.loadImageUrl = "<svg t=\"1525916222299\" class=\"icon\" style=\"\" viewBox=\"130 0 800 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"2478\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"49\" height=\"56\"><defs><style type=\"text/css\"></style></defs><path d=\"M835.55027 48.761905C876.805122 48.761905 910.222223 81.441158 910.222223 121.753604L910.222223 902.095C910.222223 902.095 910.222223 942.409011 876.805 975.238095L113.777778 975.238095 113.777778 24.380952 88.888889 48.761905 835.55027 48.761905ZM64 0 64 24.380952 64 1024L960 1024C835.55027 1024 904.277615 1024 960 969.325498L960 54.49204
448C960 54.49204 904.277615 0 835.55027 0L88.888889 0 64 0Z\" p-id=\"2479\"></path><path d=\"M775.164361 219.428572C788.910114 219.428572 800.05325 208.512847 800.05325 195.047619 800.05325 181.582391 788.910114 170.666667 775.164361 170.666667L263.111111 170.666667C249.365357 170.666667 238.222222 181.582391 238.222222 195.047619 238.222222 208.512847 249.365357 219.428572 263.111111 219.428572L775.164361 219.428572Z\" p-id=\"2481\"></path><path d=\"M775.164361 365.714285C788.910114 365.714285 800.05325 354.798562 800.05325 341.333333 800.05325 327.868105 788.910114 316.952382 775.164361 316.952382L263.111111 316.952382C249.365357 316.952382 238.222222 327.868105 238.222222 341.333333 238.222222 354.798562 249.365357 365.714285 263.111111 365.714285L775.164361 365.714285Z\" p-id=\"2482\"></path><path d=\"M775.164361 536.380951C788.910114 536.380951 800.05325 525.465229 800.05325 512 800.05325 498.534771 788.910114 487.619049 775.164361 487.619049L263.111111 487.619049C249.365357 487.619049 238.222222 498.534771 238.222222 512 238.222222 525.465229 249.365357 536.380951 263.111111 536.380951L775.164361 536.380951Z\" p-id=\"2483\"></path></svg>"; 449 450 var loadImageUrl = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); 451 loadImageUrl.setAttribute('t', '1525916222299'); 452 loadImageUrl.setAttribute('class', 'icon'); 453 loadImageUrl.setAttribute('style', ''); 454 loadImageUrl.setAttribute('viewBox', '130 0 800 1024'); 455 loadImageUrl.setAttribute('version', '1.1'); 456 loadImageUrl.setAttribute('xmlns', 'http://www.w3.org/2000/svg'); 457 loadImageUrl.setAttribute('p-id', '2478'); 458 loadImageUrl.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); 459 loadImageUrl.setAttribute('width', '49'); 460 loadImageUrl.setAttribute('height', '56'); 461 462 var defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs'); 463 var style = document.createElementNS('http://www.w3.org/2000/svg', 'style'); 464 style.setAttribute('type', 'text/css'); 465 var path1 = document.createElementNS('http://www.w3.org/2000/svg', 'path'); 466 path1.setAttribute( 467 'd', 468 'M835.55027 48.761905C876.805122 48.761905 910.222223 81.441158 910.222223 121.753604L910.222223 902.095C910.222223 902.095 910.222223 942.409011 876.805 975.238095L113.777778 975.238095 113.777778 24.380952 88.888889 48.761905 835.55027 48.761905ZM64 0 64 24.380952 64 1024L960 1024C835.55027 1024 904.277615 1024 960 969.325498L960 54.49204C960 54.49204 904.277615 0 835.55027 0L88.888889 0 64 0Z' 469 ); 470 path1.setAttribute('p-id', '2479'); 471 472 var path2 = document.createElementNS('http://www.w3.org/2000/svg', 'path'); 473 path2.setAttribute( 474 'd', 475 'M775.164361 219.428572C788.910114 219.428572 800.05325 208.512847 800.05325 195.047619 800.05325 181.582391 788.910114 170.666667 775.164361 170.666667L263.111111 170.666667C249.365357 170.666667 238.222222 181.582391 238.222222 195.047619 238.222222 208.512847 249.365357 219.428572 263.111111 219.428572L775.164361 219.428572Z' 476 ); 477 path2.setAttribute('p-id', '2481'); 478 479 var path3 = document.createElementNS('http://www.w3.org/2000/svg', 'path'); 480 path3.setAttribute( 481 'd', 482 'M775.164361 365.714285C788.910114 365.714285 800.05325 354.798562 800.05325 341.333333 800.05325 327.868105 788.910114 316.952382 775.164361 316.952382L263.111111 316.952382C249.365357 316.952382 238.222222 327.868105 238.222222 341.333333 238.222222 354.798562 249.365357 365.714285 263.111111 365.714285L775.164361 365.714285Z' 483 ); 484 path3.setAttribute('p-id', '2482'); 485 486 var path4 = document.createElementNS('http://www.w3.org/2000/svg', 'path'); 487 path4.setAttribute( 488 'd', 489 'M775.164361 536.380951C788.910114 536.380951 800.05325 525.465229 800.05325 512 800.05325 498.534771 788.910114 487.619049 775.164361 487.619049L263.111111 487.619049C249.365357 487.619049 238.222222 498.534771 238.222222 512 238.222222 525.465229 249.365357 536.380951 263.111111 536.380951L775.164361 536.380951Z' 490 ); 491 path4.setAttribute('p-id', '2483'); 492 493 defs.appendChild(style); 494 loadImageUrl.appendChild(defs); 495 loadImageUrl.appendChild(path1); 496 loadImageUrl.appendChild(path2); 497 loadImageUrl.appendChild(path3); 498 loadImageUrl.appendChild(path4); 499 500 return loadImageUrl; 501 }, 502 createLoadingImg: function (src) { 503 var preIcon = document.createElement('img'); 504 preIcon.src = src; 505 return preIcon; 506 }, 507 changeLoadingImgColor: function (base64Data, newColor) { 508 return new Promise((resolve, reject) => { 509 const img = new Image(); 510 511 img.onload = () => { 512 const canvas = document.createElement('canvas'); 513 canvas.width = img.width;
514 canvas.height = img.height; 515 516 const ctx = canvas.getContext('2d'); 517 ctx.drawImage(img, 0, 0); 518 519 ctx.globalCompositeOperation = 'source-in'; 520 ctx.fillStyle = newColor; 521 ctx.fillRect(0, 0, canvas.width, canvas.height); 522 523 const modifiedBase64Data = canvas.toDataURL(); 524 resolve(modifiedBase64Data); 525 }; 526 527 img.onerror = error => { 528 console.log(error); 529 }; 530 531 img.src = base64Data; 532 }); 533 }, 534 initAnimationHtml: async function () { 535 if (!document.createElementNS) return; 536 this.loadBox = document.createElement('div'); 537 var loadingIcon = await this.changeLoadingImgColor(loadingIconBase64, this.loadingCaptionColor); 538 var img1 = this.createLoadingImg(loadingIcon); 539 var img2 = this.createLoadingImg(loadingIcon); 540 this.img3 = this.createLoadingImg(loadingIcon); 541 542 if (isIphoneXor11()) { 543 var self = this; 544 var index = 0; 545 this.loadingAnimation = true; 546 var render = function () { 547 window.setTimeout(function () { 548 if (!self.loadingAnimation) return; 549 try { 550 var rotateY = 1.8 * index; 551 var tmpStyle = 'rotateY(-' + rotateY + 'deg) scale(0.8)'; 552 self.img3.style['-webkit-transform'] = tmpStyle; 553 self.img3.style['-o-transform'] = tmpStyle; 554 self.img3.style['-ms-transform'] = tmpStyle; 555 self.img3.style['-moz-transform'] = tmpStyle; 556 self.img3.style['transform'] = tmpStyle; 557 index++; 558 index = index % 101; 559 render(); 560 } catch (error) {} 561 }, 7); 562 }; 563 render(); 564 } else { 565 this.img3.setAttribute('class', 'loadingRun'); 566 } 567 568 this.img3.setAttribute( 569 'style', 570 'position : absolute;' + 571 'left : 20px;' + 572 'top : 0;' + 573 // "z-index : -1;" + 574 '-webkit-transform:rotateY(0deg) scale(0.8);' + 575 '-o-transform:rotateY(0deg) scale(0.8);' + 576 '-ms-transform:rotateY(0deg) scale(0.8);' + 577 '-moz-transform:rotateY(0deg) scale(0.8);' + 578 'transform:rotateY(0deg) scale(0.8);' + 579 '-webkit-transform-origin : 0 0;' + 580 '-o-transform-origin : 0 0;' + 581 '-ms-transform-origin : 0 0;' + 582 '-moz-transform-origin : 0 0;' + 583 'transform-origin : 0 0;' + 584 'will-change : transform;' + 585 'fill :' + 586 this.loadingCaptionColor + 587 ';' 588 ); 589 590 img2.setAttribute( 591 'style', 592 'position : absolute;' + 593 'left : 20px;' + 594 'top : 0;' + 595 '-webkit-transform:rotateY(180deg) scale(0.8);' + 596 '-o-transform:rotateY(180deg) scale(0.8);' + 597 '-ms-transform:rotateY(180deg) scale(0.8);' + 598 '-moz-transform:rotateY(180deg) scale(0.8);' + 599 'transform:rotateY(180deg) scale(0.8);' + 600 '-webkit-g : 0 0;' + 601 '-o-transform-origin : 0 0;' + 602 '-ms-transform-origin : 0 0;' + 603 '-moz-transform-origin : 0 0;' + 604 'transform-origin : 0 0;' + 605 'fill : ' + 606 this.loadingCaptionColor + 607 ';' 608 ); 609 610 img1.setAttribute( 611 'style', 612 'position : absolute;' + 613 'left : 20px;' + 614 'top : 0;' + 615 '-webkit-transform:rotateY(0) scale(0.8);' + 616 '-o-transform:rotateY(0) scale(0.8);' + 617 '-ms-transform:rotateY(0) scale(0.8);' + 618 '-moz-transform:rotateY(0) scale(0.8);' + 619 'transform:rotateY(0) scale(0.8);' + 620 '-webkit-transform-origin : 0 0;' + 621 '-o-transform-origin : 0 0;' + 622 '-ms-transform-origin : 0 0;' + 623 '-moz-transform-origin : 0 0;' + 624 'transform-origin : 0 0;' + 625 'fill : ' + 626 this.loadingCaptionColor + 627 ';' 628 ); 629 630 this.loadBox.appendChild(img1); 631 this.loadBox.appendChild(img2); 632 this.loadBox.appendChild(this.img3); 633 this.instance.appendChild(this.loadBox); 634 }, 635 636 startLoading: function () {}, 637 638 destroy: function () { 639 // video1.removeEventListener('ended',this); 640 641 // $('.shade').hide(); 642 // $("#videoID").hide(); 643 // $(".flipbook").show(); 644 // // $('.flipbook-viewport').show(); 645 // $('.flipbook-viewport').fadeIn(3000); 646 // $('#musicinfo').show(); 647 if (global.isIE8() || global.isIE9()) { 648 $(this.bg).animate( 649 { opacity: '0' }, 650 0.6, 651 function () { 652 this.loadingAnimation = false;
653 $('body>style').html(''); 654 $(this.bg).remove(); 655 $('body').css({ 'background-color': '' }); 656 }.bind(this) 657 ); 658 } else { 659 animateOnce( 660 $(this.bg), 661 { opacity: '0' }, 662 0.6, 663 function () { 664 this.loadingAnimation = false; 665 $(this.img3).attr('class', ''); 666 $('body>style').html(''); 667 $(this.bg).remove(); 668 $(this.image).attr('src', ''); 669 $('body').css({ 'background-color': '' }); 670 }.bind(this) 671 ); 672 window.setTimeout( 673 function () { 674 if (!this.loadingAnimation) return; 675 this.loadingAnimation = false; 676 $(this.img3).attr('class', ''); 677 $('body>style').html(''); 678 $(this.bg).remove(); 679 $(this.image).attr('src', ''); 680 $('body').css({ 'background-color': '' }); 681 }.bind(this), 682 1000 683 ); 684 } 685 }, 686 687 initCss: function () { 688 document 689 .getElementsByTagName('html')[0] 690 .setAttribute('style', 'margin : 0;' + 'padding : 0;' + 'width : 100%;' + 'height : 100%;'); 691 692 document.body.setAttribute( 693 'style', 694 'margin : 0;' + 695 'padding : 0;' + 696 'width : 100%;' + 697 'height : 100%;' + 698 'position : fixed;' + 699 'background-color :' + 700 this.loadingBackground + 701 ';' 702 ); 703 704 var width = this.upsideOnMobile ? window.innerHeight : '100%'; 705 var height = this.upsideOnMobile ? window.innerWidth : '100%'; 706 this.bg.setAttribute( 707 'style', 708 'margin : 0;' + 709 'padding : 0;' + 710 'width : 100%;' + 711 'height : 100%;' + 712 'position : fixed;' + 713 'background-color:' + 714 this.loadingBackground + 715 ';' + 716 'width : ' + 717 width + 718 'px;' + 719 'height : ' + 720 height + 721 'px;' + 722 'transform-origin : 0px 0px;' + 723 `transform : translate(${height}px) rotate(${this.upsideOnMobile ? 90 : 0}deg);` 724 ); 725 726 this.instance.setAttribute( 727 'style', 728 'width : 100%;' + 729 'height : 100%;' + 730 'opacity : 1;' + 731 'color :' + 732 this.loadingCaptionColor + 733 ';' + 734 'text-align : center;' + 735 'vertical-align : middle;' + 736 'font-family : Tahoma;' + 737 'position : relative;' 738 ); 739 740 var titleTran = 'translate(-50%, ' + this.loadingSpacing / 2 + 'px)'; 741 var loadingBoxTran = 'translate(-50% , -' + (this.loadingSpacing / 2 + 45) + 'px)'; 742 var videoImageTran = 'translate(-50% , -' + (this.loadingSpacing / 2 + 60) + 'px)'; 743 // var videoLoadImageTran = "translate(-50% , -" + (this.loadingSpacing/2 + 60) + "px)"; 744 var imageTran = 'translate(-50% , 0)'; 745 var imageTop = '5%'; 746 var imageDisplay = 'block'; 747 748 var loadingPictureHeight = Math.min(window.innerHeight * 0.35, this.loadingPictureHeight); 749 if (this.showLoadingGif || this.loadingVideo) { 750 if (window.innerHeight <= 300) imageDisplay = 'none'; 751 } else { 752 imageTop = '50%'; 753 imageTran = 'translate(-50% , -' + (this.loadingSpacing / 2 + loadingPictureHeight) + 'px)'; 754 } 755 756 if (this.image) 757 this.image.setAttribute( 758 'style', 759 'display : ' + 760 imageDisplay + 761 ';' + 762 'position : absolute;' + 763 'top : ' + 764 imageTop + 765 ';' + 766 'left : 50%;' + 767 '-webkit-transform :' + 768 imageTran + 769 ';' + 770 '-moz-transform :' + 771 imageTran + 772 ';' + 773 '-ms-transform :' + 774 imageTran + 775 ';' + 776 '-o-transform :' + 777 imageTran + 778 ';' + 779 'transform :' + 780 imageTran + 781 ';' + 782 // "width : " + this.loadingPictureWidth + "px;" + 783 'height : ' + 784 this.loadingPictureHeight + 785 'px;' + 786 'max-width : 90%;' + 787 'max-height : 35%;' 788 ); 789 790 this.title.setAttribute( 791 'style', 792 'font-family:Arial,Helvetica,sans serif;' + 793 'font-size : ' + 794 this.loadingCaptionFontSize + 795 'px;' + 796 'position : absolute;' + 797 'top : 50%;' + 798 'left : 50%;' +
799 '-webkit-transform :' + 800 titleTran + 801 ';' + 802 '-moz-transform :' + 803 titleTran + 804 ';' + 805 '-ms-transform :' + 806 titleTran + 807 ';' + 808 '-o-transform :' + 809 titleTran + 810 ';' + 811 'transform :' + 812 titleTran + 813 ';' + 814 'margin : 0;' + 815 'padding : 0;' + 816 'width:90%;' 817 ); 818 819 if (this.videoImage) 820 this.videoImage.setAttribute( 821 'style', 822 'position:relative;' + 823 'cursor:pointer;' + 824 'display:none;' + 825 'z-index:4;' + 826 'perspective:200px;' + 827 '-webkit-transform-style:preserve-3d;' + 828 '-o-transform-style:preserve-3d;' + 829 '-ms-transform-style:preserve-3d;' + 830 '-moz-transform-style:preserve-3d;' + 831 'transform-style:preserve-3d;' + 832 'position : absolute;' + 833 'width : auto;' + 834 'height : 60px;' + 835 'left : 50%;' + 836 'top : 50%;' + 837 '-webkit-transform : ' + 838 videoImageTran + 839 ';' + 840 '-moz-transform : ' + 841 videoImageTran + 842 ';' + 843 '-ms-transform : ' + 844 videoImageTran + 845 ';' + 846 '-o-transform : ' + 847 videoImageTran + 848 ';' + 849 'transform : ' + 850 videoImageTran + 851 ';' + 852 'padding : 0;' 853 ); 854 855 if (this.videoLoadImage) 856 this.videoLoadImage.style['margin-bottom'] = this.loadingSpacing / 2 + 'px'; 857 858 if (this.loadBox) 859 this.loadBox.setAttribute( 860 'style', 861 'position:relative;' + 862 'perspective:200px;' + 863 '-webkit-transform-style:preserve-3d;' + 864 '-o-transform-style:preserve-3d;' + 865 '-ms-transform-style:preserve-3d;' + 866 '-moz-transform-style:preserve-3d;' + 867 'transform-style:preserve-3d;' + 868 'position : absolute;' + 869 'width : 39.2px;' + 870 'height : 44.8px;' + 871 'left : 50%;' + 872 'top : 50%;' + 873 '-webkit-transform : ' + 874 loadingBoxTran + 875 ';' + 876 '-moz-transform : ' + 877 loadingBoxTran + 878 ';' + 879 '-ms-transform : ' + 880 loadingBoxTran + 881 ';' + 882 '-o-transform : ' + 883 loadingBoxTran + 884 ';' + 885 'transform : ' + 886 loadingBoxTran + 887 ';' + 888 'padding : 0;' 889 ); 890 }, 891 892 onResize: function () {} 893}; 894 895var jsLoadingBar = null; 896 897function GuideLoadingJS() { 898 this.initConfig(); 899 this.initHtml(); 900 this.initCss(); 901 queueMicrotask(this.onResize.bind(this)); 902 this.setLoading(true); 903} 904 905(function (g) { 906 function _get(obj, path, defaultValue) { 907 const pathArray = Array.isArray(path) ? path : path.split('.'); 908 for (let i = 0; i < pathArray.length; i++) { 909 if (!obj || !obj.hasOwnProperty(pathArray[i])) { 910 return defaultValue; 911 } 912 obj = obj[pathArray[i]]; 913 if (obj === '') { 914 if (defaultValue) return defaultValue; 915 else return ''; 916 } 917 } 918 return obj; 919 } 920 921 function initStyleSheet(id) { 922 var sheet = null; 923 var el = document.createElement('style'); 924 el.id = id; 925 document.head.append(el); 926 for (var s of document.styleSheets) { 927 if (s.ownerNode === el) { 928 sheet = s; 929 } 930 } 931 return function () { 932 return sheet; 933 }; 934 } 935 936 var getStyleSheet = initStyleSheet('loading'); 937 938 function updateStyleSheet(selectorText, kv, mediaQuery, _sheet) { 939 var sheet = _sheet ? _sheet : getStyleSheet(); 940 var rules = sheet.cssRules; 941 var rule = null; 942 for (var r of rules) { 943 if (r.selectorText === selectorText) { 944 rule = r; 945 break; 946 } 947 } 948 if (mediaQuery && mediaQuery !== '') { 949 var index = sheet.insertRule(`${mediaQuery} { ${selectorText} {} }`, rules.length); 950 rule = rules.item(index); 951 updateStyleSheet(selectorText, kv, null, rule); 952 } else { 953 if (!rule && selectorText) { 954 var index = sheet.insertRule(`${selectorText} {}`, rules.length); 955 rule = rules.item(index); 956 } 957 for (var k in kv) { 958 var v = kv[k]; 959 if (v && v === '') { 960 rule.style.removeProperty(k); 961 } else if (typeof v === 'object') { 962 updateStyleSheet( 963 `${selectorText}${k.startsWith(':') ? '' : ' '}${k}`, 964 v, 965 mediaQuery, 966 _sheet 967 ); 968 } else { 969 var p = String(v).split(' !'); 970 rule.style.setProperty(k, p[0], p[1]); 971 } 972 } 973 } 974 } 975 976 var isPhone = function () { 977 var search = window.location.search; 978 979 if ( 980 /mobile|phone/i.test(navigator.userAgent) || 981 (window._agent_ && _agent_.browser.device == _agent_.browser.DEVICE_PHONE) 982 ) { 983 return true; 984 } 985 if ( 986 search.toLowerCase().indexOf('phone=true') >= 0 || 987 search.toLowerCase().indexOf('phonebook=true') >= 0 988 ) { 989 return true; 990 } 991 return false;
992 }; 993 994 function isIOS() { 995 const isIOS = /iP(hone|od|ad)/.test(navigator.userAgent); 996 return isIOS; 997 } 998 function removeStartFrom(url, str) { 999 if (typeof str != 'string') return; 1000 if (!str) return; 1001 1002 var startIndex = url.indexOf(str); 1003 if (startIndex < 0) return url; 1004 1005 return url.substring(0, startIndex) + ''; 1006 } 1007 1008 function getMeta(metaName) { 1009 var origin = window.location.origin; 1010 var pathname = window.location.pathname; 1011 var url = window.location.href; 1012 var shotUrl; 1013 if (url.indexOf('mobile') > -1) { 1014 shotUrl = removeStartFrom(url, '/mobile/'); 1015 shotUrl = removeStartFrom(shotUrl, '/articles/'); 1016 shotUrl += '/files/shot.jpg'; 1017 } else { 1018 if (pathname.indexOf('index.html') > -1) { 1019 pathname = pathname.replace('index.html', ''); 1020 } 1021 shotUrl = origin + pathname + 'files/shot.jpg'; 1022 } 1023 return shotUrl; 1024 } 1025 1026 function debounce(fn, d = 16) { 1027 var timer = null; 1028 return () => { 1029 if (timer) { 1030 clearTimeout(timer); 1031 timer = null; 1032 } 1033 timer = setTimeout(fn.bind(this, ...arguments), d); 1034 }; 1035 } 1036 GuideLoadingJS.prototype = { 1037 BODY: 'boot', 1038 CONTENT: 'boot_content', 1039 IMG: 'boot_cover', 1040 TEXT: 'boot_title', 1041 BUTTON: 'boot_button', 1042 BRAND: 'boot_brand', 1043 DIVIDER: 'boot_divider', 1044 CARD: 'boot_card', 1045 POP: 'popContact', 1046 // isMobile: /mobile|phone/i.test(navigator.userAgent), 1047 isMobile: /mobile|phone|android/i.test(navigator.userAgent), 1048 isIOS: isIOS(), 1049 _visible: true, 1050 config: _get(g, 'htmlConfig.loadingConfig', {}), 1051 get visible() { 1052 return this._visible; 1053 }, 1054 get upsideOnMobile() { 1055 const alwaysDoublePageOnMobile = parseBool(this.config.alwaysDoublePageOnMobile); 1056 1057 if (alwaysDoublePageOnMobile && window.innerHeight > window.innerWidth) return true; 1058 return false; 1059 }, 1060 get loadingBackground() { 1061 let backgroundColor = _get(loadingConfig, 'loadingBackground', '#232D37'); 1062 const type = _get(loadingConfig, 'loadingBackgroundColorType', '1'); 1063 if (type == 0) { 1064 backgroundColor = _get(loadingConfig, 'loadingMainColor', '#232D37'); 1065 } 1066 return backgroundColor; 1067 }, 1068 set visible(val) { 1069 this._visible = val; 1070 updateStyleSheet(`#${this.BODY}`, { 1071 display: val ? 'inline-flex' : 'none' 1072 }); 1073 },
1074 initConfig: LoadingJS.prototype.initConfig.bind(this), 1075 initCss() { 1076 var loadingConfig = this.config; 1077 var css = { 1078 [`#${this.BODY}`]: { 1079 background: this.loadingBackground, 1080 display: 'inline-flex', 1081 position: 'absolute', 1082 top: 0, 1083 bottom: 0, 1084 left: 0, 1085 right: 0, 1086 transform: `translateX(${isPhone() || this.isMobile ? '-100%' : '0%'})`, 1087 'justify-content': 'center', 1088 'align-items': 'center', 1089 'z-index': '200' 1090 }, 1091 [`#${this.CONTENT}`]: { 1092 display: 'flex', 1093 'flex-direction': 'column', 1094 'align-items': 'center', 1095 width: 'calc(100% - 32px)' 1096 }, 1097 [`#${this.IMG}`]: { 1098 width: '224px', 1099 'border-radius': '8px' 1100 // 'min-height': `${224 * 1.38}px` 1101 }, 1102 [`#${this.IMG} img`]: { 1103 width: '100%', 1104 'max-height': '322px', 1105 'border-radius': '10px', 1106 'object-fit': 'contain' 1107 }, 1108 [`#${this.TEXT}`]: { 1109 width: 'calc(100% - 40px)', 1110 'max-width': '387px', 1111 color: _get(loadingConfig, 'loadingCaptionColor', '#FFF'), 1112 overflow: 'hidden', 1113 display: '-webkit-box', 1114 // 'font-size': _get(loadingConfig, 'loadingCaptionFontSize', 16) + 'px', 1115 'font-size': '19px', 1116 'margin-top': '20px', 1117 'text-align': 'center', 1118 'font-weight': 'bold', 1119 'text-overflow': 'ellipsis', 1120 '-webkit-line-clamp': 2, 1121 '-webkit-box-orient': 'vertical' 1122 }, 1123 [`#${this.BUTTON}`]: { 1124 width: 'calc(100% - 40px)', 1125 'max-width': '387px', 1126 height: '46px', 1127 'border-radius': '74px', 1128 'margin-top': '29px', 1129 background: '#0076FE', 1130 display: 'flex', 1131 cursor: 'pointer', 1132 'align-items': 'center', 1133 'justify-content': 'center' 1134 }, 1135 [`#${this.BUTTON} > svg`]: { 1136 width: '21px', //25 1137 height: '21px', //25 1138 animation: 'spin 2s linear infinite', 1139 'margin-right': '7px' 1140 }, 1141 [`#${this.BUTTON} > span`]: { 1142 color: '#fff', 1143 'font-size': '15px', 1144 'font-weight': 'bold' 1145 }, 1146 [`#${this.BRAND}`]: { 1147 width: '100%', 1148 'max-width': '387px', 1149 display: 'flex', 1150 color: '#76838F', 1151 'flex-flow': 'column', 1152 'align-items': 'center', 1153 'font-size': '14px', 1154 'margin-top': '54px' 1155 }, 1156 [`#${this.DIVIDER}`]: { 1157 display: 'flex', 1158 width: '100%', 1159 'box-sizing': 'border-box', 1160 'align-items': 'center', 1161 'justify-content': 'center' 1162 }, 1163 [`#${this.DIVIDER} i`]: { 1164 display: 'inline-block', 1165 width: '100%', 1166 height: '1px', 1167 background: '#76838F' 1168 }, 1169 [`#${this.DIVIDER} span`]: { 1170 margin: '0 14px', 1171 'white-space': 'nowrap' 1172 }, 1173 [`#${this.CARD}`]: { 1174 // width: '422px', 1175 width: '100%', 1176 height: '96px', 1177 padding: '0 18px', 1178 'border-radius': '11px', 1179 'margin-top': '16px', 1180 background: '#303943B3', 1181 display: 'flex', 1182 'box-sizing': 'border-box', 1183 'align-items': 'center' 1184 // 'justify-content': 'center', 1185 }, 1186 [`#${this.CARD} div`]: { 1187 width: 'calc(100% - 60px)' 1188 }, 1189 [`#${this.CARD} img`]: { 1190 width: '60px', 1191 height: '60px', 1192 background: '#fff', 1193 'object-fit': 'contain', 1194 'border-radius': '100%', 1195 'margin-right': '5px' 1196 }, 1197 [`#${this.CARD} h2`]: { 1198 width: '100%', 1199 color: '#fff', 1200 overflow: 'hidden', 1201 margin: 0, 1202 'font-size': '15px', 1203 'font-weight': 'bold', 1204 'text-overflow': 'ellipsis', 1205 'white-space': 'nowrap' 1206 }, 1207 [`#${this.CARD} span`]: { 1208 display: 'block', 1209 width: '100%', 1210 color: '#fff', 1211 overflow: 'hidden', 1212 'font-size': '14px', 1213 'text-overflow': 'ellipsis', 1214 'white-space': 'nowrap' 1215 }, 1216 [`#${this.POP}`]: { 1217 position: 'fixed', 1218 top: 0, 1219 bottom: 0, 1220 left: 0, 1221 right: 0, 1222 display: 'none', 1223 [`.${this.POP}Mask`]: { 1224 background: 'rgba(0,0,0,0.5)', 1225 width: '100%', 1226 height: '100%' 1227 }, 1228 [`.${this.POP}Contain`]: { 1229 transition: 'transform 0.3s', 1230 transform: `translateY(${this.upsideOnMobile ? g.innerWidth : g.innerHe
1230ight}px)` 1231 }, 1232 section: { 1233 width: '100%', 1234 background: '#F6F7FB', 1235 position: 'absolute', 1236 bottom: 0, 1237 'border-radius': '18px 18px 0 0', 1238 'padding-top': '14px' 1239 }, 1240 [`.${this.POP}Title`]: { 1241 display: 'flex', 1242 color: '#000', 1243 padding: '0 24px', 1244 'justify-content': 'center', 1245 'align-items': 'center', 1246 'font-weight': 'bold', 1247 'font-size': '15px', 1248 i: { 1249 width: '100%', 1250 height: '1px', 1251 background: '#EAEAEA' 1252 }, 1253 span: { 1254 display: 'block', 1255 padding: '0 20px', 1256 'white-space': 'nowrap' 1257 }, 1258 svg: { 1259 width: '14px', 1260 height: '14px', 1261 transform: 'rotate(90deg)' 1262 } 1263 }, 1264 [`.${this.POP}Content`]: { 1265 display: 'grid', 1266 margin: '14px 0 0', 1267 overflow: 'hidden scroll', 1268 'grid-template-columns': 'repeat(6, 64px)', 1269 'justify-content': 'space-around', 1270 'row-gap': '12px', 1271 [`.${this.POP}Item`]: { 1272 width: '58px', 1273 display: 'flex', 1274 'flex-flow': 'column', 1275 'justify-content': 'center', 1276 '*': { 1277 'pointer-events': 'none' 1278 }, 1279 div: { 1280 display: 'flex', 1281 width: '58px', 1282 height: '58px', 1283 background: '#FFF', 1284 'justify-content': 'center', 1285 'align-items': 'center', 1286 'border-radius': '16px' 1287 }, 1288 img: { 1289 width: '32px', 1290 'object-fit': 'contain' 1291 }, 1292 span: { 1293 color: '#818792', 1294 'font-size': '12px', 1295 'margin-top': '5px', 1296 'text-align': 'center' 1297 } 1298 } 1299 }, 1300 [`.${this.POP}Cancel`]: { 1301 margin: '14px', 1302 display: 'flex', 1303 background: '#FFF', 1304 height: '40px', 1305 color: '#000', 1306 'border-radius': '10px', 1307 'font-size': '12px', 1308 'align-items': 'center', 1309 'justify-content': 'center' 1310 }, 1311 [`.${this.POP}Qrcode`]: { 1312 padding: 0, 1313 display: 'none', 1314 [`.${this.POP}Title`]: { 1315 'justify-content': 'unset', 1316 padding: 0, 1317 svg: { 1318 padding: '18px' 1319 } 1320 }, 1321 [`.${this.POP}QrcodeImg`]: { 1322 width: '166px', 1323 height: '166px', 1324 margin: '20px auto 0', 1325 padding: '12px', 1326 background: '#FFF', 1327 'box-sizing': 'border-box', 1328 'border-radius': '10px', 1329 img: { 1330 width: '100%', 1331 height: '100%' 1332 } 1333 }, 1334 p: { 1335 width: '160px', 1336 color: '#333', 1337 margin: '0 auto', 1338 background: '#FFF', 1339 padding: '10px 0', 1340 'font-size': '14px', 1341 'font-weight': 'bold', 1342 'border-radius': '30px', 1343 'text-align': 'center' 1344 } 1345 } 1346 } 1347 }; 1348 var mobile_css = { 1349 [`#${this.BODY}`]: { 1350 [`.${this.CONTENT}Landscape`]: { 1351 [`#${this.IMG}box`]: { 1352 height: '96px', 1353 'flex-flow': 'row' 1354 }, 1355 [`#${this.IMG}`]: { 1356 height: '96px', 1357 display: 'flex', 1358 width: 'unset', 1359 'justify-content': 'center', 1360 'min-width': '96px', 1361 'min-height': 'unset' 1362 }, 1363 [`#${this.IMG} img`]: { 1364 width: 'unset', 1365 height: '100%' 1366 }, 1367 [`#${this.TEXT}`]: { 1368 'margin-top': '16px'
1369 }, 1370 [`#${this.BUTTON}`]: { 1371 'margin-top': '8px' 1372 } 1373 }, 1374 [`#${this.BRAND}Landscape`]: { 1375 display: 'flex', 1376 overflow: 'hidden', 1377 'margin-left': '12px', 1378 'align-items': 'center', 1379 [`#${this.BRAND}`]: { 1380 width: '255px', 1381 'margin-top': 0 1382 }, 1383 [`#${this.DIVIDER}`]: { 1384 padding: '0 26px' 1385 }, 1386 [`#${this.CARD}`]: { 1387 width: '100%', 1388 'margin-top': '8px', 1389 h2: { 1390 width: '172px' 1391 }, 1392 span: { 1393 width: '172px' 1394 } 1395 } 1396 } 1397 }, 1398 [`#${this.IMG}box`]: { 1399 display: 'flex', 1400 'flex-flow': 'column', 1401 'justify-content': 'space-between', 1402 'align-items': 'center' 1403 }, 1404 [`#${this.IMG}`]: { 1405 width: '200px', 1406 // 'min-height': `${200 * 1.38}px`, 1407 'border-radius': '8px', 1408 img: { 1409 'max-height': '288px' 1410 } 1411 }, 1412 [`#${this.IMG}Landscape`]: { 1413 width: '120px' 1414 // 'min-height': `${120 * 1.38}px` 1415 }, 1416 [`#${this.TEXT}`]: { 1417 'margin-top': '15px', 1418 'font-size': '16px' 1419 }, 1420 [`#${this.BUTTON}`]: { 1421 width: '300px', 1422 height: '42px', 1423 'border-radius': '66px', 1424 'margin-top': '28px' 1425 }, 1426 [`#${this.BUTTON} > svg`]: { 1427 width: '20px', 1428 height: '20px', 1429 'margin-right': '4px' 1430 }, 1431 [`#${this.BUTTON} > span`]: { 1432 'font-size': '13px' 1433 }, 1434 [`#${this.BRAND}`]: { 1435 'font-size': '12px', 1436 'margin-top': '47px' 1437 }, 1438 [`#${this.DIVIDER} i`]: { 1439 width: '136px' 1440 }, 1441 [`#${this.DIVIDER} span`]: { 1442 margin: '0 12px' 1443 }, 1444 [`#${this.CARD}`]: { 1445 width: '342px', 1446 height: '80px', 1447 padding: '0 16px', 1448 'border-radius': '10px', 1449 'margin-top': '13px' 1450 }, 1451 [`#${this.CARD} img`]: { 1452 width: '48px', 1453 height: '48px' 1454 }, 1455 [`#${this.CARD} h2`]: { 1456 width: '253px', 1457 'font-size': '14px', 1458 'margin-bottom': '4px' 1459 }, 1460 [`#${this.CARD} span`]: { 1461 width: '253px', 1462 'font-size': '12px' 1463 }, 1464 [`#${this.POP}`]: { 1465 [`.${this.POP}Content`]: { 1466 margin: '24px 24px 0', 1467 'justify-content': 'space-between', 1468 'grid-template-columns': 'repeat(4, 64px)' 1469 } 1470 } 1471 }; 1472 var sheet = document.styleSheets.item(document.styleSheets.length - 1); 1473 sheet.insertRule( 1474 `@keyframes spin {from {transform: rotate(0deg);}to {transform: rotate(360deg);}}` 1475 ); 1476 sheet.insertRule( 1477 `@keyframes glint {0% {background: #0076FE}50% {background: #3590FB}100% {background: #0076FE}}` 1478 ); 1479 for (var key in css) { 1480 var style = _get(css, key, null); 1481 if (style) { 1482 updateStyleSheet(key, style, '', sheet); 1483 } 1484 } 1485 for (var key in mobile_css) { 1486 var style = _get(mobile_css, key, null); 1487 if (style) { 1488 updateStyleSheet( 1489 key, 1490 style, 1491 // '@media screen and (max-device-width: 480px) and (orientation: portrait), (max-device-height: 480px) and (orientation: landscape)', 1492 '@media screen and (max-device-width: 624px), (max-device-height: 624px)', 1493 sheet 1494 ); 1495 } 1496 } 1497 1498 if (isPhone() || this.isMobile) { 1499 // document.body.style.transform = 'translateX(100%)'; 1500 document.body.id = 'phoneNeatTemplate'; 1501 updateStyleSheet('#phoneNeatTemplate', { 1502 transform: this.upsideOnMobile 1503 ? `translate(${g.innerWidth}px, ${g.innerHeight}px) rotate(90deg) !important` 1504 : `translate(${g.innerWidth}px, 0) !important`, 1505 'transform-origin': '0 0', 1506 overflow: 'unset !important' 1507 }); 1508 updateStyleSheet(`#${this.BODY}`, { 1509 height: `${this.upsideOnMobile ? g.innerWidth : g.innerHe
1509ight}px`, 1510 width: `${this.upsideOnMobile ? g.innerHeight : g.innerWidth}px` 1511 }); 1512 } 1513 1514 if ( 1515 location.search.toLowerCase().indexOf('phone=true') >= 0 || 1516 location.search.toLowerCase().indexOf('phonebook=true') >= 0 1517 ) { 1518 updateStyleSheet(`.${this.POP}Content`, { 1519 'grid-template-columns': 'repeat(4, 64px) !important' 1520 }); 1521 } 1522 }, 1523 initHtml() { 1524 var $body = document.createElement('div'); 1525 var shot_img = getMeta(); 1526 if (!shot_img || shot_img === '' || /localhost|192\.168/.test(shot_img)) 1527 shot_img = _get(g, 'htmlConfig.fliphtml5_pages.0.t', ''); 1528 $body.id = this.BODY; 1529 $body.insertAdjacentHTML( 1530 'beforeend', 1531 `<div id="${this.CONTENT}"> 1532 <div id="${this.IMG}box"> 1533 <div id="${this.IMG}" > 1534 <img src="${shot_img}?${Date.now()}" /> 1535 </div> 1536 <div id="${this.BRAND}Landscape"></div> 1537 </div> 1538 <div id="${this.TEXT}">${_get(this.config, 'loadingCaption', document.title)}</div> 1539 <div id="${this.BUTTON}"><span>${_get(g, 'htmlConfig.language.0.btnTitleText', '')}</span></div> 1540 </div>` 1541 ); 1542 document.body.insertAdjacentElement('beforeend', $body); 1543 1544 // if (brandVisible) 1545 // document.querySelector(`#${this.CONTENT}`).appendChild(this.createBrand()); 1546 this.initBrand(); 1547 1548 try { 1549 if (document.getElementById('bacgradient_image')) 1550 document.getElementById('bacgradient_image').style.visibility = 'visible'; 1551 } catch (error) {} 1552 }, 1553 initBrand() { 1554 const timer = setInterval(async () => { 1555 if (!$) return; 1556 clearInterval(timer); 1557 1558 var brandVisible = _get(g, 'htmlConfig.loadingConfig.loadingBrandInfoVisible', undefined); 1559 if (!brandVisible) return; 1560 let loadingBrandInfoUrl = _get(g, 'htmlConfig.loadingConfig.loadingBrandInfoUrl', ''); 1561 if (loadingBrandInfoUrl === '') return; 1562 loadingBrandInfoUrl = changeBookResourceBaseURL(loadingBrandInfoUrl); 1563 // const host = /192\.168|127\.0|localhost/.test(location.host) 1564 // ? 'https://test2.yunzhan365.com' 1565 // : ''; 1566 // const baseUrl = `${loadingBrandInfoUrl.replace(/\/config.json|\/default.json/, '')}`; 1567 const baseUrl = loadingBrandInfoUrl.split(/\/config.json|\/default.json/)[0]; 1568 const data = await new Promise(resolve => { 1569 $.ajax({ 1570 url: `${loadingBrandInfoUrl}`, 1571 type: 'get', 1572 dataType: 'json', 1573 success: data => resolve(data), 1574 error: () => resolve(null) 1575 }); 1576 }); 1577 1578 if (!data) return; 1579 data.baseUrl = baseUrl; 1580 g.loadingConfig['loadingBrandInfo'] = data; 1581 var $brand = document.createElement('div'); 1582 var logo = _get( 1583 data, 1584 'logo', 1585 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA9CAYAAADxoArXAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAcpSURBVHgB3VtNbBtFFB6H/vCjpg6tEOoPbMShvcU9cOCEywGOSSSOrWJfU4kkp1YqUpwDUjnF6aHXOOq1KMkRJBrnxKGHpBIHOGUDJEJAiZtQ/gqE972dt35eb2yvfxKvv2iya+/seL59b968eW82YQ4J+/v7STqgOIFLLpVSIpEomUNAwnQAllyayrtUUrYk69wGwuu2rFIpduIhtI2wJTlCZcx4ZCtQ2vuPi7v1vOJ75/xx45w7dlCzRSoFIr5g2oSWCVuik1QmjJJi8dEfXNa/+YvK32Zz+5+a7SRP9ZmhyydM+u2X/KLgGo/8DJF3TQtomnAYURBcevjMLCztsTRbgXPuOJF+0YyNnAqSn6GSb1bdmyJMZNN0mDfWAIFo7t6vZvXRn6YTSJHkJ64lTYbIW7hUcs2oeiTCVqo540m140SDgNRX5s/RuPfHfN54at6wtBsmTGQdOqzgd6GuIDp3/6k5CkyStKdvDPC4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+nBBOf1wlI0nx9ZCmka1NcDX7YELEDy96tzWzoCKkm4Wsje/jnUuUD7UQMUakiVIGEmjJTkwnLDbZh0dqvqu6d2SGCOhMMBr4t/hcYsMox6yEAToMpDl4/7VhsPBSrP59tYm2/SnP1yxfVmMpXK2BUTNte7EqeAe1TAR7c2I52wAS6sC5NYHnZT7qgdgJZtfP4Gn1PEI9Fnk8ms1mPlDHvPANsmLJbwr09/GFE+bq9gbNgXInOUIJ6v1jAUUZZe3QytzoQBaDNL2Kp1AefqicQealFSkH0g/rpErDWMFpJocTdeAekOyh4Q3+eyWbYiL75vDJi4IyBdVz4Ek2mOsalSLN7jGtg7SLpAxRLJXsjhHAG2dq2gDhvK984FtzOFMZqj4sIziaNqI5hgXUmXyM4Er1cRttZsFOfYABYnq40VmBq7V8PqhOqs3eA1hfP8rbP+2rWbgT5iGFrkDtqZd+AgtVnzPMYxxkQ3kw6smXNhqiyou/WQLHeBDmOYl2G5o0YbOg0ECRbvvi4GFlNQtlb9umaYGsjQYcHbN3GBQy7dAoxZSLZRskCU3bTYIZDjlpcpOH7nyZF5YyAIa6zyWjXVWCPqfulJ422NSCIikeOoxeHmlKHC85+8JlMPZhSQnWv0/sg74vW+aXyGtBGu6fQKC0Qx5ag0TJFKNuo7EK288yDvOzj86+SGYsO43c7bNoQQjSxVjZbearHShopn5DuoOqdLKEDXjC8uaVME7zIj/dq9BV
1585FMlXOtvM/UlveWLPG08cg7+hpIS0oUcW+t+iCDIDmSAMg6Sh45ANd4a/WWiAra/mYakceOAmwgSRubbG8CRSlEctW0ER15FU9gQ0dDxiPumOp3D0uquMYLJj5OdPA9xP8BgfFl858h6NEAAAAASUVORK5CYII=' 1586 ); 1587 if (!logo.includes('data:image')) logo = `${baseUrl}/${logo.split('./').pop()}`; 1588 1589 var business = _get(data, 'business', []); 1590 1591 $brand.id = this.BRAND; 1592 $brand.insertAdjacentHTML( 1593 'beforeend', 1594 `<div id="${this.DIVIDER}"> 1595 <i></i> 1596 <span>${_get(g, 'htmlConfig.language.0.relatedInfoText', '')}</span> 1597 <i></i> 1598 </div> 1599 1600 <div id="${this.CARD}"> 1601 <img src="${logo}" /> 1602 <div> 1603 <h2>${_get( 1604 data, 1605 'title', 1606 _get(htmlConfig, 'language.0.brandTitleUndefined', 'No brand name is set yet') 1607 )}</h2> 1608 ${business 1609 .map(function (o) { 1610 return `<span>${o.name}: ${o.value}</span>`; 1611 }) 1612 .join('')} 1613 </div> 1614 </div>` 1615 ); 1616 1617 $brand.addEventListener('click', e => { 1618 e.stopPropagation(); 1619 e.stopImmediatePropagation(); 1620 e.preventDefault(); 1621 this.showPop(); 1622 }); 1623 document.querySelector(`#${this.CONTENT}`).appendChild($brand); 1624 1625 var contactWay = _get(data, 'contactWay', []); 1626 if (contactWay.length > 0) { 1627 let timer = setInterval(() => { 1628 if (window.uiBaseURL && uiBaseURL !== '') { 1629 clearInterval(timer); 1630 this.createContactPop(contactWay); 1631 } 1632 }, 200); 1633 } 1634 const $thumb = document.querySelector(`#${this.IMG} img`); 1635 $thumb.addEventListener('error', () => { 1636 $thumb.style.setProperty('visibility', 'hidden'); 1637 updateStyleSheet(`#${this.IMG}`, { 1638 height: '200px', 1639 background: '#F9F9F9' 1640 }); 1641 }); 1642 1643 this.$brand = $brand; 1644 this.onResize(); 1645 }, 600); 1646 }, 1647 createContactPop(list) { 1648 var $pop = document.createElement('div'); 1649 $pop.id = this.POP; 1650 var $items = []; 1651 for (var c of list) $items.push(this.createContactItem(c)); 1652 $pop.insertAdjacentHTML( 1653 'beforeend', 1654 `<div class="${this.POP}Mask"></div> 1655 <div class="${this.POP}Contain"> 1656 <section class="${this.POP}Way"> 1657 <div class="${this.POP}Title"> 1658 <i></i> 1659 <span>${_get(htmlConfig, 'language.0.brandContactFrTitle', 'Contact author')}</span> 1660 <i></i> 1661 </div> 1662 <div class="${this.POP}Content">${$items.join('')}</div> 1663 <span class="${this.POP}Cancel">${_get( 1664 htmlConfig, 1665 'language.0.lblCancel', 1666 'Cancel' 1667 )}</span> 1668 </section> 1669 <section class="${this.POP}Qrcode" > 1670 <div class="${this.POP}Title"> 1671 <svg class="svg" version="1.1" id="å¾å±_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve"><path class="st0" d="M19.5,4.8C19.5,4.9,19.5,4.9,19.5,4.8c0.6,0.7,0.6,1.7-0.1,2.3l-8.3,8.1c-0.6,0.6-1.7,0.6-2.3,0L0.5,7.1l0,0c-0.6-0.6-0.6-1.6,0-2.2c0.7-0.6,1.7-0.6,2.3,0l7.2,6.9l7.1-6.9C17.8,4.2,18.8,4.2,19.5,4.8L19.5,4.8z"/></svg> 1672 </div> 1673 <p>${_get(htmlConfig, 'language.0.frmShareQRcode', 'Qrcode')}</p> 1674 <div class="${this.POP}QrcodeImg"> 1675 <img src="" /> 1676 </div> 1677 <span class="${this.POP}Cancel">${_get( 1678 htmlConfig, 1679 'language.0.lblCancel', 1680 'Cancel' 1681 )}</span> 1682 </section> 1683 </div>` 1684 ); 1685 1686 document.querySelector(`#${this.BODY}`).appendChild($pop); 1687 this.initPopEvent(); 1688 }, 1689 createContactItem(item) { 1690 var $item = `<div class="${this.POP}Item" key="${item.type}"> 1691 <div> 1692 <img src="${uiBaseURL}contactWay_${item.type}.png" /> 1693 </div> 1694 <span>${item.title}</span> 1695 </div>`; 1696 return $item; 1697 }, 1698 initEvent() { 1699 var $button = document.querySelector(`#${this.BUTTON}`); 1700 $button.addEventListener('click', e => { 1701 e.stopPropagation(); 1702 e.stopImmediatePropagation(); 1703 e.preventDefault(); 1704 if (_get($button, 'disableTap', true)) return; 1705 this.hide(); 1706 }); 1707 1708 if (isPhone() || isPad()) this.bindDragEvent(); 1709 1710 const $cover = document.getElementById(this.IMG); 1711 $cover.addEventListener('click', e => { 1712 e.stopPropagation(); 1713 e.stopImmediatePropagation(); 1714 e.preventDefault(); 1715 1716 this.hide(); 1717 }); 1718 1719 const $text = document.getElementById(this.TEXT); 1720 $text.addEventListener('click', e => { 1721 e.stopPropagation(); 1722 e.stopImmediatePropagation(); 1723 e.preventDefault(); 1724 this.hide(); 1725 }); 1726 }, 1727 initResizeEvent() { 1728 window.addEventListener('resize', debounce(this.onResize.bind(this), 300)); 1729 }, 1730 onResize() { 1731 if (!this.isMobile && !isPhone()) return; 1732 if ((g.isPad && isPad()) || (g.isPC && isPC())) return; 1733 let type = this.isIOS ? '' : screen.orientation.type.split('-')[0]; // 横å±ï¼landscape ç«å±ï¼portrait 1734 if (this.isIOS) { 1735 switch (window.orientation) { 1736 case 0: 1737 case 180: 1738 type = 'portrait'; 1739 break; 1740 case 90: 1741 case -90: 1742 type = 'landscape'; 1743 break; 1744 } 1745 } 1746 // é¢è§æ¨¡å¼ä¸ä¼è¯å«ä¸ºæ¨ªå±ï¼å¼ºå¶åæ»ä¸ºç«å± 1747 if (this.isMobile === false && isPhone()) { 1748 type = 'portrait'; 1749 } 1750 if (type === 'portrait' && this.upsideOnMobile) { 1751 type = 'landscape'; 1752 } 1753 const $content = document.getElementById(`${this.CONTENT}`); 1754 switch (type) { 1755 case 'portrait': 1756 if (this.$brand) { 1757 $content.appendChild(this.$brand); 1758 } 1759 $content.classList.remove(`${this.CONTENT}Landscape`); 1760 if (g.innerWidth < 375) { 1761 const scale = g.innerWidth / 375; 1762 // $content.style.transform = `scale(${scale})`; 1763 } 1764 break; 1765 case 'landscape': 1766 if (this.$brand) { 1767 const brandLandsape = document.getElementById(`${this.BRAND}Landscape`); 1768 brandLandsape.appendChild(this.$brand); 1769 } 1770 $content.classList.add(`${this.CONTENT}Landscape`);
1771 if (g.innerHeight < 375) { 1772 const scale = g.innerHeight / 375; 1773 // $content.style.transform = `scale(${scale})`; 1774 } 1775 break; 1776 } 1777 1778 if (isPhone() || this.isMobile) { 1779 if (this.visible) { 1780 updateStyleSheet('#phoneNeatTemplate', { 1781 transform: this.upsideOnMobile 1782 ? `translate(${g.innerWidth}px, ${g.innerHeight}px) rotate(90deg) !important` 1783 : `translate(${g.innerWidth}px, 0) !important` 1784 }); 1785 } 1786 updateStyleSheet(`#${this.BODY}`, { 1787 height: `${this.upsideOnMobile ? g.innerWidth : g.innerHeight}px`, 1788 width: `${this.upsideOnMobile ? g.innerHeight : g.innerWidth}px` 1789 }); 1790 } 1791 }, 1792 initPopEvent() { 1793 // èå±ç¹å» 1794 document.querySelector(`.${this.POP}Mask`).addEventListener('click', e => { 1795 e.stopPropagation(); 1796 e.stopImmediatePropagation(); 1797 e.preventDefault(); 1798 this.hidePop(); 1799 }); 1800 1801 // åæ¶æé®ç¹å» 1802 document.querySelectorAll(`.${this.POP}Cancel`).forEach(el => 1803 el.addEventListener('click', e => { 1804 e.stopPropagation(); 1805 e.stopImmediatePropagation(); 1806 e.preventDefault(); 1807 this.hidePop(); 1808 }) 1809 ); 1810 1811 // ç¹å»èç³»æ¹å¼ 1812 document.querySelector(`.${this.POP}Content`).addEventListener('click', e => { 1813 e.stopPropagation(); 1814 e.stopImmediatePropagation(); 1815 e.preventDefault(); 1816 1817 const el = e.target; 1818 const key = el.getAttribute('key'); 1819 if (!key) return; 1820 const contactWay = _get(g, 'loadingConfig.loadingBrandInfo.contactWay', []); 1821 const way = contactWay.find(o => o.type === key); 1822 switch (key) { 1823 // äºç»´ç 1824 case 'qrcode': 1825 case 'wechatOfficialAccount': 1826 this.showPopQrcode(way); 1827 break; 1828 // å¤å¶ 1829 case 'wechat': 1830 case 'phone': 1831 case 'douyin': 1832 case 'weibo': 1833 case 'email': 1834 case 'address': 1835 default: 1836 this.copyText(way); 1837 break; 1838 } 1839 }); 1840 1841 // ç¹å»è¿åæé® 1842 document.querySelector(`.${this.POP}Title svg`).addEventListener('click', e => { 1843 e.stopPropagation(); 1844 e.stopImmediatePropagation(); 1845 e.preventDefault(); 1846 this.hidePopQrcode(); 1847 }); 1848 }, 1849 bindDragEvent() { 1850 var that = this; 1851 var $body = document.querySelector(`#${that.BODY}`); 1852 // var startX = 0; 1853 var isDragging = false; 1854 // var lock = false; 1855 var $parent = $(document.body); 1856 1857 const hammer = new Hammer.Manager($body); 1858 hammer.add(new Hammer.Pan({ threshold: 20 })); 1859 hammer.on('panstart panmove panend pancancel', e => { 1860 if (!e || !e.pointers || e.pointers.length != 1) return; 1861 if (e.type === 'panstart') { 1862 // è®°å½èµ·å§åæ 1863 // startX = this.upsideOnMobile ? e.pointers[0].clientY : e.pointers[0].clientX; 1864 1865 updateStyleSheet('#phoneNeatTemplate', { 1866 transition: 'none', 1867 transform: this.upsideOnMobile 1868 ? `translate(${g.innerWidth}px, ${g.innerHeight}px) rotate(90deg) !important` 1869 : `translate(${g.innerWidth}px, 0) !important` 1870 }); 1871 } 1872 1873 // è®¡ç®æ°´å¹³ååç´æ¹åä¸çç§»å¨è·ç¦» 1874 var deltaX = this.upsideOnMobile ? e.deltaY : e.deltaX; 1875 if (Math.abs(deltaX) > 10) { 1876 isDragging = true; 1877 } 1878 if (!isDragging) return; 1879 // if (lock) return; 1880 if (deltaX > 0) { 1881 deltaX = 0; 1882 } else if (deltaX < (this.upsideOnMobile ? g.innerHeight : g.innerWidth) * -1) { 1883 deltaX = (this.upsideOnMobile ? g.innerHeight : g.innerWidth) * -1 + 2; 1884 } 1885 updateStyleSheet('#phoneNeatTemplate', { 1886 transform: this.upsideOnMobile 1887 ? `translate(${g.innerWidth}px, ${g.innerHeight + deltaX}px) rotate(90deg) !important` 1888 : `translate(${g.innerWidth + deltaX}px, 0) !important` 1889 }); 1890 1891 // lock = true; 1892 // setTimeout(function () { 1893 // lock = false;
1894 // }, 20); 1895 1896 if (e.type === 'panend' || e.type === 'pancancel') { 1897 if (!isDragging) return; 1898 1899 // å¦ææ°´å¹³æ¹åä¸çç§»å¨è·ç¦»å¤§äº20%åç´ ï¼åéè 1900 var flag = Math.abs(deltaX) > (this.upsideOnMobile ? g.innerHeight : g.innerWidth) * 0.2; 1901 if (flag && deltaX < 0) { 1902 that.hide(); 1903 } else that.show(); 1904 isDragging = false; 1905 } 1906 }); 1907 }, 1908 setLoading(status) { 1909 var $button = document.querySelector(`#${this.BUTTON}`); 1910 if (status) { 1911 $button.innerHTML = `<svg t="1683698016306" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1506" width="20" height="20"><path d="M128 512c0-211.2 172.8-384 384-384s384 172.8 384 384c0 38.4-25.6 64-64 64s-64-25.6-64-64c0-140.8-115.2-256-256-256S256 371.2 256 512s115.2 256 256 256c38.4 0 64 25.6 64 64s-25.6 64-64 64C300.8 896 128 723.2 128 512z" p-id="1507" fill="#ffffff"></path></svg><span>${_get( 1912 g, 1913 'htmlConfig.language.0.btnLoadingText', 1914 '' 1915 )}</span>`; 1916 $button.disableTap = true; 1917 updateStyleSheet(`#${this.BUTTON}`, { 1918 animation: 'none' 1919 }); 1920 } else { 1921 $button.innerHTML = `<span>${_get(g, 'htmlConfig.language.0.btnTitleText', '')}</span>`; 1922 $button.disableTap = false; 1923 updateStyleSheet(`#${this.BUTTON}`, { 1924 animation: 'glint 1.2s linear infinite' 1925 }); 1926 } 1927 }, 1928 copyText(way) { 1929 var $input = document.createElement('input'); 1930 var text = way.copyText; 1931 $input.setAttribute('type', 'text'); 1932 $input.setAttribute('value', text); 1933 $input.setAttribute('readonly', 'readonly'); 1934 $input.style.cssText = `opacity: 0;position: absolute;`; 1935 document.body.appendChild($input); 1936 $input.select(); 1937 $input.setSelectionRange(0, 99999);
1938 try { 1939 document.execCommand('copy'); 1940 this.tipbox(way.tipText); 1941 } catch { 1942 this.tipbox('å¤å¶å¤±è´¥'); 1943 } finally { 1944 // $input.remove(); 1945 } 1946 }, 1947 showPop() { 1948 updateStyleSheet(`#${this.POP}`, { 1949 display: 'block' 1950 }); 1951 setTimeout(() => { 1952 updateStyleSheet(`.${this.POP}Contain`, { 1953 transform: 'translateY(0) !important' 1954 }); 1955 }, 16); 1956 }, 1957 hidePop() { 1958 updateStyleSheet(`.${this.POP}Contain`, { 1959 transform: `unset` 1960 }); 1961 setTimeout(() => { 1962 updateStyleSheet(`#${this.POP}`, { 1963 display: 'none' 1964 }); 1965 this.hidePopQrcode(); 1966 }, 300); 1967 }, 1968 showPopQrcode(way) { 1969 var brandInfo = _get(g, 'loadingConfig.loadingBrandInfo', {}); 1970 var qrcode = way.qrcode; 1971 updateStyleSheet(`.${this.POP}Qrcode`, { 1972 display: 'block !important' 1973 }); 1974 updateStyleSheet(`.${this.POP}Way`, { display: 'none' }); 1975 document 1976 .querySelector(`.${this.POP}QrcodeImg img`) 1977 .setAttribute('src', `${brandInfo.baseUrl}/${qrcode.split('./').pop()}`); 1978 }, 1979 hidePopQrcode() { 1980 updateStyleSheet(`.${this.POP}Qrcode`, { display: 'none' }); 1981 updateStyleSheet(`.${this.POP}Way`, { display: 'unset' }); 1982 }, 1983 tipbox(message, d = 2000) { 1984 var $parent = document.getElementById(this.BODY); 1985 var $tips = document.createElement('div'); 1986 var className = 'loading-contact-tips'; 1987 var tipsCount = document.querySelectorAll(`.${className}`).length; 1988 $tips.className = className; 1989 $tips.innerText = message; 1990 $tips.style.cssText = `position: fixed; 1991 opacity: 1; 1992 padding: 10px 16px; 1993 background-color: #333; 1994 width: 190px; 1995 top: ${80 + tipsCount * 50}px; 1996 right: 0; 1997 left: 0; 1998 margin: auto; 1999 z-index: 99999; 2000 font-size: 15px; 2001 color: #f0f0f0; 2002 vertical-align: middle; 2003 text-align: center; 2004 box-shadow: 0 0 15px rgba(40,40,40,0.6); 2005 transition: opacity 0.3s; 2006 border-radius: 3px;`; 2007 $parent.appendChild($tips); 2008 setTimeout(() => { 2009 $tips.style.opacity = '1'; 2010 setTimeout(() => { 2011 $tips.style.opacity = '0'; 2012 setTimeout(() => $tips.remove(), 300); 2013 }, d); 2014 }, 16); 2015 }, 2016 show() { 2017 this.visible = true; 2018 updateStyleSheet('#phoneNeatTemplate', { 2019 overflow: 'unset !important' 2020 }); 2021 setTimeout(() => { 2022 if (isPhone() || this.isMobile) { 2023 updateStyleSheet('#phoneNeatTemplate', { 2024 transition: 'transform 0.3s', 2025 transform: this.upsideOnMobile 2026 ? `translate(${g.innerWidth}px, ${g.innerHeight}px) rotate(90deg) !important` 2027 : `translate(${g.innerWidth}px, 0) !important` 2028 }); 2029 } else { 2030 updateStyleSheet(`#${this.BODY}`, { 2031 opacity: '1', 2032 transition: 'opacity 0.3s', 2033 'pointer-events': 'auto' 2034 }); 2035 } 2036 }, 16); 2037 }, 2038 hide() { 2039 if (isPhone() || this.isMobile) { 2040 updateStyleSheet('#phoneNeatTemplate', { 2041 transition: 'transform 0.3s', 2042 transform: 'unset' 2043 }); 2044 } else { 2045 updateStyleSheet(`#${this.BODY}`, { 2046 opacity: '0', 2047 transition: 'opacity 0.3s', 2048 'pointer-events': 'none' 2049 }); 2050 } 2051 2052 setTimeout( 2053 function () { 2054 this.visible = false; 2055 updateStyleSheet('#phoneNeatTemplate', { 2056 overflow: 'unset' 2057 }); 2058 }.bind(this), 2059 500 2060 ); 2061 }, 2062 changeLanguage(l) { 2063 const language = _get(g, 'htmlConfig.language', []).find(o => o.language === l); 2064 const $divider = document.querySelector(`#${this.DIVIDER} span`); 2065 const $button = document.querySelector(`#${this.BUTTON} span`); 2066 if ($divider) $divider.innerText = _get(language, 'relatedInfoText', ''); 2067 if ($button) $button.innerText = _get(language, 'btnTitleText', ''); 2068 }, 2069 destroy() { 2070 this.setLoading(false); 2071 this.initEvent(); 2072 this.initResizeEvent(); 2073 } 2074 }; 2075 2076 function mitt(all) { 2077 all = all || new Map(); 2078 return { 2079 all, 2080 on(type, handler) { 2081 const handlers = all.get(type); 2082 const added = handlers && handlers.push(handler); 2083 if (!added) { 2084 all.set(type, [handler]); 2085 } 2086 }, 2087 off(type, handler) { 2088 const handlers = all.get(type); 2089 if (handlers) { 2090 handlers.splice(handlers.indexOf(handler) >>> 0, 1); 2091 } 2092 }, 2093 emit(type, evt) { 2094 (all.get(type) || []).slice().map(handler => { 2095 handler(evt); 2096 }); 2097 (all.get('*') || []).slice().map(handler => { 2098 handler(type, evt); 2099 }); 2100 } 2101 }; 2102 } 2103 // å建ä¸ä¸ªå ¨å±çäºä»¶æ»çº¿å®ä¾ 2104 window.eventEmitter = mitt(); 2105 // yunzhan 2106 function isBase64(str) { 2107 // éªè¯base64ç¼ç æ ¼å¼çæ£åè¡¨è¾¾å¼ 2108 const base64Regex = /^(?:[A-Za-z0-9+/]{4})*?(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; 2109 2110 return base64Regex.test(str); 2111 } 2112 2113 function ajax() { 2114 function createxmlHttpRequest() { 2115 if (window.ActiveXObject) { 2116 return new ActiveXObject('Microsoft.XMLHTTP'); 2117 } else if (window.XMLHttpRequest) { 2118 return new XMLHttpRequest(); 2119 } 2120 } 2121 let ajaxData = { 2122 type: (arguments[0].type || 'GET').toUpperCase(), 2123 url: arguments[0].url || '', 2124 async: arguments[0].async || 'true', 2125 data: arguments[0].data || null, 2126 dataType: arguments[0].dataType || 'json', 2127 contentType: arguments[0].contentType || 'application/x-www-form-urlencoded; charset=utf-8', 2128 beforeSend: arguments[0].beforeSend || function () {}, 2129 success: arguments[0].success || function () {}, 2130 error: arguments[0].error || function () {} 2131 }; 2132 ajaxData.beforeSend(); 2133 let xhr = createxmlHttpRequest(); 2134 xhr.open(ajaxData.type, ajaxData.url, ajaxData.async); 2135 xhr.setRequestHeader('Content-Type', ajaxData.contentType); 2136 xhr.send(); 2137 xhr.onreadystatechange = function () { 2138 if (xhr.readyState == 4) { 2139 if (xhr.status == 200) { 2140 ajaxData.success(xhr.response); 2141 } else { 2142 ajaxData.error(); 2143 } 2144 } 2145 }; 2146 } 2147 2148 function getUserInfo() { 2149 const domainRegex = /yunzhan365\.com|sharedbook\.cn|huaceshu\.cn/; 2150 const booksPathRegex = /^https?:\/\/[^/]+\/books(?:\/|$)/; 2151 const fh5DomailRegex = /fliphtml5.com|flipbuilder/; 2152 try { 2153 const url = window.location.href; 2154 const domain = window.location.hostname; 2155 if (url.indexOf('templates') > -1) return; 2156 // æ£æ¥æ¡ä»¶ 2157 if ( 2158 domainRegex.test(domain) || 2159 fh5DomailRegex.test(domain) || 2160 (!domainRegex.test(domain) && booksPathRegex.test(url)) 2161 ) { 2162 ajax({
2163 url: fh5DomailRegex.test(domain) ? '../getui.json' : '../../getui.json', 2164 success: msg => { 2165 if (!msg) return; 2166 if (!isBase64(msg)) return; 2167 const data = JSON.parse(atob(msg)); 2168 window.userInfo = data; 2169 window.eventEmitter.emit('loadUserInfo', data); 2170 }, 2171 error: err => { 2172 console.log('getui', err); 2173 } 2174 }); 2175 } 2176 } catch (e) { 2177 console.error(`URL è§£æé误: ${url}`); 2178 } 2179 } 2180 2181 getUserInfo(); 2182 2183 /** 2184 * æ¦æªé¡µé¢å ææ <a> æ ç¾çç¹å»è·³è½¬äºä»¶ 2185 * 妿å¨å¾®ä¿¡å°ç¨åºç¯å¢ä¸ï¼é»æ¢é»è®¤è·³è½¬è¡ä¸ºã 2186 * 2187 * @param {boolean} disable - æ¯å¦ç¦ç¨ a æ ç¾è·³è½¬ã为 true æ¶ç¦ç¨ã 2188 */ 2189 function interceptALinks(disable) { 2190 if (!disable) return; 2191 2192 /** 2193 * ç¹å»äºä»¶å¤ç彿° 2194 * @param {Event} event - DOM äºä»¶å¯¹è±¡ 2195 */ 2196 const handleLinkClick = event => { 2197 // æ¥æ¾äºä»¶æºæ¯å¦ä¸º <a> æ ç¾æå ¶åèç¹ 2198 let target = event.target; 2199 while (target && target !== document) { 2200 if (target.tagName && target.tagName.toLowerCase() === 'a') { 2201 event.preventDefault(); 2202 // 妿éè¦å¯æ·»å æç¤ºä¿¡æ¯ææ¥å¿è®°å½ 2203 console.warn('å½åç¯å¢ä¸ºå¾®ä¿¡å°ç¨åºï¼å·²ç¦ç¨é¾æ¥è·³è½¬ã'); 2204 break; 2205 } 2206 target = target.parentNode; 2207 } 2208 }; 2209 2210 document.addEventListener('click', handleLinkClick, true); 2211 } 2212 2213 /** 2214 * éå window.open æ¹æ³ï¼å¨å¾®ä¿¡å°ç¨åºç¯å¢ä¸ç¦æ¢æå¼æ°çªå£ 2215 * 妿éè¦ä¿çåå§é»è¾ï¼å¯éè¿å¤ä»½è¿è¡æ©å±ã 2216 * 2217 * @param {boolean} disable - æ¯å¦ç¦ç¨ window.open è°ç¨ã为 true æ¶ç¦ç¨ã 2218 */ 2219 function overrideWindowOpen(disable) { 2220 if (!disable || typeof window === 'undefined') return; 2221 2222 // å¤ä»½åå§ window.open æ¹æ³ 2223 const originalWindowOpen = window.open; 2224 2225 /** 2226 * éååç window.open æ¹æ³ 2227 * @param {...any} args - åå§ window.open çææåæ° 2228 * @returns {null} ç¦ç¨æå¼çªå£ï¼è¿å null 2229 */ 2230 window.open = function (...args) { 2231 console.warn('å½åç¯å¢ä¸ºå¾®ä¿¡å°ç¨åºï¼å·²ç¦ç¨ window.open è°ç¨ã'); 2232 return null; 2233 }; 2234 2235 // 妿éè¦ï¼å¨æªæ¥å¯ä»¥éè¿æ¡ä»¶éæ°å¯ç¨ window.openï¼ææä¾ fallback é»è¾ 2236 // window.restoreWindowOpen = () => { window.open = originalWindowOpen; } 2237 } 2238 2239 /** 2240 * åå§å微信å°ç¨åºç¯å¢ä¸ç导èªç¦ç¨åè½ 2241 * 妿å½å为微信å°ç¨åºç¯å¢ï¼åæ¦æª a æ ç¾ç¹å»åéå window.open æ¹æ³ 2242 */ 2243 function disableNavigationInMiniProgram() { 2244 const ua = window.navigator.userAgent.toLowerCase(); 2245 if (ua.match(/MicroMessenger/i) == 'micromessenger') { 2246 try { 2247 wx.miniProgram.getEnv(function (res) { 2248 if (res.miniprogram) { 2249 interceptALinks(true); 2250 overrideWindowOpen(true); 2251 } 2252 }); 2253 } catch (error) {} 2254 } 2255 } 2256 2257 disableNavigationInMiniProgram(); 2258 2259 switch (_get(g, 'htmlConfig.loadingConfig.loadingType', '0')) { 2260 case 0: 2261 case '0': 2262 jsLoadingBar = new LoadingJS(); 2263 break; 2264 case 1: 2265 case '1': 2266 jsLoadingBar = new GuideLoadingJS(); 2267 // if (!htmlConfig.loadingConfig.loadingBrandInfoUrl) jsLoadingBar = new GuideLoadingJS(); 2268 // else { 2269 // var xhr = new XMLHttpRequest(); 2270 // xhr.overrideMimeType('application/json'); 2271 // xhr.open( 2272 // 'GET', 2273 // `//${window.location.hostname}${htmlConfig.loadingConfig.loadingBrandInfoUrl}`, 2274 // true 2275 // ); 2276 // xhr.onload = function () { 2277 // if (xhr.status >= 200 && xhr.status < 300) { 2278 // var jsonData = JSON.parse(xhr.responseText); 2279 // // å¨è¿é使ç¨jsonData 2280 // htmlConfig.loadingBrandConfig = jsonData; 2281 // jsLoadingBar = new GuideLoadingJS(); 2282 // } else { 2283 // jsLoadingBar = new GuideLoadingJS(); 2284 // } 2285 // }; 2286 // xhr.send(null); 2287 // } 2288 break; 2289 } 2290})(window);
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.