如果你看到本段文字,说明该页面未正常加载全局JS,部分功能将无法使用,请点击 刷新 重新加载页面。
如果打开页面显示缩略图创建出错,请点击刷新或页面右上WIKI功能中的刷新按钮清除页面缓存并刷新,如果还有问题,请多尝试几次。
全站通知:

MediaWiki:EquipTechTree.js

来自碧蓝航线WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl + F5Ctrl + R(Mac为⌘ + R
  • Google Chrome:Ctrl + Shift + R(Mac为⌘ + Shift + R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl + F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
try{
	equipTechTreeInfo
}
catch(e){
	equipTechTreeInfo=[]
	blhsjLogo=document.createElement("img")
	blhsjLogo.src="https://patchwiki.biligame.com/images/blhx/b/b1/7dvakdwi1ynj7ajndv1aqzoqwrvgx56.png"
	blhsjLogo.onload=initializeEquipTechTree
	window.onresize=initializeEquipTechTree
	//删除重复modal
	let modals = document.getElementsByClassName("equipRDinfo")
	let modalData = []
	for (let i = 0; i < modals.length; i++) {
		let dataName = modals[i].dataset.name
		if(!modalData.includes(dataName)) {
			modalData.push(dataName)
		} else {
			modals[i].remove()
		}
	}
	function initializeEquipTechTree(){
		let equipTechTree=document.getElementsByClassName("equipTechTree")
		for(let i=0;i<equipTechTree.length;i++){
			let info
			try{
				equipTechTreeInfo[i].hasOwnProperty("root")
				info=equipTechTreeInfo[i]
			}
			catch(e){
				info={}
				equipTechTreeInfo.push(info)
				info.root=equipTechTree[i]
				info.canvas=document.createElement("canvas")
				info.root.getElementsByClassName("canvas")[0].appendChild(info.canvas)
				info.canvas.style.position="absolute"
				info.canvas.style.zIndex=-1
				info.equip=[]
			}
			let branch = info.root.getElementsByClassName("branch")[0]
			let iconWidth = (branch.getElementsByClassName("equipPlaceholder").length+branch.getElementsByClassName("equip").length)*102
			info.canvas.width=Math.max(info.root.clientWidth, iconWidth)
			info.canvas.height=info.root.clientHeight
			if (window.innerWidth < iconWidth) {
				info.root.children[0].style.height = info.canvas.height
				info.root.getElementsByClassName("icon")[0].style.position="absolute"
			}
			let brush=info.canvas.getContext("2d")
			brush.save()
			brush.globalAlpha=0.1
			let center=[info.canvas.width/2,info.canvas.height/2]
			brush.drawImage(blhsjLogo,center[0]-Math.min(info.canvas.width,info.canvas.height,1024)/2,center[1]-Math.min(info.canvas.width,info.canvas.height,1024)/2,Math.min(info.canvas.width,info.canvas.height,1024),Math.min(info.canvas.width,info.canvas.height,1024))
			brush.restore()
			let equip=info.root.getElementsByClassName("equip")
			for(let j=0;j<equip.length;j++){
				let index=equip[j].dataset.index
				info.equip[index]={}
				info.equip[index].top=equip[j].offsetTop-info.canvas.offsetTop
				info.equip[index].bottom=info.equip[index].top+equip[j].clientHeight
				info.equip[index].left=equip[j].offsetLeft
				info.equip[index].right=info.equip[index].left+equip[j].offsetWidth
				info.equip[index].wcenter=(info.equip[index].left+info.equip[index].right)/2
				info.equip[index].hcenter=(info.equip[index].top+info.equip[index].bottom)/2
			}
		}
		drawEquipTechTree()
	}
	function drawEquipTechTree(){
		let equipTechTree=document.getElementsByClassName("equipTechTree")
		for(let i=0;i<equipTechTree.length;i++){
			let ligature=equipTechTree[i].dataset.ligature.split(",")
			for(let j=0;j<ligature.length;j++){
				try{
					let index=ligature[j].split("-")
					let equip1=equipTechTreeInfo[i].equip[index[0]]
					let equip2=equipTechTreeInfo[i].equip[index[1]]
					if(equip1.hcenter==equip2.hcenter){
						if(equip1.left > equip2.left) {
							ettp2p(equipTechTreeInfo[i].canvas,[equip1.left,equip1.hcenter],[equip2.right,equip2.hcenter])
						} else {
							ettp2p(equipTechTreeInfo[i].canvas,[equip1.right,equip1.hcenter],[equip2.left,equip2.hcenter])
						}
					}
					else{
						ettp2p(equipTechTreeInfo[i].canvas,[equip1.wcenter,equip1.bottom],[equip2.wcenter,equip2.top])
					}
				}
				catch(e){}
			}
		}
	}
	function ettp2p(canvas,p1,p2){
		let brush=canvas.getContext("2d")
		brush.lineWidth=3
		brush.strokeStyle="black"
		brush.beginPath()
		brush.moveTo(...p1)
		if(p1[1]==p2[1]){
			brush.lineTo(...p2)
		}
		else{
			brush.lineTo(p1[0],p1[1]+15)
			brush.lineTo(p2[0],p1[1]+15)
			brush.lineTo(...p2)
		}
		brush.stroke()
		brush=canvas.getContext("2d")
		if(p1[1]==p2[1]){
			if(p1[0] > p2[0]) {
				brush.moveTo(p2[0]-4,p2[1])
				brush.beginPath()
				brush.lineTo(p2[0]+4,p2[1]+4)
				brush.lineTo(p2[0]+4,p2[1]-4)
				brush.lineTo(p2[0]-4,p2[1])
			} else {
				brush.moveTo(p2[0]+4,p2[1])
				brush.beginPath()
				brush.lineTo(p2[0]-4,p2[1]+4)
				brush.lineTo(p2[0]-4,p2[1]-4)
				brush.lineTo(p2[0]+4,p2[1])
			}
		}else{
			brush.moveTo(p2[0],p2[1]+4)
			brush.beginPath()
			brush.lineTo(p2[0]+4,p2[1]-4)
			brush.lineTo(p2[0]-4,p2[1]-4)
			brush.lineTo(p2[0],p2[1]+4)
		}
		brush.closePath()
		brush.fill()
	}
}

$(document).ready(function() {
    var urlParams = new URLSearchParams(window.location.search);
	var equipType = urlParams.get('equiptype');
	var equipName = urlParams.get('equipname');
	if(equipType) {
		document.getElementById(equipType).scrollIntoView()
	}
	if(equipName) {
		$(".equip[data-target="+'"'+".equipRDinfo[data-name='"+ equipName +"']"+'"'+"]")[0].click()
	}
});