You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
568tools/js/popup.js

2 lines
5.4 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

function getD(t,e){return e?(e="class")?document.getElementsByClassName(t):void 0:document.getElementById(t)}function throttle(t,e){e=e||200;let s=null;return function(){s||(s=setTimeout((()=>{t.apply(this,arguments),s=null})))}}function setSotreList(t){var e=localStorage.getItem("list");e=JSON.parse(e||"[]");for(let s in e)e[s].name==t.name&&e.splice(s,1);e.splice(8,e.length-8),e.unshift(t),localStorage.setItem("list",JSON.stringify(e))}var _URL="https://Tools.PJ568.eu.org/";function initData(){var t=getD("nav"),e=getD("list"),s=getD("keyword"),a="",i="",l=localStorage.getItem("list");if(i+='<div class="item info"><h2>欢迎使用<img alt="Main_icon" class="mainicon" src="./img/icon.svg"/>&nbsp;568Tools&nbsp;在线工具箱</h2><p>致力于创造并维护无需注册、下载和上传即可免费使用的静态在线工具环境。部分项目来源于开源项目,热门工具已被标记为浅蓝色。<a href="lib/data.json" target="_blank">点击查看</a>&nbsp;json&nbsp;数据。</p><p><strong>如果您有问题或建议,请不要吝啬您的<a rel="nofollow" target="_blank" href="./comment">留言反馈</a>,感谢使用及分享!</strong>本站欢迎<a rel="nofollow" target="_blank" href="/application">提交您的页面</a>,本站将持续更新。如果喜欢网站可以去<a rel="nofollow" target="_blank" href="https://github.com/PJ-568/568tools">托管仓库</a>点一个⭐。</p><p>下载&nbsp;<strong>[568Tools&nbsp;工具箱]</strong>&nbsp;浏览器扩展插件或应用程序以供离线使用:<a rel="nofollow" target="_blank" href="/lib/app/568Tools_在线工具箱_First_Release.apk">安卓应用</a>、<a rel="nofollow" target="_blank" href="/lib/app/568tools-windows-latest.zip.zip">Windows 应用</a>、<a rel="nofollow" target="_blank" href="/lib/app/568tools-linux.7z">Linux deb</a>、<a rel="nofollow" target="_blank" href="https://repo.pj568.eu.org/568tools/">Linux AppImage</a>、<a rel="nofollow" target="_blank" href="/lib/app/568tools-macos-latest.zip.zip">macos 应用</a>。</p></div>',l){for(var n in i+='<div class="item"><h2>最近访问</h2><div class="child">',l=JSON.parse(l)){i+=`<a class="open-in-new-tab" href="${(c=l[n]).url}" target="_self">${c.name}</a>`}i+="</div></div>"}for(var n in classify){var r=classify[n];for(var o in a+=`<a href="#${r.id}">${r.name}</a>`,i+=`<div id="${r.id}" class="item"><h2>${r.name}</h2><div class="child">`,r.list){var c;i+=`<a href="${(c=r.list[o]).url}"${1==c.hot?' class="red" ':""}idx="${n}_${o}" target="_self" title="${c.name}">${c.name}</a>`}i+="</div></div>"}a+='<a href="#0" target="_self">页内页</a><a href="#-1" target="_self">项目贡献者</a><a href="#-2" target="_self">项目活动</a><a href="#-3" target="_self">Star&nbsp;历史</a>',i+='<div id="0" class="item"><h2>页内页</h2><div class="child"><iframe title="incert" id="myIframe" src="/help.html" class="page"></iframe><a style="cursor:pointer" onclick="openLink()" target="_self">进入页面</a></div></div><div id="-1" class="item"><h2>项目贡献者</h2><div class="child"><a class="contri" href="https://github.com/PJ-568/568tools/graphs/contributors" target="_blank"><img alt="贡献者的头像图片" src="https://contrib.rocks/image?repo=PJ-568/568tools"/></a></div></div><div id="-2" class="item"><h2>项目活动</h2><div class="child"><img alt="项目活动" class="incert" src="https://repobeats.axiom.co/api/embed/0e0b27c01d4e9ff093fb3d03fedc74a300068f50.svg"/></div></div><div id="-3" class="item"><h2>Star&nbsp;历史</h2><div class="child"><img alt="Star&nbsp;历史" class="incert" src="https://api.star-history.com/svg?repos=PJ-568/568tools&type=Date"/></div></div><div class="item"><a class="ota" href="#">↑↑&nbsp;&nbsp;&nbsp;&nbsp;返回页顶&nbsp;&nbsp;&nbsp;&nbsp;↑↑</a></div>',t.innerHTML=a,e.innerHTML=i,getD("classify").addEventListener("click",setClassify),e.addEventListener("click",(function(t){t.target.getAttribute("class").indexOf("sli")>-1&&toHref(t.target)})),s.addEventListener("input",throttle(setSearch)),s.addEventListener("focus",throttle(setSearch)),s.addEventListener("blur",(function(){setTimeout((function(){getD("searchContent").innerHTML=""}),250)})),getD("closekeyword").addEventListener("click",(function(){s.value="",this.style.display="none"})),getD("searchContent").addEventListener("click",(function(t){"ssli"==t.target.getAttribute("class")&&toHref(t.target)})),getD("logo").addEventListener("click",(function(t){var e=_URL+"/tool/home.html";window.open(e,"_blank")}))}function setSearch(t){t=this.value.trim();var e=getD("searchContent"),s=getD("closekeyword"),a="";if(""==(t=t.toLowerCase()))return e.innerHTML="",void(s.style.display="none");for(var i in s.style.display="block",classify)for(var l in classify[i].list){var n=classify[i].list[l];n.name&&n.name.toLowerCase().indexOf(t)>-1&&(a+=`<a class="ssli" idx="${i}_${l}"${1==n.hot?' class="hot" ':""}target="_self" title="${n.name}">${n.name}</a>`)}e.innerHTML=a}function toHref(t){var e=t.getAttribute("idx"),s=t.getAttribute("url");if(e){e=e.split("_");var a=classify[e[0]].list[e[1]];setSotreList(a),s=a.url}s&&(s.indexOf("http://")>-1||s.indexOf("https://")>-1||(s=_URL+s),window.open(s,"_blank"))}function setClassify(){var t=getD("cls"),e=getD("nav"),s=getD("line");if(!t.getAttribute("class"))return t.setAttribute("class","rotate"),e.style.display="block",void(s.style.height="132px");t.setAttribute("class",""),s.style.height="44px",e.style.display="none"}initData();