1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3 Copyright (C) 2005, Artem Khodush <greenkaa@gmail.com>
5 This file is licensed under the GNU General Public License version 2.
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">
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
];
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 ) {
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
) {
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
) {
61 update_selected=function()
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
) {
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
];
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" );
93 link
.style
.visibility
="visible";
94 link
.href
="by-commit.html?"+url_param
;
95 label
.appendChild( document
.createTextNode( "selected: "+text
) );
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
="";
108 refs
.style
.display
="none";
111 selectall_click=function()
113 var repo
=find_repo_by( "selectall_id", this.id
);
114 repo
.selected
=this.checked
;
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
);
122 ref_check
.checked
=true;
123 ref_check
.disabled
=true;
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
;
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
) {
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
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
: [] };
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" } }
190 data
._replicate
.push( { name
: "refs", data
: {
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" }
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
} );
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; }
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
selected
</a></td>
226 <td> <a href=
"/">home
</a></td>
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>
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>
246 <td><input type=
"checkbox" id=
"selecthead" /><span id=
"headname"></span></td>
247 <td><input type=
"checkbox" id=
"selecttag" /><span id=
"tagname"></span></td>