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

📄 editor.js

📁 SK信息采集2.0功能介绍: 1.可针对任何静态网页,动态网页进行采集。包括htm,html,shtml,ASP,ASPX,JSP,PHP等。 2.增加自定文件采集.用户可采集网页中的所有文件.
💻 JS
📖 第 1 页 / 共 3 页
字号:
function UpdateToolbar()
{
	var ancestors=null;
	ancestors=GetAllAncestors();
	document.all.ShowObject.innerHTML=' ';
	for (var i=ancestors.length;--i>=0;)
	{
		var el = ancestors[i];
		if (!el) continue;
		var a=document.createElement("span");
		a.href="#";
		a.el=el;
		a.editor=this;
		if (i==0)
		{
			a.className='AncestorsMouseUp';
			EditControl=a.el;
		}
		else a.className='AncestorsStyle';
		a.onmouseover=function()
		{
			if (this.className=='AncestorsMouseUp') this.className='AncestorsMouseUpOver';
			else if (this.className=='AncestorsStyle') this.className='AncestorsMouseOver';
		};
		a.onmouseout=function()
		{
			if (this.className=='AncestorsMouseUpOver') this.className='AncestorsMouseUp';
			else if (this.className=='AncestorsMouseOver') this.className='AncestorsStyle';
		};
		a.onmousedown=function(){this.className='AncestorsMouseDown';};
		a.onmouseup=function(){this.className='AncestorsMouseUpOver';};
		a.ondragstart=YCancelEvent;
		a.onselectstart=YCancelEvent;
		a.onselect=YCancelEvent;
		a.onclick=function()
		{
			this.blur();
			SelectNodeContents(this);
			return false;
		};
		var txt='<'+el.tagName.toLowerCase();
		a.title=el.style.cssText;
		if (el.id) txt += "#" + el.id;
		if (el.className) txt += "." + el.className;
		txt=txt+'>';
		a.appendChild(document.createTextNode(txt));
		document.all.ShowObject.appendChild(a);
	}
}
function SelectNodeContents(Obj,pos)
{
	var node=Obj.el;
	EditControl=node;
	for (var i=0;i<document.all.ShowObject.children.length;i++)
	{
		if (document.all.ShowObject.children(i).className=='AncestorsMouseUp') document.all.ShowObject.children(i).className='AncestorsStyle';
	}
	//Obj.className='AncestorsMouseUp';
	KS_EditArea.focus();
	var range;
	var collapsed=(typeof pos!='undefined');
	range = KS_EditArea.document.body.createTextRange();
	range.moveToElementText(node);
	(collapsed) && range.collapse(pos);
	range.select();
}
function DeleteHTMLTag()
{
	var AvaiLabelDeleteTagName='p,a,div,span';
	if (EditControl!=null)
	{
		var DeleteTagName=EditControl.tagName.toLowerCase();
		if (AvaiLabelDeleteTagName.indexOf(DeleteTagName)!=-1)
		{
			EditControl.parentElement.innerHTML=EditControl.innerHTML;
		}
	}
	UpdateToolbar();
	ShowTableBorders();
}
function InsertRow()
{
	if (CursorInTableCell())
	{
		var SelectColsNum=0;
		var AllCells=SelectedTR.cells;
		for (var i=0;i<AllCells.length;i++)
		{
		 	SelectColsNum=SelectColsNum+AllCells[i].getAttribute('colSpan');
		}
		var NewTR=SelectedTable.insertRow(SelectedTR.rowIndex);
		for (i=0;i<SelectColsNum;i++)
		{
		 	NewTD=NewTR.insertCell();
			NewTD.innerHTML="&nbsp;";
		}
	}
	ShowTableBorders();	
}
function InsertColumn()
{
   	if (CursorInTableCell())
	{
		var MoveFromEnd=(SelectedTR.cells.length-1)-(SelectedTD.cellIndex);
		var AllRows=SelectedTable.rows;
		for (i=0;i<AllRows.length;i++)
		{
			RowCount=AllRows[i].cells.length-1;
			Position=RowCount-MoveFromEnd;
			if (Position<0)
			{
				Position=0;
			}
			NewCell=AllRows[i].insertCell(Position);
			NewCell.innerHTML="&nbsp;";
		}
		ShowTableBorders();
	}	
}
function DeleteRow()
{
	if (CursorInTableCell())
	{
		SelectedTable.deleteRow(SelectedTR.rowIndex);
	}
}
function DeleteColumn()
{
   	if (CursorInTableCell())
	{
		var MoveFromEnd=(SelectedTR.cells.length-1)-(SelectedTD.cellIndex);
		var AllRows=SelectedTable.rows;
		for (var i=0;i<AllRows.length;i++)
		{
			var EndOfRow=AllRows[i].cells.length-1;
			var Position=EndOfRow-MoveFromEnd;
			if (Position<0) Position=0;
			var AllCellsInRow=AllRows[i].cells;
			if (AllCellsInRow[Position].colSpan>1) AllCellsInRow[position].colSpan=AllCellsInRow[position].colSpan-1;
			else AllRows[i].deleteCell(Position);
		}
	}
}
function MergeColumn()
{
	if (CursorInTableCell())
	{
		var RowSpanTD=SelectedTD.getAttribute('rowSpan');
		AllRows=SelectedTable.rows;
		if (SelectedTR.rowIndex+1!=AllRows.length)
		{
			var AllCellsInNextRow=AllRows[SelectedTR.rowIndex+SelectedTD.rowSpan].cells;
			var AddRowSpan=AllCellsInNextRow[SelectedTD.cellIndex].getAttribute('rowSpan');
			var MoveTo=SelectedTD.rowSpan;
			if (!AddRowSpan) AddRowSpan=1;
			SelectedTD.rowSpan=SelectedTD.rowSpan+AddRowSpan;
			AllRows[SelectedTR.rowIndex+MoveTo].deleteCell(SelectedTD.cellIndex);
		}
		else alert('请重新选择');
	}
	ShowTableBorders();
}
function MergeRow()
{
	if (CursorInTableCell())
	{
		var ColSpanTD=SelectedTD.getAttribute('colSpan');
		var AllCells=SelectedTR.cells;
		if (SelectedTD.cellIndex+1!=SelectedTR.cells.length)
		{
			var AddColspan=AllCells[SelectedTD.cellIndex+1].getAttribute('colSpan');
			SelectedTD.colSpan=ColSpanTD+AddColspan;
			SelectedTR.deleteCell(SelectedTD.cellIndex+1);
		}	
	}
}
function SplitRows()
{
	if (!CursorInTableCell()) return;
	var AddRowsNoSpan=1;
	var NsLeftColSpan=0;
	for (var i=0;i<SelectedTD.cellIndex;i++) NsLeftColSpan+=SelectedTR.cells[i].colSpan;
	var AllRows=SelectedTable.rows;
	while (SelectedTD.rowSpan>1&&AddRowsNoSpan>0)
	{
		var NextRow=AllRows[SelectedTR.rowIndex+SelectedTD.rowSpan-1];
		SelectedTD.rowSpan-=1;
		var NcLeftColSpan=0;
		var Position=-1;
		for (var n=0;n<NextRow.cells.length;n++)
		{
			NcLeftColSpan+=NextRow.cells[n].getAttribute('colSpan');
			if (NcLeftColSpan>NsLeftColSpan)
			{
				Position=n;
				break;
			}
		}
		var NewTD=NextRow.insertCell(Position);
		NewTD.innerHTML="&nbsp;";
		AddRowsNoSpan-=1;
	}
	for (var n=0;n<AddRowsNoSpan;n++)
	{
		var numCols=0
		allCells=SelectedTR.cells
		for (var i=0;i<allCells.length;i++) numCols=numCols+allCells[i].getAttribute('colSpan')
		var newTR=SelectedTable.insertRow(SelectedTR.rowIndex+1)
		for (var j=0;j<SelectedTR.rowIndex;j++)
		{
			for (var k=0;k<AllRows[j].cells.length;k++)
			{
				if ((AllRows[j].cells[k].rowSpan>1)&&(AllRows[j].cells[k].rowSpan>=SelectedTR.rowIndex-AllRows[j].rowIndex+1)) AllRows[j].cells[k].rowSpan+=1;
			}
		}
		for (i=0;i<allCells.length;i++)
		{
			if (i!=SelectedTD.cellIndex) SelectedTR.cells[i].rowSpan+=1;
			else
			{
				NewTD=newTR.insertCell();
				NewTD.colSpan=SelectedTD.colSpan;
				NewTD.innerHTML="&nbsp;";
			}
		}
	}
	ShowTableBorders();
}
function SplitColumn()
{
	if (!CursorInTableCell()) return;
	var AddColsNoSpan=1;
	var NewCell=null;
	var NsLeftColSpan=0;
	var NsLeftRowSpanMoreOne=0;
	for (var i=0;i<SelectedTD.cellIndex;i++)
	{
		NsLeftColSpan+=SelectedTR.cells[i].colSpan;
		if (SelectedTR.cells[i].rowSpan>1) NsLeftRowSpanMoreOne+=1;
	}
	var AllRows=SelectedTable.rows;
	while (SelectedTD.colSpan>1&&AddColsNoSpan>0)
	{
		NewCell=SelectedTR.insertCell(SelectedTD.cellIndex+1);
		NewCell.innerHTML="&nbsp;"
		selectedTD.colSpan-=1;
		AddColsNoSpan-=1;
	}
	for (i=0;i<AllRows.length;i++)
	{
		var ncLeftColSpan=0;
		var position=-1;
		for (var n=0;n<AllRows[i].cells.length;n++)
		{
			ncLeftColSpan+=AllRows[i].cells[n].getAttribute('colSpan');
			if (ncLeftColSpan+NsLeftRowSpanMoreOne>NsLeftColSpan)
			{
				position=n;
				break;
			}
		}
		if (SelectedTR.rowIndex!=i)
		{
			if (position!=-1) AllRows[i].cells[position+NsLeftRowSpanMoreOne].colSpan+=AddColsNoSpan;
		}
		else
		{
			for (var n=0;n<AddColsNoSpan;n++)
			{
				NewCell=AllRows[i].insertCell(SelectedTD.cellIndex+1)
				NewCell.innerHTML="&nbsp;"
				NewCell.rowSpan=SelectedTD.rowSpan;
			}
		}
	}
	ShowTableBorders();
}
function InsertHref(Operation)
{
	KS_EditArea.focus();
	KS_EditArea.document.execCommand(Operation,true);
	KS_EditArea.focus();
}
function Pos()   
{
	var ObjReference=null;
	var RangeType=KS_EditArea.document.selection.type;
	if (RangeType!="Control")
	{
		alert('你选择的不是对象!');
		return;
	}
	var SelectedRange= KS_EditArea.document.selection.createRange();
	for (var i=0; i<SelectedRange.length; i++)
	{
		ObjReference = SelectedRange.item(i);
		if (ObjReference.style.position != 'absolute') 
		{
			ObjReference.style.position='absolute';
		}
		else
		{
			ObjReference.style.position='static';
		}
	}
	KS_EditArea.content = false;
}
function CursorInTableCell()
{
	if (KS_EditArea.document.selection.type!="Control")
	{
		var SelectedElement=KS_EditArea.document.selection.createRange().parentElement();
		while (SelectedElement.tagName.toUpperCase()!="TD"&&SelectedElement.tagName.toUpperCase()!="TH")
		{
			SelectedElement=SelectedElement.parentElement;
			if (SelectedElement==null) break;
		}
		if (SelectedElement)
		{
			SelectedTD=SelectedElement;
			SelectedTR=SelectedTD.parentElement;
			SelectedTBODY=SelectedTR.parentElement;
			SelectedTable=SelectedTBODY.parentElement;
			return true;
		}
	}
}
function PasteText()
{
	KS_EditArea.focus();
	var sText = HTMLEncode(clipboardData.getData("Text")) ;
	InsertHTMLStr(sText);
	KS_EditArea.focus();
}
function SearchStr(InstallDir)
{
  var Temp=window.showModalDialog(InstallDir+"Editor/InsertSearch.asp", window, "dialogWidth:340px; dialogHeight:190px; help: no; scroll: no; status: no");
}
//Change EditArea Height
function ChangeEditAreaHeight(KS_EditAreaHeight)
{ 
  for (var i=0; i<parent.frames.length; i++)
  {
			if (parent.frames[i].document==self.document)
			  {
				var obj=parent.frames[i].frameElement;
				var height = parseInt(obj.offsetHeight)+KS_EditAreaHeight;
				if (height+KS_EditAreaHeight>=100)
				{
				obj.height = height;
				}
			  }
	}
}
//editor Btn Click Event Function End.
function DisabledAllBtn(Flag)
{
	var AllBtnArray=document.body.getElementsByTagName('IMG'),CurrObj=null;
	for (var i=0;i<AllBtnArray.length;i++)
	{
		CurrObj=AllBtnArray[i];
		if (CurrObj.className=='Btn') CurrObj.disabled=Flag;
	}
	AllBtnArray=document.body.getElementsByTagName('SELECT');
	for (var i=0;i<AllBtnArray.length;i++)
	{
		CurrObj=AllBtnArray[i];
		if (CurrObj.className=='ToolSelectStyle') CurrObj.disabled=Flag;
	}
}

⌨️ 快捷键说明

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