tests/run-tests.html: move noscript into body
[git-browser.git] / by-commit.html
blob0fa9bdc7a22d39f43453cdd5476679642054b288
1 <!DOCTYPE html>
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6 <title>git browser</title>
7 <!--
8 Copyright (C) 2005, Artem Khodush <greenkaa@gmail.com>
10 This file is licensed under the GNU General Public License version 2.
11 -->
12 <script type="text/javascript" src="js.lib/DomTemplate.js"></script>
13 <script type="text/javascript" src="js.lib/InvisibleRequest.js"></script>
14 <script type="text/javascript" src="js.lib/Motion.js"></script>
15 <script type="text/javascript" src="js.lib/wz_jsgraphics.js"></script>
16 <script type="text/javascript" src="GitConfig.js"></script>
17 <script type="text/javascript" src="GitBrowser.js"></script>
18 <script type="text/javascript" src="GitDiagram.js"></script>
19 <script type="text/javascript">
20 /* <![CDATA[ */
22 g_diagram=null;
23 cfg_gitweb_url_sl = cfg_gitweb_url;
24 if ( cfg_gitweb_url_sl[cfg_gitweb_url_sl.length-1] != "/" ) {
25 cfg_gitweb_url_sl += "/";
28 format_log_date_number=function( n )
30 var s= n<10 ? "0" : "";
31 return s+n;
33 format_log_date=function( date )
35 var d=new Date( date );
36 return d.getFullYear()+"-"
37 +format_log_date_number( 1+d.getMonth() )+"-"
38 +format_log_date_number( d.getDate() )+" "
39 +format_log_date_number( d.getHours() )+":"
40 +format_log_date_number( d.getMinutes() )+":"
41 +format_log_date_number( d.getSeconds() );
43 escape_html=function( s )
45 s=s+""; // ensure it's a string
46 s=s.replace( /\&/g, "&amp;" );
47 s=s.replace( /\</g, "&lt;" );
48 s=s.replace( /\>/g, "&gt;" );
49 return s;
51 make_row_html=function( diagram, column, column_i, row_height )
53 var node=column.node;
54 var label=diagram.m_labels[node.id];
55 var comment_html="";
56 if( label!=null ) {
57 for( var tag_i=0; tag_i<label.tags.length; ++tag_i ) {
58 var tag=label.tags[tag_i];
59 var tag_text=tag.name;
60 // if diagram shows more than one repo, put repo name in front of each tag/head
61 if( diagram.m_repos.length>1 ) {
62 tag_text=tag.repo+":"+tag_text;
64 var style= tag.type=="t" ? "logtag" : (tag_text=="HEAD" ? "loghead" : "logbranch");
65 comment_html+="<span class=\""+style+"\">"+escape_html( tag_text )+"</span>";
68 var text_html = escape_html( node.comment );
69 if ( node.comment.length < 8 ) {
70 text_html += "&#160;&#160;&#160;&#160;&#160;" // ensure reasonable click target
72 var repo = encodeURIComponent(diagram.m_repos[0]);
73 repo = repo.replace( /%2[bB]/g, "+" );
74 repo = repo.replace( /%2[fF]/g, "/" );
75 comment_html+="<a href=\""+cfg_gitweb_url_sl+repo+"?a=commit;h="+node.id+"\">"+text_html+"</a>";
76 var indent=column.lines.length*row_height;
77 comment_html="<td><div class=\"logcell\" style=\"padding-left: "+indent+"px;\">"+comment_html+"</div></td>";
78 var row_html=comment_html+"<td><div class=\"logcell\">"+escape_html( node.author )+"</div></td>";
79 row_html+="<td><div class=\"logcell\">"+format_log_date( node.date )+"</div></td>";
80 var row_color=(diagram.m_date_columns.length-column_i)%2==0 ? GitDiagram._g_color_odd_day_background : GitDiagram._g_color_even_day_background;
81 row_html="<tr style=\"background-color: "+row_color+";\">"+row_html+"</tr>";
82 return row_html;
84 fill_log=function( context )
86 var column_i=context.diagram.m_date_columns.length; // diagram date_columns are becoming table rows - the diagram is rotated
87 var log=document.getElementById( "log" );
88 var tbody=document.getElementById( "logbody" );
89 var row= tbody==null ? null : tbody.firstChild;
90 var row_height= row==null ? null : row.clientHeight;
91 var rows_html="";
92 var table_start_html="<table id=\"logtable\" width=\"98%\" cellpadding=\"0\" cellspacing=\"0\"><colgroup><col id=\"colcomment\" /><col id=\"colauthor\" /><col id=\"coldate\" /></colgroup><tbody id=\"logbody\">";
93 var table_end_html="</tbody></table>";
94 while( column_i!=0 ) {
95 var column=context.diagram.m_date_columns[column_i-1];
96 if( row_height==null ) { // special handling to get first row height
97 log.innerHTML=table_start_html+make_row_html( context.diagram, column, column_i, 0 )+table_end_html;
98 tbody=document.getElementById( "logbody" );
99 row_height=tbody.firstChild.clientHeight;
101 rows_html+=make_row_html( context.diagram, column, column_i, row_height );
102 --column_i;
104 log.innerHTML=table_start_html+rows_html+table_end_html;
105 document.getElementById( "logtable" ).onclick=log_onclick;
107 // global initialization, diagram loading
108 draw_diagram=function( diagram )
110 var log=document.getElementById( "log" );
111 var logbody=document.getElementById( "logbody" );
112 if( log!=null && logbody!=null && logbody.firstChild!=null ) {
113 diagram.draw( logbody.firstChild.clientHeight, log.scrollTop );
116 place_and_draw=function( context )
118 context.diagram.place_nodes( false );
119 fill_log( context );
120 draw_diagram( context.diagram );
121 GitBrowser.title_update( { diagram: context.diagram } );
123 on_title_loaded=function( context )
125 var show_selectother = null;
126 try {
127 show_selectother = window.sessionStorage.getItem("arpa.urn.uuid.c5118906-b736-4785-a3ec-28a0e1f88d66");
128 } catch (e) {}
129 if( !show_selectother ) context.select_other_btn.style.visibility="hidden";
132 /* returns {
133 x, y: pixels, relative to the diagram div origin
134 id, tag: decoded by GitDiagram.match_id from event target id
135 column: the column the mouse is in
136 } */
137 decode_mouse_event=function( event )
139 var e={};
140 if( event==null ) {
141 event=window.event;
143 var elm= event.target!=null ? event.target : event.srcElement;
144 if( elm!=null && elm.id!=null ) {
145 var idtag=g_diagram._match_id( elm.id );
146 if( idtag!=null ) {
147 e.id=idtag.id;
148 e.tag=idtag.tag;
151 var mouse_pos=Motion.get_event_coords( event );
152 var diagram_pos=Motion.get_page_coords( document.getElementById( "diagram" ) );
153 e.x=mouse_pos.x-diagram_pos.x;
154 e.y=mouse_pos.y-diagram_pos.y;
155 var log=document.getElementById( "log" );
156 var logbody=document.getElementById( "logbody" );
157 if( log!=null && logbody!=null && logbody.firstChild!=null ) {
158 var column_i=g_diagram.m_date_columns.length-1-Math.floor( (mouse_pos.y+log.scrollTop)/logbody.firstChild.clientHeight );
159 if( column_i>=0 && column_i<g_diagram.m_date_columns.length ) {
160 e.column=g_diagram.m_date_columns[column_i];
163 return e;
166 diagram_on_mousemove=function( event )
168 var e=decode_mouse_event( event );
169 var s="";
170 if( e.id!=null && e.tag!=null ) {
171 s+=e.tag+" id: "+e.id;
173 if( e.column!=null ) {
174 s+=" col "+format_log_date( e.column.date );
176 // GitBrowser.status_show( "x: "+e.x+" y: "+e.y+" "+s );
178 log_onclick=function( event )
180 var e=decode_mouse_event( event );
181 if( e.column!=null ) {
182 // GitBrowser.status_show( "click column "+e.column.node.comment );
186 g_ui_map={
188 onload=function()
190 diagram_div=document.getElementById( "diagram" );
191 g_diagram=new GitDiagram( {
192 container_element: diagram_div,
193 style: "by-commit",
194 ui_handler: GitBrowser.diagram_ui_handler,
195 ui_handler_arg: g_ui_map
196 } );
197 GitBrowser.init( {
198 repos: GitBrowser.repos_decode_location( location ),
199 diagram_div: diagram_div, // diagram_div is a payload
200 diagram: g_diagram,
201 title_loaded_handler: on_title_loaded,
202 commits_first_loaded_handler: place_and_draw,
203 commits_more_loaded_handler: place_and_draw,
204 shortcomment: "1",
205 title: cfg_bycommit_title
206 } );
207 var log_div=document.getElementById( "log" );
208 Motion.track_scroll( { node: log_div, handler: draw_diagram, handler_arg: g_diagram } );
209 diagram_div.onmousemove=diagram_on_mousemove;
210 // IE assigns log column widths improperly, unless white-space: nowrap is removed from the .logcell style
211 var span=document.createElement( "SPAN" );
212 span.innerHTML="<!--[if IE]><br /><![endif]-"+"->";
213 var is_ie=span.getElementsByTagName( "BR" ).length>0;
214 if( is_ie ) {
215 var sheets=document.styleSheets;
216 for( var sheet_i=0; sheet_i<sheets.length; ++sheet_i ) {
217 var rules=sheets[sheet_i].rules;
218 for( var rule_i=0; rule_i<rules.length; ++rule_i ) {
219 var rule=rules[rule_i];
220 if( rule.selectorText==".logcell" ) {
221 rule.style.whiteSpace="";
228 // debug output
229 xdp=function( msg )
231 var o=document.getElementById( "output" );
232 o.style.display="";
233 o.appendChild( document.createElement( "DIV" ) ).appendChild( document.createTextNode( msg ) );
236 /* ]]> */
237 </script>
238 <link rel="stylesheet" type="text/css" href="GitBrowser.css"></link>
239 <style type="text/css">
240 /* <![CDATA[ */
241 html { height: 99.8%; }
242 body { height: 99.8%; font: normal normal 11px sans-serif; overflow: hidden; }
244 #diagram { z-index: 3; position: absolute; height: 85%; width: 99%; }
245 #log { z-index: 1; height: 85%; width: 98%; overflow: auto; }
247 /* styles for log table elements created by fill_log and make_row_html */
248 #log td { padding: 1px 2px; border-right: 1px solid #888; }
249 #colauthor { width: 18em; }
250 #coldate { width: 11em; }
251 .logcell { height: 13px; line-height: 13px; overflow: hidden; white-space: nowrap; }
252 .logcell a { text-decoration: none; color: #000000; }
253 .logcell a:hover { text-decoration: underline; color: #880000; }
254 .loghead { padding: 0 4px; background-color: #d3d3ff; }
255 .logbranch { padding: 0 4px; background-color: #ffff99; }
256 .logtag { padding: 0 4px; background-color: #99ff99; }
258 /* ]]> */
259 </style>
260 </head>
261 <body>
263 <script type="text/javascript"></script>
264 <noscript>Enable JavaScript to view the graph.</noscript>
266 <div id="diagram"></div>
267 <div id="log"></div>
269 <div id="output" style="display: none; position: absolute; top: 360px; left: 1ex; right: 1ex; z-index: 100; background-color: #fff; max-height: 300px; overflow: auto"></div> <!-- debug output -->
271 </body>
272 </html>