var lineComments = []; function comment() { if (document.getElementById("CommentBox").style.display=="block") { document.getElementById("CommentBox").style.display="none"; } else { document.getElementById("CommentBox").style.display="block"; document.getElementById("CommentText").focus(); } } function clear_comment() { document.getElementById("CommentText").value = ""; comment(); return true; } function del_line_comment(ev) { var td = ev.target.parentNode; while (td.childNodes.length) { td.removeChild(td.lastChild) } if (td.tagName == "TD") { var tr = td.parentNode; if (td.cellIndex > 1) { /* right cell. check left */ if (tr.cells[1] .getElementsByTagName("TEXTAREA").length == 0) { var tbl = tr.parentNode; tbl.removeChild(tr); } } else { /* left. check right */ if (tr.cells.length > 4 && tr.cells[4].getElementsByTagName("TEXTAREA").length == 0 || tr.cells.length == 2) { var tbl = tr.parentNode; tbl.removeChild(tr); } } } else { var pn = td.parentNode; pn.removeChild(td); } return false; } function add_udiff_comment(el) { if (el.tagName != "DIV" && el.tagName != "SPAN") return null; while (el && el.parentNode.className != "diff_div") { el = el.parentNode; } if (!el) return null; if (el.previousSibling && el.previousSibling.className == "lineComment") return null; if (el.id.charAt(0) != 'l' && el.id.charAt(0) != 'r' || parseInt(el.id.substr(1)) == NaN) return null; var base = document.createElement('DIV'); base.className = "lineComment"; el.parentNode.insertBefore(base, el); return add_inline_ta(el.id, base); } function add_sdiff_comment(el) { if (el.tagName != "TD" && el.tagName != "SPAN" && el.tagName != "TR") return null; while (el && el.tagName != "TD") { el = el.parentNode; } if (!el) return null; var left = el.cellIndex < 2; while (el && el.tagName != "TR") { el = el.parentNode; } if (!el || el.className == "lineComment") return null; var tds = el.getElementsByTagName('TD'); var tag_id = left ? tds[0].id : tds[3].id; if (!tag_id) return null; var tr = null; var td = null; var i = 0; if (el.previousSibling && el.previousSibling.className == "lineComment") { tds = el.previousSibling.getElementsByTagName('TD'); td = tds[(left || el.className != 'tr_diff')?1:4] if (td.getElementsByTagName('TEXTAREA').length > 0) return null; tr = el.previousSibling; } else { tr = document.getElementById('diff_table').insertRow(el.rowIndex); tr.className = 'lineComment'; tr.insertCell(i++); /* left line number */ var td1 = tr.insertCell(i++); /* comment */ td1.align = "center"; if (el.className == 'tr_diff') { tr.insertCell(i++); /* */ tr.insertCell(i++); var td3 = tr.insertCell(i++); td3.align = "center"; td = left ? td1:td3; } else { /* comment for both columns*/ td1.colSpan = 5; td = td1; } } return add_inline_ta(tag_id, td); } function add_inline_ta(tag_id, base) { var ta = document.createElement('TEXTAREA'); ta.id = "ta_"+tag_id; ta.name = "inline_comment"; ta.style.marginTop = "1em"; ta.cols = 70; ta.rows = 3; base.appendChild(ta); var btn = document.createElement('BUTTON'); btn.innerHTML = "Delete"; btn.onclick = function(e) { del_line_comment(e); e.stopPropagation(); }; base.appendChild(btn); ta.focus(); return ta; } function apply_rep(rep) { if (rep.c && rep.c[''+item_id]) { var ta = document.getElementById("CommentText"); ta.value = rep.c[''+item_id]; comment(); } if (rep.i && rep.i[''+item_id]) { var td; var icmts = rep.i[''+item_id]; for (var c in icmts) { td = document.getElementById(c); if (td) add_inline_comment(td).value = icmts[c]; } } if (rep.a && (has(rep.a, item_id) || has(rep.a, 0))) document.getElementById('ok_cb').checked = true; } function get_rep() { var rep = load_rep(); if (!rep) rep = {}; if (document.getElementById('ok_cb').checked) { if (!rep.a) rep.a = []; add(rep.a, item_id); } else { if (rep.a) if (has(rep.a, item_id)) del(rep.a, item_id); } var cmt = document.getElementById("CommentText").value; if (cmt) { if (!rep.c) rep.c = {}; rep.c[''+item_id] = cmt; } else { if (rep.c[''+item_id]) delete rep.c[''+item_id]; } var icmts = document.getElementsByName("inline_comment"); if (!rep.i) rep.i = {}; rep.i[''+item_id] = {}; for (var ic=0; ic