Snippets

Mythics Jira - auto-refresh issues list

Updated by Jonathan Hult

File jira_auto_refresh_issues_list.js Modified

  • Ignore whitespace
  • Hide word diff
             setTimeout(function() {
                 // Refresh table every 60 seconds
                 setInterval(function() {
-                    AJS.$(".refresh-table").click();
+                    AutoRefreshIssuesList.refresh();
                 }, 60000);
             }, 60000);
         });
     };
+    
+    // Refresh function - must use this to again test URL since AJAX can otherwise allow refreshes where we don't want
+    AutoRefreshIssuesList.refresh = function() {
+        if (/^(\/issues\/)/i.test(location.pathname)) {
+            AJS.$(".refresh-table").click();
+        }
+    }
 
     // Fire on initial page load
     AutoRefreshIssuesList.init();
Updated by Jonathan Hult

File jira_auto_refresh_issues_list.js Modified

  • Ignore whitespace
  • Hide word diff
 if (/^(\/issues\/)/i.test(location.pathname)) {
 
     var AutoRefreshIssuesList = AutoRefreshIssuesList || {};
-    
+
     // Main function
     AutoRefreshIssuesList.init = function() {
 
         // Wait until page is loaded
         AJS.toInit(function() {
+            // Wait for 60 seconds before calling setInterval which fires immediately
             setTimeout(function() {
                 // Refresh table every 60 seconds
-				setInterval(function() {
-					AJS.$(".refresh-table").click();
-				}, 60000);
-             }, 60000); 
+                setInterval(function() {
+                    AJS.$(".refresh-table").click();
+                }, 60000);
+            }, 60000);
         });
     };
-    
+
     // Fire on initial page load
     AutoRefreshIssuesList.init();
 }
Updated by Jonathan Hult

File jira_auto_refresh_issues_list.js Modified

  • Ignore whitespace
  • Hide word diff
     var AutoRefreshIssuesList = AutoRefreshIssuesList || {};
     
     // Main function
-    AutoRefreshIssuesList.init = function() {  
+    AutoRefreshIssuesList.init = function() {
 
         // Wait until page is loaded
         AJS.toInit(function() {
-            // Refresh table every 60 seconds
-            setInterval(function() {
-                AJS.$(".refresh-table").click();
-            }, 60000);
+            setTimeout(function() {
+                // Refresh table every 60 seconds
+				setInterval(function() {
+					AJS.$(".refresh-table").click();
+				}, 60000);
+             }, 60000); 
         });
     };
     
Updated by Jonathan Hult

File jira_auto_refresh_issues_list.js Modified

  • Ignore whitespace
  • Hide word diff
             // Refresh table every 60 seconds
             setInterval(function() {
                 AJS.$(".refresh-table").click();
-            }, 3000);
+            }, 60000);
         });
     };
     
Created by Jonathan Hult

File jira_auto_refresh_issues_list.js Added

  • Ignore whitespace
  • Hide word diff
+// Only on issues list
+if (/^(\/issues\/)/i.test(location.pathname)) {
+
+    var AutoRefreshIssuesList = AutoRefreshIssuesList || {};
+    
+    // Main function
+    AutoRefreshIssuesList.init = function() {  
+
+        // Wait until page is loaded
+        AJS.toInit(function() {
+            // Refresh table every 60 seconds
+            setInterval(function() {
+                AJS.$(".refresh-table").click();
+            }, 3000);
+        });
+    };
+    
+    // Fire on initial page load
+    AutoRefreshIssuesList.init();
+}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.