var wm_max_deep=10;
var wm_curr_deep=0;
var wm_word_box_count=0;
var wm_word_array=null;
var wm_render_mode=false; //false 横向 true 纵向
var wm_show_mode=0; //0 最简单 1 复杂
var rootId;
var wm_array_word_for_save;
var wm_word_base_curr_focuse=-1;
var wm_case=new Array()
function show_word_map(g_currEditWord){
//closeModifyWindow();//关闭单词修改窗口
wm_word_box_count=0;
wm_word_array=new Array();
wm_array_word_for_save=new Array();
wm_word_base_curr_focuse=-1;
var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
wid=getWordIndex(g_currEditWord);
var sReal = getNodeText(xAllWord[wid],"real");
rootId=wm_create_root_word(g_currEditWord);
wm_updata_word(rootId,null);
var strWordMapWin="
";
strWordMapWin += "";
strWordMapWin += "
";
strWordMapWin += "
";
strWordMapWin += "
";//套殻
strWordMapWin += "
";//套殻
strWordMapWin += "
";
strWordMapWin += "
";
strWordMapWin += "
";
getStyleClass("pop_win_full").style.display = "-webkit-flex";
getStyleClass("pop_win_full").style.animation = "2s";
document.getElementById("pop_win_inner").innerHTML=strWordMapWin;
wm_updata_title();
wm_updata_word_map();
wm_render_line();
}
function pop_win_close(){
document.getElementById("pop_win_inner").innerHTML = "";
getStyleClass("pop_win_full").style.display = "none";
}
function wm_render_title(){
var output = "
";
output += "";
if(wm_render_mode){
output += "
↔
↕
";
}
else{
output += "
↔
↕
";
}
switch(wm_show_mode){
case 0:
output += "
−
≡
Edit
";
break;
case 1:
output += "
−
≡
Edit
";
break;
case 2:
output += "
−
≡
Edit
";
break;
}
output += "
";
output += "
Word Map
";
output += "
";
return(output);
}
function wm_updata_title(){
document.getElementById("wm_title").innerHTML=wm_render_title();;
}
function wm_updata_word_map(){
document.getElementById("wm_word_block_0").innerHTML=wm_render_word_map(rootId);;
// document.getElementById("wm_body").innerHTML=wm_render_word_map(rootId);;
}
function wm_change_mode(newmode){
wm_word_box_count=0;
wm_render_mode=newmode;
wm_updata_title();
wm_updata_word_map();
wm_render_line();
}
function wm_change_show_mode(newmode){
wm_word_box_count=0;
wm_show_mode=newmode;
wm_updata_title();
wm_updata_word_map();
wm_render_line();
}
function wm_create_root_word(wordid){
wid=getWordIndex(wordid);
var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
var sReal = getNodeText(xAllWord[wid],"real");
var newWord=new Object();
var indexOfExist=wm_find_exist_part(sReal);
if(indexOfExist){
newWord.is_new=false;
newWord.id=g_DictWordList[indexOfExist].Guid;
newWord.part=g_DictWordList[indexOfExist].Factors;
newWord.partmean=g_DictWordList[indexOfExist].FactorMean;
newWord.partid=g_DictWordList[indexOfExist].PartId;
}
else{
newWord.is_new=true;
newWord.id=com_guid();
newWord.part=getNodeText(xAllWord[wid],"org");
newWord.partmean=getNodeText(xAllWord[wid],"om");
newWord.partid=wm_get_best_partid(newWord);
}
newWord.pali=sReal;
newWord.real=sReal;
newWord.type=getNodeText(xAllWord[wid],"case").split("#")[0];
newWord.gramma=getNodeText(xAllWord[wid],"case").split("#")[1];
newWord.mean=getNodeText(xAllWord[wid],"mean");
newWord.note=getNodeText(xAllWord[wid],"note");
newWord.wparent=getNodeText(xAllWord[wid],"parent").replace(/ /g,"");//去空格
newWord.parentid="";
newWord.parentNode=null;
newWord.deep=0;
wm_word_array.push(newWord);
return(newWord.id);
}
function wm_find_exist_part(word){
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word && g_DictWordList[x].Guid!=""){
return(x);
}
}
return(false);
}
function wm_create_word(word,deep,parentNodeIndex){
var newWord=new Object();
newWord.id=com_guid();
newWord.pali=word;
if(word.substring(0,1)=='['){
newWord.real=word;
}
else{
newWord.real=com_getPaliReal(word);
}
newWord.type="";
newWord.gramma="";
newWord.mean="";
newWord.note="";
newWord.wparent="";
newWord.parentid="";
newWord.part='?';
newWord.partmean="";
newWord.partid="";
newWord.parentNode=parentNodeIndex;
newWord.deep=deep;
newWord.is_new=true;
wm_word_array.push(newWord);
return(newWord.id);
}
function wm_create_word_by_index(index,deep,parentNodeIndex){
var newWord=new Object();
newWord.id=g_DictWordList[index].Guid;
newWord.pali=g_DictWordList[index].Pali;
if(g_DictWordList[index].Real){
newWord.real=g_DictWordList[index].Real;
}
else{
newWord.real=g_DictWordList[index].Pali;
}
newWord.type=g_DictWordList[index].Type;
newWord.gramma=g_DictWordList[index].Gramma;
newWord.mean=g_DictWordList[index].Mean;
newWord.note=g_DictWordList[index].Note;
newWord.wparent=g_DictWordList[index].Parent;
newWord.parentid="";
newWord.part=g_DictWordList[index].Factors;
newWord.partmean=g_DictWordList[index].FactorMean;
newWord.partid=g_DictWordList[index].PartId;
newWord.deep=deep;
newWord.parentNode=parentNodeIndex;
newWord.is_new=false;
wm_word_array.push(newWord);
return(newWord.id);
}
function wm_updata_word(wordId,parentId){
var wordindex=wm_find_word_by_id(wordId);
var parentType="null";
var parentPart="null";
if(parentId){
parentIndex=wm_find_word_by_id(parentId);
parentType = wm_word_array[parentIndex].type;
parentPart = wm_word_array[parentIndex].part;
}
if(wordindex){
var word=wm_word_array[wordindex];
if(word.deep>wm_max_deep){
return;
}
if(word.type=="" && word.is_new){
word.type=wm_get_best_type(word,parentType);
}
if(word.gramma=="" && word.is_new){
wm_get_best_gramma(word);
}
if(word.mean=="" && word.is_new){
word.mean=wm_get_best_mean(word);
}
if(word.wparent=="" && word.is_new){
word.wparent=wm_get_best_parent(word);
}
if(word.part=='?' && word.is_new){
word.part=wm_get_best_part(word);
if(word.part==""){
word.part="?";
}
}
if(word.part==parentPart){
return;
}
var newDeep=word.deep+1;
if(word.partid==""){/*没有现成的id 需要新建*/
if(word.part!="" && word.part!="?"){
var arrNewPartId= new Array();
var arrPart=word.part.split("+");
for(var iPart in arrPart){
var find_guid_index=wm_find_first_part_index(arrPart[iPart],word.type);
var newPartId="";
if(find_guid_index){
var find_guid=g_DictWordList[find_guid_index].Guid;
if(!wm_id_exists(find_guid)){
newPartId = wm_create_word_by_index(find_guid_index,newDeep,wordindex);
}
else{
newPartId = find_guid;
}
}
else{
newPartId=wm_create_word(arrPart[iPart],newDeep,wordindex);
}
arrNewPartId.push(newPartId);
wm_updata_word(newPartId,wordId);
}
word.partid=arrNewPartId.join("+");
}
}
else{
var arrPartId=word.partid.split("+");
for(var iPart in arrPartId){
if(arrPartId[iPart]==wm_word_array[wordindex].id){/*防止循环引用*/
return;
}
}
for(var iPart in arrPartId){
if(arrPartId[iPart]!=""){
if(wm_id_exists(arrPartId[iPart])){
wm_updata_word(arrPartId[iPart],wordId);
}
else{
for(var i in g_DictWordList){
if(g_DictWordList[i].Guid==arrPartId[iPart]){
newPartId = wm_create_word_by_index(i,newDeep,wordindex);
wm_updata_word(newPartId,wordId);
}
}
}
}
}
}
}
}
//在内联字典中查找第一个匹配的零件 返回索引
function wm_find_first_part_index(word,parentType){
var typeString="";
for(var x in wordmap_child_type){
if(wordmap_child_type[x].type==parentType){
typeString=wordmap_child_type[x].value;
}
}
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word && g_DictWordList[x].Type!=""){
//language filter
if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
if(typeString.indexOf(g_DictWordList[x].Type)>=0 && g_DictWordList[x].Guid.length>0){
return(x);
}
}
}
}
return(false);
}
function wm_get_best_partid(word){
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word.real && g_DictWordList[x].PartId!=""){
return(g_DictWordList[x].PartId);
}
}
return("");
}
function wm_get_best_type(word,parentType){
var typeString="";
for(var x in wordmap_child_type){
if(wordmap_child_type[x].type==parentType){
typeString=wordmap_child_type[x].value;
}
}
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word.real && g_DictWordList[x].Type!=""){
if(typeString==""){
return(g_DictWordList[x].Type);
}
else{
if(typeString.indexOf(g_DictWordList[x].Type)>=0){
return(g_DictWordList[x].Type);
}
}
}
}
return("");
}
function wm_get_best_gramma(word){
if(word.type==""){
return("");
}
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
if(g_DictWordList[x].Gramma!=""){
return(g_DictWordList[x].Gramma);
}
}
}
return("");
}
//在内联字典中查找第一个匹配的意思
function wm_get_best_mean(word){
if(word.type==""){
return("");
}
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
if(g_DictWordList[x].Mean!=""){
return(g_DictWordList[x].Mean.split("$")[0]);
}
}
}
}
return("");
}
function wm_type_match(type1,type2){
if(type1==".ti:base" || type1==".adj:base."){
if(type2==type1==".ti:base" || type1==".adj:base."){
return(true);
}
}
else{
if(type1==type2){
return(true);
}
}
return(false);
}
function wm_get_best_parent(word){
if(word.type==""){
return("");
}
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
if(g_DictWordList[x].Parent!=""){
return(g_DictWordList[x].Parent);
}
}
}
return("");
}
function wm_get_best_part(word){
if(word.type==""){
return("");
}
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
if(g_DictWordList[x].Factors!=""){
return(g_DictWordList[x].Factors);
}
}
}
return("");
}
function wm_find_word_by_id(wordId){
for(xWord in wm_word_array){
if(wm_word_array[xWord].id==wordId){
return(xWord);
}
}
return(false);
}
function wm_render_word_map(wordId){
wm_curr_deep=0;
if(wm_render_mode){
return(wm_render_word_block_H(wordId));
}
else{
return(wm_render_word_block(wordId));
}
}
function wm_render_word_block(wordId){
if(wm_curr_deep>=wm_max_deep){
return;
}
wm_word_box_count++;
wm_curr_deep++;
var wordIndex = wm_find_word_by_id(wordId);
if(wordIndex){
var output="";
output += "
";
if(wm_word_array[wordIndex].partid.length>0){
var parts=wm_word_array[wordIndex].partid.split("+");
for(var x in parts){
if(parts[x]==wm_word_array[wordIndex]){
wm_notify("Error:part ID loop link!");
return;
}
}
for(var x in parts){
output += wm_render_word_block(parts[x]);
}
}
output += "
";
output += "
";
output += "
";
wm_curr_deep--;
return(output);
}
}
function wm_render_word_block_H(wordId){
if(wm_curr_deep>=wm_max_deep){
return;
}
wm_word_box_count++;
wm_curr_deep++;
var wordIndex = wm_find_word_by_id(wordId);
if(wordIndex){
var output="";
output += "
";
return(output);
}
//閲讀模式二渲染
function wm_render_word_base_read2(wordIndex){
var output="";
var sameRecorderMenu=wm_render_same_word_recoder_menu_for_read(wordIndex);
var isNewClass="";
if(wm_word_array[wordIndex].is_new){
isNewClass=" word_new ";
}
if(wm_render_mode){
output += "
";
output += sameRecorderMenu
}
else{
output += "
";
output += sameRecorderMenu
}
var arrMean=wm_word_array[wordIndex].mean.split("$");
var strMeanMenu="";
strMeanMenu=wm_render_word_mean_menu2(wordIndex,arrMean);
var sameRecorderCount=wm_get_same_word_recorder_count(wordIndex);
var sameRecorderMenu=wm_render_same_word_recoder_menu_for_read(wordIndex);
output += "
";
return(output);
}
//渲染meaning选择列表
function wm_render_word_mean_menu(wordIndex,meanList){
//查找父节点中的对应的意思在本节点意思列表中的位置
var indexOfMean = wm_get_part_mean_index_in_list(wordIndex);
var defaultMean=meanList[0];
if(indexOfMean>=0){
defaultMean=meanList[indexOfMean];
}
var output="";
output +="
";
return(output);
}
//渲染相同拼写的成品零件选择列表
function wm_render_same_word_recoder_menu_for_read(wordIndex){
//拿到零件數據列表
var partList=wm_get_same_word_recorder(wordIndex);
//渲染數量角標
var output="";
output +="
";
var L_width_dictname=0
var L_width_typegramma=0
var L_width_mean=0
//首次抓取數據
for(var string_max_length_i in partList){
var dictname=g_DictWordList[partList[string_max_length_i]].dictname;
var thisType=getLocalGrammaStr(g_DictWordList[partList[string_max_length_i]].Type);
var thisGramma=getLocalGrammaStr(g_DictWordList[partList[string_max_length_i]].Gramma);
var thisMean=g_DictWordList[partList[string_max_length_i]].Mean;
//計算最適寬度
var L_width=getLocalGrammaStr(thisMean).replace(/[\u0391-\uFFE5]/g,"aa").length;
if(L_width_mean=12){
L_width_mean=12;
break;
}
}
for(var wm_for_read_i in partList){
output +="";
//拿到詞典信息
var dictname=g_DictWordList[partList[wm_for_read_i]].dictname;
//渲染詞典信息
output +="
";
return(output);
}
function wm_render_word_type_edit(wordIndex){
var output="";
var typeList=wm_get_word_type_list(wordIndex);
output +="";
//渲染數量角標
output +="
";
return(output);
}
function switch_input_span(id,position){
document.getElementById("info_num_"+position+"_dropdown_"+id+"_div").style.display="none";
document.getElementById(position+"_"+id+"_span").style.display="none";
document.getElementById(position+"_"+id+"_input").style.display="block";
document.getElementById(position+"_"+id+"_input").focus();
}
function switch_input_span2(id,position){
document.getElementById("info_num_"+position+"_dropdown_"+id+"_div").style.display="block";
document.getElementById(position+"_"+id+"_span").style.display="block";
document.getElementById(position+"_"+id+"_input").style.display="none";
}
function wm_render_word_parent_edit(wordIndex){
var output="";
var parentList=wm_get_word_parent_list(wordIndex);
output +="
";
//output += "";
return(output);
}
function wm_render_word_part_edit(wordIndex){
var output="";
var partList=wm_get_word_part_list(wordIndex)
output +="
";
return(output);
}
function wm_get_word_type_list(wordIndex){
var wPali=wm_word_array[wordIndex].pali;
var wReal=wm_word_array[wordIndex].real;
var wType=wm_word_array[wordIndex].type;
var output = Array();
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==wReal){
if(g_DictWordList[x].Type!=""){
var newItem= Object();
newItem.dict=g_DictWordList[x].dictname;
newItem.type=g_DictWordList[x].Type;
output.push(newItem);
}
}
}
return(output);
}
function wm_get_word_gramma_list(wordIndex){
var wPali=wm_word_array[wordIndex].pali;
var wReal=wm_word_array[wordIndex].real;
var wType=wm_word_array[wordIndex].type;
var output = Array();
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==wReal && wm_type_match(g_DictWordList[x].Type,wType)){
if(g_DictWordList[x].Gramma!=""){
var newPart= Object();
newPart.dict=g_DictWordList[x].dictname;
newPart.gramma=g_DictWordList[x].Gramma;
output.push(newPart);
}
}
}
return(output);
}
function wm_get_word_part_list(wordIndex){
var wPali=wm_word_array[wordIndex].pali;
var wReal=wm_word_array[wordIndex].real;
var wType=wm_word_array[wordIndex].type;
var output = Array();
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==wReal && wm_type_match(g_DictWordList[x].Type,wType)){
if(g_DictWordList[x].Factors!=""){
var newPart= Object();
newPart.dict=g_DictWordList[x].dictname;
newPart.part=g_DictWordList[x].Factors;
output.push(newPart);
}
}
}
return(output);
}
function wm_get_word_mean_list(wordIndex){
var wPali=wm_word_array[wordIndex].pali;
var wReal=wm_word_array[wordIndex].real;
var wType=wm_word_array[wordIndex].type;
var output = Array();
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==wReal && ( wm_type_match(g_DictWordList[x].Type,wType) || g_DictWordList[x].Type=="")){
if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
if(g_DictWordList[x].Mean!=""){
var newPart= Object();
newPart.dict=g_DictWordList[x].dictname;
newPart.mean=g_DictWordList[x].Mean;
output.push(newPart);
}
}
}
}
return(output);
}
function wm_get_word_parent_list(wordIndex){
var wPali=wm_word_array[wordIndex].pali;
var wReal=wm_word_array[wordIndex].real;
var wType=wm_word_array[wordIndex].type;
var output = Array();
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==wReal && wm_type_match(g_DictWordList[x].Type,wType)){
if(g_DictWordList[x].Parent!=""){
var newPart= Object();
newPart.dict=g_DictWordList[x].dictname;
newPart.wparent=g_DictWordList[x].Parent;
output.push(newPart);
}
}
}
return(output);
}
function wm_get_word_index_with_part_from_dict(word){
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word){
if(g_DictWordList[x].Factors!=""){
return(x);
}
}
}
return(-1);
}
function wm_get_word_first_mean(word){
for(var x in g_DictWordList){
if(g_DictWordList[x].Pali==word){
//语言过滤
if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
if(g_DictWordList[x].Mean!=""){
return(g_DictWordList[x].Mean);
}
}
}
}
return("");
}
function wm_render_line(){
if(wm_render_mode){//纵向
wm_render_line_h();
}
else{//横向划线
wm_render_line_v();
}
}
//横向划线
function wm_render_line_v(){
for(iBox=0;iBox0)
var output="";
output += "
";
output += "";
output += "
";
obj.innerHTML=output;
}
}
}
function wm_render_line_h(){
for(iBox=0;iBox0)
var output="";
output += "
";
output += "";
output += "
";
obj.innerHTML=output;
}
}
}
//获取同样拼写单词的已经存在的成品零件记录数量
function wm_get_same_word_recorder_count(wordIndex){
return(wm_get_same_word_recorder(wordIndex).length);
}
//获取同样拼写单词的已经存在的成品零件记录
function wm_get_same_word_recorder(wordIndex){
var output=new Array();
var typeString="";
for(var wm_get_same_word_recorder_x in g_DictWordList){
if(g_DictWordList[wm_get_same_word_recorder_x].Pali==wm_word_array[wordIndex].real){
if(g_DictWordList[wm_get_same_word_recorder_x].Guid && g_DictWordList[wm_get_same_word_recorder_x].Guid.length>0){//修改循環計數值的名字,并進行非空判斷
var parentIndex=wm_word_array[wordIndex].parentNode;
if(parentIndex){
if(g_DictWordList[wm_get_same_word_recorder_x].Guid!=wm_word_array[parentIndex].id){
output.push(wm_get_same_word_recorder_x);
}
}
}
}
}
return(output);
}
function wm_field_change(wordIndex,field,value){
switch(field){
case "type":
wm_word_array[wordIndex].type=value;
wm_caseChanged(wordIndex,"type",value);
wm_updata_word_root_edit(wordIndex);
break;
case "gramma":
wm_word_array[wordIndex].gramma=value;
var wm_field_change_gramma=value.split("$");
if(wm_field_change_gramma.length>0 && wm_field_change_gramma.length<4){
for(wm_field_change_gramma_i in wm_field_change_gramma){
wm_caseChanged(wordIndex,"case"+(wm_field_change_gramma_i+1),value);
}
}
else{
wm_caseChanged(wordIndex,"case1",value);
}
wm_updata_word_root_edit(wordIndex);
break;
case "mean":
wm_word_array[wordIndex].mean=value;
wm_updata_word_root_edit(wordIndex);
switch_input_span2(wordIndex,"mean");
break;
case "mean_add":
wm_word_array[wordIndex].mean+="$"+value;
wm_updata_word_root_edit(wordIndex);
break;
case "parent":
wm_word_array[wordIndex].wparent=value;
wm_updata_word_root_edit(wordIndex);
break;
case "part":
if(wm_word_array[wordIndex].part!=value){
wm_word_array[wordIndex].part=value;
wm_word_array[wordIndex].partid="";
wm_updata_word(rootId,null);
wm_updata_word_map();
wm_render_line();
switch_input_span2(wordIndex,"part");
//wm_refresh_inline_dict(wordIndex);
}
break;
}
}
function wm_dict_one_done(dictIndex){
wm_notify("pass:"+(g_dictFindParentLevel+1)+" "+g_dictList[dictIndex].name + "done");
}
function wm_dict_search_one_pass_done(pass){
wm_notify("pass:"+(pass+1)+" is done");
wm_updata_word(rootId,null);
wm_updata_word_map();
wm_render_line();
}
function wm_notify(message){
var objNotify=document.getElementById('wm_doc_notify');
if(objNotify){
objNotify.style.display="inline";
objNotify.innerHTML=message;
setTimeout("document.getElementById('wm_doc_notify').style.display='none'",5000);
}
}
function wm_dict_all_done(){
wm_updata_word(rootId,null);
wm_updata_word_map();
wm_render_line();
}
function wm_refresh_inline_dict(wordIndex){
currMatchingDictNum=0;
g_dictFindParentLevel=0;
g_dictFindAllDone=false;
g_dict_search_one_dict_done=wm_dict_one_done;
g_dict_search_one_pass_done=wm_dict_search_one_pass_done;
g_dict_search_all_done=wm_dict_all_done;
dict_mark_word_list_done();
//dict_push_word_to_download_list(wm_word_array[wordIndex].wparent,1);
var arrPart=wm_word_array[wordIndex].part.split("+");
for(var ipart in arrPart){
dict_push_word_to_download_list(arrPart[ipart],1);
}
var arrBuffer=dict_get_search_list();
if(arrBuffer.length>0){
g_CurrDictBuffer=JSON.stringify(arrBuffer);
dict_mark_word_list_done();
editor_dict_match();
}
else{
wm_notify("no new part");
}
}
function wm_recorder_change(wordIndex,newIndex){
var oldGuid=wm_word_array[wordIndex].id;
if(newIndex>=0){
var newGuid=g_DictWordList[newIndex].Guid;
var parentNodeIndex=wm_word_array[wordIndex].parentNode;
if(parentNodeIndex){
wm_word_array[parentNodeIndex].partid = wm_word_array[parentNodeIndex].partid.replace(oldGuid,newGuid);
wm_updata_word(rootId,null);
wm_updata_word_map();
wm_render_line();
}
}
else{//new
newPartId=wm_create_word(wm_word_array[wordIndex].pali,wm_word_array[wordIndex].deep,wm_word_array[wordIndex].parentNode);
var parentNodeIndex=wm_word_array[wordIndex].parentNode;
if(parentNodeIndex){
wm_word_array[parentNodeIndex].partid = wm_word_array[parentNodeIndex].partid.replace(oldGuid,newPartId);
wm_updata_word(rootId,null);
wm_updata_word_map();
wm_render_line();
}
//wm_updata_word(newPartId,wordId);
}
}
function wm_part_mean_change(wordIndex,newMean){
var wordId=wm_word_array[wordIndex].id;
var parentNodeIndex=wm_word_array[wordIndex].parentNode;
if(parentNodeIndex){
var arrPartId=wm_word_array[parentNodeIndex].partid.split('+');
var indexOfMean=-1;
for(var i in arrPartId){
if(arrPartId[i]==wordId){
indexOfMean=i;
break;
}
}
if(indexOfMean>=0){
var arrMean = wm_word_array[parentNodeIndex].partmean.split('+');
arrMean.length=arrPartId.length;
arrMean[indexOfMean]=newMean;
wm_word_array[parentNodeIndex].partmean=arrMean.join('+');
wm_updata_word(rootId,null);
wm_updata_word_map();
wm_render_line();
}
}
}
//查找父节点中的对应的意思在本节点意思列表中的位置
function wm_get_part_mean_index_in_list(wordIndex){
var wordId=wm_word_array[wordIndex].id;
var parentNodeIndex=wm_word_array[wordIndex].parentNode;
{
if(parentNodeIndex){
var arrPartId=wm_word_array[parentNodeIndex].partid.split('+');
var indexOfMean=-1;
for(var i in arrPartId){
if(arrPartId[i]==wordId){
indexOfMean=i;
break;
}
}
if(indexOfMean>=0){
var arrMean = wm_word_array[parentNodeIndex].partmean.split('+');
arrMean.length=arrPartId.length;
var parentPartMean = arrMean[indexOfMean];
var wordMeanArray=wm_word_array[wordIndex].mean.split("$");
for(var j in wordMeanArray){
if(wordMeanArray[j]==parentPartMean){
return(j);
}
}
}
}
}
return(-1);
}
function wm_id_exists(findid){
for(var i in wm_word_array){
if(wm_word_array[i].id==findid){
return(true);
}
}
return(false);
}
function wm_save_node_all(){
wm_array_word_for_save=new Array();
wm_save_node(rootId);
var_dump("save tree ok.");
wm_WbwUpdata(wm_array_word_for_save)
pop_win_close();
}
function wm_save_node(nodeId,withChild=true){
var wid=-1;
for(var i in wm_word_array){
if(wm_word_array[i].id==nodeId){
wid=i;
}
}
if(wid==-1){
return;
}
wm_array_word_for_save.push(wm_word_array[wid]);
var objDictItem=new Object();/*一个字典元素*/
objDictItem.Id = 0;
objDictItem.Guid = wm_word_array[wid].id;
objDictItem.Pali = wm_word_array[wid].pali;
objDictItem.Mean = wm_word_array[wid].mean;
objDictItem.Type = wm_word_array[wid].type;
objDictItem.Gramma = wm_word_array[wid].gramma;
objDictItem.Parent = wm_word_array[wid].wparent;
objDictItem.ParentId = wm_word_array[wid].parentid;
objDictItem.Factors = wm_word_array[wid].part;
objDictItem.PartId = wm_word_array[wid].partid;
objDictItem.FactorMean = wm_word_array[wid].partmean;
objDictItem.Note = "";
objDictItem.Confer = "";
objDictItem.Status = "1024";
objDictItem.Enable = "true";
objDictItem.Language = "sc";
objDictItem.dictname = "user";
objDictItem.dictType="user";
objDictItem.fileName="user.db3";
objDictItem.dictID="0";
objDictItem.ParentLevel = g_dictFindParentLevel;
g_DictWordList.unshift(objDictItem);
editor_insertNewWordToInlineDict(objDictItem);
if(withChild){
if(wm_word_array[wid].partid!=""){
var arrChild=wm_word_array[wid].partid.split("+");
for(var i in arrChild){
wm_save_node(arrChild[i]);
}
}
}
}
// word by word dict updata
var wm_wbwUpdataXmlHttp=null;
function wm_WbwUpdata(arrWord){
var xmlText="";
if(window.XMLHttpRequest)
{// code for IE7, Firefox, Opera, etc.
wm_wbwUpdataXmlHttp=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{// code for IE6, IE5
wm_wbwUpdataXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (wm_wbwUpdataXmlHttp!=null)
{
var queryString="";
var x = gXmlBookDataBody.getElementsByTagName("word");
var iCount=0;
var d_language=language_translation;
for(var index in arrWord){
var d_pali=arrWord[index].real;
var d_guid=arrWord[index].id;
var d_type = arrWord[index].type;
var d_gramma = arrWord[index].gramma;
var d_mean=arrWord[index].mean;
var d_note=arrWord[index].note;
var d_parent=com_getPaliReal(arrWord[index].wparent);
var d_parent_id=arrWord[index].parentid;
var d_factors=arrWord[index].part;
var d_fm=arrWord[index].partmean;
var d_part_id=arrWord[index].partid;
var d_confer="";
var d_status="1024";
var d_enable="TRUE";
if(d_pali.length>0 && !(d_mean=="" && d_factors=="" && d_fm=="" && d_type=="")){
queryString+="";
queryString+=""+d_pali+"";
queryString+=""+d_guid+"";
queryString+=""+d_type+"";
queryString+=""+d_gramma+"";
queryString+=""+d_parent+"";
queryString+=""+d_parent_id+"";
queryString+=""+d_mean+"";
queryString+=""+d_note+"";
queryString+=""+d_factors+"";
queryString+=""+d_fm+"";
queryString+=""+d_part_id+"";
queryString+=""+d_confer+"";
queryString+=""+d_status+"";
queryString+=""+d_enable+"";
queryString+=""+d_language+"";
queryString+="";
iCount++;
}
}
queryString+="";
if(iCount>0){
wm_wbwUpdataXmlHttp.onreadystatechange=wm_wbwDictUpdata_serverResponse;
debugOutput("updata user dict start.",0);
wm_wbwUpdataXmlHttp.open("POST", "dict_updata_wbw.php", true);
wm_wbwUpdataXmlHttp.send(queryString);
}
else{
debugOutput("no user dicttionary data need updata.",0);
}
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function wm_wbwDictUpdata_serverResponse(){
if (wm_wbwUpdataXmlHttp.readyState==4)// 4 = "loaded"
{
debugOutput("server response.",0);
if (wm_wbwUpdataXmlHttp.status==200)
{// 200 = "OK"
var serverText = wm_wbwUpdataXmlHttp.responseText;
var_dump(serverText);
debugOutput(serverText,0);
}
else
{
debugOutput(xmlhttp.statusText,0);
}
}
}
function wm_word_base_mouse_over(currWordIndex){
if(currWordIndex==wm_word_base_curr_focuse){
return;
}
wm_word_base_curr_focuse=currWordIndex;
switch(wm_show_mode){
case 0:
wm_updata_word_root_read(currWordIndex);
break;
case 1:
wm_updata_word_root_read2(currWordIndex);
break;
case 2://edit
wm_updata_word_root_edit(currWordIndex);
break;
}
}
function wm_look_up(word){
editor_show_right_tool_bar(true);
document.getElementById("dict_ref_search_input").value=word;
dict_search(word);
}
function wm_input_keyup(e,wordIndex,mean,value){
var keynum
//var keychar
//var numcheck
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
//var keychar = String.fromCharCode(keynum)
if(keynum==13){
wm_field_change(wordIndex,mean,value);
}
}
function wm_render_word_typegramma_edit(wm_type,case1,case2,case3,wordIndex,padding_width){
var output="";
var strTypeSelect="";
var wm_case_Select_Array=new Array();
var typeList=wm_get_word_type_list(wordIndex);
var itemList=wm_get_word_gramma_list(wordIndex);
output +="";
//渲染數量角標
output +="