2014-07-23 15:52:50 +02:00
|
|
|
"use strict";
|
2014-09-21 12:12:35 +02:00
|
|
|
var feeds = [<?php foreach ($this->feeds as $feed) { ?>{<?php
|
|
|
|
?>url: "<?php echo Minz_Url::display(array('c' => 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'); ?>",<?php
|
|
|
|
?>title: "<?php echo $feed->name(); ?>"<?php
|
|
|
|
?>},<?php } ?>],
|
2014-07-23 15:52:50 +02:00
|
|
|
feed_processed = 0,
|
|
|
|
feed_count = feeds.length;
|
|
|
|
|
|
|
|
function initProgressBar(init) {
|
|
|
|
if (init) {
|
|
|
|
$("body").after("\<div id=\"actualizeProgress\" class=\"notification good\">\
|
2015-02-08 18:55:48 +01:00
|
|
|
<?php echo _t('feedback.sub.actualize'); ?><br /><span class=\"title\">/</span><br />\
|
2014-09-21 12:12:35 +02:00
|
|
|
<span class=\"progress\">0 / " + feed_count + "</span>\
|
2014-07-23 15:52:50 +02:00
|
|
|
</div>");
|
|
|
|
} else {
|
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
}
|
2014-09-21 12:12:35 +02:00
|
|
|
function updateProgressBar(i, title_feed) {
|
2014-07-23 15:52:50 +02:00
|
|
|
$("#actualizeProgress .progress").html(i + " / " + feed_count);
|
2014-09-21 12:12:35 +02:00
|
|
|
$("#actualizeProgress .title").html(title_feed);
|
2014-07-23 15:52:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateFeeds() {
|
|
|
|
if (feed_count === 0) {
|
2015-02-08 18:55:48 +01:00
|
|
|
openNotification("<?php echo _t('feedback.sub.feed.no_refresh'); ?>", "good");
|
2014-07-23 15:52:50 +02:00
|
|
|
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',
|
2014-09-21 12:12:35 +02:00
|
|
|
url: feed['url'],
|
2014-07-23 15:52:50 +02:00
|
|
|
}).complete(function (data) {
|
|
|
|
feed_processed++;
|
2014-09-21 12:12:35 +02:00
|
|
|
updateProgressBar(feed_processed, feed['title']);
|
2014-07-23 15:52:50 +02:00
|
|
|
|
|
|
|
if (feed_processed === feed_count) {
|
|
|
|
initProgressBar(false);
|
|
|
|
} else {
|
|
|
|
updateFeed();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|