打开主菜单

少前百科GFwiki β

更改

Widget:Tdollquery

添加4,981字节2019年9月30日 (一) 09:18
无编辑摘要
background-image: repeating-linear-gradient(-45deg,red 3px,red 4px,transparent 5px,transparent 20px);
box-shadow: inset 0 0 0 2px red;
}
#tableloadingMini {
background-image: url('/images/a/ac/Gfloading.gif');
background-repeat: no-repeat;
background-attachment: local;
background-position: bottom right;
background-size: 50px;
height: 50px;
text-align: right;
padding-right: 4rem;
font-size: 1.5rem;
vertical-align: bottom;
}
#tableemptyMini {
background-size: 50px;
height: 50px;
font-size: 1.5rem;
color: red;
text-align: center;
}
#miniTdolltable{
overflow: hidden;
margin: 0px;
display: table;
}
#tableloading > td {
font-size: 1.5rem;
vertical-align: bottom;
}
#Tdolltable{
margin: 0px;
}
#tableempty > td {
overflow:hidden;
transition: all 0.1s ease-in;
margin:2px
}
 
div#TDollQuery input#inputQuery {
padding:0px;
opacity: 0.7;
filter: blur(0px);
}
@media screen and (max-width: 640px)
{
#miniTdolltable div.TDavatar {width:20%;height:20%}
}
<!--{if ($hideinput)==1}-->div#TDollQuery {display:none;}<!--{/if}-->
</style><div style="max-width: 63rem;">
<div id="buttonContainer" style="widthmargin: 100%2px;">
<!--{if ($lite) != 1}-->
<p>
<input type="checkbox" id="rarity4" onclick="apply_filter()" /><label for="rarity4">★★★★</label>
<input type="checkbox" id="rarity5" onclick="apply_filter()" /><label for="rarity5">★★★★★</label>
<input type="checkbox" id="rarity6" onclick="apply_filter()" /><label for="rarity6">★★★★★★</label> <input type="checkbox" id="rarity1" onclick="apply_filter()" /><label for="rarity1">★EXTRA</label> </p> <p> <button onclick="clearSelect(this)">清除</button> <button onclick="invertSelect(this)">反选</button> <input type="checkbox" id="buildObtain" onclick="apply_filter()" /><label for="buildObtain">建造获得</label> <input type="checkbox" id="dropObtain" onclick="apply_filter()" /><label for="dropObtain">救援获得</label> <input type="checkbox" id="otherObtain" onclick="apply_filter()" /><label for="otherObtain">其他/特殊</label>
</p>
<p>
<div id="TDollQuery"><input type="text" placeholder="输入枪名" id="inputQuery"/><button type="button" onclick="clearItem();apply_filter();">清除</button></div>
<span>[<a href="javascript:void(0);"onclick="clearSelect(this.parentNode)">全清</a>]</span>
</div>
<div style="margin: 0.5rem;">
<input type="checkbox" id="iconOnly" onclick="apply_filter()" /><label for="iconOnly">精简模式</label><span id="resultBox" style="margin-right:0.5rem;float:right">数据载入中,请稍后<span>
</div>
<!--{if ($lite)==1}-->
<div id="resultBox">列表载入中,请稍后</div>
<!--{else}-->
<table id="miniTdolltable" style="display: none;">
<tbody>
<tr>
<td id="tableloadingMini">载入中</td>
</tr>
</tbody>
</table>
<!--{$content}-->
<!--{/if}-->
var emptydiv = "\<tr class='' id=\"tableempty\"\>\<td colspan=\"14\"\>无结果\<\/td\>\<\/tr\>"; //无结果label
var loadingdiv = "\<tr class='' id=\"tableloading\"\>\<td colspan=\"14\"\>载入中\<\/td\>\<\/tr\>"; //载入中label
var sorter_order = function (){//重载及应用筛选时保留当前tablesorter筛选顺序
var sortable = document.querySelectorAll("table#Tdolltable th.headerSort");
var sortorder = "";
for(var i=0;i<sortable.length;i++){
if(RegExp("headerSortUp").test(sortable[i].classList)){sortorder = '{"sortList":[{\"'+i+'\":"descasc"}]}'} else if(RegExp("headerSortDown").test(sortable[i].classList)){sortorder = '{"sortList":[{\"'+i+'\":"ascdesc"}]}'}
}
if(!sortable.length==0||!sortorder){return null}
return JSON.parse(sortorder)
}
var sorter_reload = function(){//purge表格时解绑tablesorter事件并重载
$("table#Tdolltable th").off('keypress click');
try{
} catch(e){
console.warn("Failed load tableSorter ,try to Reload");
mw$.loader.loadgetScript('"/images/jslib/jquery.tablesorter'); setTimeout(1000.js",function(){console.log('%ctableSorter Reloaded!',"color:green;");$("table#Tdolltable").tablesorter(sorter_order())});
}
}
var reloadstop = falsetrue; //阻止重复调用refreshLoad()
var inputer = document.getElementById("buttonContainer").getElementsByTagName("input")
var baseurl = "\/w\/TDL"
querylist.push(transdata[i]);
}
querylist.sort(function (a, b){return b.dataset.timestamp - a.dataset.timestamp});
loaded = true;
reloadstop = false;
apply_filter();
$(".disabled").removeClass("disabled");
RLQ.push(function(){ //首次载入函数,RLQ.push防止mwapi未载入时加载
if(document.getElementById("section_0")){
mwdocument.loader.loadgetElementById("mediawiki.languageiconOnly").checked = true; mwdocument.loadergetElementById("Tdolltable").style.load('display = "none";//index表格模式 document.php?title=MediaWiki:JquerygetElementById("miniTdolltable").tabelsorterstyle.js&actiondisplay =raw&ctype=text"";//javascript');头像模式
}
$.ajax({
var parser = new DOMParser;
var bravo = parser.parseFromString(data,"text/html");
var rawlist=bravo.getElementsByClassName("tdollqueryline");
getdata(rawlist);},
error: function () {
function getdata(transdata){ //载入函数
querylist = []; // 清除数据
try{document.getElementById("tableloading").remove()}catch(e){document.getElementById("tableloading").removeNode(true)} document.getElementById("tableloadingMini").innerHTML = ""; document.getElementById("tableloadingMini").id = "";
for (var i = 0; i < transdata.length; i++) {
querylist.push(transdata[i]);
}
querylist.sort(function (a, b){return b.dataset.timestamp - a.dataset.timestamp})
$(".disabled").removeClass("disabled");
reloadstop = false;
loaded = true;
apply_filter();
success: function (data, textStatus, jqxhr) {
if(data.purge[0].purged === ""){
console.log("refresh quest send successfulCache removed,proceed to refreshfetching new Tdolls data."); var icon_table_content = document.querySelector("table#miniTdolltable > tbody > tr > td");
$(".tdollqueryline").remove();
icon_table_content.innerHTML = "载入中";
icon_table_content.id = "tableloadingMini";
$(loadingdiv).appendTo("table#Tdolltable");
$("table#Tdolltable>thead").addClass("disabled")
};
function apply_filter(){//筛选函数
if(!loaded){return}
if(!!document.getElementById("tableempty")){document.getElementById("tableempty").remove();}
var list = document.querySelectorAll("table#Tdolltable > tbody > tr > td:nth-child(2) a");
var qlist = document.querySelectorAll("table#Tdolltable > tbody > tr");
var pushlist=new Array();
$(".tdollqueryline").remove();
for (var i = 0; i < querylist.length; i++) {
if(filter_box(querylist[i])){
}
};
if (pushlist.length == 0){ $document.getElementById(emptydiv"resultBox").appendTo(innerHTML = "table#Tdolltable当前条件下无结果,请尝试其他组合");
} else {
$if (pushlist.length==querylist.length){ document.appendTogetElementById("table#Tdolltable >tbodyresultBox");.innerHTML = "请输入查询条件" sorter_reload} else { document.getElementById("resultBox").innerHTML = "查询到"+pushlist.length+"条结果" ; }
}
mode_switch(pushlist)//最终输出函数
};
 
function mode_switch(pushdata){
var ministat = document.getElementById("iconOnly");
var table = document.getElementById("Tdolltable");
var icon_table = document.getElementById("miniTdolltable");
var icon_table_content = document.querySelector("table#miniTdolltable > tbody > tr > td");
if (ministat.checked==true){//小图标模式
if(table.style.display!="none"){ //先前为表格模式时 隐藏表格模式并删除表格内对象
$(".tdollqueryline").remove()
table.style.display = "none";
icon_table.style.display = "";
}
if (pushdata.length == 0){
icon_table_content.innerHTML = "无结果";
icon_table_content.id = "tableemptyMini";
} else {
icon_table_content.id = "";
// 排序预留
var rawHTML = [];
for (var i = 0; i < pushdata.length; i++) {
rawHTML.push(pushdata[i].querySelector("div.TDavatar").outerHTML);
}
var miniData = rawHTML.join("").replace(/[\r\n\t]/g,"");
icon_table_content.innerHTML = miniData;
}
} else {// 表格模式
if(icon_table.style.display!="none"){ //先前为小图标模式时 隐藏小图标模式
icon_table.style.display = "none";
table.style.display = "";
icon_table_content.innerHTML = "";
}
$(".tdollqueryline").remove();
if(!!document.getElementById("tableempty")){try{document.getElementById("tableempty").remove()}catch(e){document.getElementById("tableempty").removeNode(true)}}
if (pushdata.length == 0){
$(emptydiv).appendTo("table#Tdolltable");
} else {
 
$(pushdata).appendTo("table#Tdolltable >tbody");
sorter_reload();
}
}
}
<!--{/if}-->
function invertSelect(box){//反选函数
var rCheck = new Array();
var nt=0;
for (var i = 21;i <= 6;i++){
rCheck[i] = document.getElementById('rarity'+i).checked;
if (rCheck[i]) {nt++}
}
function type_check(query){ //稀有度判断枪种判断
var tCheck = new Array();
var nt=0;
return false
}
/*------------------------------/
/ 影响格查询部分 END /
/-------------------------------*/ function obtainMethod_check(query){ //稀有度判断 var checkStat = []; checkStat.push(document.getElementById('buildObtain').checked,document.getElementById('dropObtain').checked,document.getElementById('otherObtain').checked); var j = 0; for (var i = 0;i<checkStat.length;i++){if(checkStat[i]==false){continue}else{j++}} if (j==0){return true;} if(checkStat[0]==true){if(query.dataset.build==1){return true;}} if(checkStat[1]==true){if(query.dataset.drop==1){return true;}} if(checkStat[2]==true){if(query.dataset.special==1){return true;}} return false;} 
function filter_box(cond){ //筛选条件汇总
return mod_check(cond)&&text_check(cond)&&rarity_check(cond)&&type_check(cond)&&tiles_check(cond)&&obtainMethod_check(cond);
}
 
function classIconFilter(){ //人形图标筛选
var tab = decodeURIComponent(location.hash.replace('#', ''))+"Doll";
clearSelect(document.getElementById(tab));
document.getElementById(tab).checked = 'true';
apply_filter();location.hash='';
}
 
$(window).on('hashchange', function(e){if(decodeURIComponent(location.hash.replace('#', ''))!=''){classIconFilter();}});
$("#inputQuery").on('input propertychange',debounce(250, function (){apply_filter();}));
</script>
14,357
个编辑