summaryrefslogtreecommitdiff
path: root/app/views/javascript/actualize.phtml
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-17 19:33:02 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-17 19:33:02 +0200
commit592a34f0d21ff1b6d4bd8613052d2684df39d246 (patch)
tree6c93b180bf271e32357bf1bad4baa93aa1233f5b /app/views/javascript/actualize.phtml
parent044908439bdd7280f7539e12441d7dfa6c4d4c63 (diff)
parenta2b5e8f3ce597fbcec0c25b68c551a526d2bf3ec (diff)
Merge branch 'dev' into releases
Diffstat (limited to 'app/views/javascript/actualize.phtml')
-rw-r--r--app/views/javascript/actualize.phtml45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml
new file mode 100644
index 000000000..16188422a
--- /dev/null
+++ b/app/views/javascript/actualize.phtml
@@ -0,0 +1,45 @@
+var feeds = new Array ();
+<?php foreach ($this->feeds as $feed) { ?>
+feeds.push ("<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>");
+<?php } ?>
+
+function initProgressBar (init) {
+ if (init) {
+ $("body").after ("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\
+ Actualisation <span class=\"progress\">0 / " + feeds.length + "</span><br />\
+ <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\
+ </div>");
+ } else {
+ window.location.reload ();
+ }
+}
+function updateProgressBar (i) {
+ $("#actualizeProgressBar").val(i);
+ $("#actualizeProgress .progress").html (i + " / " + feeds.length);
+}
+
+function updateFeeds () {
+ initProgressBar (true);
+
+ var i = 0;
+ for (var f in feeds) {
+ $.ajax ({
+ type: 'POST',
+ url: feeds[f],
+ }).done (function (data) {
+ i++;
+ updateProgressBar (i);
+
+ if (i == feeds.length) {
+ initProgressBar (false);
+ }
+ });
+ }
+}
+
+$(document).ready (function () {
+ $("#actualize").click (function () {
+ updateFeeds ();
+ return false;
+ });
+});