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 += "
译文来源:";
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);
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())));
}
function commit_render_comp(mode) {
let html = "";
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 += "
";
switch (mode) {
case 0:
if (iterator.translation[1].id == "") {
html += "" + iterator.translation[0].text + "";
} else {
if (iterator.translation[0].update_time > iterator.translation[1].update_time) {
html += "" + iterator.translation[1].text + " ";
html += "" + iterator.translation[0].text + "";
} else {
html += "[新]" + iterator.translation[1].text;
}
}
break;
case 1:
html += "" + iterator.translation[1].text + " ";
html += "" + 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 += "