1
2
3
4
5
6
7
8
|
1
2
3
4
5
6
7
8
9
10
11
|
+
+
+
|
/* This module contains javascript needed to render timeline graphs in Fossil.
**
** There can be multiple graphs on a single webpage, but this script is only
** loaded once.
**
** Prior to sourcing this script, there should be a separate
** <script type='application/json' id='timeline-data-NN'> for each graph,
** each containing JSON like this:
**
** { "iTableId": INTEGER, // Table sequence number (NN)
** "circleNodes": BOOLEAN, // True for circle nodes. False for squares
|
| ︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
100
101
102
103
104
105
106
107
108
109
110
111
112
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
+
+
+
+
+
+
+
-
-
+
-
-
-
-
-
+
+
-
-
-
+
-
+
|
** and a thin merge-arrow descender is drawn to the bottom of
** the screen. This array is omitted if there are no inbound
** merges.
** ci: "cherrypick-in". Like "mi" except for cherrypick merges.
** omitted if there are no cherrypick merges.
** h: The artifact hash of the object being graphed
*/
/* The amendCss() function does a one-time change to the CSS to account
** for the "circleNodes" and "showArrowheads" settings. Do this change
** only once, even if there are multiple graphs being rendered.
*/
var amendCssOnce = 1; // Only change the CSS one time
function amendCss(circleNodes,showArrowheads){
if( !amendCssOnce ) return;
var css = "";
if( circleNodes ){
css += ".tl-node, .tl-node:after { border-radius: 50%; }";
}
if( !showArrowheads ){
css += ".tl-arrow.u { display: none; }";
}
if( css!=="" ){
var style = document.createElement("style");
style.textContent = css;
document.querySelector("head").appendChild(style);
}
amendCssOnce = 0;
}
/* The <span> object that holds the tooltip */
var tooltipObj = document.createElement("span");
tooltipObj.className = "tl-tooltip";
tooltipObj.style.display = "none";
document.getElementsByClassName("content")[0].appendChild(tooltipObj);
/* Clear the close timer if the mouse is over the tooltip. */
tooltipObj.onmouseenter = function(e) {
tooltipObj.onmouseenter = function(){stopCloseTimer();}
stopCloseTimer();
};
/* Init the close timer if the mouse is no longer over the tooltip. */
tooltipObj.onmouseleave = function(e) {
if (tooltipInfo.ixActive != -1)
tooltipObj.onmouseleave = function(){
if (tooltipInfo.ixActive != -1) resumeCloseTimer();
resumeCloseTimer();
};
/* This object must be in the global scope, so that (non-shadowed) access is
** possible from within a setTimeout() closure. */
/* State information for the tooltip popup and its timers */
window.tooltipInfo = {
dwellTimeout: 250, /* The tooltip dwell timeout. */
closeTimeout: 3000, /* The tooltip close timeout. */
idTimer: 0, /* The tooltip dwell timer id. */
idTimerClose: 0, /* The tooltip close timer id. */
ixHover: -1, /* The id of the element with the mouse. */
ixActive: -1, /* The id of the element with the tooltip. */
posX: 0, posY: 0 /* The last mouse position. */
};
/* Functions used to control the tooltip popup and its timer */
function hideGraphTooltip(){
stopCloseTimer();
tooltipObj.style.display = "none";
tooltipInfo.ixActive = -1;
}
function stopDwellTimer(){
if (tooltipInfo.idTimer != 0) {
|
| ︙ | | |
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
-
+
+
|
function stopCloseTimer(){
if (tooltipInfo.idTimerClose != 0) {
clearTimeout(tooltipInfo.idTimerClose);
tooltipInfo.idTimerClose = 0;
}
}
/* Construct that graph corresponding to the timeline-data-N object */
/* Construct that graph corresponding to the timeline-data-N object that
** is passed in by the tx parameter */
function TimelineGraph(tx){
var topObj = document.getElementById("timelineTable"+tx.iTableId);
amendCss(tx.circleNodes, tx.showArrowheads);
tooltipInfo.dwellTimeout = tx.dwellTimeout
tooltipInfo.closeTimeout = tx.closeTimeout
topObj.onclick = clickOnGraph
topObj.ondblclick = dblclickOnGraph
|
| ︙ | | |
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
+
-
+
-
-
+
+
-
-
-
+
-
-
-
-
-
+
+
|
if(-1==tooltipInfo.ixHover && ix==tooltipInfo.ixActive) isReentry = true;
}
/* The tooltip is either not visible, or the mouse is over a different
** element, so clear the dwell timer, and record the new element id and
** mouse position. */
stopDwellTimer();
if(ix >= 0){
if(!isReentry){
/* Close the tooltip only if the mouse is over another element, and init
/* Close existing tooltip only if the mouse is over a different element */
** the dwell timer again. */
if(!isReentry) hideGraphTooltip();
hideGraphTooltip();
}
tooltipInfo.ixHover = ix;
tooltipInfo.posX = e.x;
tooltipInfo.posY = e.y;
/* Clear the close timer, if not already cleared by hideGraphTooltip(). */
stopCloseTimer();
if (!isReentry && tooltipInfo.dwellTimeout>0) {
tooltipInfo.idTimer = setTimeout(function() {
tooltipInfo.idTimer = 0;
/* Clear the timer to hide the tooltip. */
stopCloseTimer();
showGraphTooltip(tooltipInfo.ixHover,
showGraphTooltip();
tooltipInfo.posX,tooltipInfo.posY);
tooltipInfo.ixActive = tooltipInfo.ixHover;
},tooltipInfo.dwellTimeout);
}
}
else {
tooltipInfo.ixHover = -1;
/* The mouse is not over an element with a tooltip, init the hide
** timer. */
/* The mouse is not over an element with a tooltip */
tooltipInfo.ixHover = -1;
resumeCloseTimer();
}
};
topObj.onmouseleave = function(e) {
/* Hide the tooltip if the mouse is outside the "timelineTableN" element,
** and outside the tooltip. */
if(e.relatedTarget && e.relatedTarget != tooltipObj){
|
| ︙ | | |
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
|
-
-
+
+
+
+
-
-
+
+
-
+
+
-
+
-
+
+
|
var br = tx.rowinfo[ix].br
var dest = tx.baseUrl + "/timeline?r=" + encodeURIComponent(br)
dest += tx.fileDiff ? "&m&cf=" : "&m&c="
dest += encodeURIComponent(tx.rowinfo[ix].h)
return dest
}
function clickOnGraph(e){
var ix = findTxIndex(e);
showGraphTooltip(ix,e.x,e.y);
tooltipInfo.ixHover = findTxIndex(e);
tooltipInfo.posX = e.x;
tooltipInfo.posY = e.y;
showGraphTooltip();
}
function showGraphTooltip(ix,posX,posY){
if( ix<0 ){
function showGraphTooltip(){
if( tooltipInfo.ixHoever<0 ){
hideGraphTooltip()
}else{
}else{
var ix = tooltipInfo.ixHover
var br = tx.rowinfo[ix].br
var dest = branchHyperlink(ix)
var hbr = br.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
/* Setup while hidden, to ensure proper dimensions. */
tooltipObj.style.visibility = "hidden"
tooltipObj.innerHTML = "<a href=\""+dest+"\">"+hbr+"</a>"
tooltipObj.style.display = "inline"
tooltipObj.style.position = "absolute"
var x = posX + 4 + window.pageXOffset
var x = tooltipInfo.posX + 4 + window.pageXOffset
tooltipObj.style.left = x+"px"
var y = posY + window.pageYOffset - tooltipObj.clientHeight - 4
var y = tooltipInfo.posY + window.pageYOffset - tooltipObj.clientHeight - 4
tooltipObj.style.top = y+"px"
tooltipObj.style.visibility = "visible"
tooltipInfo.ixActive = ix;
}
}
function dblclickOnGraph(e){
var ix = findTxIndex(e);
var dest = branchHyperlink(ix)
hideGraphTooltip()
window.location.href = dest
|
| ︙ | | |