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

📄 viewdoc.js

📁 hudong维客系统
💻 JS
📖 第 1 页 / 共 2 页
字号:
var wikilinkno;
var xmlHttp;
var currentPos = null;
var dataDiv;
var dataTable;
var dataTableBody;
var curX=0,curY=0;
var gDivMoveFlag = false;//是否需要移动DIV
var gDisplayFlag = false;//是否需要钉住DIV
var gUpdateFlag = true;//是否需要更新DIV中的数据
var gDoctitle = null;//当前条目的标题
var gCurWidth=0,gCurHeight=0;//鼠标和DIV的坐标的差值。
window.onload=initVars;
var linktype=0;

function send_request(url) {//初始化、指定处理函数、发送请求的函数
  xmlHttp = false;
  //开始初始化XMLHttpRequest对象
  createXMLHttpRequest();
  xmlHttp.onreadystatechange = processRequest;
  // 确定发送请求的方式和URL以及是否同步执行下段代码
  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);
}

function handle_mouseover_IE()
{
  if (!gUpdateFlag)  return;
  showDocSummary_IE(this,this.getAttribute("linktype"));
  gUpdateFlag = false;
}

 
function handle_mouseover()
{
  if (!gUpdateFlag) 
    return;
  showDocSummary(this.getAttribute("linktype"));
  gUpdateFlag = false;
}

// 处理返回信息的函数
  function processlinks() {
      //取得条目内容里的所有内部链接
      var links=document.links;
      var total=links.length;
      for (i=0;i<total;i++){
         var vhref=null;
         try{
           vhref=links[i].href;
           if(IE){cssName=links[i].getAttribute("className");}else{cssName=links[i].getAttribute("class");}
           if(cssName!="innerlink"&&cssName!="outerlink")continue;
         } catch (e){continue;}
         if(vhref!=null){
         	linktype=0;
         	if (vhref.indexOf("doc.php?action=view&title=")!=-1) linktype=1;	
          	if (vhref.indexOf("http://www.hoodong.com/entryview.do?doc_title=")!=-1) linktype=2;
          	if(linktype!=0){
            	wikilinkno="wikilink"+i;  
	            if(IE==true){
	            	links[i].onmouseover=handle_mouseover_IE;
	               	links[i].setAttribute("target","_blank");
	               	links[i].setAttribute("linktype",linktype);
	               	links[i].onmouseout=function (){gUpdateFlag = true;}
	            }else{
	               	links[i].setAttribute("target","_blank");
	               	links[i].setAttribute("linktype",linktype);
	               	links[i].setAttribute("id",wikilinkno);
	               	links[i].onmouseover = handle_mouseover;
	               	links[i].onmouseout=function (){gUpdateFlag = true;}
	            }
	        }
	        linktype=0;
         }
      }
  }


        function initVars() {
          if (document)
            dataTableBody = document.getElementById("summaryDataBody");           
            dataTable = document.getElementById("summaryData");
            dataDiv = document.getElementById("popup");
            dataDiv.onmouseleave = onMouseLeave;  
            dataDiv.onmousedown = onMouseDown;
            dataDiv.onmouseup = onMouseUp;
            document.onmousemove = onMouseMove;
            processlinks();
        }
        
        //当鼠标离开时,除钉住或正在移动外,关闭DIV
        function onMouseLeave(){
          if (gDisplayFlag || gDivMoveFlag)
            return ; 
            clearData();
        }
        //当鼠标在DIV中按下时,1.移动DIV标记打开,2.记录鼠标和DIV的坐标的差值,3.更改鼠标的形状,4.禁止鼠标选中对象
        function onMouseDown(){
          gDivMoveFlag = true;
          if(IE==true)
            getCursor(event);
          else {  
            try {
             window.constructor.prototype.__defineGetter__("event", window_prototype_get_event);
            }catch(e) {}
          
            curX = event.pageX;
            curY = event.pageY; 
          }
          gCurWidth = curX - parseInt(dataDiv.style.left);
          gCurHeight = curY - parseInt(dataDiv.style.top);//alert(gCurWidth+"  "+gCurHeight);
          dataDiv.style.cursor="hand";
          document.onselectstart=new Function("event.returnValue=false");
        }
        //当鼠标在DIV中松开时,1.移动DIV标记关闭,2.更改鼠标的形状,3.取消禁止鼠标选中对象
        function onMouseUp(){
          gDivMoveFlag = false;
          dataDiv.style.cursor="default";
          document.onselectstart=new Function("event.returnValue=true");
        } 
        //当鼠标移动并且移动DIV标记打开时,移动DIV
        function onMouseMove(){       
          if (!gDivMoveFlag)
            return ; 
          if(IE==true)
            getCursor(event);
          else {  
            try {
             window.constructor.prototype.__defineGetter__("event", window_prototype_get_event);
            }catch(e) {}
          
            curX = event.pageX;
            curY = event.pageY; 
          }
          dataDiv.style.left = (curX-gCurWidth) + "px";
          dataDiv.style.top = (curY-gCurHeight) + "px";
        }
        function showDocSummary(ltype){
          try {
           window.constructor.prototype.__defineGetter__("event", window_prototype_get_event);
          }catch(e) {}
        
          curX = event.pageX;
          curY = event.pageY;

	    	var tempObj = event.target;
			var docTitle=tempObj.firstChild.data;
			if (0 == docTitle.Trim().length)
				return;
			while(tempObj.nodeName.toUpperCase() != "A"){
				tempObj = tempObj.parentNode;
			}  
		
		  createXMLHttpRequest();
		  offsetEl = tempObj;
		  var vhref=tempObj.href;
		  
		  if(ltype=='1'){
            	if (vhref.substring(vhref.lastIndexOf("=")+1,vhref.length) != docTitle){
					tempObj.href = vhref.substring(0,vhref.lastIndexOf("=")+1) + docTitle; 
				}
          }else if(ltype=='2'){
            	if (vhref.substring(vhref.indexOf("=")+1,vhref.length) != docTitle){
					tempObj.href = vhref.substring(0,vhref.indexOf("=")+1) + docTitle; 
				}	
          }
          
          var str =""; 
			var url = "";
	        
	        if(ltype=='1'){
	        	str = tempObj.href.substring(vhref.indexOf("title=")+6,vhref.length);
	           	url = "doc.php?action=insummary&title="+ str;
	        }
	        
	        if(ltype=='2'){
	        	str = tempObj.href.substring(vhref.indexOf("doc_title=")+10,vhref.length);
	        	url = "doc.php?action=outsummary&title="+ str;
	        }
  
	        
			if (docTitle == gDoctitle && dataDiv.style.visibility == "visible")
				return;
			gDoctitle = docTitle;
					
          xmlHttp.open("GET", url, true);
          xmlHttp.onreadystatechange = callback;
          xmlHttp.send(null);
        }
        
        function window_prototype_get_event()
        {
         var func = arguments.callee.caller; 
         var evt; 
         while(func != null){
          evt = func.arguments[0]; 
          if(evt && (evt.constructor == Event || evt.constructor == MouseEvent)) return evt; 
          func = func.caller; 
         } 
         return null; 
        }       
              
        function showDocSummary_IE(element,ltype) {

        	getCursor(event);           
            createXMLHttpRequest();
            offsetEl = element;
            
            var FLAG = "";
            
            if(ltype=='1'){
            	FLAG = "doc.php?action=view&title=";
            }
            
            if(ltype=='2'){
            	FLAG = "http://www.hoodong.com/entryview.do?doc_title=";
            }

                       
        	var vhref = element.href;
        	var beginPos = vhref.indexOf(FLAG);
        	if (beginPos < 0)
        		return;
        	var docTitle = vhref.substring(beginPos + FLAG.length, vhref.length);	
            //var docTitle=element.innerText;

			if (docTitle == gDoctitle && dataDiv.style.visibility == "visible")
				return;
			gDoctitle = docTitle;  

            var vhref=element.href;
            
            if(ltype=='1'){
            	if (vhref.substring(vhref.lastIndexOf("=")+1,vhref.length) != docTitle){
					element.href = vhref.substring(0,vhref.lastIndexOf("=")+1) + docTitle; 
				}
            }else if(ltype=='2'){
            	if (vhref.substring(vhref.indexOf("=")+1,vhref.length) != docTitle){
					element.href = vhref.substring(0,vhref.indexOf("=")+1) + docTitle; 
				}	
            }
            			
  			var str =""; 
  			var url = "";
            
            if(ltype=='1'){
            	str = element.href.substring(vhref.indexOf("title=")+6,vhref.length);
               	url = "doc.php?action=insummary&title="+ str;
            }

⌨️ 快捷键说明

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