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

📄 howave_index.js

📁 具有的功能适合于网站的运营和管理
💻 JS
📖 第 1 页 / 共 4 页
字号:
var mouseOffset = null;
var iMouseDown  = false;
var lMouseState = false;
var dragObject  = null;
var DragDrops   = [];
var curTarget   = null;
var lastTarget  = null;
var dragHelper  = null;
var tempDiv     = null;
var rootParent  = null;
var rootSibling = null;
var layoutType="normal";
var slectType="Drag";
var rss_description=[];
var now = new Date();
var nextmonth = new Date(now.getYear(),now.getMonth()+1, now.getDate());
var DragBoxArray=new Array();
var userChannel=new Array();
Number.prototype.NaN0=function(){return isNaN(this)?0:this;}

function CreateDragContainer(){
	var cDrag        = DragDrops.length;
	DragDrops[cDrag] = [];
    var _ContainerArray_=document.getElementsByClassName("DragContainer");	
	  for (var i=0; i<_ContainerArray_.length; i++) {	 	
		 var cObj = _ContainerArray_[i];
		 DragDrops[cDrag].push(cObj);
		 cObj.setAttribute('DropObj', cDrag);

		for(var j=0; j<cObj.childNodes.length; j++){

			if(cObj.childNodes[j].nodeName=='#text') continue;

			cObj.childNodes[j].setAttribute('DragObj', cDrag);
			
		}
	}
}


function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}

function getMouseOffset(target, ev){
	ev = ev || window.event;
	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
	
}

function getPosition(e){
	var left = 0;
	var top  = 0;
	while (e.offsetParent){
		left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
		top  += e.offsetTop  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
		e     = e.offsetParent;
	}

	left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
	top  += e.offsetTop  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
	return {x:left, y:top};
}


function mouseMove(ev){
	ev         = ev || window.event;
	var target   = ev.target || ev.srcElement;
	var mousePos = mouseCoords(ev);
	if(lastTarget && (target!==lastTarget)){
		var origClass = lastTarget.getAttribute('origClass');
		if(origClass) lastTarget.className = origClass;
	}

	var dragObj = target.getAttribute('DragObj');
	if(dragObj!=null){
		if(target!=lastTarget){
			var oClass = target.getAttribute('overClass');
			if(oClass){
				target.setAttribute('origClass', target.className);
				target.className = oClass;
			}
		}


		if(iMouseDown && !lMouseState){
			if((target.id).indexOf("_title")>0){
			  var __dragBox__Id= (target.id).substring(0,(target.id).indexOf("_title"));
			  target=document.getElementById(__dragBox__Id);
			  dragObj= target.getAttribute('DragObj');
			}
			curTarget     = target;
			rootParent    = curTarget.parentNode;
			rootSibling   = curTarget.nextSibling;
			mouseOffset   = getMouseOffset(target, ev);
			for(var i=0; i<dragHelper.childNodes.length; i++) dragHelper.removeChild(dragHelper.childNodes[i]);	
			dragHelper.appendChild(curTarget.cloneNode(true));			
			dragHelper.style.width=curTarget.clientWidth;
			dragHelper.style.display = 'block';
			var dragClass = curTarget.getAttribute('dragClass');
			if(dragClass){				    
				dragHelper.firstChild.className = dragClass;	
				
			}

			dragHelper.firstChild.removeAttribute('DragObj');
			var dragConts = DragDrops[dragObj];
			curTarget.setAttribute('startWidth',  parseInt(curTarget.offsetWidth));
			curTarget.setAttribute('startHeight', parseInt(curTarget.offsetHeight));	
			curTarget.style.display  = 'block';
			if(layoutType=="normal"){			
			    for(var i=0; i<dragConts.length; i++){    			 
				    with(dragConts[i]){
					    var pos = getPosition(dragConts[i]);					  
					    setAttribute('startWidth',  parseInt(offsetWidth));
					    setAttribute('startHeight', parseInt(offsetHeight));
					    setAttribute('startLeft',   pos.x);
					    setAttribute('startTop',    pos.y);
				    }

				  
				    for(var j=0; j<dragConts[i].childNodes.length; j++){
					    with(dragConts[i].childNodes[j]){
						    if((nodeName=='#text') || (dragConts[i].childNodes[j]==curTarget)) continue;
						    var pos = getPosition(dragConts[i].childNodes[j]);
						    setAttribute('startWidth',  parseInt(offsetWidth));
						    setAttribute('startHeight', parseInt(offsetHeight));
						    setAttribute('startLeft',   pos.x);
						    setAttribute('startTop',    pos.y);
					    }
				    }
				}
			}
		}
	}

	if(curTarget){
		
		dragHelper.style.top  = mousePos.y - mouseOffset.y;
		dragHelper.style.left = mousePos.x - mouseOffset.x; 
		var dragConts  = DragDrops[curTarget.getAttribute('DragObj')];
		var activeCont = null;

		var xPos = mousePos.x - mouseOffset.x + (parseInt(curTarget.getAttribute('startWidth')) /2);
		var yPos = mousePos.y - mouseOffset.y + (parseInt(curTarget.getAttribute('startHeight'))/2);		
		for(var i=0; i<dragConts.length; i++){
			with(dragConts[i]){
				if(((getAttribute('startLeft'))                               < xPos) &&
					((getAttribute('startTop'))                                < yPos) &&
					((getAttribute('startLeft') + getAttribute('startWidth'))  > xPos) &&
					((getAttribute('startTop')  + getAttribute('startHeight')) > yPos)&&layoutType=="normal"){
						
						curTarget.style.border='dashed 1px gray';						
						for(var m=0;m<curTarget.childNodes.length;m++)
							(curTarget.childNodes[m]).style.visibility='hidden';
						activeCont = dragConts[i];
						break;
				}				
			}
		}

		
		if(activeCont){		
			if(layoutType=="normal"){
			    var beforeNode = null;
			    for(var i=activeCont.childNodes.length-1; i>=0; i--){
				    with(activeCont.childNodes[i]){
					    if(nodeName=='#text') continue;
					    if(
						   ( curTarget != activeCont.childNodes[i]                              &&
						    ((getAttribute('startLeft') + getAttribute('startWidth'))  > xPos) )&&
						    ((getAttribute('startTop') + getAttribute('startHeight'))  > yPos)){
							    beforeNode = activeCont.childNodes[i];    						
					    }
    					
				    }
			    }
			    
			    if(beforeNode){
				    if(beforeNode!=curTarget.nextSibling){
					    activeCont.insertBefore(curTarget, beforeNode);
				    }
			    
			    } else {
				    if((curTarget.nextSibling) || (curTarget.parentNode!=activeCont)){
					    activeCont.appendChild(curTarget);
				    }
			    }
			   
			    if(curTarget.style.display!=''){
				    curTarget.style.display  = '';
			    }
			}			
			
		} else {			
			if(curTarget.style.display!='none'){
				curTarget.style.display  = 'none';
			}
		}
		
	}

	lMouseState = iMouseDown;	
	lastTarget  = target;	
	lMouseState = iMouseDown;	
	return false;
}

function mouseUp(ev){
	if(curTarget){		
		curTarget.style.top  = dragHelper.style.top;
		curTarget.style.left = dragHelper.style.left;
		dragHelper.style.display = 'none';		
		dragHelper.removeChild(dragHelper.childNodes[0]);		
		if(curTarget.style.display == 'none'){
			if(rootSibling){
				rootParent.insertBefore(curTarget, rootSibling);
			} else {
				rootParent.appendChild(curTarget);
			}
		}		
		curTarget.style.display = '';
		curTarget.style.border='0';
		for(var m=0;m<curTarget.childNodes.length;m++)
			(curTarget.childNodes[m]).style.visibility='visible';
	}
	curTarget  = null;
	iMouseDown = false;	
}

function mouseDown(){  
   var el = getReal(event.srcElement, "className", "dragBoxContent");
   if (el == null) {    
      iMouseDown = true;
	  if(lastTarget){	 
		return false;
	 }
   } 
   else{ 
     doDown();
   }
}

var theobject = null;
function resizeObject() {
 this.el        = null; 
 this.dir    = "";     
 this.grabx = null;     
 this.graby = null;
 this.width = null;
 this.height = null;
 this.left = null;
 this.top = null;
}
 
function getDirection(el) {
 var xPos, yPos, offset, dir;
 dir = "";
 xPos = window.event.offsetX;
 yPos = window.event.offsetY;
 offset = 8; 
 if (yPos<offset) dir += "n";
 else if (yPos > el.offsetHeight-offset) dir += "s";
 if (xPos<offset) dir += "w";
 else if (xPos > el.offsetWidth-offset) dir += "e";
 return dir;
}

function doDown() {
 var el = getReal(event.srcElement, "className", "dragBoxContent");
 if (el == null) {
  theobject = null;
  return;
 }  
 dir = getDirection(el);
 if (dir == "") return;
 
 theobject = new resizeObject(); 
 theobject.el = el;
 theobject.dir = dir;
 theobject.grabx = window.event.clientX;
 theobject.graby = window.event.clientY;
 theobject.width = el.offsetWidth;
 theobject.height = el.offsetHeight;
 theobject.left = el.offsetLeft;
 theobject.top = el.offsetTop;
 window.event.returnValue = false;
 window.event.cancelBubble = true;
}

function doUp() {
 if (theobject != null) {
  theobject = null; 
 }
}

function doMove() {
 var el, xPos, yPos, str, xMin, yMin;
 xMin = 8; 
 yMin = 8; 
 el = getReal(event.srcElement, "className", "dragBoxContent");
 if(el!=null){

⌨️ 快捷键说明

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