actualize.phtml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var feeds = new Array ();
  2. <?php foreach ($this->feeds as $feed) { ?>
  3. feeds.push ("<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>");
  4. <?php } ?>
  5. function initProgressBar (init) {
  6. if (init) {
  7. $("body").after ("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\
  8. Actualisation :\
  9. <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\
  10. <span class=\"progress\">0 / " + feeds.length + "</span>\
  11. </div>");
  12. } else {
  13. window.location.reload ();
  14. }
  15. }
  16. function updateProgressBar (i) {
  17. $("#actualizeProgressBar").val(i);
  18. $("#actualizeProgress .progress").html (i + " / " + feeds.length);
  19. }
  20. function updateFeeds () {
  21. initProgressBar (true);
  22. var i = 0;
  23. for (var f in feeds) {
  24. $.ajax ({
  25. type: 'POST',
  26. url: feeds[f],
  27. }).done (function (data) {
  28. i++;
  29. updateProgressBar (i);
  30. if (i == feeds.length) {
  31. initProgressBar (false);
  32. }
  33. });
  34. }
  35. }
  36. $(document).ready (function () {
  37. $("#actualize").click (function () {
  38. updateFeeds ();
  39. return false;
  40. });
  41. });