const currentJsPath = document.currentScript.src.replace(/\/org\/first\.js([\s\S]*)$/, '/'); // svg !function(o,l){var r,a,s="createElement",g="getElementsByTagName",b="length",E="style",d="title",y="undefined",k="setAttribute",w="getAttribute",x=null,A="__svgInject",C="--inject-",S=new RegExp(C+"\\d+","g"),I="LOAD_FAIL",t="SVG_NOT_SUPPORTED",L="SVG_INVALID",v=["src","alt","onload","onerror"],j=l[s]("a"),G=typeof SVGRect!=y,f={useCache:!0,copyAttributes:!0,makeIdsUnique:!0},N={clipPath:["clip-path"],"color-profile":x,cursor:x,filter:x,linearGradient:["fill","stroke"],marker:["marker", "marker-end","marker-mid","marker-start"],mask:x,pattern:["fill","stroke"],radialGradient:["fill","stroke"]},u=1,c=2,O=1;function T(e){return(r=r||new XMLSerializer).serializeToString(e)}function P(e,r){var t,n,i,o,a=C+O++,f=/url\("?#([a-zA-Z][\w:.-]*)"?\)/g,u=e.querySelectorAll("[id]"),c=r?[]:x,l={},s=[],d=!1;if(u[b]){for(i=0;i `0${n}`.slice(-2); let month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] let mon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'] let li = { Y: this.getFullYear().toString(), m: a(this.getMonth() + 1), d: a(this.getDate()), H: a(this.getHours()), i: a(this.getMinutes()), s: a(this.getSeconds()), F: month[this.getMonth()], M: mon[this.getMonth()] } for (let i in li) str = str.replace(i, li[i]) return str; }; // wow const styleElement = document.createElement('style'); styleElement.textContent = `[scalc],.wow,[wow],[number-roll]:not(.isstart){visibility:hidden}img{min-width:1px;min-height:1px;}[vue].visible{visibility: visible;}.container[loading]:after{background:url(${currentJsPath}images/l.gif) no-repeat center;}[masonry]:not(.isok):before{background:url(${currentJsPath}images/l.gif) no-repeat 50% 160px;position:absolute;left:0;right:0;top:0;bottom:10%;content:""}[jxloading],[map]{background:url(${currentJsPath}images/l.gif) no-repeat center;font-size:0;}[jxloading].isok{background-image:none;}`; // 将 style 元素插入到 head 中 document.head.appendChild(styleElement); // iframe跨域函数 window.$$My = { isMobile:()=>navigator.userAgent.toLowerCase().search(/(ipad|iphone os|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile)/)>-1, loading:(p)=>$$My.tip('',{...(p||{}),loading:1}), loadingRemove:()=>$$My.tipRemove(), loadingSvg(p){ p.border = p.border || (p.wh>40?3:2); p.wh = p.wh || 20; p.r = p.wh/2 - p.border; return `` }, html:(h)=>document.documentElement.insertAdjacentHTML('beforeend',h), event(e){ let p = e ? {x: e.clientX||e.originalEvent.changedTouches[0].clientX, y: e.clientY||e.originalEvent.changedTouches[0].clientY} : {x:0,y:0}; p.x += ISFunc.rect.left; p.y += ISFunc.rect.top; return p; }, moveFn: {}, move(opt){ this.eventxyO = this.eventxy; this.moveFn = opt; this.moveFn.down && this.moveFn.down.bind(this.moveFn)(this.eventxy); }, moveEl(el, mEl){ this.move({ el: typeof el=='string'?document.querySelector(el):el, moveEl: typeof mEl=='string'?document.querySelector(mEl):mEl, down(p){ this.s0 = { top: parseFloat(this.moveEl.style.top) || 0, left: parseFloat(this.moveEl.style.left) || 0 } }, move(o, p){ this.moveEl.style.top = this.s0.top + p.y - o.y + 'px'; this.moveEl.style.left = this.s0.left + p.x - o.x + 'px'; } }) }, setTime(fn, t){ if (!this.setTimes || this.setTimes>=t) { fn(); this.setTimes = 0; } this.setTimes++; requestAnimationFrame(()=>{this.setTime(fn, t)}) }, rect(a, event){ let e = typeof a == 'string' ? document.querySelector(a) : a; let vw = document.documentElement.clientWidth; let vh = document.documentElement.clientHeight; let r = e ? e.getBoundingClientRect() : {left:0,top:0,right:vw,bottom:vh,width:vw,height:vh}; let x = r.left; let y = r.top; let w = r.width; let h = r.height; let p = [ this.event(event), {x:x,y:y}, {x:x+w/2,y:y}, {x:x+w,y:y}, {x:x,y:y+h/2}, {x:x+w/2,y:y+h/2}, {x:x+w,y:y+h/2}, {x:x,y:y+h}, {x:x+w/2,y:y+h}, {x:x+w,y:y+h}, ]; for (let i in p) { p[i].style = `top:${p[i].y}px;left:${p[i].x}px;width:0px;height:0px;`; p[i].i = i; } r.position = p; return r; }, position(a, opt={}){ opt = {position:2,zIndex:900,...opt}; let ID = 'POSITION'+(opt.id || Math.random().toString().replace('.','')).replace(/[^a-zA-Z0-9_]/g,'_'); if (window[ID]) { window[ID] = {...window[ID],...opt}; } else { window[ID] = { ...opt, el: typeof a == 'string' ? document.querySelector(a) : a, remove:()=>this.el.remove(), outSide({x,y}, b){ b = $$My.rect(b); c = $$My.rect(); let r = this.position===100 ? 2 : 1; return { top: y < c.top + b.height, left: x < c.left + b.width/r, right: x > c.right - b.width/r, }; }, show(){ !this.box&&$$My.html(`
${this.html}
`); this.box = document.getElementById(ID); this.children = this.box.children[0]; let p = $$My.rect(this.el, this.event).position[this.position>9?0:this.position]; let s = `position:fixed;z-index:${this.zIndex};${p.style};display:flex;` + ( this.position===100 ? 'justify-content:center;align-items:flex-end;' : this.position===101 ? 'justify-content:start;align-items:flex-end;' : [1,2,3,5].indexOf(this.position)>=0 ? 'justify-content:center;align-items:flex-end;' : [4].indexOf(this.position)>=0 ? 'justify-content:flex-end;align-items:center;' : [6].indexOf(this.position)>=0 ? 'justify-content:flex-start;align-items:center;' : [7,8,9].indexOf(this.position)>=0 ? 'justify-content:center;align-items:start;' : '' ); if ([100,101].indexOf(this.position)>=0) { let out = this.outSide({x:p.x, y:p.y}, this.children); if (out.top) s += 'align-items:start;'; if (out.left) s += 'justify-content:flex-start;'; if (out.right) s += 'justify-content:flex-end;'; } this.box.style = s; } }; } window[ID].show(); return window[ID]; }, tip(msg, opt={}){ typeof msg == 'object' && (opt = msg, msg = ''); opt.keep = opt.id?1:0; let id = 'lG'+(opt.id || Math.random().toString().replace('.','')).replace(/[^a-zA-Z0-9_]/g,'_'); if (!window[id]) { opt.bg = opt.bg || 3; opt.str = opt.str || `
${opt.loading ? this.loadingSvg({color:opt.color,...(opt.svg||{})})+(opt.immediately?'':' loading...') : msg}
`; this.html(`
${opt.str}
`.replace(/([^a-zA-Z0-9_])self\./g, '$1window.'+id+'.')); window[id] = { ...opt, remove:()=>window[id].close(1), close(rm){ let re = !opt.keep||rm; $$My.tipClose(id, re); opt.close&&opt.close(re); re && delete window[id]; }, open(init){ init&&this.init&&this.init(); let lo = document.querySelector('.'+id); let po = lo.querySelector('popup'); lo.classList.remove('not'); setTimeout(() => {lo.classList.add('cur'); po&&po.classList.add('cur')}, opt.immediately?0:30); setTimeout(() => {lo.classList.add('MyTrans')}, 200); if (opt.time) setTimeout(() => {this.close()}, opt.time); } } } window[id].open(1); return window[id]; }, tipRemove:(id)=>$$My.tipClose(id, 1), tipClose(id, rm){ let lo = document.querySelector('.'+(id||'IGFLoading')); if (lo) { lo.classList.remove('cur'); let po = lo.querySelector('popup'); po&&po.classList.remove('cur'); setTimeout(() => {rm?lo.remove():lo.classList.add('not');lo.classList.remove('MyTrans');}, 300); } }, }; window.IGFunc = { name:()=>'z' + Math.random().toString().replace('.',''), popup(url, {callback, remove}){ let div = document.createElement('div'); let name = this.name(); url = url + (url.indexOf('?')==-1?'?':'&') + 'iframe='+name; div.id = name; div.innerHTML = ``; document.body.appendChild(div); $$My.loading(); return this.set(name, { callback: callback, remove: remove }); }, set(name, {callback, remove}){ if (!name) name = this.name(); let el = document.querySelector('[name="'+name+'"]'); window[name] = { el: el, name: name, callback: (res) => { if (callback) callback(window[name], res); }, remove: (res) => { if (remove) remove(window[name], res); document.getElementById(name).remove(); delete window[name]; }, send(type, data){ window[name].source.postMessage({type, name, data}); }, size(res){ el.style.width = res.data.width; el.style.height = res.data.height; } }; return window[name]; } }; window.ISFunc = { rect:{ width: 0, height: 0, left: 0, top: 0, }, window:{ width: 0, height: 0, }, name(){ let href = location.href; let iframe = href.match(/iframe=([^&]+)/); return iframe ? iframe[1] : ''; }, href(url){ let name = this.name(); if (name) url += (url.indexOf('?')==-1?'?':'&') + 'iframe='+name; location.href = url; }, send(type, data){ type = 'lyy:'+type; window.parent.postMessage({ type, name:this.name(), data}); }, popupEl(){ let popup = document.querySelector('popup') || document.body; return popup; }, remove(){this.close(1)}, close(time){ this.popupEl().classList.remove('cur'); setTimeout(()=>{this.send('remove')}, time||300); }, first(){ this.popupEl().classList.add('cur'); this.send('first'); } }; window.addEventListener('message', e=>{ let name = e.data.name; let type = e.data.type; let o = window[name]; if (!type || type.indexOf('lyy:')==-1) return; // 初始化 if (type.indexOf(':first')>0) { $$My.loadingRemove(); window[name].source = e.source; e.source.postMessage({type:'first'}); } // 删除iframe if (type.indexOf(':remove')>0) { console.log(name, type, e.data); o.remove(e.data); } // 设置宽高 if (type.indexOf(':size')>0) { o.size(e.data); } // 回调函数 if (type.indexOf(':callback')>0) { o.callback(e.data); } // 回调函数 if (type.indexOf(':rect')>0) { ISFunc.rect.left = e.data.data.left; ISFunc.rect.top = e.data.data.top; } }); $$My.setTime(()=>{ let ifr = document.querySelectorAll('iframe'); if (ifr) for (let i=0;i{ $$My.eventxy = $$My.event(e); $$My.moveFn.move && $$My.moveFn.move.bind($$My.moveFn)($$My.eventxyO, $$My.eventxy); }); window.addEventListener($$My.isMobile()?'touchend':'mouseup', (e)=>{ $$My.moveFn.up && $$My.moveFn.up.bind($$My.moveFn)($$My.eventxy); $$My.moveFn = {}; }); if (document.querySelector('meta[loading]')) { $$My.loading({bg:2,immediately:1,svg:{wh:50}}); }