3 Copyright (C) 2005, Artem Khodush <greenkaa@gmail.com>
5 This file is licensed under the GNU General Public License version 2.
7 <html xmlns=
"http://www.w3.org/1999/xhtml">
9 <meta charset=
"utf-8" />
10 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
11 <title>select repositories to browse
</title>
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=
"GitConfig.js"></script>
15 <script type=
"text/javascript" src=
"GitBrowser.js"></script>
16 <script type=
"text/javascript">
22 setup_map_field=function( n
, arg
) {
23 if( arg
.handler
!=null ) {
24 n
.onclick
=arg
.handler
;
26 var repo
=g_repo_map
[arg
.repo_name
];
28 g_repo_map
[arg
.repo_name
]={};
29 repo
=g_repo_map
[arg
.repo_name
];
30 repo
.name
=arg
.repo_name
;
32 if( arg
.id_field
!=null ) {
33 repo
[arg
.id_field
]=n
.id
;
34 }else if( arg
.ref_kind
!=null ) {
35 if( repo
.refs
==null ) {
38 repo
.refs
.push( { ref_kind
: arg
.ref_kind
, ref_name
: arg
.ref_name
, ref_id
: n
.id
} );
41 find_repo_by=function( id_field
, id
)
43 for( var repo_name
in g_repo_map
) {
44 var repo
=g_repo_map
[repo_name
];
45 if( repo
[id_field
]==id
) {
51 find_ref_by_id=function( id
)
53 for( var repo_name
in g_repo_map
) {
54 var repo
=g_repo_map
[repo_name
];
55 if( repo
!=null && repo
.refs
!=null ) {
56 for( var i
=0; i
<repo
.refs
.length
; ++i
) {
57 if( repo
.refs
[i
].ref_id
==id
) {
65 update_selected=function()
68 for( var repo_name
in g_repo_map
) {
69 var this_repo
=g_repo_map
[repo_name
];
70 if( this_repo
!=null ) {
71 var repo
={ heads
: [], tags
: [] };
72 if( this_repo
.selected
) {
75 if( this_repo
.refs
!=null ) {
76 for( var ref_i
=0; ref_i
<this_repo
.refs
.length
; ++ref_i
) {
77 var ref
=this_repo
.refs
[ref_i
];
79 if( ref
.ref_kind
=="t" ) {
80 repo
.tags
.push( ref
.ref_name
);
81 }else if( ref
.ref_kind
=="h" && !this_repo
.selected
) {
82 repo
.heads
.push( ref
.ref_name
);
87 repos
[repo_name
]=repo
;
90 var url_param
=GitBrowser
.repos_encode_url_param( repos
);
91 var text
=GitBrowser
.repos_encode_text( repos
);
93 var link
=document
.getElementById( "browseselected" );
94 var label
=document
.getElementById( "selected_text" );
97 link
.style
.visibility
="visible";
98 link
.href
="by-"+g_bymode
+".html?"+url_param
;
99 label
.appendChild( document
.createTextNode( "selected: "+text
) );
101 link
.style
.visibility
="hidden";
105 selectspecific_click=function()
107 var repo
=find_repo_by( "selectspecific_id", this.id
);
108 var refs
=document
.getElementById( repo
.refs_id
);
109 if( refs
.style
.display
=="none" ) {
110 refs
.style
.display
="";
112 refs
.style
.display
="none";
115 selectall_click=function()
117 var repo
=find_repo_by( "selectall_id", this.id
);
118 repo
.selected
=this.checked
;
120 if( repo
.refs
!=null ) {
121 for( var ref_i
=0; ref_i
<repo
.refs
.length
; ++ref_i
) {
122 var ref
=repo
.refs
[ref_i
];
123 if( ref
.ref_kind
=="h" ) {
124 var ref_check
=document
.getElementById( repo
.refs
[ref_i
].ref_id
);
126 ref_check
.checked
=true;
127 ref_check
.disabled
=true;
129 ref_check
.disabled
=false;
130 ref_check
.checked
=ref
.selected
;
136 selectref_click=function()
138 var ref
=find_ref_by_id( this.id
);
139 ref
.selected
=this.checked
;
143 fill_refs_status=function( repo_name
)
145 GitBrowser
.status_show( "loading "+repo_name
+" refs..." );
147 fill_refs=function( refs
, repo_name
)
149 var repo
=g_repo_map
[repo_name
];
150 if( refs
.heads
.length
>0 || refs
.tags
.length
>0 ) {
151 document
.getElementById( repo
.selectspecific_id
).style
.visibility
="visible";
153 if( refs
.heads
.length
>0 ) {
154 var headspl
= (refs
.heads
.length
!= 1) ? "s" : "";
155 document
.getElementById( repo
.headscount_id
).appendChild( document
.createTextNode( refs
.heads
.length
+" head"+headspl
+" " ) );
156 document
.getElementById( repo
.headshead_id
).style
.visibility
="visible";
158 if( refs
.tags
.length
>0 ) {
159 var tagspl
= (refs
.tags
.length
!= 1) ? "s" : "";
160 document
.getElementById( repo
.tagscount_id
).appendChild( document
.createTextNode( refs
.tags
.length
+" tag"+tagspl
+" " ) );
161 document
.getElementById( repo
.tagshead_id
).style
.visibility
="visible";
163 var limit
=Math
.max( refs
.tags
.length
, refs
.heads
.length
);
164 var table
=document
.getElementById( repo
.refstable_id
);
165 for( var i
=0; i
<limit
; ++i
) {
167 if( i
<refs
.heads
.length
) {
168 d
.selecthead
={ _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, ref_kind
: "h", ref_name
: refs
.heads
[i
], handler
: selectref_click
} },
169 d
.headname
=" "+refs
.heads
[i
]
171 if( i
<refs
.tags
.length
) {
172 d
.selecttag
={ _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, ref_kind
: "t", ref_name
: refs
.tags
[i
], handler
: selectref_click
} },
173 d
.tagname
=" "+refs
.tags
[i
]
175 table
.lastChild
.appendChild( DomTemplate
.apply( document
.getElementById( "refsrow" ), d
) ); // beware of tbody
179 change_bymode=function(btn
)
181 if (btn
.value
!= "commit" && btn
.value
!= "date") return;
182 g_bymode
= btn
.value
;
184 window
.sessionStorage
.setItem("bymode", g_bymode
);
186 var a_elems
= document
.getElementsByTagName("a");
187 if (a_elems
!= null && typeof(a_elems
.length
) == "number") {
188 for (var endi
= a_elems
.length
, i
= 0; i
< endi
; ++i
) {
190 if ((" "+e
.className
+" ").indexOf(" linkbutton ") >= 0) {
192 h
= h
.replace(/by-(commit|date)\.html/, "by-"+g_bymode
+".html");
202 window
.sessionStorage
.setItem("arpa.urn.uuid.c5118906-b736-4785-a3ec-28a0e1f88d66", 1);
204 var browse_by_btn
= document
.getElementById("browsebymode");
207 bymode
= window
.sessionStorage
.getItem("bymode");
209 if (bymode
== "date") {
211 if (browse_by_btn
!= null) browse_by_btn
.value
= g_bymode
;
213 if (browse_by_btn
!= null) {
214 if (browse_by_btn
.addEventListener
)
215 browse_by_btn
.addEventListener("change", function() {change_bymode(browse_by_btn
)});
216 else if (browse_by_btn
.attachEvent
)
217 browse_by_btn
.attachEvent("onchange", function() {change_bymode(browse_by_btn
)});
219 GitBrowser
.setup_status_error();
220 GitBrowser
.status_show( "loading..." );
221 GitBrowser
.call_server( { sub
: "get_repo_names", handler: function( repos
) {
222 var data
={ _replicate
: [] };
224 for( var repo_i
=0; repo_i
<repos
.length
; ++repo_i
) {
225 var repo_name
=repos
[repo_i
];
226 data
._replicate
.push( { name
: "repo", data
: {
227 reponame
: repos
[repo_i
],
228 browseurl
: { _href
: "by-"+g_bymode
+".html?r="+encodeURIComponent( repo_name
) },
229 selectspecific
: { _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "selectspecific_id", handler
: selectspecific_click
} },
230 selectall
: { _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "selectall_id", handler
: selectall_click
} },
231 headscount
: { _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "headscount_id" } },
232 tagscount
: { _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "tagscount_id" } }
234 data
._replicate
.push( { name
: "refs", data
: {
236 _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "refstable_id" },
237 headshead
: { _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "headshead_id" } },
238 tagshead
: { _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "tagshead_id" } }
240 _process
: setup_map_field
, _process_arg
: { repo_name
: repo_name
, id_field
: "refs_id" }
242 chain
.push( { sub
: "get_ref_names", repo
: repo_name
, handler_arg
: repo_name
} );
244 document
.body
.appendChild( DomTemplate
.apply( document
.getElementById( "repolist" ), data
) );
245 GitBrowser
.call_server( { handler
: fill_refs
, final_handler
: GitBrowser
.status_show
, before_handler
: fill_refs_status
, chain
: chain
} );
250 <link rel=
"stylesheet" type=
"text/css" href=
"GitBrowser.css"></link>
251 <style type=
"text/css">
253 .titletable td { padding: 0.5em 2em; }
254 .title { font-size: 12px; font-weight: bold
; color: #337; }
255 .selectedtext { color: #337; }
256 .repolist { padding-left: 1em; }
257 .repo { background-color: #f6f6ea; }
258 .repo .name { font-weight: bold
; font-size: 12px; color: #330; }
259 .repo td { padding: 5px 10px; border-top: 5px solid
#fff; }
260 .refs { border: 1px solid
#e8e8d8; }
261 .refs th { text-align: left
; color: #787878; }
262 .refs td { padding: 3px; font-size: 11px; }
268 <script type=
"text/javascript"></script>
269 <noscript>Enable JavaScript to browse repositories.
</noscript>
271 <table class=
"titletable"><tr>
272 <td class=
"title">Select repositories to browse
</td>
273 <td><span id=
"selected_text" class=
"selectedtext"></span></td>
274 <td><a id=
"browseselected" class=
"linkbutton" style=
"visibility: hidden;">browse
 selected
</a></td>
275 <td><select id=
"browsebymode" name=
"by"><option value=
"commit">by
 commit
</option><option value=
"date">by
 date
</option></select></td>
276 <td>  <a href=
"/">home
</a></td>
279 <div style=
"display:none;">
281 <table id=
"repolist" class=
"repolist" cellspacing=
"0" cellpadding=
"0">
283 <tr id=
"repo" class=
"repo">
284 <td width=
"150px"><span id=
"reponame" class=
"name"></span></td>
285 <td><a id=
"browseurl" class=
"linkbutton">browse all heads
</a></td>
286 <td><input id=
"selectall" type=
"checkbox" /> select all heads
</td>
287 <td><span id=
"headscount"></span><span id=
"tagscount"></span></td>
288 <td><a id=
"selectspecific" class=
"button" style=
"visibility: hidden;" href=
"#">choose heads and tags
</a></td>
291 <tr id=
"refs" style=
"display:none;">
292 <td colspan=
"5" class=
"refs">
293 <table id=
"refstable" width=
"100%">
294 <thead><tr><th id=
"headshead" style=
"visibility: hidden;">heads
</th><th id=
"tagshead" style=
"visibility: hidden;">tags
</th></tr></thead>
296 <td><input type=
"checkbox" id=
"selecthead" /><span id=
"headname"></span></td>
297 <td><input type=
"checkbox" id=
"selecttag" /><span id=
"tagname"></span></td>