table.js
来自「XML path visualiser」· JavaScript 代码 · 共 81 行
JS
81 行
// Courtesy of SimplytheBest.net (http://simplythebest.net)
var rowHighlight = true; // turn on row highlights
var colHighlight = true; // turn on row highlights
var selectedRow = null;
function getElement(el)
{
var tagList = new Object;
for (var i = 1; i < arguments.length; i++)
tagList[arguments[i]] = true;
while ((el!=null) && (tagList[el.tagName]==null))
el = el.parentElement;
return el;
}
function checkSelected()
{
var el = getElement(event.srcElement,"TD");
//alert(el)
if (el==null)
return;
//alert(el.tagName)
if (el.tagName=="TD")
{
var row = getElement(el, "TR");
var table = getElement(row, "TABLE");
row.className = "select";
if(selectedRow != null)
selectedRow.className = "";
row.className = "select";
selectedRow = row;
cache = row;
}
}
function checkHighlight(which)
{
var el = getElement(event.srcElement,"TH","TD");
if (el==null)
return;
if ((el.tagName=="TH") && (colHighlight))
{
var idx = el.cellIndex;
var table = getElement(el, "TABLE");
var column = table.all.tags("COL")[idx];
if (which)
column.className="cover";
else
column.className="";
}
if ((el.tagName=="TD") && (rowHighlight))
{
var row = getElement(el, "TR");
var table = getElement(row, "TABLE");
if (which)
row.className = "rover";
else
{
row.className = ""
if(row == selectedRow)
row.className = "select"
}
cache = row;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?