组件:搜索(自制、勿喷)

注意


此页为于 R分站维基内部使用的“组件”页。将用于在其他页面中引用。
未经组件作者或工作人员允许,请勿修改此页的内容。



关于组件

你直接引用:[[include :ari-sandbox:searchs]]就行了,本组件由 wd:lancingue2 wd:lancingue2 创作。


对了就是这样,1.0,放进去就能看到。效果在这:这里


代码

[[div style="display:none"]]
[[div class="titleblock" style="margin-top: 0;"]]
[[=]]
+ 最近创建的页面
[[/=]]
[[div_ class="option-container"]]

[[div_ class="option"]]
[[[system:list-all-pages|所有页面]]]
[[/div]]

[[div_ class="option"]]
[[[most-recently-created-cn|最近创建的原创页面]]]
[[/div]]

[[/div]]

= **注:**右上角的标记,[[span class="fa fa-check-circle" style="color: #5cb85c;"]]@<&nbsp;>@[[/span]]代表原创作品,[[span class="fa fa-times-circle" style="color: #ee3131;"]]@<&nbsp;>@[[/span]]代表待删除作品。

[[module ListPages category="*" tags="-掩藏页 -段落 -工房" separate="false" perPage="25" order="created_at desc" rss="Most Recent Pages"]]
[[div_ class="info-container"]]
[[div_ class="info-title"]]
[[span class="info-type" style="/* %%tags%% */"]]@@ @@[[/span]][[span class="info-titlename"]]%%title%%[[/span]]
[[/div]]
[[div_ class="info-link"]]
%%title_linked%%
[[/div]]
[[div_ class="info-date"]]
创建于 %%created_at|%Y-%m-%d %R|agohover%%
[[/div]]
[[div_ class="info-length"]]
%%size%%字
[[/div]]
[[div_ class="info-comment"]]
评论数:[[span style="font-family: var(--mono-font);"]]%%comments%%[[/span]]
评分:[[span style="font-family: var(--mono-font);"]]+[[#expr (%%rating%%+((%%rating_votes%%-%%rating%%)/2))]][[/span]],[[span style="font-family: var(--mono-font);"]]-[[#expr ((%%rating_votes%%-%%rating%%)/2)]][[/span]]
作者:[[span style="font-family: var(--mono-font);"]]%%created_by%%[[/span]]
[[/div]]
[[div_ class="info-icon"]]
[[span class="original fa" style="/* %%tags%% */"]]@<&nbsp;>@[[/span]]
[[/div]]
[[/div]]
[[/module]]

[[/div]]

[[div class="titleblock" style="margin-top: 0;"]]
[[=]]
+ 无标签的页面
[[/=]]

[[module ListPages category="*" tags="-" separate="false" perPage="25" order="created_at desc"]]
[[div_ class="info-container"]]
[[div_ class="info-title"]]
[[span class="info-titlename"]]%%title%%[[/span]]
[[/div]]
[[div_ class="info-link"]]
%%title_linked%%
[[/div]]
[[div_ class="info-date"]]
创建于 %%created_at|%Y-%m-%d %R|agohover%%
[[/div]]
[[div_ class="info-length"]]
%%size%%字
[[/div]]
[[div_ class="info-comment"]]
评论数:[[span style="font-family: var(--mono-font);"]]%%comments%%[[/span]]
[[/div]]
[[div_ class="info-icon"]]
[[span class="original fa" style="/* %%tags%% */"]]@<&nbsp;>@[[/span]]
[[/div]]
[[/div]]
[[/module]]

[[/div]]
[[/div]]
[[div class="search-page"]]
[[html]]
<html style="opacity:0; transition: .5s">
<head></head>
<body>
<style>
div#list-pages {
    height: 100%!important;
    overflow: auto;
}
body {background:white!important; user-select:none}
* {
    margin: 0;
    padding: 0;
}

div#root {
    height: 100%;
    position: absolute;
    width: 100%;
    font-weight: 100;
}

div#header {
    position: sticky;
    top: 0;
    height: 100px;
    box-shadow: 0 0 1rem #0002;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

div#container {
    height: 100%;
    line-height: 2;
}

hr {
    background: black;
    box-shadow: 0 0 1rem #0008;
    margin: 0 10%;
    height: 1px;
    border: none;
}

h1,h2,h3,h4,h5,h6 {
    font-weight: 400;
}

div#header p:nth-of-type(1) {
    color: #333;
}

div#header p:not(:nth-of-type(1)):hover {color: blue;}

div#header p:not(:nth-of-type(1)) {
    transition: .5s;
}

div#list-item {
    display: flex;
    justify-content: space-around;
    align-items: center;
    overflow: auto;
    margin: 0 15vw;
}

div#list-item a {
    color: gray;
    text-decoration: none;
}

div#list-item>* {
    width: 100%;
    text-align: center;
}
</style>
<div id="root">
<div id="header">
<p>搜索筛选</p>
<p id="rate">按评分筛选</p>
<p id="pagename">按文章名筛选</p>
<p id="username">按用户名筛选</p>
</div>
<div id="container">
<h1 align="center">经过筛选的页面:</h1>
<hr>
<div id="list-pages">
<p align="center">额...你尚未有任何的选择捏!</p>
</div>
</div>
</div>
<script>
const host = location.host.replace('wdfiles','wikidot');
var P_MAX = -1;
var PageLists = [];
function P(i) {
fetch(‘https://api.codetabs.com/v1/proxy?quest=https://‘ + host + ’/’ + location.href.split('/')[4] + '/p/' + (i+1)).then((r)=>r.text()).then((r)=>{
let o = document.createRange().createContextualFragment(r);
if (P_MAX === -1) P_MAX = o.querySelectorAll('.pager .target').length;
let infos = o.querySelectorAll('.titleblock:has(span:nth-of-type(4)) .info-container');
let link = o.querySelectorAll('.info-container .info-link a');
let ratings_up = o.querySelectorAll('.info-container .info-comment span:nth-of-type(2)');
let ratings_down = o.querySelectorAll('.info-container .info-comment span:nth-of-type(3)');
let users = o.querySelectorAll('.info-container .info-comment span:nth-of-type(4)');
let PageTitles = o.querySelectorAll('.info-title .info-titlename');
for (var j=0;j<ratings_up.length;j++) {
PageLists.push({link: link[j].href, ratingUp: +ratings_up[j].innerHTML, ratingDown: +ratings_down[j].innerHTML, user: users[j].innerHTML, tits: PageTitles[j].innerHTML});
}
if (i === P_MAX - 1) {document.querySelector('html').style.opacity = 1;}
if (i < P_MAX - 1) P(i+1)
})
};
P(0);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
document.querySelector('p#rate').onclick = function(){
let p = prompt('输入你所需要评分(用a~b或一个比值)')
if (+p !== +p) var min = +p.split('~')[0],max = +p.split('~')[1]
let needsPage = [];
for (var i = 0;i < PageLists.length;i++) {
    if (+p === +p) {
         if  ((PageLists[i].ratingUp+1) / (-PageLists[i].ratingDown+1) >= +p) {
             needsPage.push(PageLists[i])
         }
    }
    else {
        if (PageLists[i].ratingUp + PageLists[i].ratingDown <= max && PageLists[i].ratingUp + PageLists[i].ratingDown >= min) {
              needsPage.push(PageLists[i])
          }
    }
}
Render(needsPage)
}

document.querySelector('p#pagename').onclick = function(){
let p = prompt('输入你所需要名称')
let needsPage = [];
let regexp = eval(`(${new RegExp(p)})`);
for (var i = 0;i < PageLists.length;i++) {
if (PageLists[i].tits.match(regexp) !== null || PageLists[i].link.match(regexp) !== null) {
needsPage.push(PageLists[i])
}
}
Render(needsPage)
}

document.querySelector('p#username').onclick = function(){
let p = prompt('输入你所需要用户名创作')
let needsPage = [];
for (var i = 0;i < PageLists.length;i++) {
if (PageLists[i].user === p.trim()) {
needsPage.push(PageLists[i])
}
}
Render(needsPage)
}

var Render = function(arr) {
if (arr.length === 0) {document.querySelector('#list-pages').innerHTML = '<p align="center">额...尚未有任何关于你所规定的文章捏!</p>'; return;}
document.querySelector('#list-pages').innerHTML = '';
for (var i = 0;i< arr.length;i++) {
document.querySelector('#list-pages').innerHTML += ‘<div id="list-item"><a href="javascript:top.location.replace(’${arr[i].link}')">${arr[i].tits}</a><span><span style="color:green">${arr[i].ratingUp}</span>, <span style="color:red">${arr[i].ratingDown}</span></span><span>作者名:${arr[i].user}</span></div>`
}
}
</script>
</body>
</html>
[[/html]]
[[/div]]
[[module CSS]]
.search-page {
    background: linear-gradient(90deg,#efefef,white,#efefef,white,#efefef,white,#efefef),linear-gradient(0deg,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee,white,#eee);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.search-page::before {
    content: '';
    width: 100%;
    height: 1px;
    position: absolute;
    background: white;
    box-shadow: 0 0rem 2rem 2rem white;
    animation: searchPageAnimation 1s infinite;
}

@keyframes searchPageAnimation {
    0% {
        top:0;
    }
    100% {
        top:100%
    }
}

.search-page p, .search-page p iframe {
    height: 100%!important;
    width: 100%;
    margin: 0;
    z-index:222;
    position:absolute;
    top:0; left:0; right:0; bottom:0;
    inset:0;
}
[[/module]]
_default: 原创 组件
页面版本:3,最后编辑:2025年8月1日 17:50(UTC+08:00)
除非特别注明,本页内容采用以下授权方式:Creative Commons Attribution-ShareAlike 3.0 License。