@@ -10,7 +10,7 @@ var width;
1010
1111function offset ( d , i ) {
1212 // increase the y offset if the document name changed in this revision
13- if ( i > 0 && data [ i - 1 ] . name !== d . name || d . rev . match ( "rfc" ) )
13+ if ( i > 0 && data [ i - 1 ] . name !== d . name || d . rev . match ( "^ rfc\d+$ " ) )
1414 bar_y += bar_height ;
1515 return "translate(" + x_scale ( d . published ) + ", " + bar_y + ")" ;
1616}
@@ -59,8 +59,7 @@ function update_timeline() {
5959
6060
6161function draw_timeline ( ) {
62- bar_height = parseFloat ( $ ( "body" ) . css ( 'line-height' ) ) ;
63- // bar_height = 20;
62+ bar_height = parseFloat ( $ ( "body" ) . css ( "line-height" ) ) ;
6463
6564 var div = $ ( "#timeline" ) ;
6665 if ( div . is ( ":empty" ) )
@@ -70,12 +69,16 @@ function draw_timeline() {
7069 var gradient = chart . append ( "defs" )
7170 . append ( "linearGradient" )
7271 . attr ( "id" , "gradient" ) ;
73- gradient . append ( 'stop' )
74- . attr ( 'class' , 'stop-left' )
75- . attr ( 'offset' , '0' ) ;
76- gradient . append ( 'stop' )
77- . attr ( 'class' , 'stop-right' )
78- . attr ( 'offset' , '1' ) ;
72+ gradient . append ( "stop" )
73+ . attr ( {
74+ class : "gradient left" ,
75+ offset : 0
76+ } ) ;
77+ gradient . append ( "stop" )
78+ . attr ( {
79+ class : "gradient right" ,
80+ offset : 1
81+ } ) ;
7982
8083 var y_labels = data
8184 . map ( function ( elem ) { return elem . name ; } )
@@ -121,6 +124,10 @@ function draw_timeline() {
121124 } )
122125 . text ( function ( d ) { return d . rev ; } ) ;
123126
127+ // since the gradient is defined inside the SVG, we need to set the CSS
128+ // style here, so the relative URL works
129+ $ ( "#timeline .bar:nth-last-child(2) rect" ) . css ( "fill" , "url(#gradient)" ) ;
130+
124131 var y_scale = d3 . scale . ordinal ( )
125132 . domain ( y_labels )
126133 . rangePoints ( [ 0 , bar_y ] ) ;
@@ -150,22 +157,24 @@ function draw_timeline() {
150157 d3 . select ( ".x.axis" ) . each ( function ( ) {
151158 x_label_height = this . getBBox ( ) . height ;
152159 } ) ;
153- chart . attr ( ' height' , bar_y + x_label_height ) ;
160+ chart . attr ( " height" , bar_y + x_label_height ) ;
154161}
155162
156163
157164d3 . json ( "doc.json" , function ( error , json ) {
158- if ( error ) return ; // console.warn(error);
165+ if ( error ) return ;
159166 data = json [ "rev_history" ] ;
160167
161- // make js dates out of publication dates
162- data . forEach ( function ( d ) { d . published = new Date ( d . published ) ; } ) ;
168+ if ( data . length ) {
169+ // make js dates out of publication dates
170+ data . forEach ( function ( d ) { d . published = new Date ( d . published ) ; } ) ;
163171
164- // add pseudo entry 185 days after last revision (when the ID will expire)
165- var pseudo = new Date ( data [ data . length - 1 ] . published . getTime ( ) +
166- 1000 * 60 * 60 * 24 * 185 ) ;
167- data . push ( { name : "" , rev : "" , published : pseudo } ) ;
168- draw_timeline ( ) ;
172+ // add pseudo entry 185 days after last rev (when the ID will expire)
173+ var pseudo = new Date ( data [ data . length - 1 ] . published . getTime ( ) +
174+ 1000 * 60 * 60 * 24 * 185 ) ;
175+ data . push ( { name : "" , rev : "" , published : pseudo } ) ;
176+ draw_timeline ( ) ;
177+ }
169178} ) ;
170179
171180
0 commit comments