<style>
li.btn.queryParams.selected {
color: #333 !important;
background-color: #e6e6e6;
border-color: #adadad;
outline: 0;
-webkit-box-shadow: inset 0 3px 5px rgba(0,0,0,.125);
box-shadow: inset 0 3px 5px rgba(0,0,0,.125);
}
</style>
<div style="float:left;line-height: 44px;"> 查询到结果 <span id="queryCount">0</span> 个,每页显示 <span id="queryLimit">0</span> 个</div>
<nav style="text-align:right;" aria-label="Page navigation">
<ul class="pagination" data-ul="1">
<li class="gridFirstPageBtn" data-page="0">
«
</li>
<li class="gridPageBtn">
1</li>
<li class="gridPageBtn">
2</li>
<li class="gridPageBtn">
3</li>
<li class="gridPageBtn">
4</li>
<li class="gridPageBtn">
5</li>
<li class="gridLastPageBtn" data-page="-1">
»
</li>
</ul>
</nav>
<div id="queryDataGrid" class="resp-tabs-box" style="margin-top:10px;font-size: larger;">初始化...</div>
<nav style="text-align:right;" aria-label="Page navigation">
<ul class="pagination" data-ul="2">
<li class="gridFirstPageBtn" data-page="0">
«
</li>
<li class="gridPageBtn">
1</li>
<li class="gridPageBtn">
2</li>
<li class="gridPageBtn">
3</li>
<li class="gridPageBtn">
4</li>
<li class="gridPageBtn">
5</li>
<li class="gridLastPageBtn" data-page="-1">
»
</li>
</ul>
</nav>
<script type="text/javascript">
var GameModeCache = window.location.href.split("#")[0] + "GameMode";
var GameModeCacheOn = "";
if(!GameModeCacheOn) sessionStorage.clear();
var GameMode=sessionStorage.getItem(GameModeCache);
if(window.location.href.split("#").length > 1)
GameMode = decodeURI(window.location.href.split("#")[1]);
console.log("GameModeCache :"+sessionStorage.getItem(GameModeCache));
console.log("GameMode :"+GameMode);
var submitBtnId = "";
var tableHeader = ("").replace("{ |", "{|");
var tableFooter = "" || '\n|}';
var defaultSearch = "";
var conditions = "";
var params = "";
var cur_conditions = [];
var printColumn = paramsFormmatter("", "|?");
var parameters = paramsFormmatter(("")/*.replace(/:/g, "=")*/, "|");
var mdScreen = window.innerWidth > 992 && window.innerWidth < 1200;
var limit = - ( mdScreen ? 4 : 0 );
var count = 0;
var defaultParams = "";
var $defaultHide;
var $defaultSelect;
var loopCount = 0;
var $ready = function (){
defaultParams = getQueryParams();
$defaultHide = $("tr.iteminfo");
$defaultSelect = $(".queryParams.selected");
$("#searchBtn").append("<input style=\"width: 120px;\" placeholder=\"例:夏侯、刘\" />");
bindClickEvents();
}
function bindClickEvents(){
//input回车开始
$("#searchBtn").children("input").keyup(function(e){
if(e.keyCode==13){
$('#queryDataBtn').click(); //处理事件
// $(this).blur();
}
});
//input回车结束
$("body").on("click", ".btn.queryParams", function(){
var bodyScroll = document.body.scrollHeight - document.body.scrollTop;
var isSelected = $(this).hasClass("selected");
//选项
cur_conditions = [];
$(".selected").not("[data-id!='']").each(function (index,element) {
var tmp = $(this).attr("data-conditions");
if(tmp)cur_conditions.push(tmp);
});
var tmpX = $(this).not("[data-id!='']").attr("data-conditions");
if(!isSelected)
{
if(tmpX) cur_conditions.push(tmpX);
}else
{
cur_conditions.forEach(function(item, index, arr) {
if(item === tmpX) {
arr.splice(index, 1);
}
});
}
console.log(cur_conditions);
var id=$(this).attr("data-id");
var group=$(this).attr("data-group");
if(group)
{
var $group=$('*[data-group*='+group+']').not(this);
var $id2 = $('*[data-group*='+group+']'+"[data-id!='']").not(this);
if(!isSelected)
{
$group.removeClass("selected");
$id2.each(function (index,element) {//遍历每个对象
var tmpid = $(this).attr("data-id");
if(tmpid)
{
var $tmp = $('*[data-id*='+tmpid+']'+"[data-ask-key]").not(this);
$tmp.addClass("iteminfo");
$tmp.find("li").removeClass("selected");
}
});
}
}
if(id)
{
var $id=$('*[data-id*='+id+']'+"[data-ask-key]").not(this);
if(!isSelected)
{
$id.removeClass("iteminfo");
SetCondtion(id);
}else
{
$id.addClass("iteminfo");
$id.find("li").removeClass("selected");
}
}
$(this)[isSelected?"removeClass":"addClass"]("selected");
var $tmp = $(".queryParams.selected");
if($tmp.length == 0)
{
Default();
}
document.body.scrollTop = document.body.scrollHeight - bodyScroll;
GameModeCacheFunc();
}).on("click", "#" + submitBtnId, function(){
queryData();
}).on("click", "#clearParamBtn", function(){
cur_conditions = [];
var bodyScroll = document.body.scrollHeight - document.body.scrollTop;
$("#searchBtn").children("input").val("");
var $tmp = $("tr").not("iteminfo").find("li.selected").not("*[data-group*='version']");
console.log($tmp);
if($tmp.length==0)
{
Default();
}else
{
$tmp.removeClass("selected");
}
document.body.scrollTop = document.body.scrollHeight - bodyScroll;
GameModeCacheFunc();
}).on("click", ".gridPageBtn, .gridFirstPageBtn, .gridLastPageBtn", function(){
if($(this).hasClass("hide") || $(this).hasClass("active")) return false;
var page = $(this).attr("data-page") || $(this).text();
getPageData(limit, refreshPager(count, limit, page,$(this).parents("ul").eq(0).attr("data-ul")));
})
if(defaultSearch === "true" || defaultSearch === "1")
{
Load();
}
}
function Load()
{
try {
$("li").filter("*[data-conditions*='[[分类:武将]][[武将版本::"+ GameMode +"]]']").click();
queryData();
}
catch(err) {
loopCount = loopCount + 1;
if(loopCount>=100)
{
alert("响应时间超过3秒!");
return false;
}
setTimeout("Load()",30);
}
}
function Default()
{
$(".queryParams.selected ").removeClass("selected");
$("tr.iteminfo").removeClass("iteminfo");
$defaultHide.addClass("iteminfo");
$defaultSelect.addClass("selected");
//SetCondtion($defaultSelect.filter("*[data-id!='']:first").attr("data-id"));
}
function queryData(){
if(GameMode == "经典" || GameMode == "国战" || GameMode == "界限" || GameMode == "自走棋")
history.replaceState(null,null,window.location.href.split("#")[0]);
conditions = getQueryParams()|| defaultParams;
params = conditions + printColumn + parameters;
//替换处理
params=params.replaceAll("$input",$("#searchBtn").children("input").val());
for (var i = 0; i < replaces.length; i ++) {
var tmp = replaces[i].split("@");
params = params.replace(tmp[0],tmp[1]);
conditions = conditions.replace(tmp[0],tmp[1]);
}
//是否有历史版本
var ShowChange = false;
if(params.indexOf("技能历史版本") >= 0 ) {
ShowChange=true;
}
Set_Highlight(ShowChange);
console.log("技能高亮状态:"+ShowChange);
$.getJSON( mw.util.wikiScript( 'api'), {
format: 'json',
action: 'parse',
text: '{'+'{#ask:'+ conditions +'|format=count}}',
contentmodel: 'wikitext'
}).done( function ( data ) {
count = parseInt($(data.parse.text["*"]).text());
$("#queryCount").text(count);
$("#queryLimit").text(limit);
refreshPager(count, limit, 1);
getPageData(limit, 1);
ShuaXin();
});
}
function getPageData(limit, page){
limit = Number(limit);
page = Number(page);
var Limit_And_Offset = "|limit=" + limit + "|offset=" + (page-1) * limit;
var iconCoditions = "";
$(".btn.queryParams.selected").each(function(){
if($(this).attr("data-iconCoditions")!="")
iconCoditions = iconCoditions +$(this).attr("data-iconCoditions")+"||";
});
var queryText = tableHeader + '{'+'{#ask:'+ params.replace("[[分类:","[[分类:"+ iconCoditions ) + Limit_And_Offset + '}}' + tableFooter;
console.log(queryText);console.log(defaultParams);
var html_img = "";
for(var i=0;i < (count == 0 ? 1 : (count > limit ? limit : count));i++)
{
html_img = html_img + "<div class=\"headshot tt-box\"><img src=\"https://patchwiki.biligame.com/images/sgs/c/c9/5wxdfoa2e28dudv99gui5barojmx3jf.png\" alt=\"\" width=\"100\" height=\"100\" class=\"handbook-round-corner\"/><img src=\"https://patchwiki.biligame.com/images/sgs/5/5d/9nce3414gps9a61monxotpd5zog8eba.gif\" alt=\"\" width=\"100\" height=\"100\" style=\"position:absolute;top:0;left:0;\"/></div>";
}
$("#queryDataGrid").html("<div class=\"handbook-100\">" + html_img + "</div>");
$.getJSON( mw.util.wikiScript( 'api'), {
format: 'json',
action: 'parse',
text: queryText,
contentmodel: 'wikitext'
}).done( function ( data ) {
$("#queryDataGrid").html(data.parse.text["*"]);
//外链处理
/* 技术处理外链 来源:异星工厂WIKI
$("#queryDataGrid").find("a").each(function(){
url=$(this).attr("href");
if(typeof(url)!="undefined"){
key=["game.bilibili.com","space.bilibili.com","wiki.biligame.com",
"sanguosha.com","www.sanguosha.com","club.sanguosha.com","web.sanguosha.com","sgs10thanniversary.sanguosha.com","h5.sanguosha.com",
"hu6.me","jq.qq.com","tieba.baidu.com","www.huya.com","www.douyu.com"];
var status=false;
key.forEach(function(k){
status=url.replace(/^.+linkfilter\/\?url=https*:\/\/([^\/]+).*$/ig, "$1").indexOf(k)>=0||status;
});
url=status?url.replace(/^.+linkfilter\/\?url=(.+)/g, "$1"):url;
$(this).attr("href",url);
}
});*/
$(".sortable").tablesorter();
});
}
function refreshPager(count, limit, page , scroll){
var sumPage = Math.min(Math.ceil(Number(count)/Number(limit)));
page = Number(page);
page = page === 0 ? 1 : page;
page = page < 0 ? sumPage : page;
var pageStart = Math.max(1, page-2);
var pageEnd = Math.min(Math.ceil(count/limit), pageStart + 4);
pageStart = pageEnd <= 5 ? 1 : pageStart;
var $a = $("<a>").attr({href:"javascript:void(0);"});
var btnArray = [];
for(var i = pageStart; i <= pageEnd; i++){
btnArray.push($("<li>").attr({class:"gridPageBtn" + (page === i?" active":"")}).append($a.clone().text(i)));
}
$(".gridPageBtn").remove();
$(".pagination li:first-child").after(btnArray);
$(".gridFirstPageBtn")[page === 1?"addClass":"removeClass"]("hide");
$(".gridLastPageBtn")[page === sumPage || pageEnd === 1?"addClass":"removeClass"]("hide");
//alert(document.body.clientWidth);
if(scroll)
{
//if(scroll!=2)
document.body.scrollTop = $("#queryDataGrid").offset().top - (document.body.clientWidth < 747 ? 100 : 150);
//document.body.scrollTop = $(".pagination[data-ul*='2']").offset().top - window.innerHeight + 150;
}
return page;
}
var replaces = [];
function getQueryParams(){
var conditions = {}, query = [], str = "";
replaces = [];
$(".btn.queryParams.selected").each(function(){
var replace = $(this).attr("data-replace");
replace=("$"+replace).split("$").filter(Boolean);
console.log(replace);
for(var i = 0; i < replace.length; i++)
{
replaces .push(replace[i]);
}
var key = $(this).parents("tr").attr("data-ask-key");
var cond = $(this).attr("data-conditions");
if(key === "") { if(cond.includes("]]")){str += cond;} return true}
if(conditions[key] === undefined) conditions[key] = [];
conditions[key].push($(this).attr("data-conditions"));
})
//输入框input模块开始
var $input = $("#searchBtn").children("input");
var key = $("#searchBtn").attr("data-ask-key");
if($input.val())
{
if($input.val().includes("]]"))
str+=$input.val();
else
{
var inputs = $input.val().split("、");
if(conditions[key] === undefined) conditions[key] = [];
for(var i=0;i<inputs.length;i++)
{
if(inputs[i])
conditions[key].push("~*"+inputs[i]+"*");
}
}
}
//输入框input模块结束
$.each(conditions, function(key, valArr){
query.push("["+"[" + key + valArr.join("||") + "]"+"]")
});
console.log(replaces);
return query.join("") + str;
}
function paramsFormmatter(param, connector){
return (";" + param).split(";").join(connector);
}
function ShuaXin()
{
var queryText= '
▶ 刷新筛选内容('+ count +')
'
console.log(queryText);
$.getJSON( mw.util.wikiScript( 'api'), {
format: 'json',
action: 'parse',
text: queryText,
contentmodel: 'wikitext'
}).done( function ( data ) {
$("#refreshContainer").html(data.parse.text["*"]);
$(".sortable").tablesorter();
});
}
function SetCondtion(id)
{
var t; var id2;
$('tr[data-id*='+id+']').find("li").each(function (index,element) {
for(var i=0;i<cur_conditions.length;i++)
{
if($(this).attr("data-conditions")==cur_conditions[i]) $(this).addClass("selected");
if(cur_conditions[i].includes("上线时间::+")) t=1;
}
});
if(id=="guo")
{
id2="国战";
}else if(id=="jie")
{
id2="界限";
}else if(id=="Default")
{
id2="经典";
}
if(t && id2)
{
$("li").filter("*[data-conditions*='[["+id2+"上线时间::+]]']").addClass("selected");
}
}
function GameModeCacheFunc()
{
if(GameModeCacheOn)
{
var Mode1 = $("li").filter("*[data-conditions='[[分类:武将]][[武将版本::"+"经典"+"]]']").hasClass("selected");
var Mode2 = $("li").filter("*[data-conditions='[[分类:武将]][[武将版本::"+"界限"+"]]']").hasClass("selected");
var Mode3 = $("li").filter("*[data-conditions='[[分类:武将]][[武将版本::"+"国战"+"]]']").hasClass("selected");
var Mode4 = $("li").filter("*[data-conditions='[[分类:武将]][[武将版本::"+"自走棋"+"]]']").hasClass("selected");
sessionStorage.setItem(GameModeCache,(Mode1 ? "经典" : (Mode2 ? "界限" : (Mode3 ? "国战" : (Mode4 ? "自走棋" : "")))));
}
}
</script>
<script>(function () { var t = function () { window.jQuery && window.mw ? $ready() : window.setTimeout(t, 100); }; t(); })();</script>