const throttle = (fn, interval) => { let isThrottled = false return (...args) => { if (!isThrottled) { isThrottled = true setTimeout(() => { fn.apply(this, args) isThrottled = false }, interval) } } } , debounce = (fn, delay) => { let timerId = null return (...args) => { clearTimeout(timerId) timerId = setTimeout(() => { fn.apply(this, args) }, delay) } } , addFirstDom = (nodeList, callback) => { nodeList.forEach((value, index) => { const svgDom = document.createElement('div'), firstDom = value.firstChild svgDom.id = 'linkSvg' + index value.insertBefore(svgDom, firstDom) const svg = new Vivus(`linkSvg${index}`, { duration: 100, start: 'inViewport', file: `${path()}images/link_icon${index + 1}.svg` }, callback) svgDom.parentElement.addEventListener('mouseover', () => { svg.getStatus() === 'end' ? svg.reset().play() : void 0 }) }) } , path =()=>{ const ip = window.location.origin const link =document.querySelectorAll('link') for(i of link){ if(i.type == 'image/x-icon'){ return i.href.replace(ip,'').replace('favicon.ico','') } } } , addElement = (node,videoPath)=>{ const video = document.createElement('video') video.src = `${path()}${videoPath}` video.id = 'videos1' video.autoplay = 'autoplay' video.loop = 'loop' video.muted = 'muted' node?.appendChild(video) } $(function(){ new SDAPP({ "menu":{ type:"aside" } }); $(".search-submit").click(function(event){ $(this).removeAttr("name"); event.preventDefault(); var val = $.trim($(".search-title").val()); if(val!==""){ $(".wp-search").find("form").submit(); }else{ alert("请输入关键词"); } return false; }); $(".searchbox_btns").click(function(){ $("#search-con").slideDown(); }); $(".layer .close").click(function(){ $("#search-con").slideUp(); }) /*媒体链接*/ $(".shares li").each(function(){ $(this).children("a").hover(function(){ $(this).parent().find(".con").stop(true,true).fadeIn(); },function(){ $(this).parent().find(".con").stop(true,true).fadeOut(); }); }); /*友情链接下拉*/ $(".botlinks").each(function (index, el) { $(el) .find(".links-wrap") .hover( function () { $(this) .addClass("wrap-open") .children(".link-items") .stop(true, true) .slideDown(300); }, function () { $(this) .removeClass("wrap-open") .children(".link-items") .stop(true, true) .slideUp(100); } ); }); const videoDom = document.querySelector('.list #globalBanner .col_menu') , videoPath = 'video/video1.mp4' addElement(videoDom ,videoPath ) });