var arrTerm = new Array(); var arrTerm2 = new Array(); var arrMyTerm = new Array(); var arrAllMean = new Array(); var arrTermAllPali = new Array(); var arrWordIdTermId = new Array(); var strTermTanslationTmp="[%mean%](%pali% %mean2% %mymean%)"; var strTermTanslationTmp2="[%mean%]"; var termCounter=new Array(); var noteCounter=0; //正文内注释计数器 function note(noteId,strDef="unkow"){ document.write("haha"); } function note_replace(strIn){ /* */ var output = strIn.replace("/*",""); return(output); } //将存储状态的字符串转换为预显示字符串 //设置状态为 0:未处理的原始状态 function term_std_str_to_tran(strIn){ return(strIn.replace(/\[\[/g,"").replace(/\]\]/g,"")); } function term_std_str_to_edit(strIn){ var arrText = strIn.split("/"); for(var i in arrText){ //头尾是* if(arrText[i].substring(0,1)=="*" && arrText[i].substring(arrText[i].length-1)=="*"){ var arrOneTermWord=arrText[i].split("@"); if(arrOneTermWord.length==2){ arrText[i]="*"+arrOneTermWord[1]; } } } return(arrText.join("/")); } function term_tran_edit_replace(strIn){ var strEdit=strIn; for(var x=0;x0){ try{ arrTermAllPali = JSON.parse(data); } catch(e){ console.error("term_get_all_pali:"+e+" data:"+data); } } }); } function term_lookup_all(pali){ for(var x in arrTermAllPali){ if(arrTermAllPali[x].word==pali){ return(arrTermAllPali[x]); } } return(null); } function term_get_my(){ $.get("term.php", { op:"my" }, function(data,status){ if(data.length>0){ try{ arrMyTerm = JSON.parse(data); } catch(e){ console.error(e.error+" data:"+data); } } }); } //在我的术语字典里查询 function term_lookup_my(pali){ for(var x in arrMyTerm){ if(arrMyTerm[x].meaning==pali){ return(arrMyTerm[x]); } if(arrMyTerm[x].word==pali){ return(arrMyTerm[x]); } } return(null); } function term_lookup_my_id(id){ for(var x in arrMyTerm){ if(arrMyTerm[x].guid==id){ return(arrMyTerm[x]); } } return(null); } function term_get_all_meaning(word){ $.get("term.php", { op:"allmean", word:word }, function(data,status){ $("#term_win_other_mean").html(data); }); } //刷新文档正在使用的术语数据 function term_array_updata(){ arrTerm2=new Array(); var arrTermDownLoadList=new Array(); var arrWordIdTermId=new Array(); var xAllWord = gXmlBookDataBody.getElementsByTagName("word"); for(var x=0;x0){ var idlist=arrTermDownLoadList.join(); idlist = idlist.replace(/,/g,"','"); idlist = "'"+ idlist + "'"; $.get("term.php", { op:"extract", list:idlist }, function(data,status){ var obj = JSON.parse(data); for(var x in obj){ arrTerm[obj[x].guid]=obj[x]; arrTerm2.push(obj[x]); } if(g_eCurrWord){ updataWordHeadById(getNodeText(g_eCurrWord,"id")); refreshWordNote(g_eCurrWord.parentNode.parentNode); } for(var i=0;i["+noteCounter+"]"); noteCounter++; } else{ if(status==0){ let myterm=term_lookup_my(termText);//我的术语字典 if(myterm){ $(this).attr("status","1"); $(this).attr("type","0"); $(this).attr("guid",myterm.guid); $(this).attr("pali",myterm.word); $(this).attr("mean",myterm.meaning); $(this).attr("mean2",myterm.other_meaning); $(this).attr("replace",myterm.meaning); } else{ $(this).attr("status","2"); } } let guid=$(this).attr("guid"); let pali=$(this).attr("pali"); let mean=$(this).attr("mean"); let mean2=$(this).attr("mean2"); var renderTo=$(this).attr("pos"); var noteText=""; if(termCounter[guid]){ termCounter[guid]=2; } else{ termCounter[guid]=1; } var myterm=term_lookup_my(pali);//我的术语字典 let linkclass=""; if(myterm){ linkclass="term_link"; } else{ linkclass="term_link_new"; } if(guid){ if(renderTo=="wbw"){ noteText="%note%"; } else{ if(termCounter[guid]==1){ noteText=strTermTanslationTmp; } else{ noteText=strTermTanslationTmp2; } } noteText=noteText.replace("[",""); noteText=noteText.replace("]",""); noteText=noteText.replace("%mean%",""+mean+""); noteText=noteText.replace("%pali%",""+pali+""); noteText=noteText.replace("%mean2%",""+mean2+""); noteText=noteText.replace("%note%",""+""+""); if(myterm){ if(myterm.meaning!=mean){ noteText=noteText.replace("%mymean%",""+myterm.meaning+""); } else{ noteText=noteText.replace("%mymean%",""); } } else{ noteText=noteText.replace("%mymean%",""); } } else{ noteText=""+termText+""; } $(this).html(noteText); } }); } function term_show_win(guid,keyWord=""){ if(guid==""){ $(term_body).html("当前词条未创建。
现在创建"); } else{ let currWord = term_lookup_my_id(guid); if(currWord){ let termString=""; let pali=currWord.word; let pali_1= pali.substring(0,1).toUpperCase(); pali=pali_1+pali.substring(1); let mean=currWord.meaning; let myterm=term_lookup_my(currWord.word);//我的术语字典 termString+="
"+pali+"
"; termString+="
意思:"+currWord.meaning+"
"; termString+="
其他意思:"+currWord.other_meaning+"
"; termString+="
我的词库:"; if(myterm){ termString+=""+myterm.meaning+" "; } else{ termString+=""; } termString+="其他:"; termString+="
"; if(currWord.note){ termString+="
"+currWord.note+"
"; } else{ termString+="
Loading
"; } $(term_body).html(termString); term_get_all_meaning(currWord.word); if(!currWord.note){ $.get("term.php", { op:"load_id", id:currWord.guid }, function(data,status,xhr){ switch(status){ case "success": try{ let loadWord = JSON.parse(data); $("#term_win_note").html(loadWord[0].note); //修改内存数据 for(let x in arrMyTerm){ if(arrMyTerm[x].guid==loadWord[0].guid){ arrMyTerm[x].note=loadWord[0].note; return; } } } catch(e){ console.error(e+" data:"+data); } break; case "error": console.error("Error: "+xhr.status+": "+xhr.statusText); break; } }); } } else{ $(term_body).html("undefined guid"); } } document.getElementById("term_win").style.display="flex"; } function term_tmp(type,tmp){ if(tmp=="new"){ switch(type){ case "a": strTermTanslationTmp=$("#term_my_tmp").val(); break; case "a2": strTermTanslationTmp2=$("#term_my_tmp").val(); break; } } else{ switch(type){ case "a": strTermTanslationTmp=tmp; break; case "a2": strTermTanslationTmp2=tmp; break; } } term_updata_translation(); } function term_add_new(keyword){ document.getElementById("term_win").style.display="none"; editor_show_right_tool_bar(true); tab_click_b('term_dict','tab_rb_dict'); note_lookup(keyword,"term_dict"); }