"use strict"; var feeds = [feeds as $feed) { ?>{url: " 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'); ?>",title: "name(); ?>"},], feed_processed = 0, feed_count = feeds.length; function initProgressBar(init) { if (init) { $("body").after("\
\
/
\ 0 / " + feed_count + "\
"); } else { window.location.reload(); } } function updateProgressBar(i, title_feed) { $("#actualizeProgress .progress").html(i + " / " + feed_count); $("#actualizeProgress .title").html(title_feed); } function updateFeeds() { if (feed_count === 0) { openNotification("", "good"); ajax_loading = false; return; } initProgressBar(true); for (var i = 0; i < 10; i++) { updateFeed(); } } function updateFeed() { var feed = feeds.pop(); if (feed == undefined) { return; } $.ajax({ type: 'POST', url: feed['url'], }).complete(function (data) { feed_processed++; updateProgressBar(feed_processed, feed['title']); if (feed_processed === feed_count) { initProgressBar(false); } else { updateFeed(); } }); }