Fossil

Diff
Login

Differences From Artifact [76f38f8847]:

To Artifact [58d4e7acfa]:


75
76
77
78
79
80
81

82
83
84


85
86
87
88

89
90
91
92
93
94
95
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99







+



+
+




+







  amendCssOnce = 0;
}
var tooltipObj = document.createElement("span");
tooltipObj.className = "tl-tooltip";
tooltipObj.style.visibility = "hidden";
document.getElementsByClassName("content")[0].appendChild(tooltipObj);

/* Construct that graph corresponding to the timeline-data-N object */
function TimelineGraph(tx){
  var topObj = document.getElementById("timelineTable"+tx.iTableId);
  amendCss(tx.circleNodes, tx.showArrowheads);
  topObj.onclick = clickOnGraph
  topObj.ondblclick = dblclickOnGraph
  var canvasDiv;
  var railPitch;
  var mergeOffset;
  var node, arrow, arrowSmall, line, mArrow, mLine, wArrow, wLine;

  function initGraph(){
    var parent = topObj.rows[0].cells[1];
    parent.style.verticalAlign = "top";
    canvasDiv = document.createElement("div");
    canvasDiv.className = "tl-canvas";
    canvasDiv.style.position = "absolute";
    parent.appendChild(canvasDiv);
165
166
167
168
169
170
171
172

173
174
175
176
177
178











179
180
181
182
183
184
185
169
170
171
172
173
174
175

176






177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194







-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+







    if( h ) n.style.height = h+"px";
    if( color ) n.style.backgroundColor = color;
    n.className = "tl-"+cls;
    canvasDiv.appendChild(n);
    return n;
  }
  function absoluteY(obj){
    var top = 0;
    var y = 0;
    if( obj.offsetParent ){
      do{
        top += obj.offsetTop;
      }while( obj = obj.offsetParent );
    }
    return top;
    do{
      y += obj.offsetTop;
    }while( obj = obj.offsetParent );
    return y;
  }
  function absoluteX(obj){
    var x = 0;
    do{
      x += obj.offsetLeft;
    }while( obj = obj.offsetParent );
    return x;
  }
  function miLineY(p){
    return p.y + node.h - mLine.w - 1;
  }
  function drawLine(elem,color,x0,y0,x1,y1){
    var cls = elem.cls + " ";
    if( x1===null ){
210
211
212
213
214
215
216
217
218
219
220
221

222
223
224
225
226
227
228
229
219
220
221
222
223
224
225





226

227
228
229
230
231
232
233







-
-
-
-
-
+
-







    var y0 = from.y + node.h/2;
    var y1 = Math.ceil(to.y + node.h);
    var n = drawLine(dotLine,null,x,y0,null,y1)
    if( color ) n.style.borderColor = color
    addToolTip(n,id)
  }
  function addToolTip(n,id){
    if( id ){
      n.onmouseenter = tooltipEnter
      n.onmouseleave = tooltipLeave
      n.onclick = tooltipClick
      n.setAttribute("data-ix",id-tx.iTopRow)
    if( id ) n.setAttribute("data-ix",id-tx.iTopRow)
    }
  }
  /* Draw thin horizontal or vertical lines representing merges */
  function drawMergeLine(x0,y0,x1,y1){
    drawLine(mLine,null,x0,y0,x1,y1);
  }
  function drawCherrypickLine(x0,y0,x1,y1){
    drawLine(cpLine,null,x0,y0,x1,y1);
265
266
267
268
269
270
271

272
273
274
275
276
277
278
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283







+







    var cls = node.cls;
    if( p.hasOwnProperty('mi') && p.mi.length ) cls += " merge";
    if( p.f&1 ) cls += " leaf";
    var n = drawBox(cls,p.bg,p.x,p.y);
    n.id = "tln"+p.id;
    addToolTip(n,p.id)
    n.onclick = clickOnNode;
    n.ondblclick = dblclickOnNode;
    n.style.zIndex = 10;
    if( !tx.omitDescenders ){
      if( p.u==0 ){
        if( p.hasOwnProperty('mo') && p.r==p.mo ){
          var ix = p.hasOwnProperty('cu') ? p.cu : p.mu;
          var top = tx.rowinfo[ix-tx.iTopRow]
          drawUpArrow(p,{x: p.x, y: top.y-node.h}, p.fg, p.id);
404
405
406
407
408
409
410
411

412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427

428





429
430
431
432
433
434
435
436
437
438
439
440
441






































442
443

444
445
446
447
448
449
450
451
452
453
454
455
456
409
410
411
412
413
414
415

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439













440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483



484
485
486
487
488
489
490







-
+
















+

+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


+



-
-
-







    var btm = absoluteY(tlBtm) - canvasY + tlBtm.offsetHeight;
    for( var i=0; i<tx.nrail; i++) mergeBtm[i] = btm;
    for( var i=tx.rowinfo.length-1; i>=0; i-- ){
      drawNode(tx.rowinfo[i], btm);
    }
  }
  var selRow;
  function clickOnNode(){
  function clickOnNode(e){
    var p = tx.rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-tx.iTopRow];
    if( !selRow ){
      selRow = p;
      this.className += " sel";
      canvasDiv.className += " sel";
    }else if( selRow==p ){
      selRow = null;
      this.className = this.className.replace(" sel", "");
      canvasDiv.className = canvasDiv.className.replace(" sel", "");
    }else{
      if( tx.fileDiff ){
        location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h
      }else{
        location.href=tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h
      }
    }
    e.stopPropagation()
  }
  function dblclickOnNode(e){
    var p = tx.rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-tx.iTopRow];
    window.location.href = tx.baseUrl+"/info/"+p.h
    e.stopPropagation()
  }
  function tooltipEnter(e){
    var ix = this.getAttribute("data-ix")
    tooltipObj.textContent = tx.rowinfo[ix].br
    tooltipObj.style.display = "inline"
    tooltipObj.style.position = "absolute"
    var x = e.x + 4 + window.pageXOffset
    tooltipObj.style.left = x+"px"
    var y = e.y + window.pageYOffset - tooltipObj.clientHeight - 4
    tooltipObj.style.top = y+"px"
    tooltipObj.style.visibility = "visible"
  }
  function tooltipClick(e){
    var ix = this.getAttribute("data-ix")
  function findTxIndex(e){
    /* Look at all the graph elements.  If any graph elements that is near
    ** the click-point "e" and has a "data-ix" attribute, then return
    ** the value of that attribute.  Otherwise return -1 */
    var x = e.x + window.pageXOffset - absoluteX(canvasDiv);
    var y = e.y + window.pageYOffset - absoluteY(canvasDiv);
    var aNode = canvasDiv.childNodes
    var nNode = aNode.length;
    var i;
    for(i=0;i<nNode;i++){
      var n = aNode[i]
      if( !n.hasAttribute("data-ix") ) continue;
      if( x<n.offsetLeft-5 ) continue;
      if( x>n.offsetLeft+n.offsetWidth+5 ) continue;
      if( y<n.offsetTop-5 ) continue;
      if( y>n.offsetTop+n.offsetHeight ) continue;
      return n.getAttribute("data-ix")
    }
    return -1
  }
  function clickOnGraph(e){
    var ix = findTxIndex(e);
    if( ix<0 ){
      tooltipObj.style.display = "none"
    }else{  
      tooltipObj.textContent = tx.rowinfo[ix].br
      tooltipObj.style.display = "inline"
      tooltipObj.style.position = "absolute"
      var x = e.x + 4 + window.pageXOffset
      tooltipObj.style.left = x+"px"
      var y = e.y + window.pageYOffset - tooltipObj.clientHeight - 4
      tooltipObj.style.top = y+"px"
      tooltipObj.style.visibility = "visible"
    }
  }
  function dblclickOnGraph(e){
    if( tx.fileDiff ) return
    var ix = findTxIndex(e);
    var br = tx.rowinfo[ix].br
    var dest = "/timeline?r=" + encodeURIComponent(br)
    dest += "&c=" + encodeURIComponent(tx.rowinfo[ix].h)
    tooltipObj.style.display = "none"
    window.location.href = tx.baseUrl + dest
  }
  function tooltipLeave(e){
    tooltipObj.style.display = "none"
  }
  function changeDisplay(selector,value){
    var x = document.getElementsByClassName(selector);
    var n = x.length;
    for(var i=0; i<n; i++) {x[i].style.display = value;}
  }
  function changeDisplayById(id,value){
    var x = document.getElementById(id);