actualize.phtml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. var feeds = [];
  3. <?php foreach ($this->feeds as $feed) { ?>
  4. feeds.push("<?php echo Minz_Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>");
  5. <?php } ?>
  6. function initProgressBar(init) {
  7. if (init) {
  8. $("body").after("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\
  9. <?php echo Minz_Translate::t ('refresh'); ?> <span class=\"progress\">0 / " + feeds.length + "</span><br />\
  10. <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\
  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. if (feeds.length === 0) {
  22. return;
  23. }
  24. initProgressBar(true);
  25. var i = 0;
  26. for (var f in feeds) {
  27. $.ajax({
  28. type: 'POST',
  29. url: feeds[f],
  30. }).done(function (data) {
  31. i++;
  32. updateProgressBar(i);
  33. if (i === feeds.length) {
  34. initProgressBar(false);
  35. }
  36. });
  37. }
  38. }