1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/freshrss_ynh.git synced 2024-09-03 18:36:33 +02:00
freshrss_ynh/sources/app/views/javascript/actualize.phtml
2014-07-23 15:52:50 +02:00

57 lines
1.3 KiB
PHTML
Executable file

"use strict";
var feeds = [<?php
foreach ($this->feeds as $feed) {
echo "'", Minz_Url::display(array('c' => 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'), "',\n";
}
?>],
feed_processed = 0,
feed_count = feeds.length;
function initProgressBar(init) {
if (init) {
$("body").after("\<div id=\"actualizeProgress\" class=\"notification good\">\
<?php echo _t('refresh'); ?> <span class=\"progress\">0 / " + feed_count + "</span><br />\
<progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feed_count + "\"></progress>\
</div>");
} else {
window.location.reload();
}
}
function updateProgressBar(i) {
$("#actualizeProgressBar").val(i);
$("#actualizeProgress .progress").html(i + " / " + feed_count);
}
function updateFeeds() {
if (feed_count === 0) {
openNotification("<?php echo _t('no_feed_to_refresh'); ?>", "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,
}).complete(function (data) {
feed_processed++;
updateProgressBar(feed_processed);
if (feed_processed === feed_count) {
initProgressBar(false);
} else {
updateFeed();
}
});
}