var _commit_data; var previewWin; var sentData; function commit_init(param) { previewWin = model_win_init({ container: "model_win" }); _commit_data = param; previewWin.show(commit_preview_render()); } function commit_render_head(step) { let html = ""; html += "
"; html += "
1
选择版本
"; html += "
2
文本比对
"; html += "
3
完成
"; html += "
"; return html; } function commit_render_channel_select() { let html = ""; html += "
"; html += commit_render_head(1); html += "
"; if (typeof _commit_data.src != "undefined") { html += "
译文来源
"; html += "
"; let isFound = false; for (const iterator of _my_channal) { if (_commit_data.src == iterator.id) { html += iterator.name; isFound = true; break; } } if (!isFound) { for (const iterator of _channalData) { if (_commit_data.src == iterator.id) { html += iterator.name; isFound = true; break; } } } if (!isFound) { html += "无法找到Channel"; } html += "
"; } else { html += "
请选择译文来源"; html += "
"; } html += "
目标译文:
"; html += "
"; html += ""; html += "
"; html += "
"; if (typeof _commit_data.express != "undefined" && _commit_data.express == true) { if (typeof _commit_data.sent != "undefined" && _commit_data.sent.length != 0) { html += ""; } else { html += "没有句子数据"; } } else { html += ""; } html += "
"; html += "
"; html += "
"; return html; } function commit_preview_render() { let html = ""; html += "
"; html += commit_render_head(2); _commit_data.dest = $("#dest_channel").val(); if ( typeof _commit_data.src != "undefined" && _commit_data.src != null && _commit_data.src != "" && typeof _commit_data.dest != "undefined" && _commit_data.dest != null && _commit_data.dest != "" ) { if (typeof _commit_data.sent == "undefined" || _commit_data.sent.length == 0) { let sentList = new Array(); for (const iterator of _arrData) { sentList.push(iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end); } _commit_data.sent = sentList; } let arrSentInfo = new Array(); for (const iterator of _commit_data.sent) { let id = com_guid(); arrSentInfo.push({ id: id, data: iterator }); } if (arrSentInfo.length > 0) { let setting = new Object(); setting.lang = ""; setting.channal = _commit_data.src + "," + _commit_data.dest; $.post( "../term/note.php", { setting: JSON.stringify(setting), data: JSON.stringify(arrSentInfo), }, function (data, status) { if (status == "success") { try { sentData = JSON.parse(data); } catch (e) {} previewWin.show(commit_render_comp(0)); } } ); html += "加载中 请稍等……"; html += "
"; return html; } else { html += "没有句子被选择"; html += ""; return html; } } else { return commit_render_channel_select(); } } function commit_compare_mode_change(obj) { previewWin.show(commit_render_comp(parseInt($(obj).val()))); } /* { id: 0, string: "自动" }, { id: 1, string: "全选" }, { id: 2, string: "全不选" }, */ function commit_render_comp(mode) { let html = ""; html += "
"; html += commit_render_head(2); html += "
"; html += ""; html += ""; html += ""; html += "
"; html += "
"; html += "
"; html += ""; html += "
"; html += "
巴利原文
"; html += "
当前版本:" + channal_getById(_commit_data.src).name + "
"; html += "
推送到:" + channal_getById(_commit_data.dest).name + "
"; html += "
"; let textCount = 0; let sentIndex = 0; for (let iterator of sentData) { iterator.checked = false; if (iterator.translation[0].text != iterator.translation[1].text) { textCount++; if (iterator.translation[0].id != "") { html += "
"; html += "
"; html += " iterator.translation[1].update_time) { html += " checked "; iterator.checked = true; } } break; case 1: html += " checked "; iterator.checked = true; break; case 2: break; default: break; } html += " sent_id='" + iterator.pali_sent_id; html += "' onclick='commit_sent_select(this)' />
"; html += "
" + iterator.palitext + "
"; html += "
"; html += iterator.translation[0].text; html += "
"; html += "
"; } else { if (iterator.translation[0].update_time > iterator.translation[1].update_time) { html += str_diff(iterator.translation[1].text, iterator.translation[0].text); } else { html += "[新]" + iterator.translation[1].text; } } break; case 1: html += str_diff(iterator.translation[1].text, iterator.translation[0].text); break; case 2: html += iterator.translation[1].text; break; } html += "
"; html += "
"; } } sentIndex++; } if (textCount == 0) { html += "全部相同,无需推送。"; } html += "
"; return html; } function commit_sent_select(obj) { let sent_id = $(obj).attr("sent_id"); for (let iterator of sentData) { if (iterator.pali_sent_id == sent_id) { let html = ""; iterator.checked = obj.checked; if (obj.checked) { if (iterator.translation[1].id != "") { html += "" + iterator.translation[1].text + "
"; } html += "" + iterator.translation[0].text + ""; } else { html += iterator.translation[1].text; } $(".dest_text[sent_id='" + sent_id + "']").html(html); } } } function commit_render_final(result) { let html = ""; html += "
"; html += commit_render_head(3); if (typeof result.update != "undefined") { html += "
修改:" + result.update + "
"; } if (typeof result.insert != "undefined") { html += "
新增:" + result.insert + "
"; } if (typeof result.pr != "undefined") { html += "
提交修改建议:" + result.pr + "
"; } html += "
刷新页面查看修改结果。关闭
"; html += "
"; return html; } function commit_pull() { localStorage.setItem("commit_src_" + _commit_data.src, _commit_data.dest); let pullData = new Array(); for (const iterator of sentData) { if (iterator.checked) { pullData.push(iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end); } } _commit_data.sent = pullData; if (pullData.length == 0) { alert("没有数据被选择"); return; } $.post( "../commit/commit.php", { data: JSON.stringify(_commit_data), }, function (data, status) { if (status == "success") { let html = ""; try { let result = JSON.parse(data); if (result.status == 0) { previewWin.show(commit_render_final(result)); } else { alert(result.message); } } catch (e) {} } } ); } function commit_close() {} function dest_change(obj) { _commit_data.dest = $(obj).val(); localStorage.setItem("commit_src_" + _commit_data.src, _commit_data.dest); } function src_change(obj) { _commit_data.src = $(obj).val(); localStorage.setItem("commit_last_src", _commit_data.src); }