##// END OF EJS Templates
summary: redirect from repo URLs with #branchname to changelog with this branch...
Mads Kiilerich -
r3655:c78de39f beta
parent child Browse files
Show More
@@ -1,734 +1,749 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%def name="title()">
4 4 ${_('%s Summary') % c.repo_name} &middot; ${c.rhodecode_name}
5 5 </%def>
6 6
7 7 <%def name="breadcrumbs_links()">
8 8 ${_('Summary')}
9 9 </%def>
10 10
11 11 <%def name="page_nav()">
12 12 ${self.menu('repositories')}
13 13 </%def>
14 14
15 15 <%def name="head_extra()">
16 16 <link href="${h.url('atom_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('%s ATOM feed') % c.repo_name}" type="application/atom+xml" />
17 17 <link href="${h.url('rss_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('%s RSS feed') % c.repo_name}" type="application/rss+xml" />
18
19 <script>
20 redirect_hash_branch = function(){
21 var branch = window.location.hash.replace(/^#(.*)/, '$1');
22 if (branch){
23 window.location = "${h.url('changelog_home',repo_name=c.repo_name,branch='__BRANCH__')}"
24 .replace('__BRANCH__',branch);
25 }
26 }
27 redirect_hash_branch();
28 window.onhashchange = function() {
29 redirect_hash_branch();
30 };
31 </script>
32
18 33 </%def>
19 34
20 35 <%def name="main()">
21 36 ${self.context_bar('summary')}
22 37 <%
23 38 summary = lambda n:{False:'summary-short'}.get(n)
24 39 %>
25 40 %if c.show_stats:
26 41 <div class="box box-left">
27 42 %else:
28 43 <div class="box">
29 44 %endif
30 45 <!-- box / title -->
31 46 <div class="title">
32 47 ${self.breadcrumbs()}
33 48 </div>
34 49 <!-- end box / title -->
35 50 <div class="form">
36 51 <div id="summary" class="fields">
37 52
38 53 <div class="field">
39 54 <div class="label-summary">
40 55 <label>${_('Name')}:</label>
41 56 </div>
42 57 <div class="input ${summary(c.show_stats)}">
43 58
44 59 ## locking icon
45 60 %if c.rhodecode_db_repo.enable_locking:
46 61 %if c.rhodecode_db_repo.locked[0]:
47 62 <span class="locking_locked tooltip" title="${_('Repository locked by %s') % h.person_by_id(c.rhodecode_db_repo.locked[0])}"></span>
48 63 %else:
49 64 <span class="locking_unlocked tooltip" title="${_('Repository unlocked')}"></span>
50 65 %endif
51 66 %endif
52 67 ##REPO TYPE
53 68 %if h.is_hg(c.dbrepo):
54 69 <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
55 70 %endif
56 71 %if h.is_git(c.dbrepo):
57 72 <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
58 73 %endif
59 74
60 75 ##PUBLIC/PRIVATE
61 76 %if c.dbrepo.private:
62 77 <img style="margin-bottom:2px" class="icon" title="${_('Private repository')}" alt="${_('Private repository')}" src="${h.url('/images/icons/lock.png')}"/>
63 78 %else:
64 79 <img style="margin-bottom:2px" class="icon" title="${_('Public repository')}" alt="${_('Public repository')}" src="${h.url('/images/icons/lock_open.png')}"/>
65 80 %endif
66 81
67 82 ##REPO NAME
68 83 <span class="repo_name" title="${_('Non changable ID %s') % c.dbrepo.repo_id}">${h.repo_link(c.dbrepo.groups_and_repo)}</span>
69 84
70 85 ##FORK
71 86 %if c.dbrepo.fork:
72 87 <div style="margin-top:5px;clear:both">
73 88 <a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}"><img class="icon" alt="${_('Public')}" title="${_('Fork of')} ${c.dbrepo.fork.repo_name}" src="${h.url('/images/icons/arrow_divide.png')}"/>
74 89 ${_('Fork of')} ${c.dbrepo.fork.repo_name}
75 90 </a>
76 91 </div>
77 92 %endif
78 93 ##REMOTE
79 94 %if c.dbrepo.clone_uri:
80 95 <div style="margin-top:5px;clear:both">
81 96 <a href="${h.url(str(h.hide_credentials(c.dbrepo.clone_uri)))}"><img class="icon" alt="${_('Remote clone')}" title="${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}" src="${h.url('/images/icons/connect.png')}"/>
82 97 ${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}
83 98 </a>
84 99 </div>
85 100 %endif
86 101 </div>
87 102 </div>
88 103
89 104 <div class="field">
90 105 <div class="label-summary">
91 106 <label>${_('Description')}:</label>
92 107 </div>
93 108 %if c.visual.stylify_metatags:
94 109 <div class="input ${summary(c.show_stats)} desc">${h.urlify_text(h.desc_stylize(c.dbrepo.description))}</div>
95 110 %else:
96 111 <div class="input ${summary(c.show_stats)} desc">${h.urlify_text(c.dbrepo.description)}</div>
97 112 %endif
98 113 </div>
99 114
100 115 <div class="field">
101 116 <div class="label-summary">
102 117 <label>${_('Contact')}:</label>
103 118 </div>
104 119 <div class="input ${summary(c.show_stats)}">
105 120 <div class="gravatar">
106 121 <img alt="gravatar" src="${h.gravatar_url(c.dbrepo.user.email)}"/>
107 122 </div>
108 123 ${_('Username')}: ${c.dbrepo.user.username}<br/>
109 124 ${_('Name')}: ${c.dbrepo.user.name} ${c.dbrepo.user.lastname}<br/>
110 125 ${_('Email')}: <a href="mailto:${c.dbrepo.user.email}">${c.dbrepo.user.email}</a>
111 126 </div>
112 127 </div>
113 128
114 129 <div class="field">
115 130 <div class="label-summary">
116 131 <label>${_('Clone url')}:</label>
117 132 </div>
118 133 <div class="input ${summary(c.show_stats)}">
119 134 <input style="width:${'75%' if c.show_stats else '80%'}" type="text" id="clone_url" readonly="readonly" value="${c.clone_repo_url}"/>
120 135 <input style="display:none;width:${'75%' if c.show_stats else '80%'}" type="text" id="clone_url_id" readonly="readonly" value="${c.clone_repo_url_id}"/>
121 136 <div style="display:none" id="clone_by_name" class="ui-btn clone">${_('Show by Name')}</div>
122 137 <div id="clone_by_id" class="ui-btn clone">${_('Show by ID')}</div>
123 138 </div>
124 139 </div>
125 140
126 141 <div class="field">
127 142 <div class="label-summary">
128 143 <label>${_('Trending files')}:</label>
129 144 </div>
130 145 <div class="input ${summary(c.show_stats)}">
131 146 %if c.show_stats:
132 147 <div id="lang_stats"></div>
133 148 %else:
134 149 ${_('Statistics are disabled for this repository')}
135 150 %if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
136 151 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")}
137 152 %endif
138 153 %endif
139 154 </div>
140 155 </div>
141 156
142 157 <div class="field">
143 158 <div class="label-summary">
144 159 <label>${_('Download')}:</label>
145 160 </div>
146 161 <div class="input ${summary(c.show_stats)}">
147 162 %if len(c.rhodecode_repo.revisions) == 0:
148 163 ${_('There are no downloads yet')}
149 164 %elif not c.enable_downloads:
150 165 ${_('Downloads are disabled for this repository')}
151 166 %if h.HasPermissionAll('hg.admin')('enable downloads on from summary'):
152 167 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")}
153 168 %endif
154 169 %else:
155 170 ${h.select('download_options',c.rhodecode_repo.get_changeset().raw_id,c.download_options)}
156 171 <span id="${'zip_link'}">${h.link_to(_('Download as zip'), h.url('files_archive_home',repo_name=c.dbrepo.repo_name,fname='tip.zip'),class_="archive_icon ui-btn")}</span>
157 172 <span style="vertical-align: bottom">
158 173 <input id="archive_subrepos" type="checkbox" name="subrepos" />
159 174 <label for="archive_subrepos" class="tooltip" title="${h.tooltip(_('Check this to download archive with subrepos'))}" >${_('with subrepos')}</label>
160 175 </span>
161 176 %endif
162 177 </div>
163 178 </div>
164 179 </div>
165 180 <div id="summary-menu-stats">
166 181 <ul>
167 182 <li>
168 183 <a class="followers" title="${_('Followers')}" href="${h.url('repo_followers_home',repo_name=c.repo_name)}">
169 184 ${_('Followers')}
170 185 <span style="float:right" id="current_followers_count">${c.repository_followers}</span>
171 186 </a>
172 187 </li>
173 188 <li>
174 189 <a class="forks" title="${_('Forks')}" href="${h.url('repo_forks_home',repo_name=c.repo_name)}">
175 190 ${_('Forks')}
176 191 <span style="float:right">${c.repository_forks}</span>
177 192 </a>
178 193 </li>
179 194
180 195 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
181 196 <li>
182 197 ${h.link_to(_('Settings'),h.url('edit_repo',repo_name=c.repo_name),class_='settings')}
183 198 </li>
184 199 %endif
185 200
186 201 <li>
187 202 %if c.rhodecode_user.username != 'default':
188 203 ${h.link_to(_('Feed'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='feed')}
189 204 %else:
190 205 ${h.link_to(_('Feed'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name),class_='feed')}
191 206 %endif
192 207 </li>
193 208
194 209 %if c.rhodecode_user.username != 'default':
195 210 <li class="repo_size">
196 211 <a href="#" class="repo-size" onclick="javascript:showRepoSize('repo_size_2','${c.dbrepo.repo_name}','${str(h.get_token())}')">${_('Repository Size')}</a>
197 212 <span id="repo_size_2"></span>
198 213 </li>
199 214 %endif
200 215 </ul>
201 216 </div>
202 217 </div>
203 218 </div>
204 219
205 220 %if c.show_stats:
206 221 <div class="box box-right" style="min-height:455px">
207 222 <!-- box / title -->
208 223 <div class="title">
209 224 <h5>${_('Commit activity by day / author')}</h5>
210 225 </div>
211 226
212 227 <div class="graph">
213 228 <div style="padding:0 10px 10px 17px;">
214 229 %if c.no_data:
215 230 ${c.no_data_msg}
216 231 %if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
217 232 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")}
218 233 %endif
219 234 %else:
220 235 ${_('Stats gathered: ')} ${c.stats_percentage}%
221 236 %endif
222 237 </div>
223 238 <div id="commit_history" style="width:450px;height:300px;float:left"></div>
224 239 <div style="clear: both;height: 10px"></div>
225 240 <div id="overview" style="width:450px;height:100px;float:left"></div>
226 241
227 242 <div id="legend_data" style="clear:both;margin-top:10px;">
228 243 <div id="legend_container"></div>
229 244 <div id="legend_choices">
230 245 <table id="legend_choices_tables" class="noborder" style="font-size:smaller;color:#545454"></table>
231 246 </div>
232 247 </div>
233 248 </div>
234 249 </div>
235 250 %endif
236 251
237 252 <div class="box">
238 253 <div class="title">
239 254 <div class="breadcrumbs">
240 255 %if c.repo_changesets:
241 256 ${h.link_to(_('Latest changes'),h.url('changelog_home',repo_name=c.repo_name))}
242 257 %else:
243 258 ${_('Quick start')}
244 259 %endif
245 260 </div>
246 261 </div>
247 262 <div class="table">
248 263 <div id="shortlog_data">
249 264 <%include file='../shortlog/shortlog_data.html'/>
250 265 </div>
251 266 </div>
252 267 </div>
253 268
254 269 %if c.readme_data:
255 270 <div id="readme" class="anchor">
256 271 <div class="box" style="background-color: #FAFAFA">
257 272 <div class="title" title="${_("Readme file at revision '%s'" % c.rhodecode_db_repo.landing_rev)}">
258 273 <div class="breadcrumbs">
259 274 <a href="${h.url('files_home',repo_name=c.repo_name,revision='tip',f_path=c.readme_file)}">${c.readme_file}</a>
260 275 <a class="permalink" href="#readme" title="${_('Permalink to this readme')}">&para;</a>
261 276 </div>
262 277 </div>
263 278 <div class="readme">
264 279 <div class="readme_box">
265 280 ${c.readme_data|n}
266 281 </div>
267 282 </div>
268 283 </div>
269 284 </div>
270 285 %endif
271 286
272 287 <script type="text/javascript">
273 288 var clone_url = 'clone_url';
274 289 YUE.on(clone_url,'click',function(e){
275 290 if(YUD.hasClass(clone_url,'selected')){
276 291 return
277 292 }
278 293 else{
279 294 YUD.addClass(clone_url,'selected');
280 295 YUD.get(clone_url).select();
281 296 }
282 297 })
283 298
284 299 YUE.on('clone_by_name','click',function(e){
285 300 // show url by name and hide name button
286 301 YUD.setStyle('clone_url','display','');
287 302 YUD.setStyle('clone_by_name','display','none');
288 303
289 304 // hide url by id and show name button
290 305 YUD.setStyle('clone_by_id','display','');
291 306 YUD.setStyle('clone_url_id','display','none');
292 307
293 308 })
294 309 YUE.on('clone_by_id','click',function(e){
295 310
296 311 // show url by id and hide id button
297 312 YUD.setStyle('clone_by_id','display','none');
298 313 YUD.setStyle('clone_url_id','display','');
299 314
300 315 // hide url by name and show id button
301 316 YUD.setStyle('clone_by_name','display','');
302 317 YUD.setStyle('clone_url','display','none');
303 318 })
304 319
305 320
306 321 var tmpl_links = {};
307 322 %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()):
308 323 tmpl_links["${archive['type']}"] = '${h.link_to('__NAME__', h.url('files_archive_home',repo_name=c.dbrepo.repo_name, fname='__CS__'+archive['extension'],subrepos='__SUB__'),class_='archive_icon ui-btn')}';
309 324 %endfor
310 325
311 326 YUE.on(['download_options','archive_subrepos'],'change',function(e){
312 327 var sm = YUD.get('download_options');
313 328 var new_cs = sm.options[sm.selectedIndex];
314 329
315 330 for(k in tmpl_links){
316 331 var s = YUD.get(k+'_link');
317 332 if(s){
318 333 var title_tmpl = "${_('Download %s as %s') % ('__CS_NAME__','__CS_EXT__')}";
319 334 title_tmpl= title_tmpl.replace('__CS_NAME__',new_cs.text);
320 335 title_tmpl = title_tmpl.replace('__CS_EXT__',k);
321 336
322 337 var url = tmpl_links[k].replace('__CS__',new_cs.value);
323 338 var subrepos = YUD.get('archive_subrepos').checked;
324 339 url = url.replace('__SUB__',subrepos);
325 340 url = url.replace('__NAME__',title_tmpl);
326 341 s.innerHTML = url
327 342 }
328 343 }
329 344 });
330 345 </script>
331 346 %if c.show_stats:
332 347 <script type="text/javascript">
333 348 var data = ${c.trending_languages|n};
334 349 var total = 0;
335 350 var no_data = true;
336 351 var tbl = document.createElement('table');
337 352 tbl.setAttribute('class','trending_language_tbl');
338 353 var cnt = 0;
339 354 for (var i=0;i<data.length;i++){
340 355 total+= data[i][1].count;
341 356 }
342 357 for (var i=0;i<data.length;i++){
343 358 cnt += 1;
344 359 no_data = false;
345 360
346 361 var hide = cnt>2;
347 362 var tr = document.createElement('tr');
348 363 if (hide){
349 364 tr.setAttribute('style','display:none');
350 365 tr.setAttribute('class','stats_hidden');
351 366 }
352 367 var k = data[i][0];
353 368 var obj = data[i][1];
354 369 var percentage = Math.round((obj.count/total*100),2);
355 370
356 371 var td1 = document.createElement('td');
357 372 td1.width = 150;
358 373 var trending_language_label = document.createElement('div');
359 374 trending_language_label.innerHTML = obj.desc+" ("+k+")";
360 375 td1.appendChild(trending_language_label);
361 376
362 377 var td2 = document.createElement('td');
363 378 td2.setAttribute('style','padding-right:14px !important');
364 379 var trending_language = document.createElement('div');
365 380 var nr_files = obj.count+" ${_('files')}";
366 381
367 382 trending_language.title = k+" "+nr_files;
368 383
369 384 if (percentage>22){
370 385 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"% "+nr_files+ "</b>";
371 386 }
372 387 else{
373 388 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"%</b>";
374 389 }
375 390
376 391 trending_language.setAttribute("class", 'trending_language top-right-rounded-corner bottom-right-rounded-corner');
377 392 trending_language.style.width=percentage+"%";
378 393 td2.appendChild(trending_language);
379 394
380 395 tr.appendChild(td1);
381 396 tr.appendChild(td2);
382 397 tbl.appendChild(tr);
383 398 if(cnt == 3){
384 399 var show_more = document.createElement('tr');
385 400 var td = document.createElement('td');
386 401 lnk = document.createElement('a');
387 402
388 403 lnk.href='#';
389 404 lnk.innerHTML = "${_('Show more')}";
390 405 lnk.id='code_stats_show_more';
391 406 td.appendChild(lnk);
392 407
393 408 show_more.appendChild(td);
394 409 show_more.appendChild(document.createElement('td'));
395 410 tbl.appendChild(show_more);
396 411 }
397 412
398 413 }
399 414
400 415 YUD.get('lang_stats').appendChild(tbl);
401 416 YUE.on('code_stats_show_more','click',function(){
402 417 l = YUD.getElementsByClassName('stats_hidden')
403 418 for (e in l){
404 419 YUD.setStyle(l[e],'display','');
405 420 };
406 421 YUD.setStyle(YUD.get('code_stats_show_more'),
407 422 'display','none');
408 423 });
409 424 </script>
410 425 <script type="text/javascript">
411 426 /**
412 427 * Plots summary graph
413 428 *
414 429 * @class SummaryPlot
415 430 * @param {from} initial from for detailed graph
416 431 * @param {to} initial to for detailed graph
417 432 * @param {dataset}
418 433 * @param {overview_dataset}
419 434 */
420 435 function SummaryPlot(from,to,dataset,overview_dataset) {
421 436 var initial_ranges = {
422 437 "xaxis":{
423 438 "from":from,
424 439 "to":to,
425 440 },
426 441 };
427 442 var dataset = dataset;
428 443 var overview_dataset = [overview_dataset];
429 444 var choiceContainer = YUD.get("legend_choices");
430 445 var choiceContainerTable = YUD.get("legend_choices_tables");
431 446 var plotContainer = YUD.get('commit_history');
432 447 var overviewContainer = YUD.get('overview');
433 448
434 449 var plot_options = {
435 450 bars: {show:true,align:'center',lineWidth:4},
436 451 legend: {show:true, container:"legend_container"},
437 452 points: {show:true,radius:0,fill:false},
438 453 yaxis: {tickDecimals:0,},
439 454 xaxis: {
440 455 mode: "time",
441 456 timeformat: "%d/%m",
442 457 min:from,
443 458 max:to,
444 459 },
445 460 grid: {
446 461 hoverable: true,
447 462 clickable: true,
448 463 autoHighlight:true,
449 464 color: "#999"
450 465 },
451 466 //selection: {mode: "x"}
452 467 };
453 468 var overview_options = {
454 469 legend:{show:false},
455 470 bars: {show:true,barWidth: 2,},
456 471 shadowSize: 0,
457 472 xaxis: {mode: "time", timeformat: "%d/%m/%y",},
458 473 yaxis: {ticks: 3, min: 0,tickDecimals:0,},
459 474 grid: {color: "#999",},
460 475 selection: {mode: "x"}
461 476 };
462 477
463 478 /**
464 479 *get dummy data needed in few places
465 480 */
466 481 function getDummyData(label){
467 482 return {"label":label,
468 483 "data":[{"time":0,
469 484 "commits":0,
470 485 "added":0,
471 486 "changed":0,
472 487 "removed":0,
473 488 }],
474 489 "schema":["commits"],
475 490 "color":'#ffffff',
476 491 }
477 492 }
478 493
479 494 /**
480 495 * generate checkboxes accordindly to data
481 496 * @param keys
482 497 * @returns
483 498 */
484 499 function generateCheckboxes(data) {
485 500 //append checkboxes
486 501 var i = 0;
487 502 choiceContainerTable.innerHTML = '';
488 503 for(var pos in data) {
489 504
490 505 data[pos].color = i;
491 506 i++;
492 507 if(data[pos].label != ''){
493 508 choiceContainerTable.innerHTML +=
494 509 '<tr><td><input type="checkbox" id="id_user_{0}" name="{0}" checked="checked" /> \
495 510 <label for="id_user_{0}">{0}</label></td></tr>'.format(data[pos].label);
496 511 }
497 512 }
498 513 }
499 514
500 515 /**
501 516 * ToolTip show
502 517 */
503 518 function showTooltip(x, y, contents) {
504 519 var div=document.getElementById('tooltip');
505 520 if(!div) {
506 521 div = document.createElement('div');
507 522 div.id="tooltip";
508 523 div.style.position="absolute";
509 524 div.style.border='1px solid #fdd';
510 525 div.style.padding='2px';
511 526 div.style.backgroundColor='#fee';
512 527 document.body.appendChild(div);
513 528 }
514 529 YUD.setStyle(div, 'opacity', 0);
515 530 div.innerHTML = contents;
516 531 div.style.top=(y + 5) + "px";
517 532 div.style.left=(x + 5) + "px";
518 533
519 534 var anim = new YAHOO.util.Anim(div, {opacity: {to: 0.8}}, 0.2);
520 535 anim.animate();
521 536 }
522 537
523 538 /**
524 539 * This function will detect if selected period has some changesets
525 540 for this user if it does this data is then pushed for displaying
526 541 Additionally it will only display users that are selected by the checkbox
527 542 */
528 543 function getDataAccordingToRanges(ranges) {
529 544
530 545 var data = [];
531 546 var new_dataset = {};
532 547 var keys = [];
533 548 var max_commits = 0;
534 549 for(var key in dataset){
535 550
536 551 for(var ds in dataset[key].data){
537 552 commit_data = dataset[key].data[ds];
538 553 if (commit_data.time >= ranges.xaxis.from && commit_data.time <= ranges.xaxis.to){
539 554
540 555 if(new_dataset[key] === undefined){
541 556 new_dataset[key] = {data:[],schema:["commits"],label:key};
542 557 }
543 558 new_dataset[key].data.push(commit_data);
544 559 }
545 560 }
546 561 if (new_dataset[key] !== undefined){
547 562 data.push(new_dataset[key]);
548 563 }
549 564 }
550 565
551 566 if (data.length > 0){
552 567 return data;
553 568 }
554 569 else{
555 570 //just return dummy data for graph to plot itself
556 571 return [getDummyData('')];
557 572 }
558 573 }
559 574
560 575 /**
561 576 * redraw using new checkbox data
562 577 */
563 578 function plotchoiced(e,args){
564 579 var cur_data = args[0];
565 580 var cur_ranges = args[1];
566 581
567 582 var new_data = [];
568 583 var inputs = choiceContainer.getElementsByTagName("input");
569 584
570 585 //show only checked labels
571 586 for(var i=0; i<inputs.length; i++) {
572 587 var checkbox_key = inputs[i].name;
573 588
574 589 if(inputs[i].checked){
575 590 for(var d in cur_data){
576 591 if(cur_data[d].label == checkbox_key){
577 592 new_data.push(cur_data[d]);
578 593 }
579 594 }
580 595 }
581 596 else{
582 597 //push dummy data to not hide the label
583 598 new_data.push(getDummyData(checkbox_key));
584 599 }
585 600 }
586 601
587 602 var new_options = YAHOO.lang.merge(plot_options, {
588 603 xaxis: {
589 604 min: cur_ranges.xaxis.from,
590 605 max: cur_ranges.xaxis.to,
591 606 mode:"time",
592 607 timeformat: "%d/%m",
593 608 },
594 609 });
595 610 if (!new_data){
596 611 new_data = [[0,1]];
597 612 }
598 613 // do the zooming
599 614 plot = YAHOO.widget.Flot(plotContainer, new_data, new_options);
600 615
601 616 plot.subscribe("plotselected", plotselected);
602 617
603 618 //resubscribe plothover
604 619 plot.subscribe("plothover", plothover);
605 620
606 621 // don't fire event on the overview to prevent eternal loop
607 622 overview.setSelection(cur_ranges, true);
608 623
609 624 }
610 625
611 626 /**
612 627 * plot only selected items from overview
613 628 * @param ranges
614 629 * @returns
615 630 */
616 631 function plotselected(ranges,cur_data) {
617 632 //updates the data for new plot
618 633 var data = getDataAccordingToRanges(ranges);
619 634 generateCheckboxes(data);
620 635
621 636 var new_options = YAHOO.lang.merge(plot_options, {
622 637 xaxis: {
623 638 min: ranges.xaxis.from,
624 639 max: ranges.xaxis.to,
625 640 mode:"time",
626 641 timeformat: "%d/%m",
627 642 },
628 643 });
629 644 // do the zooming
630 645 plot = YAHOO.widget.Flot(plotContainer, data, new_options);
631 646
632 647 plot.subscribe("plotselected", plotselected);
633 648
634 649 //resubscribe plothover
635 650 plot.subscribe("plothover", plothover);
636 651
637 652 // don't fire event on the overview to prevent eternal loop
638 653 overview.setSelection(ranges, true);
639 654
640 655 //resubscribe choiced
641 656 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, ranges]);
642 657 }
643 658
644 659 var previousPoint = null;
645 660
646 661 function plothover(o) {
647 662 var pos = o.pos;
648 663 var item = o.item;
649 664
650 665 //YUD.get("x").innerHTML = pos.x.toFixed(2);
651 666 //YUD.get("y").innerHTML = pos.y.toFixed(2);
652 667 if (item) {
653 668 if (previousPoint != item.datapoint) {
654 669 previousPoint = item.datapoint;
655 670
656 671 var tooltip = YUD.get("tooltip");
657 672 if(tooltip) {
658 673 tooltip.parentNode.removeChild(tooltip);
659 674 }
660 675 var x = item.datapoint.x.toFixed(2);
661 676 var y = item.datapoint.y.toFixed(2);
662 677
663 678 if (!item.series.label){
664 679 item.series.label = 'commits';
665 680 }
666 681 var d = new Date(x*1000);
667 682 var fd = d.toDateString()
668 683 var nr_commits = parseInt(y);
669 684
670 685 var cur_data = dataset[item.series.label].data[item.dataIndex];
671 686 var added = cur_data.added;
672 687 var changed = cur_data.changed;
673 688 var removed = cur_data.removed;
674 689
675 690 var nr_commits_suffix = " ${_('commits')} ";
676 691 var added_suffix = " ${_('files added')} ";
677 692 var changed_suffix = " ${_('files changed')} ";
678 693 var removed_suffix = " ${_('files removed')} ";
679 694
680 695 if(nr_commits == 1){nr_commits_suffix = " ${_('commit')} ";}
681 696 if(added==1){added_suffix=" ${_('file added')} ";}
682 697 if(changed==1){changed_suffix=" ${_('file changed')} ";}
683 698 if(removed==1){removed_suffix=" ${_('file removed')} ";}
684 699
685 700 showTooltip(item.pageX, item.pageY, item.series.label + " on " + fd
686 701 +'<br/>'+
687 702 nr_commits + nr_commits_suffix+'<br/>'+
688 703 added + added_suffix +'<br/>'+
689 704 changed + changed_suffix + '<br/>'+
690 705 removed + removed_suffix + '<br/>');
691 706 }
692 707 }
693 708 else {
694 709 var tooltip = YUD.get("tooltip");
695 710
696 711 if(tooltip) {
697 712 tooltip.parentNode.removeChild(tooltip);
698 713 }
699 714 previousPoint = null;
700 715 }
701 716 }
702 717
703 718 /**
704 719 * MAIN EXECUTION
705 720 */
706 721
707 722 var data = getDataAccordingToRanges(initial_ranges);
708 723 generateCheckboxes(data);
709 724
710 725 //main plot
711 726 var plot = YAHOO.widget.Flot(plotContainer,data,plot_options);
712 727
713 728 //overview
714 729 var overview = YAHOO.widget.Flot(overviewContainer,
715 730 overview_dataset, overview_options);
716 731
717 732 //show initial selection on overview
718 733 overview.setSelection(initial_ranges);
719 734
720 735 plot.subscribe("plotselected", plotselected);
721 736 plot.subscribe("plothover", plothover)
722 737
723 738 overview.subscribe("plotselected", function (ranges) {
724 739 plot.setSelection(ranges);
725 740 });
726 741
727 742 // user choices on overview
728 743 YUE.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, initial_ranges]);
729 744 }
730 745 SummaryPlot(${c.ts_min},${c.ts_max},${c.commit_data|n},${c.overview_data|n});
731 746 </script>
732 747 %endif
733 748
734 749 </%def>
General Comments 0
You need to be logged in to leave comments. Login now