##// END OF EJS Templates
backported fix for issue #271
marcink -
r1891:6b25e681 default
parent child Browse files
Show More
@@ -140,11 +140,9 class SummaryController(BaseRepoControll
140 "desc": LANGUAGES_EXTENSIONS_MAP.get(x)})
140 "desc": LANGUAGES_EXTENSIONS_MAP.get(x)})
141 for x, y in lang_stats_d.items())
141 for x, y in lang_stats_d.items())
142
142
143 c.trending_languages = json.dumps(OrderedDict(
143 c.trending_languages = json.dumps(
144 sorted(lang_stats, reverse=True,
144 sorted(lang_stats, reverse=True, key=lambda k: k[1])[:10]
145 key=lambda k: k[1])[:10]
145 )
146 )
147 )
148 last_rev = stats.stat_on_revision + 1
146 last_rev = stats.stat_on_revision + 1
149 c.repo_last_rev = c.rhodecode_repo.count()\
147 c.repo_last_rev = c.rhodecode_repo.count()\
150 if c.rhodecode_repo.revisions else 0
148 if c.rhodecode_repo.revisions else 0
@@ -201,69 +201,71
201
201
202 })
202 })
203 })
203 })
204 var data = ${c.trending_languages|n};
204 var data = ${c.trending_languages|n};
205 var total = 0;
205 var total = 0;
206 var no_data = true;
206 var no_data = true;
207 for (k in data){
207 var tbl = document.createElement('table');
208 total += data[k].count;
208 tbl.setAttribute('class','trending_language_tbl');
209 no_data = false;
209 var cnt = 0;
210 }
210
211 var tbl = document.createElement('table');
211 for (var i=0;i<data.length;i++){
212 tbl.setAttribute('class','trending_language_tbl');
212 total += data[i][1].count;
213 var cnt = 0;
213 cnt += 1;
214 for (k in data){
214 no_data = false;
215 cnt += 1;
215
216 var hide = cnt>2;
216 var hide = cnt>2;
217 var tr = document.createElement('tr');
217 var tr = document.createElement('tr');
218 if (hide){
218 if (hide){
219 tr.setAttribute('style','display:none');
219 tr.setAttribute('style','display:none');
220 tr.setAttribute('class','stats_hidden');
220 tr.setAttribute('class','stats_hidden');
221 }
221 }
222 var percentage = Math.round((data[k].count/total*100),2);
222 var k = data[i][0];
223 var value = data[k].count;
223 var obj = data[i][1];
224 var td1 = document.createElement('td');
224 var percentage = Math.round((obj.count/total*100),2);
225 td1.width = 150;
225
226 var trending_language_label = document.createElement('div');
226 var td1 = document.createElement('td');
227 trending_language_label.innerHTML = data[k].desc+" ("+k+")";
227 td1.width = 150;
228 td1.appendChild(trending_language_label);
228 var trending_language_label = document.createElement('div');
229 trending_language_label.innerHTML = obj.desc+" ("+k+")";
230 td1.appendChild(trending_language_label);
231
232 var td2 = document.createElement('td');
233 td2.setAttribute('style','padding-right:14px !important');
234 var trending_language = document.createElement('div');
235 var nr_files = obj.count+" ${_('files')}";
229
236
230 var td2 = document.createElement('td');
237 trending_language.title = k+" "+nr_files;
231 td2.setAttribute('style','padding-right:14px !important');
238
232 var trending_language = document.createElement('div');
239 if (percentage>22){
233 var nr_files = value+" ${_('files')}";
240 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"% "+nr_files+ "</b>";
234
241 }
235 trending_language.title = k+" "+nr_files;
242 else{
236
243 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"%</b>";
237 if (percentage>22){
244 }
238 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"% "+nr_files+ "</b>";
245
239 }
246 trending_language.setAttribute("class", 'trending_language top-right-rounded-corner bottom-right-rounded-corner');
240 else{
247 trending_language.style.width=percentage+"%";
241 trending_language.innerHTML = "<b style='font-size:0.8em'>"+percentage+"%</b>";
248 td2.appendChild(trending_language);
242 }
249
243
250 tr.appendChild(td1);
244 trending_language.setAttribute("class", 'trending_language top-right-rounded-corner bottom-right-rounded-corner');
251 tr.appendChild(td2);
245 trending_language.style.width=percentage+"%";
252 tbl.appendChild(tr);
246 td2.appendChild(trending_language);
253 if(cnt == 3){
247
254 var show_more = document.createElement('tr');
248 tr.appendChild(td1);
255 var td = document.createElement('td');
249 tr.appendChild(td2);
256 lnk = document.createElement('a');
250 tbl.appendChild(tr);
257
251 if(cnt == 3){
258 lnk.href='#';
252 var show_more = document.createElement('tr');
259 lnk.innerHTML = "${_('show more')}";
253 var td = document.createElement('td');
260 lnk.id='code_stats_show_more';
254 lnk = document.createElement('a');
261 td.appendChild(lnk);
255
262
256 lnk.href='#';
263 show_more.appendChild(td);
257 lnk.innerHTML = "${_('show more')}";
264 show_more.appendChild(document.createElement('td'));
258 lnk.id='code_stats_show_more';
265 tbl.appendChild(show_more);
259 td.appendChild(lnk);
266 }
260
267
261 show_more.appendChild(td);
268 }
262 show_more.appendChild(document.createElement('td'));
263 tbl.appendChild(show_more);
264 }
265
266 }
267 if(no_data){
269 if(no_data){
268 var tr = document.createElement('tr');
270 var tr = document.createElement('tr');
269 var td1 = document.createElement('td');
271 var td1 = document.createElement('td');
General Comments 0
You need to be logged in to leave comments. Login now