diff options
| author | 2013-04-13 15:27:36 +0200 | |
|---|---|---|
| committer | 2013-04-13 15:27:36 +0200 | |
| commit | 9b9543109e36a5409fe71eb084cfac680dfc7cbd (patch) | |
| tree | 0876746883cd90d5f1e9a63e208342699e427690 /app/views/javascript/actualize.phtml | |
| parent | a4beb7b772fdc3c8c894b93611bfb030c9456f07 (diff) | |
Fix issue #39 : actualisation de tous les flux grâce à Ajax
Diffstat (limited to 'app/views/javascript/actualize.phtml')
| -rw-r--r-- | app/views/javascript/actualize.phtml | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml new file mode 100644 index 000000000..ad1c4e2e6 --- /dev/null +++ b/app/views/javascript/actualize.phtml @@ -0,0 +1,46 @@ +var feeds = new Array (); +<?php foreach ($this->feeds as $feed) { ?> +feeds.push ("<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>"); +<?php } ?> + +function initProgressBar (init) { + if (init) { + $("body").after ("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\ + Actualisation :\ + <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\ + <span class=\"progress\">0 / " + feeds.length + "</span>\ + </div>"); + } else { + window.location.reload (); + } +} +function updateProgressBar (i) { + $("#actualizeProgressBar").val(i); + $("#actualizeProgress .progress").html (i + " / " + feeds.length); +} + +function updateFeeds () { + 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); + } + }); + } +} + +$(document).ready (function () { + $("#actualize").click (function () { + updateFeeds (); + return false; + }); +}); |
