aboutsummaryrefslogtreecommitdiff
path: root/app/views/javascript
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <github@ainw.org> 2014-02-05 00:18:39 -0500
committerGravatar Alexis Degrugillier <github@ainw.org> 2014-02-05 20:12:23 -0500
commited61f9346f4946e27a894d6901a5c64c9f6677cc (patch)
tree4ddfcde841af9ef4597992184c5c087cb24990ea /app/views/javascript
parenta2c64ad89659c1d1332b76649ae3db0a208fd449 (diff)
Changement du rafraichissement manuel des flux
Au lieu de lancer un rafraichissement sur l'ensemble des flux, le rafraichissement se fait sur 10 flux simultanément. Quand un flux est rafraichit, il lance le rafraichissement d'un autre flux jusqu'à épuisement des flux disponibles.
Diffstat (limited to 'app/views/javascript')
-rw-r--r--app/views/javascript/actualize.phtml45
1 files changed, 28 insertions, 17 deletions
diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml
index 1f6072c29..272d1b419 100644
--- a/app/views/javascript/actualize.phtml
+++ b/app/views/javascript/actualize.phtml
@@ -3,12 +3,14 @@ var feeds = [];
<?php foreach ($this->feeds as $feed) { ?>
feeds.push("<?php echo Minz_Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>");
<?php } ?>
+var feed_count = feeds.length;
+var feed_processed = 0;
function initProgressBar(init) {
if (init) {
$("body").after("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\
- <?php echo Minz_Translate::t ('refresh'); ?> <span class=\"progress\">0 / " + feeds.length + "</span><br />\
- <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\
+ <?php echo Minz_Translate::t ('refresh'); ?> <span class=\"progress\">0 / " + feed_count + "</span><br />\
+ <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feed_count + "\"></progress>\
</div>");
} else {
window.location.reload();
@@ -16,27 +18,36 @@ function initProgressBar(init) {
}
function updateProgressBar(i) {
$("#actualizeProgressBar").val(i);
- $("#actualizeProgress .progress").html(i + " / " + feeds.length);
+ $("#actualizeProgress .progress").html(i + " / " + feed_count);
}
function updateFeeds() {
- if (feeds.length === 0) {
+ if (feed_count === 0) {
return;
}
initProgressBar(true);
- var i = 0;
- for (var f in feeds) {
- $.ajax({
- type: 'POST',
- url: feeds[f],
- }).done(function (data) {
- i++;
- updateProgressBar(i);
-
- if (i === feeds.length) {
- initProgressBar(false);
- }
- });
+ for (var i = 0; i < 10; i++) {
+ updateFeed();
}
}
+
+function updateFeed() {
+ if (feeds.length === 0) {
+ return;
+ }
+ var feed = feeds.pop();
+ $.ajax({
+ type: 'POST',
+ url: feed,
+ }).done(function (data) {
+ feed_processed++;
+ updateProgressBar(feed_processed);
+
+ if (feed_processed === feed_count) {
+ initProgressBar(false);
+ } else {
+ updateFeed();
+ }
+ });
+} \ No newline at end of file