--- reviewpages/scripts/tools.js (revision 265)
+++ reviewpages/scripts/tools.js (working copy)
@@ -45,6 +45,18 @@
return false;
}
+function add_u_static_comment(line, comments) {
+ var div = document.getElementById(line);
+ var base = document.getElementById("ds"+line)
+ if (!base) {
+ base = document.createElement('DIV');
+ base.id = 'ds_'+line;
+ base.className = "lineStaticComment";
+ div.parentNode.insertBefore(base, div);
+ }
+ add_inline_dl(line, base, comments);
+}
+
function add_udiff_comment(el) {
if (el.tagName != "DIV" && el.tagName != "SPAN")
return null;
@@ -61,6 +73,44 @@
el.parentNode.insertBefore(base, el);
return add_inline_ta(el.id, base);
+}
+
+function add_s_static_comment(line, comments) { // line: [ [ time, author, comment ]
+ var td0 = document.getElementById(line);
+ var left = td0.cellIndex < 2;
+ var tr = td0.parentNode;
+ var tds = tr.getElementsByTagName('TD');
+ var tag_id = left ? tds[0].id : tds[3].id;
+ if (!tag_id) return null;
+
+ var tr_new = null;
+ var td = null;
+ var i = 0;
+ if (tr.previousSibling && tr.previousSibling.className == "lineStaticComment") {
+ tds = tr.previousSibling.getElementsByTagName('TD');
+ td = tds[(left || tr.className != 'tr_diff')?1:4]
+ if (td.getElementsByTagName('DL').length > 0)
+ return null;
+ tr_new = tr.previousSibling;
+ } else {
+ tr_new = document.getElementById('diff_table').insertRow(tr.rowIndex);
+ tr_new.className = 'lineStaticComment';
+ tr_new.insertCell(i++); /* left line number */
+ var td1 = tr_new.insertCell(i++); /* comment */
+ td1.align = "left";
+ if (tr.className == 'tr_diff') {
+ tr_new.insertCell(i++); /* */
+ tr_new.insertCell(i++);
+ var td3 = tr_new.insertCell(i++);
+ td3.align = "left";
+ td = left ? td1:td3;
+ } else { /* comment for both columns*/
+ td1.colSpan = 5;
+ td = td1;
+ }
+ }
+
+ return add_inline_dl(line, td, comments);
}
function add_sdiff_comment(el) {
@@ -110,6 +160,43 @@
}
return add_inline_ta(tag_id, td);
+}
+
+function add_inline_dl(line, base, comments) { // line: [ [ time, author, comment ]
+ comments.sort(function(a,b) { return a[0] > b[0]; });
+ var dl = document.createElement('DL');
+ dl.id = "dl_"+line;
+ dl.className = "x";
+ dl.name = "inline_static_comment";
+ base.appendChild(dl);
+
+ var comment;
+ var name = getCookie('rp_name');
+ for (var i=0; i<comments.length; ++i) {
+ comment = comments[i];
+ var dt_id = escape_id("dt_"+line+'_'+comment[0]+'_'+escape(comment[1]));
+ if (document.getElementById(dt_id)) {
+ continue;
+ }
+ var dt = document.createElement('DT');
+ dt.id = dt_id;
+ dt.innerHTML = comment[1]+
+ (' ('+
+ new Date(parseInt(comment[0])+1287854282865).toLocaleString()+')').small()
+ +':';
+ var dd = document.createElement('DD');
+ if (name == comment[1]) {
+ dt.className = 'xs';
+ dd.className = 'xs';
+ } else {
+ dt.className = 'x';
+ }
+ dd.innerHTML = comment[2];
+ dl.appendChild(dt);
+ dl.appendChild(dd);
+ }
+
+ return dl;
}
function add_inline_ta(tag_id, base) {
@@ -132,6 +219,33 @@
}
function apply_rep(rep) {
+ if (!rep)
+ return;
+ var id;
+ if (rep.x) {
+ var line;
+ var comments = {}; // { line: [ [ time, author, comment ], ... ] }
+ var data, data1;
+ for (var author in rep.x) {
+ data = rep.x[author];
+ for (var time in data) {
+ data1 = data[time];
+ if (data1.i && data1.i[item_id]) {
+ for (line in data1.i[item_id]) {
+ if (!comments[line])
+ comments[line] = [];
+ comments[line].push([
+ time,
+ author,
+ data1.i[item_id][line]]);
+ }
+ }
+ }
+ }
+ for (line in comments) {
+ add_inline_static_comment(line, comments[line]);
+ }
+ }
if (rep.c && rep.c[''+item_id]) {
var ta = document.getElementById("CommentText");
ta.value = rep.c[''+item_id];