日期:2012-04-01 浏览次数:21039 次
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 += "\n(这样将生成一个空的新文件)";
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";