⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgtree.js

📁 论坛BBS
💻 JS
📖 第 1 页 / 共 2 页
字号:
	var cm = findNode(el.tree, loc);
	if (cm == null) return;		// No valid message

	var nm = getNextTopThread(cm);

	if (nm != null && nm.href != null)
		nm.html.all.tags("A")[0].click();
}

function markTree(inputNode) {
	var el = document.all.messageTree;
	
	var loc = inputNode.parentElement.children.tags("A")[0].href;
	
	var cm = findNode(el.tree, loc);

	if (cm == null) return;		// No valid message
	
	markTree2(cm, inputNode.status);
		
}

function markTree2(node, marked) {
	if (marked) {
		var	nc = node.children;
		if (nc.length > 0) {
			for (var i=0; i < nc.length; i++) {
				var inputNode = nc[i].html.children.tags("INPUT")[0];
				inputNode.status = true;
				addToIdList(inputNode);
				markTree2(nc[i], true);
			}
		}
	}
	else if (node.parent.html != null) {
		var parentInputNode = node.parent.html.children.tags("INPUT")[0];
		parentInputNode.status = false;
		addToIdList(parentInputNode);
		markTree2(node.parent, false);
	}
}

function findNode(t, href) {
	if (t == null) return null;
	if (t.href != null && href != null && t.href == href) {
		return t;
	}
	else {
		for (var i=0; i<t.children.length; i++) {
			var ans = findNode(t.children[i], href);
			if (ans != null)
				return ans;
		}
	}
}

function getNextSibbling(cm) {
	if (cm == null) return;
	var ns = cm.nextSibbling();
	if (ns != null)
		return ns;
	else 
		return getNextSibbling(cm.parent);
}
			
function getNextTopThread(cm) {
	if (cm.parent.href == "")
		return cm.nextSibbling();
	else
		return getNextTopThread(cm.parent);
}

function addToIdList(inputNode) {
	var href = inputNode.parentElement.children.tags("A")[0].href;
	var index = href.indexOf("id=");
	var id = href.substring(index+3,href.length);
	parent.toolframe.idList["_" + id] = inputNode.status;
	parent.toolframe.checkDeleteButtonStatus();
}

function hideItem(plusEl) {
		var el = plusEl.parentElement;
		
		var children = el.children;
		var childrenLength = children.length;
		
		for (var i=0; i<childrenLength; i++) {
			var child = children.item(i);
			if (child.className == "item") {
				child.style.display = "none";
				plusEl.innerHTML = plusString;
			}
		}
}

function showItem(plusEl) {
		var el = plusEl.parentElement;
		
		var children = el.children;
		var childrenLength = children.length;
		
		for (var i=0; i<childrenLength; i++) {
			var child = children.item(i);
			if (child.className == "item") {
				child.style.display = "block";
				plusEl.innerHTML = minusString;
			}
		}
}


// These two functions describe how the items should look when highlighted

function highLight(el) {
	if (ieVersion() == 5) {
		el.style.background = "highlight";
		el.style.color = "highlighttext";
	}
}

function unHighLight(el) {
	if (ieVersion() == 5) {
		el.style.background = ""; //"window";
		el.style.color = "windowtext";
	}
}

function numberOfChildItems() {
	var itemDivs = new Array();
	var index = 0;

	var divs = document.all.tags("DIV");
	var divsLength = divs.length;

	for (var i=0; i<divsLength; i++) {
		if (divs[i].className == "item")
			itemDivs[index++] = divs[i];
	}
	
	var itemsLength = itemDivs.length;
	for (i=0; i<itemsLength; i++) {
		itemChildren = getChildren(itemDivs[i]);

		var atag = itemDivs[i].children.tags("A")[0]
		var subjectSpan = atag.children[0];
		var nameSpan = atag.children[1];
		var dateSpan = atag.children[2];

		atag.title = subjectSpan.innerText + "\n" + nameSpan.innerText + "\n" + dateSpan.innerText;

		if (itemChildren > 0 && showNumberOfReplys) {

			subjectSpan.innerHTML += replysStartTag + itemChildren + replysEndTag;
		}
	}
}

function getChildren(el) {
	var l = el.children.tags("DIV").length;

	if (l == 0)
		return 0;
	else {
		var ec = el.children.tags("DIV");
		var ecl = ec.length
		for (var i=0; i < ecl; i++) {
			l += getChildren(ec[i]);
		}
		return l;
	}
}

function fixSubPadding(depth) {
	var str2, val;
	
	var width = document.all("messageHeader").offsetWidth/2 ;//300;

	for (var i=0; i < depth; i++) {
		str2 = "";
		val  = 0;
		for (var j=0; j < i; j++) {
			str2 += ".item "
			val += 18;
		}
		document.styleSheets[0].addRule(str2 + ".plus", "width: " + val);
		document.styleSheets[0].addRule(str2 + ".subject", "width: " + (width - val));
	}
}

function fixScrollDivSize() {
//	alert(document.body.clientHeight - messageHeader.offsetHeight)
	document.styleSheets[0].addRule("#scrollDiv", "height: " + (document.body.clientHeight - messageHeader.offsetHeight));
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// treeSort.js	This is a rewriting of the tableSort script available at BigMole
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
var ie5 = (document.all && document.getElementsByTagName);

if (ie5)
	initSortTree();

var arrowUp, arrowDown;

function initSortTree() {
// Note that the class arrow should be defined in the css
	arrowUp = document.createElement("SPAN");
	var tn = document.createTextNode("6");
	arrowUp.appendChild(tn);
	arrowUp.className = "arrow";

	arrowDown = document.createElement("SPAN");
	var tn = document.createTextNode("5");
	arrowDown.appendChild(tn);
	arrowDown.className = "arrow";
}


function sortBy(type) {
	if (ie5) {
		if (document.all.startArrow != null) {
			sentHeader._descending = true;
			startArrow.parentNode.removeChild(startArrow);
		}
		var el = document.getElementById(type + "Header");
		sortTree(el, messageTree.childNodes[0], type);
	}
}

function sortByColumn(srcEl, type, bDesc) {
	sortTree(srcEl, messageTree, type, bDesc);
}

function sortTree(srcEl, treeNode, type, bDesc) {
	var el = srcEl;
	
	if (el == null)
		return;

	if (bDesc != null)
		el._descending = bDesc;
	else
		if (el._descending)	// catch the null
			el._descending = false;
		else
			el._descending = true;
		
	if (treeNode.arrow != null) {
		if (treeNode.arrow.parentNode != el) {
			treeNode.arrow.parentNode._descending = null;	//reset sort order		
		}
		treeNode.arrow.parentNode.removeChild(treeNode.arrow);
	}
	
	if (el._descending)
		treeNode.arrow = arrowDown.cloneNode(true);
	else
		treeNode.arrow = arrowUp.cloneNode(true);
		
	el.appendChild(treeNode.arrow);

	var trs = treeNode.childNodes;
	var a = new Array();
	
	for (var i=0; i<trs.length-1; i++) {	// First is empty
		a[i] = trs[i+1];
	}
	
	a.sort(compareByColumn(type,el._descending));
	
	for (var i=0; i<a.length; i++) {
		treeNode.appendChild(a[i]);
	}
}

function compareByColumn(type, bDescending) {
	var t = type;
	var d = bDescending;

	function _compareSent(n1,n2) {
		if (n1.date > n2.date)
			return (d) ? -1 : +1;
		else if (n1.date < n2.date)
			return (d) ? +1 : -1;
		else 
			return 0;
	}

	function _compareSubject(n1,n2) {
		if (n1.innerText.toLowerCase() < n2.innerText.toLowerCase())
			return (d) ? -1 : +1;
		else if (n1.innerText.toLowerCase() > n2.innerText.toLowerCase())
			return (d) ? +1 : -1;
		else 
			return 0;
	}
	
	function _compareFrom(n1,n2) {
		if (n1.childNodes[1].childNodes[1].innerText.toLowerCase() < n2.childNodes[1].childNodes[1].innerText.toLowerCase())
			return (d) ? -1 : +1;
		else if (n1.childNodes[1].childNodes[1].innerText.toLowerCase() > n2.childNodes[1].childNodes[1].innerText.toLowerCase())
			return (d) ? +1 : -1;
		else 
			return 0;
	}

	function _compareFromAdmin(n1,n2) {
		if (n1.childNodes[2].childNodes[1].innerText.toLowerCase() < n2.childNodes[2].childNodes[1].innerText.toLowerCase())
			return (d) ? -1 : +1;
		else if (n1.childNodes[2].childNodes[1].innerText.toLowerCase() > n2.childNodes[2].childNodes[1].innerText.toLowerCase())
			return (d) ? +1 : -1;
		else 
			return 0;
	}
	switch (type) {
		case "sent":
		return _compareSent;
		
		case "subject":
		return _compareSubject;
		
		case "from":
		if (document.body.password != null)
			return _compareFromAdmin;
		else
			return _compareFrom;
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// end treeSort.js
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -