Merge branch 'dev' into beta

pull/491/merge
Marien Fressinaud 11 years ago
commit 4799db4ad1
  1. 58
      app/views/index/stats.phtml
  2. 77
      p/scripts/main.js

@ -4,73 +4,73 @@
<h1><?php echo Minz_Translate::t ('stats'); ?></h1>
<div class="stat">
<h2><?php echo Minz_Translate::t ('stats_entry_repartition')?></h2>
<h2><?php echo Minz_Translate::t ('stats_entry_repartition'); ?></h2>
<table>
<thead>
<tr>
<th> </th>
<th><?php echo Minz_Translate::t ('main_stream')?></th>
<th><?php echo Minz_Translate::t ('all_feeds')?></th>
<th><?php echo Minz_Translate::t ('main_stream'); ?></th>
<th><?php echo Minz_Translate::t ('all_feeds'); ?></th>
</tr>
</thead>
<tbody>
<tr>
<th><?php echo Minz_Translate::t ('status_total')?></th>
<td class="numeric"><?php echo $this->repartition['main_stream']['total']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['total']?></td>
<th><?php echo Minz_Translate::t ('status_total'); ?></th>
<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['total']); ?></td>
<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['total']); ?></td>
</tr>
<tr>
<th><?php echo Minz_Translate::t ('status_read')?></th>
<td class="numeric"><?php echo $this->repartition['main_stream']['read']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['read']?></td>
<th><?php echo Minz_Translate::t ('status_read'); ?></th>
<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['read']); ?></td>
<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['read']); ?></td>
</tr>
<tr>
<th><?php echo Minz_Translate::t ('status_unread')?></th>
<td class="numeric"><?php echo $this->repartition['main_stream']['unread']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['unread']?></td>
<th><?php echo Minz_Translate::t ('status_unread'); ?></th>
<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['unread']); ?></td>
<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['unread']); ?></td>
</tr>
<tr>
<th><?php echo Minz_Translate::t ('status_favorites')?></th>
<td class="numeric"><?php echo $this->repartition['main_stream']['favorite']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['favorite']?></td>
<th><?php echo Minz_Translate::t ('status_favorites'); ?></th>
<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['favorite']); ?></td>
<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['favorite']); ?></td>
</tr>
</tbody>
</table>
</div>
<div class="stat">
<h2><?php echo Minz_Translate::t ('stats_entry_per_day')?></h2>
<h2><?php echo Minz_Translate::t ('stats_entry_per_day'); ?></h2>
<div id="statsEntryPerDay" style="height: 300px"></div>
</div>
<div class="stat">
<h2><?php echo Minz_Translate::t ('stats_feed_per_category')?></h2>
<h2><?php echo Minz_Translate::t ('stats_feed_per_category'); ?></h2>
<div id="statsFeedPerCategory" style="height: 300px"></div>
<div id="statsFeedPerCategoryLegend"></div>
</div>
<div class="stat">
<h2><?php echo Minz_Translate::t ('stats_entry_per_category')?></h2>
<h2><?php echo Minz_Translate::t ('stats_entry_per_category'); ?></h2>
<div id="statsEntryPerCategory" style="height: 300px"></div>
<div id="statsEntryPerCategoryLegend"></div>
</div>
<div class="stat">
<h2><?php echo Minz_Translate::t ('stats_top_feed')?></h2>
<h2><?php echo Minz_Translate::t ('stats_top_feed'); ?></h2>
<table>
<thead>
<tr>
<th><?php echo Minz_Translate::t ('feed')?></th>
<th><?php echo Minz_Translate::t ('category')?></th>
<th><?php echo Minz_Translate::t ('stats_entry_count')?></th>
<th><?php echo Minz_Translate::t ('feed'); ?></th>
<th><?php echo Minz_Translate::t ('category'); ?></th>
<th><?php echo Minz_Translate::t ('stats_entry_count'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($this->topFeed as $feed):?>
<?php foreach ($this->topFeed as $feed): ?>
<tr>
<td><?php echo $feed['name']?></td>
<td><?php echo $feed['category']?></td>
<td class="numeric"><?php echo $feed['count']?></td>
<td><?php echo $feed['name']; ?></td>
<td><?php echo $feed['category']; ?></td>
<td class="numeric"><?php echo formatNumber($feed['count']); ?></td>
</tr>
<?php endforeach;?>
</tbody>
@ -96,7 +96,7 @@ function initStats() {
bars: {horizontal: false, show: true},
xaxis: {noTicks: 6, showLabels: false, tickDecimals: 0},
yaxis: {min: 0},
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.y;}}
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
});
// Feed per category
Flotr.draw(document.getElementById('statsFeedPerCategory'),
@ -106,7 +106,7 @@ function initStats() {
pie: {explode: 10, show: true, labelFormatter: function(){return '';}},
xaxis: {showLabels: false},
yaxis: {showLabels: false},
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ obj.y + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ numberFormat(obj.y) + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
legend: {container: document.getElementById('statsFeedPerCategoryLegend'), noColumns: 3}
});
// Entry per category
@ -117,7 +117,7 @@ function initStats() {
pie: {explode: 10, show: true, labelFormatter: function(){return '';}},
xaxis: {showLabels: false},
yaxis: {showLabels: false},
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ obj.y + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return obj.series.label + ' - '+ numberFormat(obj.y) + ' ('+ (obj.fraction * 100).toFixed(1) + '%)';}},
legend: {container: document.getElementById('statsEntryPerCategoryLegend'), noColumns: 3}
});
}

@ -20,33 +20,47 @@ function redirect(url, new_tab) {
}
}
function numberFormat(nStr) {
// Thx to http://www.mredkj.com/javascript/numberFormat.html
nStr += '';
var x = nStr.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + " " + '$2');
}
return x1 + x2;
}
function incLabel(p, inc) {
var i = (parseInt(p.replace(/\D/g, ''), 10) || 0) + inc;
return i > 0 ? ' (' + i + ')' : '';
return i > 0 ? ' (' + numberFormat(i) + ')' : '';
}
function incUnreadsFeed(article, feed_id, nb) {
//Update unread: feed
var elem = $('#' + feed_id + '>.feed').get(0),
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0,
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0,
feed_priority = elem ? (parseInt(elem.getAttribute('data-priority'), 10) || 0) : 0;
if (elem) {
elem.setAttribute('data-unread', Math.max(0, feed_unreads + nb));
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
}
//Update unread: category
elem = $('#' + feed_id).parent().prevAll('.category').children(':first').get(0);
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
if (elem) {
elem.setAttribute('data-unread', Math.max(0, feed_unreads + nb));
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
}
//Update unread: all
if (feed_priority > 0) {
elem = $('#aside_flux .all').children(':first').get(0);
if (elem) {
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
elem.setAttribute('data-unread', Math.max(0, feed_unreads + nb));
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
}
}
@ -54,8 +68,8 @@ function incUnreadsFeed(article, feed_id, nb) {
if (article && article.closest('div').hasClass('favorite')) {
elem = $('#aside_flux .favorites').children(':first').get(0);
if (elem) {
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
elem.setAttribute('data-unread', Math.max(0, feed_unreads + nb));
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + nb)));
}
}
@ -133,16 +147,19 @@ function mark_favorite(active) {
var favourites = $('.favorites>a').contents().last().get(0);
if (favourites && favourites.textContent) {
favourites.textContent = favourites.textContent.replace(/((?: \(\d+\))?\s*)$/, function (m, p1) {
// Without javascript, the text displayed is « Favorites (1544) » where 1544 is the number unformatted.
// With Javascript, we replace this with « Favorites (1 544) ». To update this, the text is converted
// to the non-javascript format before.
favourites.textContent = favourites.textContent.replace(/ /g, '').replace('(', ' (').replace(/((?: \(\d+\))?\s*)$/, function (m, p1) {
return incLabel(p1, inc);
});
}
if (active.closest('div').hasClass('not_read')) {
var elem = $('#aside_flux .favorites').children(':first').get(0),
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
if (elem) {
elem.setAttribute('data-unread', Math.max(0, feed_unreads + inc));
elem.setAttribute('data-unread', numberFormat(Math.max(0, feed_unreads + inc)));
}
}
});
@ -527,7 +544,7 @@ function refreshUnreads() {
$.each(data, function(feed_id, nbUnreads) {
feed_id = 'f_' + feed_id;
var elem = $('#' + feed_id + '>.feed').get(0),
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0;
feed_unreads = elem ? (parseInt(elem.getAttribute('data-unread').replace(' ', ''), 10) || 0) : 0;
if ((incUnreadsFeed(null, feed_id, nbUnreads - feed_unreads) || isAll) && //Update of current view?
(nbUnreads - feed_unreads > 0)) {
$('#new-article').show();
@ -632,9 +649,9 @@ function init_loginForm() {
c = dcodeIO.bcrypt.hashSync(data.nonce + s, strong ? 4 : poormanSalt());
$('#challenge').val(c);
if (s == '' || c == '') {
alert('Crypto error!');
alert('Crypto error!');
} else {
success = true;
success = true;
}
} catch (e) {
alert('Crypto exception! ' + e);
@ -738,6 +755,34 @@ function init_print_action() {
});
}
function init_number_formats() {
// Init global counter
var elem = $('#aside_flux .categories li .all a');
elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
// Init favorites counters
elem = $('#aside_flux .categories li .favorites a');
elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
var numFavorites = elem.text().replace(/((?: \(\d+\))?\s*)$/, function (m, p1) {
return numberFormat(p1)
});
elem.text(numFavorites);
// Init feeds counters
$('#aside_flux .categories li .stick').each(function() {
// Category-level counter
elem = $(this).find('a');
elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
// Feeds counters
$(this).parent().find('ul.feeds li.item').each(function() {
elem = $(this).find('a.feed'); // There are two links here. a.feed is the title.
elem.attr('data-unread', numberFormat(elem.attr('data-unread')));
});
});
}
function init_all() {
if (!(window.$ && window.url_freshrss && ((!full_lazyload) || $.fn.lazyload))) {
if (window.console) {
@ -768,7 +813,7 @@ function init_all() {
init_print_action();
window.setInterval(refreshUnreads, 120000);
}
init_number_formats();
if (window.console) {
console.log('FreshRSS init done.');
}

Loading…
Cancel
Save