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