From 9b9543109e36a5409fe71eb084cfac680dfc7cbd Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 13 Apr 2013 15:27:36 +0200 Subject: Fix issue #39 : actualisation de tous les flux grâce à Ajax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/javascript/actualize.phtml | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app/views/javascript/actualize.phtml (limited to 'app/views/javascript/actualize.phtml') 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 (); +feeds as $feed) { ?> +feeds.push (" 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>"); + + +function initProgressBar (init) { + if (init) { + $("body").after ("\
\ + Actualisation :\ + \ + 0 / " + feeds.length + "\ +
"); + } 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; + }); +}); -- cgit v1.2.3