?? xml.js
字號:
var curSelectColor ="A2A200";//"A2A200"; 光標按下和選擇時的顏色
var curPassColor ="#d5dffd";//"A2A200"; 光標按下和選擇時的顏色
var startX, startY, endX, endY;
var inSelecting = false;
function getRectOf(obj)
{
var x=0;
var y=0;
var temp = obj;
while(temp.offsetParent != null)
{
x += temp.offsetLeft;
y += temp.offsetTop;
temp = temp.offsetParent;
}
function Rect(x, y, width, height)
{//alert("a");
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.cover = cover;
this.show = show;
}
function cover(that)
{
if((((this.x >= that.x)&&(this.x <= that.x + that.width))||
((this.x + this.width >= that.x)&&(this.x + this.width <= that.x + that.width))||
((this.x < that.x)&&(this.x + this.width > that.x + that.width)))&&
(((this.y >= that.y)&&(this.y <= that.y + that.height))||
((this.y + this.height >= that.y)&&(this.y + this.height <= that.y + that.height))||
((this.y < that.y)&&(this.y + this.height > that.y + that.height)))){
return true;
}
return false;
}
function show()
{
alert("x:" + this.x + " y:" + this.y + " width:" + this.width + " height:" + this.height);
}
return new Rect(x, y, obj.offsetWidth, obj.offsetHeight);
}
function mouseDown(divCal){
var divCalRect = getRectOf(divCal)
if(event.button == 1){
inSelecting = true;
startX = divCal.scrollLeft + event.clientX - divCalRect.x;
startY = divCal.scrollTop + event.clientY - divCalRect.y;
}
// window.alert (this)
}
function mouseMove(divCal,imgBox,imgPail){
var divCalRect = getRectOf(divCal);
imgPail.style.pixelLeft = divCal.scrollLeft + event.clientX - divCalRect.x + 10;
imgPail.style.pixelTop = divCal.scrollTop + event.clientY - divCalRect.y - 10;
if(event.button == 1 && inSelecting == true){//window.alert (this)
imgBox.style.display = "block";
if( startX < divCal.scrollLeft + event.clientX - divCalRect.x){
imgBox.style.pixelLeft = startX - 2;
imgBox.style.pixelWidth = divCal.scrollLeft + event.clientX - divCalRect.x - startX;
}
else{
imgBox.style.pixelLeft = divCal.scrollLeft + event.clientX - divCalRect.x - 2;
imgBox.style.pixelWidth = startX - divCal.scrollLeft - event.clientX + divCalRect.x;
}
if( startY < divCal.scrollTop + event.clientY - divCalRect.y){
imgBox.style.pixelTop = startY - 2;
imgBox.style.pixelHeight= divCal.scrollTop + event.clientY - divCalRect.y - startY;
}
else{
imgBox.style.pixelTop = divCal.scrollTop + event.clientY- divCalRect.y - 2;
imgBox.style.pixelHeight= startY - divCal.scrollTop - event.clientY + divCalRect.y;
}
imgBox.style.display = "block";
}
}
function mouseUp(imgBox){
if( inSelecting == true){
var boxRect;
if((imgBox.style.pixelWidth == 0)&&(imgBox.style.pixelHeight == 0)){
boxRect = new Rect(event.clientX, event.clientY, 0, 0);
}
else{
boxRect = getRectOf(imgBox);
}
paintRect(boxRect)
inSelecting = false;
imgBox.style.pixelLeft = 0;
imgBox.style.pixelTop = 0;
imgBox.style.pixelWidth = 0;
imgBox.style.pixelHeight= 0;
imgBox.style.display = "none";
}
}
function paintRect(boxRect)
{
var rect = getRectOf(DataGrid1.rows[0]);
if((rect.x > boxRect.x + boxRect.width)||
(rect.x + rect.width < boxRect.x)){
return;
}
for(i=0; i<DataGrid1.rows.length; i++){
rect = getRectOf(DataGrid1.rows[i]);
if(rect.y > boxRect.y + boxRect.height) return;
if((rect.y <= boxRect.y + boxRect.height)&&
(rect.y + rect.height >= boxRect.y)){
var currRow=DataGrid1.rows[i]
currRow.style.backgroundColor=curSelectColor;
//window.alert (gettype(DataGrid1.rows[i].cells[0].children[0])
if(currRow.cells[0].children[0]!=null )
if(currRow.cells[0].children[0].type.toLowerCase() == "checkbox" )
currRow.cells[0].children[0].checked=true;
// changeClass(DataGrid1.rows[i].recNo, curSelectColor);
}
}
}
function mouseOver(divCal,imgPail){
var divCalRect = getRectOf(divCal)
imgPail.style.display = "block";
imgPail.style.pixelLeft = divCal.scrollLeft + event.clientX - divCalRect.x + 10;
imgPail.style.pixelTop = divCal.scrollTop + event.clientY - divCalRect.y - 10;
//alert (imgPail.style.pixelLeft)
}
function mouseOut(imgPail){
imgPail.style.display = "none";
}
function rowMouseOut(item)
{
if(item.cells[0].children[0]==null)
{
item.style.background="#ffffff";
return;
}
if(item.cells[0].children[0].checked)
{item.style.backgroundColor=curSelectColor;
}
else
item.style.background="#ffffff";
}
function rowMouseDown(item)
{
item.style.background=curSelectColor;
if(item.cells[0].children[0]==null) return;
item.cells[0].children[0].checked=true;
}
function Rect(x, y, width, height)
{
/*
/ this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.cover = cover;
this.show = show;*/
}
function cover(that)
{
if((((this.x >= that.x)&&(this.x <= that.x + that.width))||
((this.x + this.width >= that.x)&&(this.x + this.width <= that.x + that.width))||
((this.x < that.x)&&(this.x + this.width > that.x + that.width)))&&
(((this.y >= that.y)&&(this.y <= that.y + that.height))||
((this.y + this.height >= that.y)&&(this.y + this.height <= that.y + that.height))||
((this.y < that.y)&&(this.y + this.height > that.y + that.height)))){
return true;
}
return false;
}
function show()
{
alert("x:" + this.x + " y:" + this.y + " width:" + this.width + " height:" + this.height);
}
function XmlToTable(sXml,fileXslt)
{
var xml = new ActiveXObject("Msxml2.DOMDocument.3.0");
xml.async=false;
xml.loadXML(sXml);
if (xml.parseError.errorCode != 0)
{
//WScript.Echo ("XML 文件錯誤 : " + xml.parseError.reason);
return;
}
var xslt = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
xslt.async=false;
xslt.load(fileXslt);
if (xslt.parseError.errorCode != 0)
{
//WScript.Echo ("XSL 文件錯誤 : " + xslt.parseError.reason);
return;
}
try
{
//WScript.Echo (xml.transformNode(xslt.documentElement));
return xml.transformNode(xslt);
}
catch(err)
{
;//WScript.Echo ("轉換錯誤: " + err.number + "*" + err.description);
}
}
function GetTableOuterHTML(TableName)
{
//window.alert (TableName);
var Table=AjaxData.GetTableOuterHTML(TableName);
return Table.value;
//window.alert (Table.value);
//divDataGrid.innerHTML=Table.value;
}
function OpenAddWin(frmWin,width,height)
{
var ret=window.showModalDialog(frmWin,window,'dialogWidth='+width +'px;dialogHeight='+height+'px;help:no;status:no')
return ret;
}
function OpenEditWin(frmWin,width,height)
{
var objs = DataGrid1.getElementsByTagName("input");
var code,isSelect;
isSelect=false;
for(var i=0; i<objs.length; i++)
{
if(objs[i].type.toLowerCase() == "checkbox" )
if(objs[i].checked)
{ //window.alert(objs[i].parentElement.parentElement.cells[2].innerText);//children InnerHtml //innerHTML
code=objs[i].parentElement.parentElement.cells[2].innerText;
isSelect=true;
break;
}
}
if(isSelect)
{
var frmEditWin=frmWin+"?code="+code
var ret= OpenAddWin(frmEditWin,width,height);
return ret;
}
else
window.alert("您沒有選擇所要更新的行!");
}
function ButtonOver(buttonTD)
{
if(buttonTD.childNodes.length && buttonTD.childNodes[0].tagName == "IMG")
{
buttonTD.childNodes[0].className='ButtonOver';
}
}
function ButtonOut(buttonTD)
{
if(buttonTD.childNodes.length && buttonTD.childNodes[0].tagName == "IMG")
{
buttonTD.childNodes[0].className='ButtonOut';
}
}
function ButtonDown(buttonTD,imageOver,imageDown)
{
if(buttonTD.childNodes.length && buttonTD.childNodes[0].tagName == "IMG")
{
buttonTD.childNodes[0].className='ButtonDown';
}
}
function ButtonUp(buttonTD,ftbName,imageOver,imageDown)
{
if(buttonTD.childNodes.length && buttonTD.childNodes[0].tagName == "IMG")
{
buttonTD.childNodes[0].className='ButtonUp';
}
}
//刪除所選擇的行
function DeleteSeleteRows(TableName)
{//alert(TableName);
if (confirm("您真的刪除所選擇的行嗎?")==false) return;
var objs = DataGrid1.getElementsByTagName("input");
for(var i=objs.length-1; i>0; i--)
{
var CurrCheckbox=objs[i];
if(CurrCheckbox.type.toLowerCase() == "checkbox" )
{
if(CurrCheckbox.checked)
{
var ID=CurrCheckbox.parentElement.nextSibling.innerText;
var isSuccess= AjaxData.DeleteRow(TableName,ID);
if(isSuccess.value)
{
var rowIndex=CurrCheckbox.parentElement.parentElement.rowIndex
DataGrid1.deleteRow(rowIndex);
if(TableName=="tInfoClass")
DomTree.deleteItem("C"+ID);
}
}
}
}
}
//在表Table1的RowIndex位置插入一行,該行的數據來源于DataRow
function InsertRow(Table1,ID)
{
if(Table1.rows.length==0||Table1==null) return;//表為空
if(ID<0) return;
//alert(ID);
var LastRow=Table1.rows[Table1.rows.length-1];
var NewRow=LastRow.cloneNode(true) ;
NewRow.children[1].innerText=ID;//parseInt(NewRow.children[1].innerText)+1;//保證是新增加時自動加一,與數據表一致
// alert(NewRow.children[1].innerText)
// var Row=Table1.rows[RowIndex] ;
SetRowText(NewRow);
LastRow.parentNode.insertAdjacentElement('beforeEnd',NewRow);
/*下面的方法有刷新感覺,且replace方法不適合大字符串,且向divDataGrid.innerHTML重新裝載的效率是否佳?所以暫不用
var length=DataGrid1.rows.length;
var oldRow=DataGrid1.insertRow(length).outerHTML;
//alert(oldRow);
var strTable=DataGrid1.outerHTML;
txtName.value =strTable;
//alert(strTable);
// var oldRow=ThisCell.parentElement.innerHTML;
var NewRow=AjaxData.GetRowOuterHTML().value;
txtName.value =NewRow;
var NewTable=strTable.replace(oldRow,NewRow);
divDataGrid.innerHTML=NewTable;
*/
}
//設置行的文本,把數組DataRow的賦值給Row
function SetRowText(Row)
{
try
{
var RowID=Row.children[1].innerText;
var DataRow=AjaxData.GetDataRow(RowID).value;
alert(DataRow)
if(DataRow==null) return;//沒有數據
if(DataRow.length==0) return;//沒有數據
if(Row.children.length==0||Row==null) return;//行為空
if(DataRow.length>Row.children.length) return;//
alert(DataRow[6])
alert(DataRow[7])
alert(DataRow[8])
for(var i=0;i<DataRow.length;i++)
if(DataRow[i]!=null)
Row.childNodes[i+1].innerText=DataRow[i];
}
catch(err)
{
alert(err.description);//WScript.Echo ("轉換錯誤: " + err.number + "*" + err.description);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -