//-----------------------------------------------------------
//得到用户输入的单词
function getWord()
{
//只有当在单词输入框中按回车或
//按“保存”按钮时才继续做下去
if (window.event.type != "keypress" && window.event.type != "click")
return;
else
if (window.event.type == "keypress" && window.event.keyCode != 13) return;
var eleSrc;
var iIndex, iNxtWrdIdx;
var strWord;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iNxtWrdIdx :新单词在单词数组中的索引。整型
//strWord :用户输入的单词。字符串型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc); //获得索引
strWord = trim(txtWord[iIndex].value); //获得用户输入的单词
//检测输入的单词是否合法
//若是非法的单词则退出
if (strWord == "")
{
//若输入的单词为空或空格字符串
alert("单词不能为空或空格字符串");
txtWord[iIndex].select();
return;
}
if (strWord.indexOf(",") != -1 || strWord.indexOf(" ") != -1)
{
//若输入的单词包含逗号或空格
alert("单词不能包含逗号或空格");
txtWord[iIndex].select();
return;
}
//将单词保存到词汇数组中
iNxtWrdIdx = m_astrWords[iIndex].length;
m_astrWords[iIndex][iNxtWrdIdx] = strWord;
//showArray(m_astrWords[iIndex]);
//将单词写入到页面中
valueList(m_astrWords[iIndex], iIndex);
txtWord[iIndex].value = "";
txtWord[iIndex].focus();
}
//-----------------------------------------------------------
//将当前类别所有的单词从内存中删去
function reset()
{
var eleSrc;
var iIndex, iCount;
var strPrompt;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iCount :计数器。整型
//strPrompt :操作提示。字符串型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
strPrompt = "您确定要从内存中清除[" + m_astrSenPart[iIndex] + "]部分所有的单词吗?";
if (window.confirm(strPrompt) == false) return;
m_astrWords[iIndex] = new Array();
valueList(m_astrWords[iIndex], iIndex);
//showArray(m_astrWords[iIndex]);
strPrompt = "单词清除完毕";
alert(strPrompt);
txtWord[iIndex].select();
}
//-----------------------------------------------------------
//将所选类别的当前词汇保存进文件中
function save()
{
var eleSrc;
var iIndex, iCount;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iCount :计数器。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
if (m_astrWords[iIndex].length == 0)
{
//如果所选类别的当前单词个数为零
var strPrompt;
strPrompt = "[" + m_astrSenPart[iIndex] + "]部分现在一个可选单词也没有,您确定要保存吗?";
strPrompt += " (这样将生成一个空的新文件)";
if (window.confirm(strPrompt) == false) return;
}
//保存当前内存中所有的单词
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
eval("frmWords.txtWords" + iCount).value = m_astrWords[iCount].join(",");
frmWords.txtSenPart.value = iIndex;
frmWords.txtOpWay.value = "SAVE";
frmWords.submit();
}
//-----------------------------------------------------------
//从文件中读取所选类别的单词纪录
function load()
{
var eleSrc;
var iIndex, iCount;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iCount :计数器。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
//保存当前内存中所有的单词
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
eval("frmWords.txtWords" + iCount).value = m_astrWords[iCount].join(",")
frmWords.txtSenPart.value = iIndex;
frmWords.txtOpWay.value = "LOAD";
frmWords.submit();
}
//-----------------------------------------------------------
//显示词汇列表
function showList(iIndex)
{
//如果未给定参数 iIndex
//获得 iIndex
if (iIndex == undefined)
{
//如果已有单词列表被固定,退出函数
if (m_iListFixed != -1) return;
var eleSrc;
var iIndex;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
}
//alert("iIndex: "+iIndex);
//显示词汇列表
//lblWordList[iIndex].innerText = "[" + lblWordList[iIndex].innerText + "]";
//lblWordList[iIndex].innerText = lblWordList[iIndex].innerText + ">";
lblWordList[iIndex].className = "lblMOver";
divWordList[iIndex].className= "listShown";
}
//-----------------------------------------------------------
//隐藏词汇列表
function hideList(iIndex)
{
//如果未给定参数 iIndex
//获得 iIndex
if (iIndex == undefined)
{
//如果已有单词列表被固定,退出函数
if (m_iListFixed != -1) return;
var eleSrc;
var iIndex;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
}
//alert("iIndex: "+iIndex);
//隐藏词汇列表
//lblWordList[iIndex].innerText = lblWordList[iIndex].innerText.slice(0, -1);
lblWordList[iIndex].className = "lblMOut";
divWordList[iIndex].className= "listHidden";
}
//-----------------------------------------------------------
//固定词汇列表
function fixList()
{
var eleSrc;
var iIndex;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
switch (m_iListFixed)
{
case -1:
//如果还没有单词列表被固定
//固定当前列表
m_iListFixed = iIndex;
lblWordList[iIndex].className = "lblClicked";
divWordList[iIndex].className= "listFixed";
break;
case iIndex:
//如果被固定单词列表是当前列表
//解固当前列表
m_iListFixed = -1;
lblWordList[iIndex].className = "lblMOver";
divWordList[iIndex].className= "listShown";
break;
default:
//如果被固定单词列表不是当前列表
//解固被固定列表
hideList(m_iListFixed);
m_iListFixed = -1;
lblWordList[iIndex].className = "lblMOver";
showList(iIndex);
break;
}
//alert("m_iListFixed: " + m_iListFixed + " iIndex: " + iIndex);
}
//-----------------------------------------------------------
//写入某类词汇已载入的单词
function valueList(aWords, iSenPart)
{
var iCount, iWrdCnt;
var strListPpt;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//iWrdCnt :某类词汇单词的数目。整型
//strListPpt :单词列表中的提示。字符串型
//------------------------------------------
//数据准备
iWrdCnt = aWords.length;
lblWordCount[iSenPart].innerText = iWrdCnt;
strListPpt = "<div><span style='color: RED; font-style: Italic; font-size: 10.5pt;'>";
strListPpt += "双击单词将其删除</span></div>";
//将单词写入列表
if (iWrdCnt != 0)
{
divWordList[iSenPart].innerHTML = strListPpt;
for (iCount = 0; iCount < iWrdCnt; iCount ++)
divWordList[iSenPart].innerHTML += makeOpt(aWords[iCount], iCount);
}
else
divWordList[iSenPart].innerHTML = strListPpt;
}
//-----------------------------------------------------------
//显示帮助列表
function showHelp()
{
//如果帮助列表已被固定,退出函数
if (m_iHelpFixed == 0) return;
//显示帮助
lblHelp.className = "lblMOver";
divHelp.className = "helpShown";
}
//-----------------------------------------------------------
//隐藏帮助列表
function hideHelp()
{
//如果帮助列表已被固定,退出函数
if (m_iHelpFixed == 0) return;
//隐藏帮助
lblHelp.className = "lblMOut";
divHelp.className = "helpHidden";
}
//-----------------------------------------------------------
//固定帮助列表
function fixHelp()
{
if (m_iHelpFixed == -1)
{
//如果帮助列表还未被固定
//固定它
m_iHelpFixed = 0;
lblHelp.className = "lblClicked";
divHelp.className = "helpFixed";
}
else
{
//如果帮助列表已被固定
//解固它
m_iHelpFixed = -1;
lblHelp.className = "lblMOver";
divHelp.className = "helpShown";
}
}
//-----------------------------------------------------------
//重置页面至初始状态
function resetAll()
{
var iCount;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//------------------------------------------
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
{
txtWord[iCount].value= "";
m_astrWords[iCount] = new Array(); //将单词数组清空
valueList(m_astrWords[iCount], iCount);
}
txtSentence.value = "";
txtWord[0].focus();
}
//-----------------------------------------------------------
//把所有类别的单词都存入文件
function saveAll()
{
var iCount, iEmptyCnt;
var strPrompt;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//iEmptyCnt :单词数目为0的类别个数。整型
//strPrompt :操作提示。字符串型
//------------------------------------------
iEmptyCnt = 0;
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
{
//保存当前内存中所有的单词
eval("frmWords.txtWords" + iCount).value = m_astrWords[iCount].join(",");
if (m_astrWords[iCount].length == 0)
iEmptyCnt ++;
}
//alert("iEmptyCnt: " + iEmptyCnt);
if (iEmptyCnt > 0)
{
switch (iEmptyCnt)
{
case m_iPartCnt:
strPrompt = "所有类别的词汇单词个数都为0,操作将会产生" + m_iPartCnt + "个空文件";
strPrompt += " 您确定要这样做吗?";
break;
default:
strPrompt = "其中,";
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
if (
//得到用户输入的单词
function getWord()
{
//只有当在单词输入框中按回车或
//按“保存”按钮时才继续做下去
if (window.event.type != "keypress" && window.event.type != "click")
return;
else
if (window.event.type == "keypress" && window.event.keyCode != 13) return;
var eleSrc;
var iIndex, iNxtWrdIdx;
var strWord;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iNxtWrdIdx :新单词在单词数组中的索引。整型
//strWord :用户输入的单词。字符串型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc); //获得索引
strWord = trim(txtWord[iIndex].value); //获得用户输入的单词
//检测输入的单词是否合法
//若是非法的单词则退出
if (strWord == "")
{
//若输入的单词为空或空格字符串
alert("单词不能为空或空格字符串");
txtWord[iIndex].select();
return;
}
if (strWord.indexOf(",") != -1 || strWord.indexOf(" ") != -1)
{
//若输入的单词包含逗号或空格
alert("单词不能包含逗号或空格");
txtWord[iIndex].select();
return;
}
//将单词保存到词汇数组中
iNxtWrdIdx = m_astrWords[iIndex].length;
m_astrWords[iIndex][iNxtWrdIdx] = strWord;
//showArray(m_astrWords[iIndex]);
//将单词写入到页面中
valueList(m_astrWords[iIndex], iIndex);
txtWord[iIndex].value = "";
txtWord[iIndex].focus();
}
//-----------------------------------------------------------
//将当前类别所有的单词从内存中删去
function reset()
{
var eleSrc;
var iIndex, iCount;
var strPrompt;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iCount :计数器。整型
//strPrompt :操作提示。字符串型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
strPrompt = "您确定要从内存中清除[" + m_astrSenPart[iIndex] + "]部分所有的单词吗?";
if (window.confirm(strPrompt) == false) return;
m_astrWords[iIndex] = new Array();
valueList(m_astrWords[iIndex], iIndex);
//showArray(m_astrWords[iIndex]);
strPrompt = "单词清除完毕";
alert(strPrompt);
txtWord[iIndex].select();
}
//-----------------------------------------------------------
//将所选类别的当前词汇保存进文件中
function save()
{
var eleSrc;
var iIndex, iCount;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iCount :计数器。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
if (m_astrWords[iIndex].length == 0)
{
//如果所选类别的当前单词个数为零
var strPrompt;
strPrompt = "[" + m_astrSenPart[iIndex] + "]部分现在一个可选单词也没有,您确定要保存吗?";
strPrompt += " (这样将生成一个空的新文件)";
if (window.confirm(strPrompt) == false) return;
}
//保存当前内存中所有的单词
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
eval("frmWords.txtWords" + iCount).value = m_astrWords[iCount].join(",");
frmWords.txtSenPart.value = iIndex;
frmWords.txtOpWay.value = "SAVE";
frmWords.submit();
}
//-----------------------------------------------------------
//从文件中读取所选类别的单词纪录
function load()
{
var eleSrc;
var iIndex, iCount;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//iCount :计数器。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
//保存当前内存中所有的单词
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
eval("frmWords.txtWords" + iCount).value = m_astrWords[iCount].join(",")
frmWords.txtSenPart.value = iIndex;
frmWords.txtOpWay.value = "LOAD";
frmWords.submit();
}
//-----------------------------------------------------------
//显示词汇列表
function showList(iIndex)
{
//如果未给定参数 iIndex
//获得 iIndex
if (iIndex == undefined)
{
//如果已有单词列表被固定,退出函数
if (m_iListFixed != -1) return;
var eleSrc;
var iIndex;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
}
//alert("iIndex: "+iIndex);
//显示词汇列表
//lblWordList[iIndex].innerText = "[" + lblWordList[iIndex].innerText + "]";
//lblWordList[iIndex].innerText = lblWordList[iIndex].innerText + ">";
lblWordList[iIndex].className = "lblMOver";
divWordList[iIndex].className= "listShown";
}
//-----------------------------------------------------------
//隐藏词汇列表
function hideList(iIndex)
{
//如果未给定参数 iIndex
//获得 iIndex
if (iIndex == undefined)
{
//如果已有单词列表被固定,退出函数
if (m_iListFixed != -1) return;
var eleSrc;
var iIndex;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
}
//alert("iIndex: "+iIndex);
//隐藏词汇列表
//lblWordList[iIndex].innerText = lblWordList[iIndex].innerText.slice(0, -1);
lblWordList[iIndex].className = "lblMOut";
divWordList[iIndex].className= "listHidden";
}
//-----------------------------------------------------------
//固定词汇列表
function fixList()
{
var eleSrc;
var iIndex;
//------------------------------------------
//常变量说明
//eleSrc :发生事件的元素
//iIndex :表示词汇分类的数字。整型
//------------------------------------------
eleSrc = window.event.srcElement;
iIndex = getEleIndex(eleSrc);
switch (m_iListFixed)
{
case -1:
//如果还没有单词列表被固定
//固定当前列表
m_iListFixed = iIndex;
lblWordList[iIndex].className = "lblClicked";
divWordList[iIndex].className= "listFixed";
break;
case iIndex:
//如果被固定单词列表是当前列表
//解固当前列表
m_iListFixed = -1;
lblWordList[iIndex].className = "lblMOver";
divWordList[iIndex].className= "listShown";
break;
default:
//如果被固定单词列表不是当前列表
//解固被固定列表
hideList(m_iListFixed);
m_iListFixed = -1;
lblWordList[iIndex].className = "lblMOver";
showList(iIndex);
break;
}
//alert("m_iListFixed: " + m_iListFixed + " iIndex: " + iIndex);
}
//-----------------------------------------------------------
//写入某类词汇已载入的单词
function valueList(aWords, iSenPart)
{
var iCount, iWrdCnt;
var strListPpt;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//iWrdCnt :某类词汇单词的数目。整型
//strListPpt :单词列表中的提示。字符串型
//------------------------------------------
//数据准备
iWrdCnt = aWords.length;
lblWordCount[iSenPart].innerText = iWrdCnt;
strListPpt = "<div><span style='color: RED; font-style: Italic; font-size: 10.5pt;'>";
strListPpt += "双击单词将其删除</span></div>";
//将单词写入列表
if (iWrdCnt != 0)
{
divWordList[iSenPart].innerHTML = strListPpt;
for (iCount = 0; iCount < iWrdCnt; iCount ++)
divWordList[iSenPart].innerHTML += makeOpt(aWords[iCount], iCount);
}
else
divWordList[iSenPart].innerHTML = strListPpt;
}
//-----------------------------------------------------------
//显示帮助列表
function showHelp()
{
//如果帮助列表已被固定,退出函数
if (m_iHelpFixed == 0) return;
//显示帮助
lblHelp.className = "lblMOver";
divHelp.className = "helpShown";
}
//-----------------------------------------------------------
//隐藏帮助列表
function hideHelp()
{
//如果帮助列表已被固定,退出函数
if (m_iHelpFixed == 0) return;
//隐藏帮助
lblHelp.className = "lblMOut";
divHelp.className = "helpHidden";
}
//-----------------------------------------------------------
//固定帮助列表
function fixHelp()
{
if (m_iHelpFixed == -1)
{
//如果帮助列表还未被固定
//固定它
m_iHelpFixed = 0;
lblHelp.className = "lblClicked";
divHelp.className = "helpFixed";
}
else
{
//如果帮助列表已被固定
//解固它
m_iHelpFixed = -1;
lblHelp.className = "lblMOver";
divHelp.className = "helpShown";
}
}
//-----------------------------------------------------------
//重置页面至初始状态
function resetAll()
{
var iCount;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//------------------------------------------
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
{
txtWord[iCount].value= "";
m_astrWords[iCount] = new Array(); //将单词数组清空
valueList(m_astrWords[iCount], iCount);
}
txtSentence.value = "";
txtWord[0].focus();
}
//-----------------------------------------------------------
//把所有类别的单词都存入文件
function saveAll()
{
var iCount, iEmptyCnt;
var strPrompt;
//------------------------------------------
//常变量说明
//iCount :计数器。整型
//iEmptyCnt :单词数目为0的类别个数。整型
//strPrompt :操作提示。字符串型
//------------------------------------------
iEmptyCnt = 0;
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
{
//保存当前内存中所有的单词
eval("frmWords.txtWords" + iCount).value = m_astrWords[iCount].join(",");
if (m_astrWords[iCount].length == 0)
iEmptyCnt ++;
}
//alert("iEmptyCnt: " + iEmptyCnt);
if (iEmptyCnt > 0)
{
switch (iEmptyCnt)
{
case m_iPartCnt:
strPrompt = "所有类别的词汇单词个数都为0,操作将会产生" + m_iPartCnt + "个空文件";
strPrompt += " 您确定要这样做吗?";
break;
default:
strPrompt = "其中,";
for (iCount = 0; iCount < m_iPartCnt; iCount ++)
if (