Explorar el Código

Block user to click many times on the refresh button

See https://github.com/marienfressinaud/FreshRSS/issues/513
Marien Fressinaud hace 11 años
padre
commit
ab9d656135
Se han modificado 2 ficheros con 15 adiciones y 4 borrados
  1. 4 2
      app/views/javascript/actualize.phtml
  2. 11 2
      p/scripts/main.js

+ 4 - 2
app/views/javascript/actualize.phtml

@@ -10,7 +10,7 @@ var feeds = [<?php
 function initProgressBar(init) {
 	if (init) {
 		$("body").after("\<div id=\"actualizeProgress\" class=\"notification good\">\
-			<?php echo Minz_Translate::t ('refresh'); ?> <span class=\"progress\">0 / " + feed_count + "</span><br />\
+			<?php echo _t('refresh'); ?> <span class=\"progress\">0 / " + feed_count + "</span><br />\
 			<progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feed_count + "\"></progress>\
 		</div>");
 	} else {
@@ -24,7 +24,8 @@ function updateProgressBar(i) {
 
 function updateFeeds() {
 	if (feed_count === 0) {
-		openNotification("<?php echo Minz_Translate::t ('no_feed_to_refresh'); ?>", "good");
+		openNotification("<?php echo _t('no_feed_to_refresh'); ?>", "good");
+		ajax_loading = false;
 		return;
 	}
 	initProgressBar(true);
@@ -39,6 +40,7 @@ function updateFeed() {
 	if (feed == undefined) {
 		return;
 	}
+
 	$.ajax({
 		type: 'POST',
 		url: feed,

+ 11 - 2
p/scripts/main.js

@@ -1,7 +1,8 @@
 "use strict";
 var $stream = null,
 	isCollapsed = true,
-	shares = 0;
+	shares = 0,
+	ajax_loading = false;
 
 function is_normal_mode() {
 	return $stream.hasClass('normal');
@@ -684,14 +685,22 @@ function init_actualize() {
 	var auto = false;
 
 	$("#actualize").click(function () {
+		if (ajax_loading) {
+			return false;
+		}
+
+		ajax_loading = true;
+
 		$.getScript('./?c=javascript&a=actualize').done(function () {
 			if (auto && feed_count < 1) {
 				auto = false;
-				return;
+				ajax_loading = false;
+				return false;
 			}
 
 			updateFeeds();
 		});
+
 		return false;
 	});