function term_edit_dlg_init(title = gLocal.gui.dict_terms) { $("body").append('
'); $("#term_edit_dlg").dialog({ autoOpen: false, width: 550, outerHeight: "80vh", buttons: [ { id:"term_edit_dlg_save", text: gLocal.gui.submit, click: function () { term_edit_dlg_save(); $(this).dialog("close"); }, }, { text: gLocal.gui.cancel, click: function () { $(this).dialog("close"); }, }, ], }); } /* obj:调用此函数的按钮的handle */ function term_edit_dlg_open(id = "", word = "",channel="",lang="",obj=null) { if (id == "") { let newWord = new Object(); newWord.guid = ""; newWord.word = word; newWord.meaning = ""; newWord.other_meaning = ""; newWord.tag = ""; newWord.note = ""; newWord.language = lang; newWord.channel = channel; let html = term_edit_dlg_render(newWord,obj); $("#term_edit_dlg_content").html(html); $("#term_edit_dlg").dialog("open"); } else { $.post( "../term/term_get_id.php", { id: id, }, function (data) { let word = JSON.parse(data); let html = term_edit_dlg_render(word,obj); $("#term_edit_dlg_content").html(html); $("#term_edit_dlg").dialog("open"); } ); } } function term_edit_dlg_render(word = null,obj=null) { if (word == null) { word = new Object(); word.guid = ""; word.word = ""; word.meaning = ""; word.other_meaning = ""; word.tag = ""; word.note = ""; } let output = ""; output += "
"; output += ""; output += "
"; output += "" + gLocal.gui.spell + ""; if(word.guid === "" && word.word === ""){ //新建术语 而且词头为空 允许修改word 拼写 ""+word.word+""; output += ""; } output += "
"; output += "
"; output += "" + gLocal.gui.first_choice_word + ""; output += ""; output += "
"; output += "
"; output += "" + gLocal.gui.other_meaning + ""; output += ""; output += "
"; output += "
"; output += "" + gLocal.gui.language + ""; output += ""; output += "
"; output += "
"; output += "" + gLocal.gui.tag + ""; output += ""; output += "
"; output += "
"; output += "" + gLocal.gui.encyclopedia + ""; output += ""; output += "
"; output += "
"; output += "" + gLocal.gui.channel + ""; let currChannel=null;//当前单词的channel if(typeof word.channel == "undefined" && typeof word.channal != "undefined"){ word.channel = word.channal; } for (const iterator of _my_channal) { if(iterator.uid==word.channel){ currChannel = iterator; } } //查询术语所在句子的channel let sentChannel=null; let sentChannelId=null; if(obj){ let sentObj = find_sent_tran_div(obj); if(sentObj){ sentChannelId = sentObj.attr('channel'); for (const iterator of _my_channal) { if(iterator.uid==sentChannelId){ sentChannel = iterator; } } } } let style='display:none;'; if(word.guid === ''){ //新建术语 可以修改channel style = 'display:block;'; }else{ //修改术语 不能修改channel output +="
当前:" ; if(word.channel === ''){ output += "通用于所有版本"; //判断是否只读 if(sentChannel !==null && sentChannel.power !== 30){ output += "(只读)"; } }else{ output += "仅使用于版本"; if(currChannel !== null){ //我有写权限 output += currChannel.name; }else{ //我没有写权限 设置按钮为disable output += word.channel; output += "(只读)"; } output += ""; } output += "
"; output +="
另存为
"; } output += "
"; output += ""; output += "
只有选择通用版本或者本句版本才会应用到这个句子
"; output += "
"; output += "
"; output += "
"; return output; } function set_term_dlg_channel_msg(msg){ $("#term_dlg_channel_msg").text(msg); } function term_edit_dlg_save() { $.ajax({ type: "POST", //方法类型 dataType: "json", //预期服务器返回的数据类型 url: "../term/term_post.php", //url data: $("#form_term").serialize(), success: function (result) { console.log(result); //打印服务端返回的数据(调试用) if (result.status == 0) { alert(result.message + gLocal.gui.saved + gLocal.gui.successful); for (let index = 0; index < arrMyTerm.length; index++) { const element = arrMyTerm[index]; if(element.guid==result.data.guid){ arrMyTerm.splice(index,1); break; } } arrMyTerm.push(result.data); term_updata_translation(); } else { alert("error:" + result.message); } }, error: function (data, status) { alert("异常!" + data.responseText); switch (status) { case "timeout": break; case "error": break; case "notmodified": break; case "parsererror": break; default: break; } }, }); } function term_save_as(obj){ if(obj.checked){ $("#term_save_as_channel").show(); }else{ $("#term_save_as_channel").hide(); } }