git-browser.cgi: fix handling of latin-1 characters
[git-browser-mirror.git] / index.html
blob03b1faa57c0775e894a0d967d451ae9b6cf60e37
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <!--
3 Copyright (C) 2005, Artem Khodush <greenkaa@gmail.com>
5 This file is licensed under the GNU General Public License version 2.
6 -->
7 <html>
8 <head>
9 <title>select repositories to browse</title>
10 <script type="text/javascript" src="js.lib/DomTemplate.js"></script>
11 <script type="text/javascript" src="js.lib/InvisibleRequest.js"></script>
12 <script type="text/javascript" src="GitBrowser.js"></script>
13 <script type="text/javascript">
14 <!--
16 g_repo_map={};
18 setup_map_field=function( n, arg ) {
19 if( arg.handler!=null ) {
20 n.onclick=arg.handler;
22 var repo=g_repo_map[arg.repo_name];
23 if( repo==null ) {
24 g_repo_map[arg.repo_name]={};
25 repo=g_repo_map[arg.repo_name];
26 repo.name=arg.repo_name;
28 if( arg.id_field!=null ) {
29 repo[arg.id_field]=n.id;
30 }else if( arg.ref_kind!=null ) {
31 if( repo.refs==null ) {
32 repo.refs=[];
34 repo.refs.push( { ref_kind: arg.ref_kind, ref_name: arg.ref_name, ref_id: n.id } );
37 find_repo_by=function( id_field, id )
39 for( var repo_name in g_repo_map ) {
40 var repo=g_repo_map[repo_name];
41 if( repo[id_field]==id ) {
42 return repo;
45 return null;
47 find_ref_by_id=function( id )
49 for( var repo_name in g_repo_map ) {
50 var repo=g_repo_map[repo_name];
51 if( repo!=null && repo.refs!=null ) {
52 for( var i=0; i<repo.refs.length; ++i ) {
53 if( repo.refs[i].ref_id==id ) {
54 return repo.refs[i];
59 return null;
61 update_selected=function()
63 var repos={};
64 for( var repo_name in g_repo_map ) {
65 var this_repo=g_repo_map[repo_name];
66 if( this_repo!=null ) {
67 var repo={ heads: [], tags: [] };
68 if( this_repo.selected ) {
69 repo.all_heads=true;
71 if( this_repo.refs!=null ) {
72 for( var ref_i=0; ref_i<this_repo.refs.length; ++ref_i ) {
73 var ref=this_repo.refs[ref_i];
74 if( ref.selected ) {
75 if( ref.ref_kind=="t" ) {
76 repo.tags.push( ref.ref_name );
77 }else if( ref.ref_kind=="h" && !this_repo.selected ) {
78 repo.heads.push( ref.ref_name );
83 repos[repo_name]=repo;
86 var url_param=GitBrowser.repos_encode_url_param( repos );
87 var text=GitBrowser.repos_encode_text( repos );
89 var link=document.getElementById( "browseselected" );
90 var label=document.getElementById( "selected_text" );
91 label.innerHTML="";
92 if( url_param!="" ) {
93 link.style.visibility="visible";
94 link.href="by-commit.html?"+url_param;
95 label.appendChild( document.createTextNode( "selected: "+text ) );
96 }else {
97 link.style.visibility="hidden";
101 selectspecific_click=function()
103 var repo=find_repo_by( "selectspecific_id", this.id );
104 var refs=document.getElementById( repo.refs_id );
105 if( refs.style.display=="none" ) {
106 refs.style.display="";
107 }else {
108 refs.style.display="none";
111 selectall_click=function()
113 var repo=find_repo_by( "selectall_id", this.id );
114 repo.selected=this.checked;
115 update_selected();
116 if( repo.refs!=null ) {
117 for( var ref_i=0; ref_i<repo.refs.length; ++ref_i ) {
118 var ref=repo.refs[ref_i];
119 if( ref.ref_kind=="h" ) {
120 var ref_check=document.getElementById( repo.refs[ref_i].ref_id );
121 if( this.checked ) {
122 ref_check.checked=true;
123 ref_check.disabled=true;
124 }else {
125 ref_check.disabled=false;
126 ref_check.checked=ref.selected;
132 selectref_click=function()
134 var ref=find_ref_by_id( this.id );
135 ref.selected=this.checked;
136 update_selected();
139 fill_refs_status=function( repo_name )
141 GitBrowser.status_show( "loading "+repo_name+" refs..." );
143 fill_refs=function( refs, repo_name )
145 var repo=g_repo_map[repo_name];
146 if( refs.heads.length>0 || refs.tags.length>0 ) {
147 document.getElementById( repo.selectspecific_id ).style.visibility="visible";
149 if( refs.heads.length>0 ) {
150 document.getElementById( repo.headscount_id ).appendChild( document.createTextNode( refs.heads.length+" heads " ) );
151 document.getElementById( repo.headshead_id ).style.visibility="visible";
153 if( refs.tags.length>0 ) {
154 document.getElementById( repo.tagscount_id ).appendChild( document.createTextNode( refs.tags.length+" tags " ) );
155 document.getElementById( repo.tagshead_id ).style.visibility="visible";
157 var limit=Math.max( refs.tags.length, refs.heads.length );
158 var table=document.getElementById( repo.refstable_id );
159 for( var i=0; i<limit; ++i ) {
160 var d={};
161 if( i<refs.heads.length ) {
162 d.selecthead={ _process: setup_map_field, _process_arg: { repo_name: repo_name, ref_kind: "h", ref_name: refs.heads[i], handler: selectref_click } },
163 d.headname=" "+refs.heads[i]
165 if( i<refs.tags.length ) {
166 d.selecttag={ _process: setup_map_field, _process_arg: { repo_name: repo_name, ref_kind: "t", ref_name: refs.tags[i], handler: selectref_click } },
167 d.tagname=" "+refs.tags[i]
169 table.lastChild.appendChild( DomTemplate.apply( document.getElementById( "refsrow" ), d ) ); // beware of tbody
173 onload=function()
175 GitBrowser.setup_status_error();
176 GitBrowser.status_show( "loading..." );
177 GitBrowser.call_server( { sub: "get_repo_names", handler: function( repos ) {
178 var data={ _replicate: [] };
179 var chain=[];
180 for( var repo_i=0; repo_i<repos.length; ++repo_i ) {
181 var repo_name=repos[repo_i];
182 data._replicate.push( { name: "repo", data: {
183 reponame: repos[repo_i],
184 browseurl: { _href: "by-commit.html?r="+encodeURIComponent( repo_name ) },
185 selectspecific: { _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "selectspecific_id", handler: selectspecific_click } },
186 selectall: { _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "selectall_id", handler: selectall_click } },
187 headscount: { _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "headscount_id" } },
188 tagscount: { _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "tagscount_id" } }
189 } } );
190 data._replicate.push( { name: "refs", data: {
191 refstable: {
192 _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "refstable_id" },
193 headshead: { _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "headshead_id" } },
194 tagshead: { _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "tagshead_id" } }
196 _process: setup_map_field, _process_arg: { repo_name: repo_name, id_field: "refs_id" }
197 } } );
198 chain.push( { sub: "get_ref_names", repo: repo_name, handler_arg: repo_name } );
200 document.body.appendChild( DomTemplate.apply( document.getElementById( "repolist" ), data ) );
201 GitBrowser.call_server( { handler: fill_refs, final_handler: GitBrowser.status_show, before_handler: fill_refs_status, chain: chain } );
202 } } );
204 //-->
205 </script>
206 <link rel="stylesheet" type="text/css" href="GitBrowser.css"></link>
207 <style type="text/css">
208 .titletable td { padding: 0.5em 2em; }
209 .title { font-size: 12px; font-weight: bold; color: #337; }
210 .selectedtext { color: #337; }
211 .repolist { padding-left: 1em; }
212 .repo { background-color: #f6f6ea; }
213 .repo .name { font-weight: bold; font-size: 12px; color: #330; }
214 .repo td { padding: 5px 10px; border-top: 5px solid #fff; }
215 .refs { border: 1px solid #e8e8d8; }
216 .refs th { text-align: left; color: #787878; }
217 .refs td { padding: 3px; font-size: 11px; }
218 </style>
219 </head>
220 <body>
222 <table class="titletable"><tr>
223 <td class="title">Select repositories to browse</td>
224 <td><span id="selected_text" class="selectedtext"></span></td>
225 <td><a id="browseselected" class="linkbutton" style="visibility: hidden;">browse&nbsp;selected</a></td>
226 <td>&nbsp;&nbsp;<a href="/">home</a></td>
227 </tr></table>
229 <div style="display:none;">
231 <table id="repolist" class="repolist" cellspacing="0" cellpadding="0">
233 <tr id="repo" class="repo">
234 <td width="150px"><span id="reponame" class="name"></span></td>
235 <td><a id="browseurl" class="linkbutton">browse all heads</a></td>
236 <td><input id="selectall" type="checkbox" /> select all heads</td>
237 <td><span id="headscount"></span><span id="tagscount"></span></td>
238 <td><a id="selectspecific" class="button" style="visibility: hidden;" href="#">choose heads and tags</a></td>
239 </tr>
241 <tr id="refs" style="display:none;">
242 <td colspan="5" class="refs">
243 <table id="refstable" width="100%">
244 <thead><tr><th id="headshead" style="visibility: hidden;">heads</th><th id="tagshead" style="visibility: hidden;">tags</th></tr></thead>
245 <tr id="refsrow">
246 <td><input type="checkbox" id="selecthead" /><span id="headname"></span></td>
247 <td><input type="checkbox" id="selecttag" /><span id="tagname"></span></td>
248 </tr>
249 </table>
250 </td>
251 </tr>
253 </table>
255 </div>
257 </body>
258 </html>