明
//iCount :计数器。整型
//iLength :字串的长度。整型
//------------------------------------------
iLength = strTemp.length;
for(iCount = iLength - 1; iCount >= 0; iCount --)
if (strTemp.charAt(iCount) != " ")
return strTemp.substring(0, iCount + 1);
return "";
}
//************************
//函数名 :trim
//功能 :去掉字串两边的空格
//输入 :1、strTemp :要规整的字串。字符串型
//输出 :规整后的字串。字符串型
//************************
function trim(strTemp)
{
return rTrim(lTrim(strTemp));
}
//将2位数字转换成2位数字字串
//************************
//函数名 :get2bNumStr
//功能 :转换2位的数字成2位的数字字串
//输入 :1、iNumber :要转换的数字。整型
//输出 :转换后得到的数字字串。整型
//************************
function get2bNumStr(iNumber)
{
var str2bNum;
//------------------------------------------
//常变量说明
//str2bNum :数字字串。字符串型
//------------------------------------------
if (parseInt(iNumber) < 10)
str2bNum = "0" + iNumber;
else
str2bNum = "" + iNumber;
return str2bNum;
}
//************************
//函数名 :assignFunc
//功能 :指定元素的事件处理函数
//输入 :1、ele :要指定事件处理函数的元素。对象型
// 2、func :事件处理函数。函数型
// 3、event :事件类型。字符串型
//输出 :无
//************************
function assignFunc(ele, func, event)
{
var iCount, iEleCount;
var strEvent;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//iEleCount :同名元素集合中元素的个数。整型
//strEvent :事件类型。字符串型
//------------------------------------------
if (event == null)
strEvent = "onclick";
else
strEvent = event;
iEleCount = ele.length;
if (iEleCount == undefined)
eval("ele." + strEvent + " = " + func);
else
for (iCount = 0; iCount < iEleCount; iCount ++)
eval("ele[iCount]." + strEvent + " = " + func);
}
//************************
//函数名 :getEleIndex
//功能 :得到发生事件的元素在同名集合中的索引
//输入 :1、eleSrc :发生事件的元素。对象型
//输出 :发生事件的元素在同名集合中的索引
//************************
function getEleIndex(eleSrc)
{
var colSrc;
var iCount, iEleCount;
//------------------------------------------
//常变量说明
//colSrc :同名元素集合。对象型数组
//iCount :计数器。整型
//iEleCount :同名元素集合中元素的个数。整型
//------------------------------------------
colSrc = eval(eleSrc.id);
iEleCount = colSrc.length;
for (iCount = 0; iCount < iEleCount; iCount ++)
{
if (colSrc[iCount] == eleSrc)
return iCount;
}
return -1;
}
//显示常变量的值(调试用)
//!准备删去
function show(strDef1, strDef2, strDef3, strDef4)
{
var iCount, iDefCnt;
var strShow, strTemp;
iDefCnt = 4;
strShow = "[常变量值]";
for (iCount = 1; iCount <= iDefCnt; iCount ++)
{
strTemp = eval("strDef" + iCount);
if (strTemp != undefined && strTemp != null)
strShow += "
" + strTemp + ": " + eval(strTemp);
}
alert(strShow);
}
//************************
//函数名 :showArray
//功能 :显示一维数组的元素(调试用)
//输入 :1、array :要显示的一维数组。数组
//输出 :无
//************************
function showArray(array)
{
var iCount, iEleCount;
var strShow;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//iEleCount :数组元素的个数。整型
//strShow :数组元素值构成的字串。字符串型
//------------------------------------------
iEleCount = array.length;
strShow = "Array Length: " + iEleCount;
strShow += "
---------------------------------
";
for (iCount = 0; iCount < iEleCount; iCount ++)
{
if (typeof(array[iCount]) == "object")
strShow += array[iCount].id + " ";
else
strShow += array[iCount] + " ";
}
alert(strShow);
}
//************************
//函数名 :show2DArray
//功能 :显示二维数组的元素(调试用)
//输入 :1、array :要显示的二维数组。数组
//输出 :无
//************************
function show2DArray(array)
{
var iX, iY, iLen1, iLen2;
var strShow;
//------------------------------------------
//常变量说明
//iX :计数器。整型
//iY :计数器。整型
//iLen1 :数组一维的数目。整型
//iLen2 :数组二维的数目。整型
//strShow :数组元素值构成的字串。字符串型
//------------------------------------------
iLen1 = array.length;
strShow = "Array 1D Length: " + iLen1;
strShow += "
---------------------------------";
for (iX = 0; iX < iLen1; iX ++)
{
strShow += "
";
iLen2 = array[iX].length;
for (iY = 0; iY < iLen2; iY ++)
strShow += array[iX][iY] + " ";
}
alert(strShow);
}
//-->
</script>
<script language="JavaScript">
<!--
//--------------------函数列表--------------------------
//window_onload
//
//getWord
//reset
//save
//load
//
//showList
//hideList
//fixList
//valueList
//
//showHelp
//hideHelp
//fixHelp
//
//resetAll
//saveAll
//loadAll
//assemble
//
//lightBtn
//delightBtn
//lightOpt
//delightOpt
//
//makeOpt
//removeOpt
//-----------------------------------------------------------
var m_iPartCnt;
var m_astrSenPart, m_astrWords;
var m_strPrompt;
var m_iListFixed, m_iHelpFixed;
//------------------------------------------
//常变量说明
//m_iPartCnt :词汇分类的数目。整型
//m_astrSenPart :词汇分类的名称。字符型数组
//m_astrWords :纪录各类词汇。二维字符型数组
//m_strPrompt :文件操作完毕后的提示信息。字符串型
//m_iListFixed :代表被固定单词列表的数字。整型
// -1表示没有单词列表被固定
//m_iHelpFixed :表示帮助列表固定状态的数字。整型
// -1表示帮助列表没有被固定
//------------------------------------------
window.onload = window_onload;
//-----------------------------------------------------------
//初始化页面
function window_onload()
{
var iCount, iEleCnt;
var colButton;
var strHelp;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//iEleCnt :集合中元素的个数。整型
//colButton :BUTTON元素的集合。对象型数组
//strHelp :帮助文件内容。字符串型
//------------------------------------------
m_iPartCnt = <%= m_iPartCnt%>;
m_strPrompt = "<%= m_strPrompt%>";
m_iListFixed = -1;
m_iHelpFixed = -1;
m_astrSenPart = new Array();
m_astrWords = new Array();
//alert("m_iPartCnt: " + m_iPartCnt + "
m_strPrompt: " + m_strPrompt);
//得到词汇分类的名称和已载入的各类词汇
<%For m_iCount = 0 To (m_iPartCnt - 1)%>
//得到已载入的各类词汇
<%If IsEmpty(m_astrWords(m_iCount)) = True Then%>
m_astrWords[<%= m_iCount%>] = new Array();
<%Else%>
m_astrWords[<%= m_iCount%>] = "<%= Join(m_astrWords(m_iCount), ",")%>".split(",");
<%End If%>
//得到词汇分类的名称
m_astrSenPart[<%= m_iCount%>] = "<%= m_astrSenPart(m_iCount)%>";
<%Next%>
//show2DArray(m_astrWords);
//showArray(m_astrSenPart);
//将已载入的各类词汇写入到页面中
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
valueList(m_astrWords[iCount], iCount);
//载入帮助文件
//strHelp = tblHelp.outerHTML;
//strHelp = divHelp1.innerHTML;
//tblHelp.outerHTML = "";
//divHelp.innerHTML = strHelp;
//tblHelp.style.display = "";
//divHelp.style.display = "NONE";
//divHelp.style.left = divHelp1.style.left;
//alert("left: "+divHelp.style.left + "
left: " + divHelp1.style.left);
//alert("pixelleft: "+divHelp.style.pixelLeft + "
pixelleft: " + divHelp1.style.pixelLeft);
//alert("posLeft: "+divHelp.style.posLeft + "
posLeft: " + divHelp1.style.posLeft);
//alert("offsetLeft : "+divHelp.offsetLeft + "
offsetLeft : " + divHelp1.offsetLeft );
//alert("clientLeft : "+divHelp.clientLeft + "
clientLeft : " + divHelp1.clientLeft );
//指定页面元素的事件处理函数
assignFunc(txtWord, getWord, "onkeypress");
assignFunc(btnGetWord, getWord);
assignFunc(btnReset, reset);
assignFunc(btnSave, save);
assignFunc(btnLoad, load);
assignFunc(lblWordList, showList, "onmouseover");
assignFunc(lblWordList, hideList, "onmouseout");
assignFunc(lblWordList, fixList);
assignFunc(lblHelp, showHelp, "onmouseover");
assignFunc(lblHelp, hideHelp, "onmouseout");
assignFunc(lblHelp, fixHelp);
assignFunc(btnResetAll, resetAll);
assignFunc(btnSaveAll, saveAll);
assignFunc(btnLoadAll, loadAll);
assignFunc(btnAsb, assemble);
colButton = document.all.tags("BUTTON");
iEleCnt = colButton.length;
//showArray(colButton);
//alert("iEleCnt: " + iEleCnt);
for (iCount = 0; iCount < iEleCnt; iCount ++)
{
assignFunc(colButton[iCount], lightBtn, "onmouseover");
assignFunc(colButton[iCount], delightBtn, "onmouseout");
}
//设置页面初始状态
if (m_strPrompt != "")
alert(m_strPrompt);
txtWord[0].focus();
}
上一页 [1] [2]