wordmap.js 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976
  1. var wm_max_deep=10;
  2. var wm_curr_deep=0;
  3. var wm_word_box_count=0;
  4. var wm_word_array=null;
  5. var wm_render_mode=false; //false 横向 true 纵向
  6. var wm_show_mode=0; //0 最简单 1 复杂
  7. var rootId;
  8. var wm_array_word_for_save;
  9. var wm_word_base_curr_focuse=-1;
  10. var wm_case=new Array()
  11. function show_word_map(g_currEditWord){
  12. //closeModifyWindow();//关闭单词修改窗口
  13. wm_word_box_count=0;
  14. wm_word_array=new Array();
  15. wm_array_word_for_save=new Array();
  16. wm_word_base_curr_focuse=-1;
  17. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  18. wid=getWordIndex(g_currEditWord);
  19. var sReal = getNodeText(xAllWord[wid],"real");
  20. rootId=wm_create_root_word(g_currEditWord);
  21. wm_updata_word(rootId,null);
  22. var strWordMapWin="<div class='wm_div'>";
  23. strWordMapWin += "<div id='wm_title'></div>";
  24. strWordMapWin += "<div id='wm_body'>";
  25. strWordMapWin += "<div id='wm_body_inner'>";
  26. strWordMapWin += "<div id='wm_word_block_0'>";//套殻
  27. strWordMapWin += "</div>";//套殻
  28. strWordMapWin += "</div>";
  29. strWordMapWin += "</div>";
  30. strWordMapWin += "</div>";
  31. getStyleClass("pop_win_full").style.display = "-webkit-flex";
  32. getStyleClass("pop_win_full").style.animation = "2s";
  33. document.getElementById("pop_win_inner").innerHTML=strWordMapWin;
  34. wm_updata_title();
  35. wm_updata_word_map();
  36. wm_render_line();
  37. }
  38. function pop_win_close(){
  39. document.getElementById("pop_win_inner").innerHTML = "";
  40. getStyleClass("pop_win_full").style.display = "none";
  41. }
  42. function wm_render_title(){
  43. var output = "<div><span id=\"wm_doc_notify\" style=\"position: absolute;top: 3em;\"></span>";
  44. output += "<button onclick='pop_win_close()'>Close</button>";
  45. if(wm_render_mode){
  46. output += "<ul class='radio-button'><li onclick=\"wm_change_mode(false)\">↔</li><li class='li_act'>↕</li></ul>";
  47. }
  48. else{
  49. output += "<ul class='radio-button'><li class='li_act'>↔</li><li onclick=\"wm_change_mode(true)\">↕</li></ul>";
  50. }
  51. switch(wm_show_mode){
  52. case 0:
  53. output += "<ul class='radio-button'><li class='li_act'>−</li><li onclick=\"wm_change_show_mode(1)\">≡</li><li onclick=\"wm_change_show_mode(2)\">Edit</li></ul>";
  54. break;
  55. case 1:
  56. output += "<ul class='radio-button'><li onclick=\"wm_change_show_mode(0)\">−</li><li class='li_act'>≡</li><li onclick=\"wm_change_show_mode(2)\">Edit</li></ul>";
  57. break;
  58. case 2:
  59. output += "<ul class='radio-button'><li onclick=\"wm_change_show_mode(0)\">−</li><li onclick=\"wm_change_show_mode(1)\">≡</li><li class='li_act'>Edit</li></ul>";
  60. break;
  61. }
  62. output += "</div>";
  63. output += "<div><span>Word Map</span></div>";
  64. output += "<div><button onclick='wm_refresh_inline_dict(0)'>Look Up</button><button onclick='wm_save_node_all()'>Save</button><div>";
  65. return(output);
  66. }
  67. function wm_updata_title(){
  68. document.getElementById("wm_title").innerHTML=wm_render_title();;
  69. }
  70. function wm_updata_word_map(){
  71. document.getElementById("wm_word_block_0").innerHTML=wm_render_word_map(rootId);;
  72. // document.getElementById("wm_body").innerHTML=wm_render_word_map(rootId);;
  73. }
  74. function wm_change_mode(newmode){
  75. wm_word_box_count=0;
  76. wm_render_mode=newmode;
  77. wm_updata_title();
  78. wm_updata_word_map();
  79. wm_render_line();
  80. }
  81. function wm_change_show_mode(newmode){
  82. wm_word_box_count=0;
  83. wm_show_mode=newmode;
  84. wm_updata_title();
  85. wm_updata_word_map();
  86. wm_render_line();
  87. }
  88. function wm_create_root_word(wordid){
  89. wid=getWordIndex(wordid);
  90. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  91. var sReal = getNodeText(xAllWord[wid],"real");
  92. var newWord=new Object();
  93. var indexOfExist=wm_find_exist_part(sReal);
  94. if(indexOfExist){
  95. newWord.is_new=false;
  96. newWord.id=g_DictWordList[indexOfExist].Guid;
  97. newWord.part=g_DictWordList[indexOfExist].Factors;
  98. newWord.partmean=g_DictWordList[indexOfExist].FactorMean;
  99. newWord.partid=g_DictWordList[indexOfExist].PartId;
  100. }
  101. else{
  102. newWord.is_new=true;
  103. newWord.id=com_guid();
  104. newWord.part=getNodeText(xAllWord[wid],"org");
  105. newWord.partmean=getNodeText(xAllWord[wid],"om");
  106. newWord.partid=wm_get_best_partid(newWord);
  107. }
  108. newWord.pali=sReal;
  109. newWord.real=sReal;
  110. newWord.type=getNodeText(xAllWord[wid],"case").split("#")[0];
  111. newWord.gramma=getNodeText(xAllWord[wid],"case").split("#")[1];
  112. newWord.mean=getNodeText(xAllWord[wid],"mean");
  113. newWord.note=getNodeText(xAllWord[wid],"note");
  114. newWord.wparent=getNodeText(xAllWord[wid],"parent").replace(/ /g,"");//去空格
  115. newWord.parentid="";
  116. newWord.parentNode=null;
  117. newWord.deep=0;
  118. wm_word_array.push(newWord);
  119. return(newWord.id);
  120. }
  121. function wm_find_exist_part(word){
  122. for(var x in g_DictWordList){
  123. if(g_DictWordList[x].Pali==word && g_DictWordList[x].Guid!=""){
  124. return(x);
  125. }
  126. }
  127. return(false);
  128. }
  129. function wm_create_word(word,deep,parentNodeIndex){
  130. var newWord=new Object();
  131. newWord.id=com_guid();
  132. newWord.pali=word;
  133. if(word.substring(0,1)=='['){
  134. newWord.real=word;
  135. }
  136. else{
  137. newWord.real=com_getPaliReal(word);
  138. }
  139. newWord.type="";
  140. newWord.gramma="";
  141. newWord.mean="";
  142. newWord.note="";
  143. newWord.wparent="";
  144. newWord.parentid="";
  145. newWord.part='?';
  146. newWord.partmean="";
  147. newWord.partid="";
  148. newWord.parentNode=parentNodeIndex;
  149. newWord.deep=deep;
  150. newWord.is_new=true;
  151. wm_word_array.push(newWord);
  152. return(newWord.id);
  153. }
  154. function wm_create_word_by_index(index,deep,parentNodeIndex){
  155. var newWord=new Object();
  156. newWord.id=g_DictWordList[index].Guid;
  157. newWord.pali=g_DictWordList[index].Pali;
  158. if(g_DictWordList[index].Real){
  159. newWord.real=g_DictWordList[index].Real;
  160. }
  161. else{
  162. newWord.real=g_DictWordList[index].Pali;
  163. }
  164. newWord.type=g_DictWordList[index].Type;
  165. newWord.gramma=g_DictWordList[index].Gramma;
  166. newWord.mean=g_DictWordList[index].Mean;
  167. newWord.note=g_DictWordList[index].Note;
  168. newWord.wparent=g_DictWordList[index].Parent;
  169. newWord.parentid="";
  170. newWord.part=g_DictWordList[index].Factors;
  171. newWord.partmean=g_DictWordList[index].FactorMean;
  172. newWord.partid=g_DictWordList[index].PartId;
  173. newWord.deep=deep;
  174. newWord.parentNode=parentNodeIndex;
  175. newWord.is_new=false;
  176. wm_word_array.push(newWord);
  177. return(newWord.id);
  178. }
  179. function wm_updata_word(wordId,parentId){
  180. var wordindex=wm_find_word_by_id(wordId);
  181. var parentType="null";
  182. var parentPart="null";
  183. if(parentId){
  184. parentIndex=wm_find_word_by_id(parentId);
  185. parentType = wm_word_array[parentIndex].type;
  186. parentPart = wm_word_array[parentIndex].part;
  187. }
  188. if(wordindex){
  189. var word=wm_word_array[wordindex];
  190. if(word.deep>wm_max_deep){
  191. return;
  192. }
  193. if(word.type=="" && word.is_new){
  194. word.type=wm_get_best_type(word,parentType);
  195. }
  196. if(word.gramma=="" && word.is_new){
  197. wm_get_best_gramma(word);
  198. }
  199. if(word.mean=="" && word.is_new){
  200. word.mean=wm_get_best_mean(word);
  201. }
  202. if(word.wparent=="" && word.is_new){
  203. word.wparent=wm_get_best_parent(word);
  204. }
  205. if(word.part=='?' && word.is_new){
  206. word.part=wm_get_best_part(word);
  207. if(word.part==""){
  208. word.part="?";
  209. }
  210. }
  211. if(word.part==parentPart){
  212. return;
  213. }
  214. var newDeep=word.deep+1;
  215. if(word.partid==""){/*没有现成的id 需要新建*/
  216. if(word.part!="" && word.part!="?"){
  217. var arrNewPartId= new Array();
  218. var arrPart=word.part.split("+");
  219. for(var iPart in arrPart){
  220. var find_guid_index=wm_find_first_part_index(arrPart[iPart],word.type);
  221. var newPartId="";
  222. if(find_guid_index){
  223. var find_guid=g_DictWordList[find_guid_index].Guid;
  224. if(!wm_id_exists(find_guid)){
  225. newPartId = wm_create_word_by_index(find_guid_index,newDeep,wordindex);
  226. }
  227. else{
  228. newPartId = find_guid;
  229. }
  230. }
  231. else{
  232. newPartId=wm_create_word(arrPart[iPart],newDeep,wordindex);
  233. }
  234. arrNewPartId.push(newPartId);
  235. wm_updata_word(newPartId,wordId);
  236. }
  237. word.partid=arrNewPartId.join("+");
  238. }
  239. }
  240. else{
  241. var arrPartId=word.partid.split("+");
  242. for(var iPart in arrPartId){
  243. if(arrPartId[iPart]==wm_word_array[wordindex].id){/*防止循环引用*/
  244. return;
  245. }
  246. }
  247. for(var iPart in arrPartId){
  248. if(arrPartId[iPart]!=""){
  249. if(wm_id_exists(arrPartId[iPart])){
  250. wm_updata_word(arrPartId[iPart],wordId);
  251. }
  252. else{
  253. for(var i in g_DictWordList){
  254. if(g_DictWordList[i].Guid==arrPartId[iPart]){
  255. newPartId = wm_create_word_by_index(i,newDeep,wordindex);
  256. wm_updata_word(newPartId,wordId);
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. //在内联字典中查找第一个匹配的零件 返回索引
  266. function wm_find_first_part_index(word,parentType){
  267. var typeString="";
  268. for(var x in wordmap_child_type){
  269. if(wordmap_child_type[x].type==parentType){
  270. typeString=wordmap_child_type[x].value;
  271. }
  272. }
  273. for(var x in g_DictWordList){
  274. if(g_DictWordList[x].Pali==word && g_DictWordList[x].Type!=""){
  275. //language filter
  276. if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
  277. if(typeString.indexOf(g_DictWordList[x].Type)>=0 && g_DictWordList[x].Guid.length>0){
  278. return(x);
  279. }
  280. }
  281. }
  282. }
  283. return(false);
  284. }
  285. function wm_get_best_partid(word){
  286. for(var x in g_DictWordList){
  287. if(g_DictWordList[x].Pali==word.real && g_DictWordList[x].PartId!=""){
  288. return(g_DictWordList[x].PartId);
  289. }
  290. }
  291. return("");
  292. }
  293. function wm_get_best_type(word,parentType){
  294. var typeString="";
  295. for(var x in wordmap_child_type){
  296. if(wordmap_child_type[x].type==parentType){
  297. typeString=wordmap_child_type[x].value;
  298. }
  299. }
  300. for(var x in g_DictWordList){
  301. if(g_DictWordList[x].Pali==word.real && g_DictWordList[x].Type!=""){
  302. if(typeString==""){
  303. return(g_DictWordList[x].Type);
  304. }
  305. else{
  306. if(typeString.indexOf(g_DictWordList[x].Type)>=0){
  307. return(g_DictWordList[x].Type);
  308. }
  309. }
  310. }
  311. }
  312. return("");
  313. }
  314. function wm_get_best_gramma(word){
  315. if(word.type==""){
  316. return("");
  317. }
  318. for(var x in g_DictWordList){
  319. if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
  320. if(g_DictWordList[x].Gramma!=""){
  321. return(g_DictWordList[x].Gramma);
  322. }
  323. }
  324. }
  325. return("");
  326. }
  327. //在内联字典中查找第一个匹配的意思
  328. function wm_get_best_mean(word){
  329. if(word.type==""){
  330. return("");
  331. }
  332. for(var x in g_DictWordList){
  333. if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
  334. if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
  335. if(g_DictWordList[x].Mean!=""){
  336. return(g_DictWordList[x].Mean.split("$")[0]);
  337. }
  338. }
  339. }
  340. }
  341. return("");
  342. }
  343. function wm_type_match(type1,type2){
  344. if(type1==".ti:base" || type1==".adj:base."){
  345. if(type2==type1==".ti:base" || type1==".adj:base."){
  346. return(true);
  347. }
  348. }
  349. else{
  350. if(type1==type2){
  351. return(true);
  352. }
  353. }
  354. return(false);
  355. }
  356. function wm_get_best_parent(word){
  357. if(word.type==""){
  358. return("");
  359. }
  360. for(var x in g_DictWordList){
  361. if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
  362. if(g_DictWordList[x].Parent!=""){
  363. return(g_DictWordList[x].Parent);
  364. }
  365. }
  366. }
  367. return("");
  368. }
  369. function wm_get_best_part(word){
  370. if(word.type==""){
  371. return("");
  372. }
  373. for(var x in g_DictWordList){
  374. if(g_DictWordList[x].Pali==word.real && wm_type_match(g_DictWordList[x].Type,word.type)){
  375. if(g_DictWordList[x].Factors!=""){
  376. return(g_DictWordList[x].Factors);
  377. }
  378. }
  379. }
  380. return("");
  381. }
  382. function wm_find_word_by_id(wordId){
  383. for(xWord in wm_word_array){
  384. if(wm_word_array[xWord].id==wordId){
  385. return(xWord);
  386. }
  387. }
  388. return(false);
  389. }
  390. function wm_render_word_map(wordId){
  391. wm_curr_deep=0;
  392. if(wm_render_mode){
  393. return(wm_render_word_block_H(wordId));
  394. }
  395. else{
  396. return(wm_render_word_block(wordId));
  397. }
  398. }
  399. function wm_render_word_block(wordId){
  400. if(wm_curr_deep>=wm_max_deep){
  401. return;
  402. }
  403. wm_word_box_count++;
  404. wm_curr_deep++;
  405. var wordIndex = wm_find_word_by_id(wordId);
  406. if(wordIndex){
  407. var output="";
  408. output += "<div class='wm_word_block'>";
  409. output += "<table><tr>";
  410. output += "<td>";
  411. output += wm_render_word_base(wordId);
  412. output += "</td>";
  413. output += "<td id='wm_line_"+(wm_word_box_count-1)+"' width='50px'>";
  414. output += "</td>";
  415. output += "<td><div id='wm_children_"+(wm_word_box_count-1)+"'>";
  416. if(wm_word_array[wordIndex].partid.length>0){
  417. var parts=wm_word_array[wordIndex].partid.split("+");
  418. for(var x in parts){
  419. if(parts[x]==wm_word_array[wordIndex]){
  420. wm_notify("Error:part ID loop link!");
  421. return;
  422. }
  423. }
  424. for(var x in parts){
  425. output += wm_render_word_block(parts[x]);
  426. }
  427. }
  428. output += "</div></td>";
  429. output += "</tr></table>";
  430. output += "</div>";
  431. wm_curr_deep--;
  432. return(output);
  433. }
  434. }
  435. function wm_render_word_block_H(wordId){
  436. if(wm_curr_deep>=wm_max_deep){
  437. return;
  438. }
  439. wm_word_box_count++;
  440. wm_curr_deep++;
  441. var wordIndex = wm_find_word_by_id(wordId);
  442. if(wordIndex){
  443. var output="";
  444. output += "<div class='wm_word_block'>";
  445. output += "<div class='wm_root_div'>";
  446. output += wm_render_word_base(wordId);
  447. output += "</div>";
  448. output += "<div id='wm_line_"+(wm_word_box_count-1)+"' class=\"wm_line\">";
  449. output += "</div>";
  450. output += "<div><div id='wm_children_"+(wm_word_box_count-1)+"' class=\"wm_child_div\">";
  451. if(wm_word_array[wordIndex].partid.length>0){
  452. var parts=wm_word_array[wordIndex].partid.split("+");
  453. for(var x in parts){
  454. output += wm_render_word_block_H(parts[x]);
  455. }
  456. }
  457. output += "</div></div>";
  458. output += "</div>";
  459. wm_curr_deep--;
  460. return(output);
  461. }
  462. }
  463. function wm_render_word_base(wordId){
  464. var wordIndex = wm_find_word_by_id(wordId);
  465. var output="";
  466. output += "<div class='wm_word_block_root_shell' id='wm_word_block_root_shell_"+wordIndex+"'>";
  467. switch(wm_show_mode){
  468. case 0:
  469. output +=wm_render_word_base_read(wordIndex);
  470. break;
  471. case 1:
  472. output +=wm_render_word_base_read2(wordIndex);
  473. break;
  474. case 2://edit
  475. output +=wm_render_word_base_edit(wordIndex);
  476. break;
  477. }
  478. output += "</div>";
  479. return(output);
  480. }
  481. function wm_updata_word_root_edit(wordIndex){
  482. document.getElementById("wm_word_block_root_shell_"+wordIndex).innerHTML=wm_render_word_base_edit(wordIndex);
  483. }
  484. function wm_updata_word_root_read(wordIndex){
  485. document.getElementById("wm_word_block_root_shell_"+wordIndex).innerHTML=wm_render_word_base_read(wordIndex);
  486. }
  487. function wm_updata_word_root_read2(wordIndex){
  488. document.getElementById("wm_word_block_root_shell_"+wordIndex).innerHTML=wm_render_word_base_read2(wordIndex);
  489. }
  490. //编辑模式渲染
  491. function wm_render_word_base_edit(wordIndex){
  492. var isNewClass="";
  493. var wm_case = new Array();
  494. var typeList=wm_get_word_type_list(wordIndex);
  495. var caseList=wm_get_word_gramma_list(wordIndex);
  496. if(typeList.length!=0 && typeList[0].type){
  497. wm_case.push(typeList[0].type);
  498. if(caseList.length!=0 && caseList[0].gramma){
  499. var wm_case_array=caseList[0].gramma.split("$")
  500. for(get_case_i in wm_case_array){
  501. wm_case.push(wm_case_array[get_case_i]);
  502. }
  503. }
  504. else{
  505. wm_case[1]=""
  506. wm_case[2]=""
  507. wm_case[3]=""
  508. }
  509. }
  510. else{
  511. wm_case.push("?");
  512. wm_case[1]=""
  513. wm_case[2]=""
  514. wm_case[3]=""
  515. }
  516. var sameRecorderMenu=wm_render_same_word_recoder_menu_for_read(wordIndex);
  517. var output="";
  518. if(wm_word_array[wordIndex].is_new){
  519. isNewClass=" word_new ";
  520. }
  521. if(wm_render_mode){
  522. output += "<div class='wm_word_block_root wm_word_block_root_h"+isNewClass+"'>";
  523. output += sameRecorderMenu
  524. }
  525. else{
  526. output += "<div class='wm_word_block_root wm_word_block_root_v"+isNewClass+"'>";
  527. output += sameRecorderMenu
  528. }
  529. var sameRecorderCount=wm_get_same_word_recorder_count(wordIndex);
  530. output += "<div class='toolbar'>";
  531. output += "<span style='margin-right: auto'>"
  532. output += "<input type='checkbox' checked>";
  533. output += gLocal.gui.read_only;
  534. output += "</span>"
  535. output += "<button style='min-width:4em; display:inline-flex; padding:0.1em 0.5em; margin: auto 0;' ";
  536. output += "onclick='wm_recorder_change("+wordIndex+",null)'>"
  537. output += gLocal.gui.new
  538. output += "</button>";
  539. output += "</div>";
  540. output += "<div>";
  541. output += "<a onclick='wm_look_up(\""+wm_word_array[wordIndex].real+"\")'>"+wm_word_array[wordIndex].pali;
  542. output += "</a></div>";
  543. output += "<div id='wm_edit_gramma_"+wordIndex+"' style='height:1.6em; margin:0.3em 0'>";
  544. output += wm_render_word_typegramma_edit(wm_case[0],wm_case[1],wm_case[2],wm_case[3],wordIndex,0.5)+"</div>";
  545. //output += wm_render_word_type_edit(wordIndex);
  546. //output += wm_render_word_gramma_edit(wordIndex);
  547. output += "<div style='height:1.6em; margin:0.3em 0'>";
  548. output += wm_render_word_parent_edit(wordIndex)+"</div>";
  549. output += "<div style='height:1.6em; margin:0.3em 0'>";
  550. output += wm_render_word_mean_edit(wordIndex)+"</div>";
  551. output += "<div style='height:1.6em; margin:0.3em 0'>";
  552. output += wm_render_word_part_edit(wordIndex)+"</div>";
  553. output += "</div>";
  554. return(output);
  555. }
  556. //閲讀模式渲染
  557. function wm_render_word_base_read(wordIndex){
  558. var output="";
  559. var sameRecorderMenu=wm_render_same_word_recoder_menu_for_read(wordIndex);
  560. var isNewClass="";
  561. if(wm_word_array[wordIndex].is_new){
  562. isNewClass=" word_new ";
  563. }
  564. if(wm_render_mode){
  565. output += "<div class='wm_word_block_root wm_word_block_root_h"+isNewClass+"'>";
  566. output += sameRecorderMenu
  567. }
  568. else{
  569. output += "<div class='wm_word_block_root wm_word_block_root_v"+isNewClass+"'>";
  570. output += sameRecorderMenu
  571. }
  572. var sameRecorderCount=wm_get_same_word_recorder_count(wordIndex);
  573. output += "<div>"
  574. output += "<a onclick='wm_look_up(\""+wm_word_array[wordIndex].real+"\")'>"
  575. output += wm_word_array[wordIndex].pali;//巴利拼寫加查詞
  576. output += "</a></div>"
  577. var arrMean=wm_word_array[wordIndex].mean.split("$");
  578. var strMeanMenu="";
  579. if(arrMean.length>1){
  580. strMeanMenu=wm_render_word_mean_menu(wordIndex,arrMean);
  581. }
  582. else{
  583. strMeanMenu=arrMean[0];
  584. }
  585. if(wm_word_array[wordIndex].wparent!=" " && wm_word_array[wordIndex].wparent.length>0){//有parent信息
  586. output += "<div>"+strMeanMenu+"</div>";
  587. output += "<div class='case_dropdown wm_gramma_info'>";
  588. output += "<span class='cell'>";
  589. output += getLocalGrammaStr(wm_word_array[wordIndex].type);//類型
  590. output += "</span>";
  591. output += getLocalGrammaStr(wm_word_array[wordIndex].gramma);
  592. output += "<i> *";
  593. output += wm_word_array[wordIndex].wparent;
  594. output += "</i></div>";
  595. }
  596. else{//无parent 信息
  597. output += "<div>"+strMeanMenu+"</div>";
  598. output += "<div class='case_dropdown wm_gramma_info'>";
  599. output += "<span class='cell'>";
  600. output += getLocalGrammaStr(wm_word_array[wordIndex].type);//類型
  601. output += "</span>";
  602. output += getLocalGrammaStr(wm_word_array[wordIndex].gramma);
  603. output += "</div>";
  604. }
  605. output += "</div>";
  606. return(output);
  607. }
  608. //閲讀模式二渲染
  609. function wm_render_word_base_read2(wordIndex){
  610. var output="";
  611. var sameRecorderMenu=wm_render_same_word_recoder_menu_for_read(wordIndex);
  612. var isNewClass="";
  613. if(wm_word_array[wordIndex].is_new){
  614. isNewClass=" word_new ";
  615. }
  616. if(wm_render_mode){
  617. output += "<div class='wm_word_block_root wm_word_block_root_h"+isNewClass+"'>";
  618. output += sameRecorderMenu
  619. }
  620. else{
  621. output += "<div class='wm_word_block_root wm_word_block_root_v"+isNewClass+"'>";
  622. output += sameRecorderMenu
  623. }
  624. var arrMean=wm_word_array[wordIndex].mean.split("$");
  625. var strMeanMenu="";
  626. strMeanMenu=wm_render_word_mean_menu2(wordIndex,arrMean);
  627. var sameRecorderCount=wm_get_same_word_recorder_count(wordIndex);
  628. var sameRecorderMenu=wm_render_same_word_recoder_menu_for_read(wordIndex);
  629. output += "<div>"+"<a onclick='wm_look_up(\""+wm_word_array[wordIndex].real+"\")'>"+ wm_word_array[wordIndex].pali+ "<span class='type'>" + getLocalGrammaStr(wm_word_array[wordIndex].type)+"</span>"+"</div>";
  630. output += "<div>"+ strMeanMenu+"</div>";
  631. output += "<div>" + getLocalGrammaStr(wm_word_array[wordIndex].gramma)+"</div>";
  632. output += "<div>"+ wm_word_array[wordIndex].wparent+"</div>";
  633. output += "<div>"+ wm_word_array[wordIndex].partmean+"</div>";
  634. output += "</div>";
  635. return(output);
  636. }
  637. //渲染meaning选择列表
  638. function wm_render_word_mean_menu(wordIndex,meanList){
  639. //查找父节点中的对应的意思在本节点意思列表中的位置
  640. var indexOfMean = wm_get_part_mean_index_in_list(wordIndex);
  641. var defaultMean=meanList[0];
  642. if(indexOfMean>=0){
  643. defaultMean=meanList[indexOfMean];
  644. }
  645. var output="";
  646. output +="<div class=\"case_dropdown\" style='display:inline-block;'>";
  647. output += "<p class='case_dropbtn' >";
  648. output += defaultMean+"("+meanList.length+") ";
  649. output +="</p>";
  650. output +="<div class=\"case_dropdown-content\">";
  651. for(var i in meanList){
  652. output +="<a onclick='wm_part_mean_change(\""+wordIndex+"\",\""+meanList[i]+"\")'>"+meanList[i]+"</a>";
  653. }
  654. output +="</div></div>";
  655. return(output);
  656. }
  657. //渲染meaning选择列表
  658. function wm_render_word_mean_menu2(wordIndex,meanList){
  659. var output="";
  660. var liclass="";
  661. output +="<ul class=\"radio-button\" style='display:inline-block;'>";
  662. //查找父节点中的对应的意思在本节点意思列表中的位置
  663. var indexOfMean = wm_get_part_mean_index_in_list(wordIndex);
  664. for(var i in meanList){
  665. if(indexOfMean==i){
  666. liclass="li_act";
  667. }
  668. else{
  669. liclass="";
  670. }
  671. output +="<li class='"+liclass+"'><a onclick='wm_part_mean_change(\""+wordIndex+"\",\""+meanList[i]+"\")'>"+meanList[i]+"</a></li>";
  672. }
  673. output +="</ul>";
  674. return(output);
  675. }
  676. //渲染相同拼写的成品零件选择列表
  677. function wm_render_same_word_recoder_menu_for_read(wordIndex){
  678. //拿到零件數據列表
  679. var partList=wm_get_same_word_recorder(wordIndex);
  680. //渲染數量角標
  681. var output="";
  682. output +="<div class=\"info_num_case_dropdown\" >";
  683. if(partList.length!=0){
  684. output +="<span class='info_num'>"//order-radius: 99px;
  685. output += partList.length;
  686. output += "</span>"
  687. }
  688. output +="<div class=\"case_dropdown-content\">";
  689. var L_width_dictname=0
  690. var L_width_typegramma=0
  691. var L_width_mean=0
  692. //首次抓取數據
  693. for(var string_max_length_i in partList){
  694. var dictname=g_DictWordList[partList[string_max_length_i]].dictname;
  695. var thisType=getLocalGrammaStr(g_DictWordList[partList[string_max_length_i]].Type);
  696. var thisGramma=getLocalGrammaStr(g_DictWordList[partList[string_max_length_i]].Gramma);
  697. var thisMean=g_DictWordList[partList[string_max_length_i]].Mean;
  698. //計算最適寬度
  699. var L_width=getLocalGrammaStr(thisMean).replace(/[\u0391-\uFFE5]/g,"aa").length;
  700. if(L_width_mean<L_width/1.7 && L_width_mean<12){
  701. L_width_mean=L_width/1.7;
  702. }
  703. else if(L_width_mean>=12){
  704. L_width_mean=12;
  705. break;
  706. }
  707. }
  708. for(var wm_for_read_i in partList){
  709. output +="<a class='wm_selection_menu_a' onclick='wm_recorder_change(\""+wordIndex+"\","+partList[wm_for_read_i]+")'>";
  710. //拿到詞典信息
  711. var dictname=g_DictWordList[partList[wm_for_read_i]].dictname;
  712. //渲染詞典信息
  713. output +="<div class='wm_dictname_div'>";
  714. output +="<span class='wm_wordtype' style='width:auto; display:inline-flex'>";
  715. output +=getLocalDictname(dictname);
  716. output +="</span>";
  717. output +="</div>";
  718. //拿到語法訊息
  719. var thisType=getLocalGrammaStr(g_DictWordList[partList[wm_for_read_i]].Type);
  720. var thisGramma=getLocalGrammaStr(g_DictWordList[partList[wm_for_read_i]].Gramma);
  721. //渲染語法信息
  722. output +="<div class='wm_wordtype_div'>";
  723. output +="<span class='wm_wordtype' style='width:auto; display:inline-flex'>";
  724. output +=getLocalGrammaStr(thisType);
  725. //output +=getLocalGrammaStr(thisGramma);
  726. output +="</span>";
  727. output +="</div>";
  728. //拿到含義信息
  729. var thisMean=g_DictWordList[partList[wm_for_read_i]].Mean;
  730. //整理含義格式
  731. thisMean=thisMean.replace(/\$/g,"; ");
  732. thisMean=thisMean.replace(/ \;/g,";");
  733. thisMean=thisMean.replace(/\;\;/g,";");
  734. //掐頭
  735. if(thisMean.charAt(0)==";"){
  736. thisMean=thisMean.slice(1,thisMean.length);
  737. }
  738. //去尾
  739. if(thisMean.charAt(thisMean.length)==";"){
  740. thisMean=thisMean.slice(0,-1);
  741. }
  742. //渲染含義信息
  743. output +="<span class='wm_wordmean' style='width:"+L_width_mean+"em;'>";
  744. output +=thisMean;
  745. output +="</span>";
  746. output +="</a>";
  747. }
  748. output +="</div></div>";
  749. return(output);
  750. }
  751. function wm_render_word_type_gramma_edit(wordIndex){
  752. var output="";
  753. var typeList=wm_get_word_type_list(wordIndex);
  754. output +="<div class=\"case_dropdown\" style='display:inline-block;'>";
  755. //output += "<p class='case_dropbtn' >";
  756. //output += "<input type='input' onchange='wm_field_change(\""+wordIndex+"\",\"type\",this.value)' size='7' value='"+wm_word_array[wordIndex].type+"' />";
  757. //output += "</p>";
  758. output +="<div class=\"case_dropdown-content\">";
  759. output +="<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='wm_field_change(\""+wordIndex+"\",\"type\",\"\")'>"+gLocal.gui.empty1+"</button>"
  760. for(var i in typeList){
  761. output +="<a onclick='wm_field_change(\""+wordIndex+"\",\"type\",\""+typeList[i].type+"\")'>["+getLocalDictname(typeList[i].dict)+"]"+typeList[i].type+"</a>";
  762. }
  763. output +="</div></div>";
  764. return(output);
  765. }
  766. function wm_render_word_type_edit(wordIndex){
  767. var output="";
  768. var typeList=wm_get_word_type_list(wordIndex);
  769. output +="<span class='wm_inline_control'>";
  770. //渲染數量角標
  771. output +="<div id='info_num_type_dropdown_"+wordIndex+"_div' ";
  772. output +="class=\"info_num_gramma_dropdown\" ";
  773. output +="style='display:block'>";
  774. if(typeList.length && typeList.length!=0){
  775. output +="<span class='detail_info_num'>"//order-radius: 99px;
  776. output += typeList.length;
  777. output += "</span>"
  778. }
  779. output +="<div class=\"case_dropdown-content\">";
  780. output +="<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='wm_field_change(\""+wordIndex+"\",\"type\",\"\")'>"+gLocal.gui.empty1+"</button>"
  781. for(var type_edit_i in typeList){
  782. output +="<a onclick='wm_field_change(\""+wordIndex+"\",\"type\",\""+typeList[type_edit_i].type+"\")'>["+getLocalDictname(typeList[type_edit_i].dict)+"]"+getLocalGrammaStr(typeList[type_edit_i].type)+"</a>";
  783. }
  784. output += "</div></div>";
  785. output +="<div class=\"wm_edit_type\">";
  786. //output += "<p class='case_dropbtn' >";
  787. //output += "<input type='input' onchange='wm_field_change(\""+wordIndex+"\",\"type\",this.value)' size='7' value='"+wm_word_array[wordIndex].type+"' />";
  788. //output +="</p>";
  789. if(wm_word_array[wordIndex].type!="" && wm_word_array[wordIndex].type!="?"){
  790. output += "<span id='type_"+wordIndex+"_span' class='wm_input_span cell' ";
  791. //output += "onclick=\"switch_input_span("+wordIndex+",\'type\')\"";
  792. output += ">";
  793. output += getLocalGrammaStr(wm_word_array[wordIndex].type);
  794. output += "</span>"
  795. output += "</div>";
  796. //output +="</p>";
  797. }
  798. else{
  799. output += "<span id='type_"+wordIndex+"_span' class='wm_input_span cell' ";
  800. output += "style='display:block'"
  801. output += "onclick=\"switch_input_span("+wordIndex+",\'type\')\">";
  802. output += "<i>?</i>";
  803. output += "</span>"
  804. output += "</div>";
  805. }
  806. return(output);
  807. }
  808. function wm_render_word_gramma_edit(wordIndex){
  809. var output="";
  810. var itemList=wm_get_word_gramma_list(wordIndex);
  811. output +="<div class=\"wm_edit_gramma\">";
  812. //output += "<p class='case_dropbtn' >";
  813. //output += "<input type='input' onchange='wm_field_change(\""+wordIndex+"\",\"gramma\",this.value)' size='7' value='"+wm_word_array[wordIndex].gramma+"' />";
  814. //output +="</p>";
  815. if(wm_word_array[wordIndex].gramma!="" && wm_word_array[wordIndex].gramma!="?"){
  816. output += "<span id='gramma_"+wordIndex+"_span' class='wm_input_span' ";
  817. //output += "onclick=\"switch_input_span("+wordIndex+",\'gramma\')\"";
  818. output += ">";
  819. output += getLocalGrammaStr(wm_word_array[wordIndex].gramma);
  820. output += "</span>"
  821. output += "</div>";
  822. //output +="</p>";
  823. }
  824. else{
  825. output += "<span id='gramma_"+wordIndex+"_span' class='wm_input_span' ";
  826. output += "style='display:block'"
  827. output += "onclick=\"switch_input_span("+wordIndex+",\'gramma\')\">";
  828. output += "<i>?</i>";
  829. output += "</span>"
  830. output += "</div>";
  831. }
  832. //渲染數量角標
  833. output +="<div id='info_num_gramma_dropdown_"+wordIndex+"_div' ";
  834. output +="class=\"info_num_gramma_dropdown\" ";
  835. output +="style='display:block'>";
  836. if(itemList.length && itemList.length!=0){
  837. output +="<span class='detail_info_num'>"//order-radius: 99px;
  838. output += itemList.length;
  839. output += "</span>"
  840. }
  841. output +="<div class=\"case_dropdown-content\">";
  842. output +="<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='wm_field_change(\""+wordIndex+"\",\"gramma\",\"\")'>"+gLocal.gui.empty1+"</button>"
  843. for(var gramma_edit_i in itemList){
  844. output +="<a onclick='wm_field_change(\""+wordIndex+"\",\"gramma\",\""+itemList[gramma_edit_i].gramma+"\")'>["+getLocalDictname(itemList[gramma_edit_i].dict)+"]"+getLocalGrammaStr(itemList[gramma_edit_i].gramma)+"</a>";
  845. }
  846. output +="</div></div></span>";
  847. return(output);
  848. }
  849. function switch_input_span(id,position){
  850. document.getElementById("info_num_"+position+"_dropdown_"+id+"_div").style.display="none";
  851. document.getElementById(position+"_"+id+"_span").style.display="none";
  852. document.getElementById(position+"_"+id+"_input").style.display="block";
  853. document.getElementById(position+"_"+id+"_input").focus();
  854. }
  855. function switch_input_span2(id,position){
  856. document.getElementById("info_num_"+position+"_dropdown_"+id+"_div").style.display="block";
  857. document.getElementById(position+"_"+id+"_span").style.display="block";
  858. document.getElementById(position+"_"+id+"_input").style.display="none";
  859. }
  860. function wm_render_word_parent_edit(wordIndex){
  861. var output="";
  862. var parentList=wm_get_word_parent_list(wordIndex);
  863. output +="<span class='wm_inline_control'><div class=\"wm_edit_parent\">";
  864. //output += "<p class='case_dropbtn' >";
  865. if(wm_word_array[wordIndex].wparent!="" && wm_word_array[wordIndex].wparent!=" "){
  866. output += "<span id='parent_"+wordIndex+"_span' class='wm_input_span' ";
  867. output += "onclick=\"switch_input_span("+wordIndex+",\'parent\')\">";
  868. output += wm_word_array[wordIndex].wparent;
  869. output += "</span>"
  870. output += "<input id='parent_"+wordIndex+"_input' type='input' style='display:none' ";
  871. output += "onblur='wm_field_change(\""+wordIndex+"\",\"parent\",this.value)' ";
  872. output += "onchange='wm_field_change(\""+wordIndex+"\",\"parent\",this.value)' ";
  873. output += "value='"+wm_word_array[wordIndex].wparent+"' /></div>";
  874. //output +="</p>";
  875. }
  876. else{
  877. output += "<span id='parent_"+wordIndex+"_span' class='wm_input_span' ";
  878. output += "style='display:block;color: rgb(134, 134, 134)'"
  879. output += "onclick=\"switch_input_span("+wordIndex+",\'parent\')\">";
  880. output += "<i>"+gLocal.gui.parent_input+"</i>";
  881. output += "</span>"
  882. output += "<input id='parent_"+wordIndex+"_input' type='input' style='display:none' ";
  883. output += "onblur='wm_field_change(\""+wordIndex+"\",\"parent\",this.value)' ";
  884. output += "onchange='wm_field_change(\""+wordIndex+"\",\"parent\",this.value)' ";
  885. //output += "onblur=\"switch_input_span2("+wordIndex+",\'mean\')\"";
  886. output += "value='' /></div>";
  887. }
  888. //渲染數量角標
  889. output +="<sup><div id='info_num_parent_dropdown_"+wordIndex+"_div' ";
  890. output +="class=\"info_num_detail_dropdown\" ";
  891. output +="style='display:block'>";
  892. if(parentList.length && parentList.length!=0){
  893. output +="<span class='detail_info_num'>"//order-radius: 99px;
  894. output += parentList.length;
  895. output += "</span>"
  896. }
  897. output +="<div class=\"case_dropdown-content\">";
  898. output +="<button style='font-size:100%; display:inline-flex; padding:0.1em 0.5em' onclick='wm_field_change(\""+wordIndex+"\",\"parent\",\"\")'>"+gLocal.gui.empty1+"</button>";
  899. for(var i in parentList){
  900. output +="<a onclick='wm_field_change(\""+wordIndex+"\",\"parent\",\""+parentList[i].wparent+"\")'>["+getLocalDictname(parentList[i].dict)+"]"+parentList[i].wparent+"</a>";
  901. }
  902. output +="</div></div></sup></span>";
  903. return(output);
  904. }
  905. function wm_render_word_mean_edit(wordIndex){
  906. var output="";
  907. var partList=wm_get_word_mean_list(wordIndex)
  908. output +="<span class='wm_inline_control'><div class=\"wm_edit_mean\">";
  909. //output += "<p class='case_dropbtn' >";
  910. if(wm_word_array[wordIndex].mean!=""){
  911. output += "<span id='mean_"+wordIndex+"_span' class='wm_input_span' ";
  912. output += "style='display:block'"
  913. output += "onclick=\"switch_input_span("+wordIndex+",\'mean\')\">";
  914. output += wm_word_array[wordIndex].mean.replace(/\$/g,";");
  915. output += "</span>";
  916. output += "<input id='mean_"+wordIndex+"_input' type='input' style='display:none' ";
  917. output += "onblur='wm_field_change(\""+wordIndex+"\",\"mean\",this.value)' ";
  918. output += "onchange='wm_field_change(\""+wordIndex+"\",\"mean\",this.value)' ";
  919. //output += "onkeyup='wm_input_keyup(event,\""+wordIndex+"\",\"mean\",this.value)' ";
  920. //output += "onblur=\"switch_input_span2("+wordIndex+",\'mean\')\"";
  921. output += "value='"+wm_word_array[wordIndex].mean+"' /></div>";
  922. }
  923. else{
  924. output += "<span id='mean_"+wordIndex+"_span' class='wm_input_span' ";
  925. output += "style='display:block;color: rgb(134, 134, 134)'"
  926. output += "onclick=\"switch_input_span("+wordIndex+",\'mean\')\">";
  927. output += "<i>"+gLocal.gui.meaning_input+"</i>";
  928. output += "</span>";
  929. output += "<input id='mean_"+wordIndex+"_input' type='input' style='display:none' ";
  930. output += "onblur='wm_field_change(\""+wordIndex+"\",\"mean\",this.value)' ";
  931. output += "onchange='wm_field_change(\""+wordIndex+"\",\"mean\",this.value)' ";
  932. //output += "onkeyup='wm_input_keyup(event,\""+wordIndex+"\",\"mean\",this.value)' ";
  933. output += "value='' /></div>";
  934. }
  935. //渲染數量角標
  936. output +="<sup><div id='info_num_mean_dropdown_"+wordIndex+"_div' ";
  937. output +="class=\"info_num_detail_dropdown\" ";
  938. output +="style='display:block'>";
  939. if(partList.length!=0){
  940. output +="<span class='detail_info_num'>"//order-radius: 99px;
  941. output += partList.length;
  942. output += "</span>"
  943. }
  944. output +="<div class=\"case_dropdown-content\">";
  945. output +="<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='wm_field_change(\""+wordIndex+"\",\"mean\",\"\")'>"+gLocal.gui.empty1+"</button>"
  946. for(var edti_mean_i in partList){
  947. var meanGroup = partList[edti_mean_i].mean.split('$');
  948. var htmlMean="";
  949. for(var iMean in meanGroup){
  950. htmlMean += "<span class='wm_one_mean' onclick='wm_field_change(\""+wordIndex+"\",\"mean_add\",\""+meanGroup[iMean]+"\")'>"
  951. htmlMean += meanGroup[iMean]+"</span>";
  952. }
  953. output +="<a ><span class='wm_dictname' onclick='wm_field_change(\""+wordIndex+"\",\"mean\",\""+partList[edti_mean_i].mean+"\")'>";
  954. output +=getLocalDictname(partList[edti_mean_i].dict);
  955. output +="</span>"+htmlMean+"</a>";
  956. }
  957. output +="</div></div></sup></span>";
  958. //output += "</p>";
  959. return(output);
  960. }
  961. function wm_render_word_part_edit(wordIndex){
  962. var output="";
  963. var partList=wm_get_word_part_list(wordIndex)
  964. output +="<span class='wm_inline_control'><div class=\"wm_edit_part\">";
  965. //output += "<p class='case_dropbtn' >";
  966. if(wm_word_array[wordIndex].part!=""){
  967. output += "<span id='part_"+wordIndex+"_span' class='wm_input_span' ";
  968. output += "style='display:inline-block'"
  969. output += "onclick=\"switch_input_span("+wordIndex+",\'part\')\">";
  970. output += wm_word_array[wordIndex].part;
  971. output += "</span>";
  972. output += "<input id='part_"+wordIndex+"_input' type='input' style='display:none' ";
  973. output += "onblur='wm_field_change(\""+wordIndex+"\",\"part\",this.value)' ";
  974. output += "onchange='wm_field_change(\""+wordIndex+"\",\"part\",this.value)' ";
  975. //output += "onblur=\"switch_input_span2("+wordIndex+",\'part\')\"";
  976. output += "value='"+wm_word_array[wordIndex].part+"' /></div>";
  977. }
  978. else{
  979. output += "<span id='part_"+wordIndex+"_span' class='wm_input_span' ";
  980. output += "style='display:block;color: rgb(134, 134, 134)'"
  981. output += "onclick=\"switch_input_span("+wordIndex+",\'part\')\">";
  982. output += "<i>"+gLocal.gui.factors_input+"</i>";
  983. output += "</span>";
  984. output += "<input id='part_"+wordIndex+"_input' type='input' style='display:none' ";
  985. output += "onblur='wm_field_change(\""+wordIndex+"\",\"part\",this.value)' ";
  986. output += "onchange='wm_field_change(\""+wordIndex+"\",\"part\",this.value)' ";
  987. //output += "onclick=\"switch_input_span2("+wordIndex+",\'part\')\"";
  988. output += "value='' /></div>";
  989. }
  990. //渲染數量角標
  991. output +="<sup><div id='info_num_part_dropdown_"+wordIndex+"_div' ";
  992. output +="class=\"info_num_detail_dropdown\" ";
  993. output +="style='display:block'>";
  994. if(partList.length!=0){
  995. output +="<span class='detail_info_num'>"//order-radius: 99px;
  996. output += partList.length;
  997. output += "</span>"
  998. }
  999. output +="<div class=\"case_dropdown-content\">";
  1000. output +="<a onclick='wm_field_change(\""+wordIndex+"\",\"part\",\""+wm_word_array[wordIndex].real+"\")'>";
  1001. output +="["+wm_word_array[wordIndex].real+"]";
  1002. output +="</a>";
  1003. for(var edit_part_x in partList){
  1004. output +="<a>";
  1005. output +="<span class='wm_dictname' ";
  1006. output +="onclick='wm_field_change(\""+wordIndex+"\",\"part\",\""+partList[edit_part_x].part+"\")'>";
  1007. output +=getLocalDictname(partList[edit_part_x].dict);
  1008. output +="</span>"+partList[edit_part_x].part+"</a>";
  1009. }
  1010. //output +="</p>";
  1011. output +="</div></div></sup></span>";
  1012. return(output);
  1013. }
  1014. function wm_get_word_type_list(wordIndex){
  1015. var wPali=wm_word_array[wordIndex].pali;
  1016. var wReal=wm_word_array[wordIndex].real;
  1017. var wType=wm_word_array[wordIndex].type;
  1018. var output = Array();
  1019. for(var x in g_DictWordList){
  1020. if(g_DictWordList[x].Pali==wReal){
  1021. if(g_DictWordList[x].Type!=""){
  1022. var newItem= Object();
  1023. newItem.dict=g_DictWordList[x].dictname;
  1024. newItem.type=g_DictWordList[x].Type;
  1025. output.push(newItem);
  1026. }
  1027. }
  1028. }
  1029. return(output);
  1030. }
  1031. function wm_get_word_gramma_list(wordIndex){
  1032. var wPali=wm_word_array[wordIndex].pali;
  1033. var wReal=wm_word_array[wordIndex].real;
  1034. var wType=wm_word_array[wordIndex].type;
  1035. var output = Array();
  1036. for(var x in g_DictWordList){
  1037. if(g_DictWordList[x].Pali==wReal && wm_type_match(g_DictWordList[x].Type,wType)){
  1038. if(g_DictWordList[x].Gramma!=""){
  1039. var newPart= Object();
  1040. newPart.dict=g_DictWordList[x].dictname;
  1041. newPart.gramma=g_DictWordList[x].Gramma;
  1042. output.push(newPart);
  1043. }
  1044. }
  1045. }
  1046. return(output);
  1047. }
  1048. function wm_get_word_part_list(wordIndex){
  1049. var wPali=wm_word_array[wordIndex].pali;
  1050. var wReal=wm_word_array[wordIndex].real;
  1051. var wType=wm_word_array[wordIndex].type;
  1052. var output = Array();
  1053. for(var x in g_DictWordList){
  1054. if(g_DictWordList[x].Pali==wReal && wm_type_match(g_DictWordList[x].Type,wType)){
  1055. if(g_DictWordList[x].Factors!=""){
  1056. var newPart= Object();
  1057. newPart.dict=g_DictWordList[x].dictname;
  1058. newPart.part=g_DictWordList[x].Factors;
  1059. output.push(newPart);
  1060. }
  1061. }
  1062. }
  1063. return(output);
  1064. }
  1065. function wm_get_word_mean_list(wordIndex){
  1066. var wPali=wm_word_array[wordIndex].pali;
  1067. var wReal=wm_word_array[wordIndex].real;
  1068. var wType=wm_word_array[wordIndex].type;
  1069. var output = Array();
  1070. for(var x in g_DictWordList){
  1071. if(g_DictWordList[x].Pali==wReal && ( wm_type_match(g_DictWordList[x].Type,wType) || g_DictWordList[x].Type=="")){
  1072. if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
  1073. if(g_DictWordList[x].Mean!=""){
  1074. var newPart= Object();
  1075. newPart.dict=g_DictWordList[x].dictname;
  1076. newPart.mean=g_DictWordList[x].Mean;
  1077. output.push(newPart);
  1078. }
  1079. }
  1080. }
  1081. }
  1082. return(output);
  1083. }
  1084. function wm_get_word_parent_list(wordIndex){
  1085. var wPali=wm_word_array[wordIndex].pali;
  1086. var wReal=wm_word_array[wordIndex].real;
  1087. var wType=wm_word_array[wordIndex].type;
  1088. var output = Array();
  1089. for(var x in g_DictWordList){
  1090. if(g_DictWordList[x].Pali==wReal && wm_type_match(g_DictWordList[x].Type,wType)){
  1091. if(g_DictWordList[x].Parent!=""){
  1092. var newPart= Object();
  1093. newPart.dict=g_DictWordList[x].dictname;
  1094. newPart.wparent=g_DictWordList[x].Parent;
  1095. output.push(newPart);
  1096. }
  1097. }
  1098. }
  1099. return(output);
  1100. }
  1101. function wm_get_word_index_with_part_from_dict(word){
  1102. for(var x in g_DictWordList){
  1103. if(g_DictWordList[x].Pali==word){
  1104. if(g_DictWordList[x].Factors!=""){
  1105. return(x);
  1106. }
  1107. }
  1108. }
  1109. return(-1);
  1110. }
  1111. function wm_get_word_first_mean(word){
  1112. for(var x in g_DictWordList){
  1113. if(g_DictWordList[x].Pali==word){
  1114. //语言过滤
  1115. if(dict_language_enable.indexOf(g_DictWordList[x].Language)>=0){
  1116. if(g_DictWordList[x].Mean!=""){
  1117. return(g_DictWordList[x].Mean);
  1118. }
  1119. }
  1120. }
  1121. }
  1122. return("");
  1123. }
  1124. function wm_render_line(){
  1125. if(wm_render_mode){//纵向
  1126. wm_render_line_h();
  1127. }
  1128. else{//横向划线
  1129. wm_render_line_v();
  1130. }
  1131. }
  1132. //横向划线
  1133. function wm_render_line_v(){
  1134. for(iBox=0;iBox<wm_word_box_count;iBox++){
  1135. var obj = document.getElementById("wm_line_"+iBox);
  1136. var objChildren = document.getElementById("wm_children_"+iBox);
  1137. if(obj){
  1138. var objWH=getElementWH(obj);
  1139. var width=50;
  1140. var height=objWH.height;
  1141. if(height>0)
  1142. var output="";
  1143. output += "<div class=\"wordmap_line_shell\" style='width:"+width+"px; height:"+height+"px'>";
  1144. output += "<svg viewBox=\"0 0 "+width+" "+height+"\" class=\"wordmap_line\" xmlns=\"http://www.w3.org/2000/svg\">";
  1145. var lineY=0;
  1146. for(xNode in objChildren.childNodes){
  1147. var newChildHeigh=getElementWH(objChildren.childNodes[xNode]).height;
  1148. if(newChildHeigh>0){
  1149. lineY+=newChildHeigh/2;
  1150. output += "<line x1=\"3\" y1=\""+height/2+"\" x2=\""+(width-3)+"\" y2=\""+lineY+"\" stroke-width=\"2px\" stroke-linecap=\"round\"/>";
  1151. lineY+=newChildHeigh/2;
  1152. }
  1153. }
  1154. output += "</svg>";
  1155. output += "</div> ";
  1156. obj.innerHTML=output;
  1157. }
  1158. }
  1159. }
  1160. function wm_render_line_h(){
  1161. for(iBox=0;iBox<wm_word_box_count;iBox++){
  1162. var obj = document.getElementById("wm_line_"+iBox);
  1163. var objChildren = document.getElementById("wm_children_"+iBox);
  1164. if(obj){
  1165. var objWH=getElementWH(obj);
  1166. var objChildrenWH=getElementWH(objChildren);
  1167. var width=objWH.width;
  1168. var height=objWH.height;
  1169. if(width>0)
  1170. var output="";
  1171. output += "<div class=\"wordmap_line_shell\" style='width:"+width+"px; height:"+height+"px'>";
  1172. output += "<svg viewBox=\"0 0 "+width+" "+height+"\" class=\"wordmap_line\" xmlns=\"http://www.w3.org/2000/svg\">";
  1173. var lineX=0;
  1174. for(xNode in objChildren.childNodes){
  1175. var newChildWidth=getElementWH(objChildren.childNodes[xNode]).width;
  1176. if(newChildWidth>0){
  1177. lineX+=newChildWidth/2;
  1178. output += "<line x1=\""+width/2+"\" y1=\"3\" x2=\""+lineX+"\" y2=\""+(height-3)+"\" stroke-width=\"2px\" stroke-linecap=\"round\"/>";
  1179. lineX+=newChildWidth/2;
  1180. }
  1181. }
  1182. output += "</svg>";
  1183. output += "</div> ";
  1184. obj.innerHTML=output;
  1185. }
  1186. }
  1187. }
  1188. //获取同样拼写单词的已经存在的成品零件记录数量
  1189. function wm_get_same_word_recorder_count(wordIndex){
  1190. return(wm_get_same_word_recorder(wordIndex).length);
  1191. }
  1192. //获取同样拼写单词的已经存在的成品零件记录
  1193. function wm_get_same_word_recorder(wordIndex){
  1194. var output=new Array();
  1195. var typeString="";
  1196. for(var wm_get_same_word_recorder_x in g_DictWordList){
  1197. if(g_DictWordList[wm_get_same_word_recorder_x].Pali==wm_word_array[wordIndex].real){
  1198. if(g_DictWordList[wm_get_same_word_recorder_x].Guid && g_DictWordList[wm_get_same_word_recorder_x].Guid.length>0){//修改循環計數值的名字,并進行非空判斷
  1199. var parentIndex=wm_word_array[wordIndex].parentNode;
  1200. if(parentIndex){
  1201. if(g_DictWordList[wm_get_same_word_recorder_x].Guid!=wm_word_array[parentIndex].id){
  1202. output.push(wm_get_same_word_recorder_x);
  1203. }
  1204. }
  1205. }
  1206. }
  1207. }
  1208. return(output);
  1209. }
  1210. function wm_field_change(wordIndex,field,value){
  1211. switch(field){
  1212. case "type":
  1213. wm_word_array[wordIndex].type=value;
  1214. wm_caseChanged(wordIndex,"type",value);
  1215. wm_updata_word_root_edit(wordIndex);
  1216. break;
  1217. case "gramma":
  1218. wm_word_array[wordIndex].gramma=value;
  1219. var wm_field_change_gramma=value.split("$");
  1220. if(wm_field_change_gramma.length>0 && wm_field_change_gramma.length<4){
  1221. for(wm_field_change_gramma_i in wm_field_change_gramma){
  1222. wm_caseChanged(wordIndex,"case"+(wm_field_change_gramma_i+1),value);
  1223. }
  1224. }
  1225. else{
  1226. wm_caseChanged(wordIndex,"case1",value);
  1227. }
  1228. wm_updata_word_root_edit(wordIndex);
  1229. break;
  1230. case "mean":
  1231. wm_word_array[wordIndex].mean=value;
  1232. wm_updata_word_root_edit(wordIndex);
  1233. switch_input_span2(wordIndex,"mean");
  1234. break;
  1235. case "mean_add":
  1236. wm_word_array[wordIndex].mean+="$"+value;
  1237. wm_updata_word_root_edit(wordIndex);
  1238. break;
  1239. case "parent":
  1240. wm_word_array[wordIndex].wparent=value;
  1241. wm_updata_word_root_edit(wordIndex);
  1242. break;
  1243. case "part":
  1244. if(wm_word_array[wordIndex].part!=value){
  1245. wm_word_array[wordIndex].part=value;
  1246. wm_word_array[wordIndex].partid="";
  1247. wm_updata_word(rootId,null);
  1248. wm_updata_word_map();
  1249. wm_render_line();
  1250. switch_input_span2(wordIndex,"part");
  1251. //wm_refresh_inline_dict(wordIndex);
  1252. }
  1253. break;
  1254. }
  1255. }
  1256. function wm_dict_one_done(dictIndex){
  1257. wm_notify("pass:"+(g_dictFindParentLevel+1)+" "+g_dictList[dictIndex].name + "done");
  1258. }
  1259. function wm_dict_search_one_pass_done(pass){
  1260. wm_notify("pass:"+(pass+1)+" is done");
  1261. wm_updata_word(rootId,null);
  1262. wm_updata_word_map();
  1263. wm_render_line();
  1264. }
  1265. function wm_notify(message){
  1266. var objNotify=document.getElementById('wm_doc_notify');
  1267. if(objNotify){
  1268. objNotify.style.display="inline";
  1269. objNotify.innerHTML=message;
  1270. setTimeout("document.getElementById('wm_doc_notify').style.display='none'",5000);
  1271. }
  1272. }
  1273. function wm_dict_all_done(){
  1274. wm_updata_word(rootId,null);
  1275. wm_updata_word_map();
  1276. wm_render_line();
  1277. }
  1278. function wm_refresh_inline_dict(wordIndex){
  1279. currMatchingDictNum=0;
  1280. g_dictFindParentLevel=0;
  1281. g_dictFindAllDone=false;
  1282. g_dict_search_one_dict_done=wm_dict_one_done;
  1283. g_dict_search_one_pass_done=wm_dict_search_one_pass_done;
  1284. g_dict_search_all_done=wm_dict_all_done;
  1285. dict_mark_word_list_done();
  1286. //dict_push_word_to_download_list(wm_word_array[wordIndex].wparent,1);
  1287. var arrPart=wm_word_array[wordIndex].part.split("+");
  1288. for(var ipart in arrPart){
  1289. dict_push_word_to_download_list(arrPart[ipart],1);
  1290. }
  1291. var arrBuffer=dict_get_search_list();
  1292. if(arrBuffer.length>0){
  1293. g_CurrDictBuffer=JSON.stringify(arrBuffer);
  1294. dict_mark_word_list_done();
  1295. editor_dict_match();
  1296. }
  1297. else{
  1298. wm_notify("no new part");
  1299. }
  1300. }
  1301. function wm_recorder_change(wordIndex,newIndex){
  1302. var oldGuid=wm_word_array[wordIndex].id;
  1303. if(newIndex>=0){
  1304. var newGuid=g_DictWordList[newIndex].Guid;
  1305. var parentNodeIndex=wm_word_array[wordIndex].parentNode;
  1306. if(parentNodeIndex){
  1307. wm_word_array[parentNodeIndex].partid = wm_word_array[parentNodeIndex].partid.replace(oldGuid,newGuid);
  1308. wm_updata_word(rootId,null);
  1309. wm_updata_word_map();
  1310. wm_render_line();
  1311. }
  1312. }
  1313. else{//new
  1314. newPartId=wm_create_word(wm_word_array[wordIndex].pali,wm_word_array[wordIndex].deep,wm_word_array[wordIndex].parentNode);
  1315. var parentNodeIndex=wm_word_array[wordIndex].parentNode;
  1316. if(parentNodeIndex){
  1317. wm_word_array[parentNodeIndex].partid = wm_word_array[parentNodeIndex].partid.replace(oldGuid,newPartId);
  1318. wm_updata_word(rootId,null);
  1319. wm_updata_word_map();
  1320. wm_render_line();
  1321. }
  1322. //wm_updata_word(newPartId,wordId);
  1323. }
  1324. }
  1325. function wm_part_mean_change(wordIndex,newMean){
  1326. var wordId=wm_word_array[wordIndex].id;
  1327. var parentNodeIndex=wm_word_array[wordIndex].parentNode;
  1328. if(parentNodeIndex){
  1329. var arrPartId=wm_word_array[parentNodeIndex].partid.split('+');
  1330. var indexOfMean=-1;
  1331. for(var i in arrPartId){
  1332. if(arrPartId[i]==wordId){
  1333. indexOfMean=i;
  1334. break;
  1335. }
  1336. }
  1337. if(indexOfMean>=0){
  1338. var arrMean = wm_word_array[parentNodeIndex].partmean.split('+');
  1339. arrMean.length=arrPartId.length;
  1340. arrMean[indexOfMean]=newMean;
  1341. wm_word_array[parentNodeIndex].partmean=arrMean.join('+');
  1342. wm_updata_word(rootId,null);
  1343. wm_updata_word_map();
  1344. wm_render_line();
  1345. }
  1346. }
  1347. }
  1348. //查找父节点中的对应的意思在本节点意思列表中的位置
  1349. function wm_get_part_mean_index_in_list(wordIndex){
  1350. var wordId=wm_word_array[wordIndex].id;
  1351. var parentNodeIndex=wm_word_array[wordIndex].parentNode;
  1352. {
  1353. if(parentNodeIndex){
  1354. var arrPartId=wm_word_array[parentNodeIndex].partid.split('+');
  1355. var indexOfMean=-1;
  1356. for(var i in arrPartId){
  1357. if(arrPartId[i]==wordId){
  1358. indexOfMean=i;
  1359. break;
  1360. }
  1361. }
  1362. if(indexOfMean>=0){
  1363. var arrMean = wm_word_array[parentNodeIndex].partmean.split('+');
  1364. arrMean.length=arrPartId.length;
  1365. var parentPartMean = arrMean[indexOfMean];
  1366. var wordMeanArray=wm_word_array[wordIndex].mean.split("$");
  1367. for(var j in wordMeanArray){
  1368. if(wordMeanArray[j]==parentPartMean){
  1369. return(j);
  1370. }
  1371. }
  1372. }
  1373. }
  1374. }
  1375. return(-1);
  1376. }
  1377. function wm_id_exists(findid){
  1378. for(var i in wm_word_array){
  1379. if(wm_word_array[i].id==findid){
  1380. return(true);
  1381. }
  1382. }
  1383. return(false);
  1384. }
  1385. function wm_save_node_all(){
  1386. wm_array_word_for_save=new Array();
  1387. wm_save_node(rootId);
  1388. var_dump("save tree ok.");
  1389. wm_WbwUpdata(wm_array_word_for_save)
  1390. pop_win_close();
  1391. }
  1392. function wm_save_node(nodeId,withChild=true){
  1393. var wid=-1;
  1394. for(var i in wm_word_array){
  1395. if(wm_word_array[i].id==nodeId){
  1396. wid=i;
  1397. }
  1398. }
  1399. if(wid==-1){
  1400. return;
  1401. }
  1402. wm_array_word_for_save.push(wm_word_array[wid]);
  1403. var objDictItem=new Object();/*一个字典元素*/
  1404. objDictItem.Id = 0;
  1405. objDictItem.Guid = wm_word_array[wid].id;
  1406. objDictItem.Pali = wm_word_array[wid].pali;
  1407. objDictItem.Mean = wm_word_array[wid].mean;
  1408. objDictItem.Type = wm_word_array[wid].type;
  1409. objDictItem.Gramma = wm_word_array[wid].gramma;
  1410. objDictItem.Parent = wm_word_array[wid].wparent;
  1411. objDictItem.ParentId = wm_word_array[wid].parentid;
  1412. objDictItem.Factors = wm_word_array[wid].part;
  1413. objDictItem.PartId = wm_word_array[wid].partid;
  1414. objDictItem.FactorMean = wm_word_array[wid].partmean;
  1415. objDictItem.Note = "";
  1416. objDictItem.Confer = "";
  1417. objDictItem.Status = "1024";
  1418. objDictItem.Enable = "true";
  1419. objDictItem.Language = "sc";
  1420. objDictItem.dictname = "user";
  1421. objDictItem.dictType="user";
  1422. objDictItem.fileName="user.db3";
  1423. objDictItem.dictID="0";
  1424. objDictItem.ParentLevel = g_dictFindParentLevel;
  1425. g_DictWordList.unshift(objDictItem);
  1426. editor_insertNewWordToInlineDict(objDictItem);
  1427. if(withChild){
  1428. if(wm_word_array[wid].partid!=""){
  1429. var arrChild=wm_word_array[wid].partid.split("+");
  1430. for(var i in arrChild){
  1431. wm_save_node(arrChild[i]);
  1432. }
  1433. }
  1434. }
  1435. }
  1436. // word by word dict updata
  1437. var wm_wbwUpdataXmlHttp=null;
  1438. function wm_WbwUpdata(arrWord){
  1439. var xmlText="";
  1440. if(window.XMLHttpRequest)
  1441. {// code for IE7, Firefox, Opera, etc.
  1442. wm_wbwUpdataXmlHttp=new XMLHttpRequest();
  1443. }
  1444. else if(window.ActiveXObject)
  1445. {// code for IE6, IE5
  1446. wm_wbwUpdataXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  1447. }
  1448. if (wm_wbwUpdataXmlHttp!=null)
  1449. {
  1450. var queryString="<wordlist>";
  1451. var x = gXmlBookDataBody.getElementsByTagName("word");
  1452. var iCount=0;
  1453. var d_language=language_translation;
  1454. for(var index in arrWord){
  1455. var d_pali=arrWord[index].real;
  1456. var d_guid=arrWord[index].id;
  1457. var d_type = arrWord[index].type;
  1458. var d_gramma = arrWord[index].gramma;
  1459. var d_mean=arrWord[index].mean;
  1460. var d_note=arrWord[index].note;
  1461. var d_parent=com_getPaliReal(arrWord[index].wparent);
  1462. var d_parent_id=arrWord[index].parentid;
  1463. var d_factors=arrWord[index].part;
  1464. var d_fm=arrWord[index].partmean;
  1465. var d_part_id=arrWord[index].partid;
  1466. var d_confer="";
  1467. var d_status="1024";
  1468. var d_enable="TRUE";
  1469. if(d_pali.length>0 && !(d_mean=="" && d_factors=="" && d_fm=="" && d_type=="")){
  1470. queryString+="<word>";
  1471. queryString+="<pali>"+d_pali+"</pali>";
  1472. queryString+="<guid>"+d_guid+"</guid>";
  1473. queryString+="<type>"+d_type+"</type>";
  1474. queryString+="<gramma>"+d_gramma+"</gramma>";
  1475. queryString+="<parent>"+d_parent+"</parent>";
  1476. queryString+="<parent_id>"+d_parent_id+"</parent_id>";
  1477. queryString+="<mean>"+d_mean+"</mean>";
  1478. queryString+="<note>"+d_note+"</note>";
  1479. queryString+="<factors>"+d_factors+"</factors>";
  1480. queryString+="<fm>"+d_fm+"</fm>";
  1481. queryString+="<part_id>"+d_part_id+"</part_id>";
  1482. queryString+="<confer>"+d_confer+"</confer>";
  1483. queryString+="<status>"+d_status+"</status>";
  1484. queryString+="<enable>"+d_enable+"</enable>";
  1485. queryString+="<language>"+d_language+"</language>";
  1486. queryString+="</word>";
  1487. iCount++;
  1488. }
  1489. }
  1490. queryString+="</wordlist>";
  1491. if(iCount>0){
  1492. wm_wbwUpdataXmlHttp.onreadystatechange=wm_wbwDictUpdata_serverResponse;
  1493. debugOutput("updata user dict start.",0);
  1494. wm_wbwUpdataXmlHttp.open("POST", "dict_updata_wbw.php", true);
  1495. wm_wbwUpdataXmlHttp.send(queryString);
  1496. }
  1497. else{
  1498. debugOutput("no user dicttionary data need updata.",0);
  1499. }
  1500. }
  1501. else
  1502. {
  1503. alert("Your browser does not support XMLHTTP.");
  1504. }
  1505. }
  1506. function wm_wbwDictUpdata_serverResponse(){
  1507. if (wm_wbwUpdataXmlHttp.readyState==4)// 4 = "loaded"
  1508. {
  1509. debugOutput("server response.",0);
  1510. if (wm_wbwUpdataXmlHttp.status==200)
  1511. {// 200 = "OK"
  1512. var serverText = wm_wbwUpdataXmlHttp.responseText;
  1513. var_dump(serverText);
  1514. debugOutput(serverText,0);
  1515. }
  1516. else
  1517. {
  1518. debugOutput(xmlhttp.statusText,0);
  1519. }
  1520. }
  1521. }
  1522. function wm_word_base_mouse_over(currWordIndex){
  1523. if(currWordIndex==wm_word_base_curr_focuse){
  1524. return;
  1525. }
  1526. wm_word_base_curr_focuse=currWordIndex;
  1527. switch(wm_show_mode){
  1528. case 0:
  1529. wm_updata_word_root_read(currWordIndex);
  1530. break;
  1531. case 1:
  1532. wm_updata_word_root_read2(currWordIndex);
  1533. break;
  1534. case 2://edit
  1535. wm_updata_word_root_edit(currWordIndex);
  1536. break;
  1537. }
  1538. }
  1539. function wm_look_up(word){
  1540. editor_show_right_tool_bar(true);
  1541. document.getElementById("dict_ref_search_input").value=word;
  1542. dict_search(word);
  1543. }
  1544. function wm_input_keyup(e,wordIndex,mean,value){
  1545. var keynum
  1546. //var keychar
  1547. //var numcheck
  1548. if(window.event) // IE
  1549. {
  1550. keynum = e.keyCode
  1551. }
  1552. else if(e.which) // Netscape/Firefox/Opera
  1553. {
  1554. keynum = e.which
  1555. }
  1556. //var keychar = String.fromCharCode(keynum)
  1557. if(keynum==13){
  1558. wm_field_change(wordIndex,mean,value);
  1559. }
  1560. }
  1561. function wm_render_word_typegramma_edit(wm_type,case1,case2,case3,wordIndex,padding_width){
  1562. var output="";
  1563. var strTypeSelect="";
  1564. var wm_case_Select_Array=new Array();
  1565. var typeList=wm_get_word_type_list(wordIndex);
  1566. var itemList=wm_get_word_gramma_list(wordIndex);
  1567. output +="<span class='wm_inline_control'>";
  1568. //渲染數量角標
  1569. output +="<div id='info_num_type_dropdown_"+wordIndex+"_div' ";
  1570. output +="class=\"info_num_gramma_dropdown\" ";
  1571. output +="style='display:block'>";
  1572. if(typeList.length && typeList.length!=0){
  1573. output +="<span class='detail_info_num'>"//order-radius: 99px;
  1574. output += typeList.length;
  1575. output += "</span>";
  1576. }
  1577. //渲染type詞典數據下拉菜單
  1578. output +="<div class=\"case_dropdown-content\">";
  1579. output +="<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' ";
  1580. output +="onclick='wm_field_change(\""+wordIndex+"\",\"type\",\"\")'>";
  1581. output +=gLocal.gui.empty1;
  1582. output +="</button>";
  1583. for(var type_edit_i in typeList){
  1584. output +="<a onclick='wm_field_change(\""+wordIndex+"\",\"type\",\""+typeList[type_edit_i].type+"\")'>["+getLocalDictname(typeList[type_edit_i].dict)+"]"+getLocalGrammaStr(typeList[type_edit_i].type)+"</a>";
  1585. }
  1586. output += "</div></div>";
  1587. output +="<div class=\"wm_edit_type\" style=\"display:inline-flex;\">";
  1588. //output += "<p class='case_dropbtn' >";
  1589. //output += "<input type='input' onchange='wm_field_change(\""+wordIndex+"\",\"type\",this.value)' size='7' value='"+wm_word_array[wordIndex].type+"' />";
  1590. //output +="</p>";
  1591. if(wm_type!="" && wm_type!="?"){
  1592. wm_case[0]=wm_type;
  1593. wm_case_Select_Array[0]=wm_type;
  1594. strTypeSelect = "<div id=\"id_wm_case_dropdown_0_"+wordIndex+"\" ";
  1595. strTypeSelect+= "class=\"case_dropdown gramma_selector\" ";
  1596. strTypeSelect+= "style='min-width: unset;padding-right: ";
  1597. strTypeSelect+= padding_width+"em;'>";
  1598. strTypeSelect+= "<p class=\"case_dropbtn cell\" style='line-height: 1.2em;'>";
  1599. strTypeSelect+= getLocalGrammaStr(wm_case_Select_Array[0])+"</p>";//顯示
  1600. }
  1601. else{
  1602. wm_case[0]="";
  1603. strTypeSelect = "<div id=\"id_wm_case_dropdown_0_"+wordIndex+"\" ";
  1604. strTypeSelect+= "class=\"case_dropdown gramma_selector\" ";
  1605. strTypeSelect+= "style='min-width: unset;padding-right: ";
  1606. strTypeSelect+= padding_width+"em;'>";
  1607. strTypeSelect+= "<p class=\"case_dropbtn cell\" style='line-height: 1.2em;'>";
  1608. strTypeSelect+= "?</p>";
  1609. }
  1610. strTypeSelect+="<div class=\"case_dropdown-content\">";
  1611. //生成type下拉菜單
  1612. for(var wm_iType in gLocal.type_str){
  1613. strTypeSelect+="<a onclick=\"wm_caseChanged('"+wordIndex+"','type','"+gLocal.type_str[wm_iType].id+"')\">";
  1614. strTypeSelect+=gLocal.type_str[wm_iType].value+"</a>"
  1615. }
  1616. strTypeSelect+="</div>";
  1617. strTypeSelect+="</div>";
  1618. output+="<span>"+strTypeSelect+"</span>";//輸出type下拉菜單
  1619. for(var wm_iCase in gramma_str){//歷遍所有type數組
  1620. if(gramma_str[wm_iCase].id==wm_type){//獲取與當前type相同的後續內容
  1621. var strTypeSelect="";
  1622. gramma=gramma_str[wm_iCase].a;//獲取該wm_case[0]下第一列內容
  1623. if(gramma.length>0){//歷遍所有a列內容
  1624. items=gramma.split("$");//以$分隔
  1625. if(case1==""){//當抓取道的wm_case[0]為空
  1626. wm_case_Select_Array[1]=items[0];//令wm_case[0]以列表默認第一個進行賦值
  1627. wm_case[1]=wm_case_Select_Array[1];//以匹配的數據做為顯示的值
  1628. }
  1629. else{
  1630. wm_case_Select_Array[1]=case1
  1631. wm_case[1]=case1
  1632. }
  1633. //下拉菜單渲染
  1634. strTypeSelect="<div id=\"id_wm_case_dropdown_1_"+wordIndex+"\" ";
  1635. strTypeSelect+="class=\"case_dropdown gramma_selector\" ";
  1636. strTypeSelect+="style='min-width: unset;padding-right: "+padding_width+"em;'>";
  1637. strTypeSelect+="<p class=\"case_dropbtn\" style='line-height: 1.2em;'>";
  1638. strTypeSelect+=getLocalGrammaStr(wm_case_Select_Array[1])+"</p>";
  1639. strTypeSelect+="<div class=\"case_dropdown-content\">";
  1640. //菜單主體
  1641. for(iItem=0;iItem<items.length;iItem++){
  1642. strTypeSelect+="<a onclick=\"wm_caseChanged('"+wordIndex+"','case1','"+items[iItem]+"')\">";
  1643. strTypeSelect+=getLocalGrammaStr(items[iItem])+"</a>"
  1644. }
  1645. strTypeSelect+="</div>";
  1646. strTypeSelect+="</div>";
  1647. }
  1648. else{
  1649. wm_case[1]="";
  1650. }
  1651. output+="<span>"+strTypeSelect+"</span>";
  1652. strTypeSelect="";
  1653. gramma=gramma_str[wm_iCase].b;
  1654. if(gramma.length>0){
  1655. items=gramma.split("$");
  1656. if(case2==""){
  1657. wm_case_Select_Array[2]=items[0];
  1658. wm_case[2]=wm_case_Select_Array[2];
  1659. }
  1660. else{
  1661. wm_case_Select_Array[2]=case2
  1662. wm_case[2]=case2
  1663. }
  1664. strTypeSelect="<div id=\"id_wm_case_dropdown_2_"+wordIndex+"\" ";
  1665. strTypeSelect+="class=\"case_dropdown gramma_selector\" ";
  1666. strTypeSelect+="style='min-width: unset;padding-right: "
  1667. strTypeSelect+=padding_width+"em;'>";
  1668. strTypeSelect+="<p class=\"case_dropbtn\" style='line-height: 1.2em;'>";
  1669. strTypeSelect+=getLocalGrammaStr(wm_case_Select_Array[2])+"</p>";
  1670. strTypeSelect+="<div class=\"case_dropdown-content\">";
  1671. for(iItem=0;iItem<items.length;iItem++){
  1672. strTypeSelect+="<a onclick=\"wm_caseChanged('"+wordIndex+"','case2','"+items[iItem]+"')\">"+getLocalGrammaStr(items[iItem])+"</a>"
  1673. }
  1674. strTypeSelect+="</div>";
  1675. strTypeSelect+="</div>";
  1676. }
  1677. else{
  1678. wm_case[2]="";
  1679. }
  1680. //eCaseItems[2].innerHTML=strTypeSelect;
  1681. output+="<span>"+strTypeSelect+"</span>";
  1682. strTypeSelect="";
  1683. gramma=gramma_str[wm_iCase].c;
  1684. if(gramma.length>0){
  1685. items=gramma.split("$");
  1686. if(case3==""){
  1687. wm_case_Select_Array[3]=items[0];
  1688. wm_case[3]=wm_case_Select_Array[3];
  1689. }
  1690. else{
  1691. wm_case_Select_Array[3]=case3
  1692. wm_case[3]=case3
  1693. }
  1694. strTypeSelect="<div id=\"id_wm_case_dropdown_3_"+wordIndex+"\" ";
  1695. strTypeSelect+="class=\"case_dropdown gramma_selector\" ";
  1696. strTypeSelect+="style='min-width: unset;padding-right: "+padding_width+"em;'>";
  1697. strTypeSelect+="<p class=\"case_dropbtn\" style='line-height: 1.2em;'>";
  1698. strTypeSelect+=getLocalGrammaStr(wm_case_Select_Array[3])+"</p>";
  1699. strTypeSelect+="<div class=\"case_dropdown-content\">";
  1700. for(iItem=0;iItem<items.length;iItem++){
  1701. strTypeSelect+="<a onclick=\"wm_caseChanged('"+wordIndex+"','case3','"+items[iItem]+"')\">"+getLocalGrammaStr(items[iItem])+"</a>"
  1702. }
  1703. strTypeSelect+="</div>";
  1704. strTypeSelect+="</div>";
  1705. }
  1706. else{
  1707. wm_case[3]="";
  1708. }
  1709. //eCaseItems[3].innerHTML=strTypeSelect;
  1710. output+="<span>"+strTypeSelect+"</span>";
  1711. }
  1712. }
  1713. output +="</div>";//<div class=\"wm_edit_gramma\">
  1714. //output += "<p class='case_dropbtn' >";
  1715. //output += "<input type='input' onchange='wm_field_change(\""+wordIndex+"\",\"gramma\",this.value)' size='7' value='"+wm_word_array[wordIndex].gramma+"' />";
  1716. //output +="</p>";
  1717. if(wm_word_array[wordIndex].gramma==" "/* && wm_word_array[wordIndex].gramma!="?"*/){
  1718. output += "<span id='gramma_"+wordIndex+"_span' class='wm_input_span' ";
  1719. //output += "onclick=\"switch_input_span("+wordIndex+",\'gramma\')\"";
  1720. output += ">";
  1721. output += getLocalGrammaStr(wm_word_array[wordIndex].gramma);
  1722. output += "</span>"
  1723. output += "</div>";
  1724. //output +="</p>";
  1725. }
  1726. //else{
  1727. // output += "<span id='gramma_"+wordIndex+"_span' class='wm_input_span' ";
  1728. // output += "style='display:block'"
  1729. // output += "onclick=\"switch_input_span("+wordIndex+",\'gramma\')\">";
  1730. // output += "<i>?</i>";
  1731. // output += "</span>"
  1732. // output += "</div>";
  1733. //}
  1734. //渲染數量角標
  1735. output +="<div id='info_num_gramma_dropdown_"+wordIndex+"_div' ";
  1736. output +="class=\"info_num_gramma_dropdown\" ";
  1737. output +="style='display:block'>";
  1738. if(itemList.length && itemList.length!=0){
  1739. output +="<span class='detail_info_num'>"//order-radius: 99px;
  1740. output += itemList.length;
  1741. output += "</span>"
  1742. }
  1743. output +="<div class=\"case_dropdown-content\">";
  1744. output +="<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='wm_field_change(\""+wordIndex+"\",\"gramma\",\"\")'>"+gLocal.gui.empty1+"</button>"
  1745. for(var gramma_edit_i in itemList){
  1746. output +="<a onclick='wm_field_change(\""+wordIndex+"\",\"gramma\",\""+itemList[gramma_edit_i].gramma+"\")'>["+getLocalDictname(itemList[gramma_edit_i].dict)+"]"+getLocalGrammaStr(itemList[gramma_edit_i].gramma)+"</a>";
  1747. }
  1748. output +="</div></div></span>";
  1749. return(output);
  1750. }
  1751. function wm_caseChanged(wordIndex,position,newValue){
  1752. switch(position){
  1753. case "type":
  1754. wm_case[0]=newValue;
  1755. wm_case[1]+="";
  1756. wm_case[2]+="";
  1757. wm_case[3]+="";
  1758. for(wm_caseChanged_i in wm_case){
  1759. if(wm_case[wm_caseChanged_i]=="undefined"){
  1760. wm_case[wm_caseChanged_i]=""
  1761. }
  1762. }
  1763. break;
  1764. case "case1":
  1765. wm_case[0]+="";
  1766. wm_case[1]=newValue;
  1767. wm_case[2]+="";
  1768. wm_case[3]+="";
  1769. for(wm_caseChanged_i in wm_case){
  1770. if(wm_case[wm_caseChanged_i]=="undefined"){
  1771. wm_case[wm_caseChanged_i]=""
  1772. }
  1773. }
  1774. break;
  1775. case "case2":
  1776. wm_case[0]+="";
  1777. wm_case[1]+="";
  1778. wm_case[2]=newValue;
  1779. wm_case[3]+="";
  1780. for(wm_caseChanged_i in wm_case){
  1781. if(wm_case[wm_caseChanged_i]=="undefined"){
  1782. wm_case[wm_caseChanged_i]=""
  1783. }
  1784. }
  1785. break;
  1786. case "case3":
  1787. wm_case[0]+="";
  1788. wm_case[1]+="";
  1789. wm_case[2]+="";
  1790. wm_case[3]=newValue;
  1791. for(wm_caseChanged_i in wm_case){
  1792. if(wm_case[wm_caseChanged_i]=="undefined"){
  1793. wm_case[wm_caseChanged_i]=""
  1794. }
  1795. }
  1796. break;
  1797. }
  1798. wm_refreshCaseSelect(wordIndex,wm_case);
  1799. }
  1800. function wm_refreshCaseSelect(wordIndex,wm_case){
  1801. document.getElementById("wm_edit_gramma_"+wordIndex).innerHTML=wm_render_word_typegramma_edit(wm_case[0],wm_case[1],wm_case[2],wm_case[3],wordIndex,0.5);
  1802. //var wm_newType=wm_case[0];
  1803. if(wm_case[1]!="" && wm_case[1]){
  1804. var wm_newGramma=wm_case[1];
  1805. }
  1806. if(wm_case[1]!="" && wm_case[1]){
  1807. wm_newGramma+="$"+wm_case[2];
  1808. }
  1809. if(wm_case[1]!="" && wm_case[1]){
  1810. wm_newGramma+="$"+wm_case[3];
  1811. }
  1812. wm_word_array[wordIndex].type=wm_case[0];
  1813. wm_word_array[wordIndex].gramma=wm_newGramma;
  1814. //document.getElementById("wm_input_case").value=wm_newCaseString;
  1815. }