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

📄 showforum.js

📁 基于Windows平台的ASP.net框架
💻 JS
字号:
function validate(theform, previewpost, switcheditormode) {
	if (theform.title.value == "" || theform.message.value == "") {
		alert("请完成标题和内容栏。");
		return false;
	} else if (theform.title.value.length > 60) {
		alert("您的标题超过 60 个字符的限制。");
		theform.title.focus();
		return false;
	}
		
	if (!disablepostctrl && ((postminchars != 0 && theform.message.value.length < postminchars) || (postmaxchars != 0 && theform.message.value.length > postmaxchars))) {
		alert("您的帖子长度不符合要求。\n\n当前长度: "+theform.message.value.length+" 字节\n系统限制: "+postminchars+" 到 "+postmaxchars+" 字节");
		return false;
	}
	
	if (!previewpost && !switcheditormode){
		theform.replysubmit.disabled = true;
	}
	return true;

}


function gotopage(topicid,index){
	page = parseInt(document.getElementById("divInput_pagenumber_" + topicid).value);
	if (is_ie){
		curpage = parseInt(document.getElementById("div_curpage_" + topicid).innerText);
		total = parseInt(document.getElementById("div_Totalpage_" + topicid).innerText);
	}
	else{
		curpage = parseInt(document.getElementById("div_curpage_" + topicid).textContent);
		total = parseInt(document.getElementById("div_Totalpage_" + topicid).textContent);
	}
	if (!(parseInt(page)==page && page>0)){
		alert("页码无效");
		return false;
	}
	
	if (!(parseInt(curpage)==curpage && curpage>0)){
		curpage = page;
	}
	
	if (!(parseInt(total)==total && total>0)){
		alert("总页码无效");
		return false;
	}
	
	if (curpage>total || curpage < 1){
		alert("页码无效");
		return false;
	}
	
	
	switch (index){
		case 1:
			if (page-1<1){
				alert("已经是第一页");
				return false
			}
			document.getElementById("divFollow_" + topicid + "_" + curpage).style.display="none";
			document.getElementById("divFollow_" + topicid + "_" + (curpage-1)).style.display="block";
			document.getElementById("divInput_pagenumber_" + topicid).value = curpage - 1;
			break;
		case 2:
			if (page+1>total){
				alert("已经到达最后一页");
				return false
			}
			document.getElementById("divFollow_" + topicid + "_" + curpage).style.display="none";
			document.getElementById("divFollow_" + topicid + "_" + (parseInt(curpage) +1)).style.display="block";
			document.getElementById("divInput_pagenumber_" + topicid).value = parseInt(curpage) + 1;
			break;
		case 3:
			if (page>total || page<1){
				alert("页码应在 1-" + total + " 之间");
				return false
			}
			document.getElementById("divFollow_" + topicid + "_" + curpage).style.display="none";
			document.getElementById("divFollow_" + topicid + "_" + page).style.display="block";
			break;
	}
	if (is_ie){
		document.getElementById("div_curpage_" + topicid).innerText = document.getElementById("divInput_pagenumber_" + topicid).value;
	}
	else{
		document.getElementById("div_curpage_" + topicid).textContent = document.getElementById("divInput_pagenumber_" + topicid).value;
	}
}

function writetree(obj,topicid,ppp){
	var td = document.getElementById("tdTopicFollow" + topicid);

	var err = obj.getElementsByTagName('error');
	if (err[0] != null && err[0] != undefined)
	{
		var errdiv = document.createElement("DIV");
		errdiv.className='errcontext';

	    if (err[0].childNodes.length > 1) {
		    errdiv.innerHTML = '<div style="margin: 0px 15px 0px 40px;">' + err[0].childNodes[1].nodeValue + '</div>';
		} else {
		    errdiv.innerHTML = '<div style="margin: 0px 15px 0px 40px;">' + err[0].firstChild.nodeValue + '</div>';    		
		}

		td.appendChild(errdiv);
		document.getElementById("trTopicFollow" + topicid).style.display = "";
		document.getElementById("divShowContext_" + topicid).style.display = "none";
		return;
	}

	var dataArray = obj.getElementsByTagName('post');
	var dataArrayLen = dataArray.length;
	
		var page = 0;
		var divIsShow = "block";
		for(i=0;i<dataArrayLen;i++){
			page ++;
			div = document.createElement("DIV");
			div.id = "divFollow_" + topicid + "_" + page;
			div.style.display = divIsShow;
			div.style.lineHeight = "180%";
			var list = "";
			for (j=0;j<10;j++){
				list += "<li><a href=\"showtopic-";
				list += topicid;
				if (ppp>0){
					list += "-";
					list += Math.ceil((i+2)/ppp);
				}
				list += ".aspx#";
				list += dataArray[i].getAttribute("pid");
				list +="\">";
				list += dataArray[i].getAttribute("message").substring(0,50);
				list += "</a>&nbsp; --- &nbsp; (<a target=\"_blank\" href=\"userinfo.aspx?userid=";
				list += dataArray[i].getAttribute("posterid");
				list += "\">";
				list += dataArray[i].getAttribute("poster");
				list += "</a> 发表于 ";
				list += dataArray[i].getAttribute("postdatetime");
				list += ")</li>";
				i++;
				if (i>=dataArrayLen){
					break;
				}
			}
			if ( list != "" )
			{
			
				i--;
				
			}
			div.innerHTML = list;
			divIsShow = "none";
			td.appendChild(div);
		}
		div = document.createElement("DIV");
		div.id = "divFollow_page_" + topicid;
		div.style.marginTop = "5px"
		div.innerHTML = "页数:<span id=\"div_curpage_" + topicid + "\">1</span>/<span id=\"div_Totalpage_" + topicid + "\">" + page + "</span>&nbsp;&nbsp;&nbsp;<span onclick=\"gotopage(" + topicid + ",1);\" style=\"cursor:pointer;\" title=\"上一页\"><img src=\"templates/" + templatepath + "/images/prev.gif\" /></span>&nbsp;<input type=\"text\" id=\"divInput_pagenumber_" + topicid + "\" value=\"1\" size=\"3\" style=\"text-align:center\" class=\"colorblur\" onKeyDown=\"if(event.keyCode==13) { gotopage(" + topicid + ",3); return false; }\">&nbsp;<span onclick=\"gotopage(" + topicid + ",2);\" style=\"cursor:pointer;\" title=\"下一页\"><img src=\"templates/" + templatepath + "/images/next.gif\" /></span>"
		td.appendChild(div);
		document.getElementById("trTopicFollow" + topicid).style.display = "";
		document.getElementById("divShowContext_" + topicid).style.display = "none";

}

function showtree(topicid,ppp){
	var imgsrcCol = "templates/" + templatepath + "/images/topItem_col.gif";
	var imgsrcExp = "templates/" + templatepath + "/images/topItem_exp.gif"

	if (!document.getElementById("trTopicFollow" + topicid)){
		var tr = document.getElementById("trTopic" + topicid);
		var table = document.getElementById("category_" + fid);
		
			tr = table.insertRow(tr.rowIndex+1);
			tr.id="trTopicFollow" + topicid;
			tr.className = "row"
			tr.style
			td = tr.insertCell(-1);
			td.innerHTML = "&nbsp;";
			td = tr.insertCell(-1);
			td.innerHTML = "&nbsp;";
			td =  tr.insertCell(-1);
			td.id = "tdTopicFollow" + topicid;
			td.colSpan = 5;

			div = document.createElement("DIV");
			div.id = "divShowContext_" + topicid;
			
			div.innerHTML = "正在生成回复列表,请稍等...";
			td.appendChild(div);
			
			ajaxRead("tools/ajax.aspx?t=topictree&topicid=" + topicid, "writetree(obj," + topicid + "," + ppp + ");");
	}
	
	if (document.getElementById("imgButton_" + topicid).src.indexOf(imgsrcCol)!=-1){	
		document.getElementById("imgButton_" + topicid).src = imgsrcExp;
		document.getElementById("imgButton_" + topicid).alt = "展开帖子列表";
		document.getElementById("imgButton_" + topicid).title = "展开帖子列表";

		document.getElementById("trTopicFollow" + topicid).style.display = "none";
	}
	else{
		document.getElementById("imgButton_" + topicid).src = imgsrcCol;
		document.getElementById("imgButton_" + topicid).alt = "关闭帖子列表";
		document.getElementById("imgButton_" + topicid).title = "关闭帖子列表";
		if (document.getElementById("trTopicFollow" + topicid)){
			document.getElementById("trTopicFollow" + topicid).style.display = "";
		}
	}
	
}

⌨️ 快捷键说明

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