]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Refactor scan history auto-scrolling 3800/head
authormoisseev <moiseev@mezonplus.ru>
Thu, 17 Jun 2021 16:35:34 +0000 (19:35 +0300)
committermoisseev <moiseev@mezonplus.ru>
Thu, 17 Jun 2021 16:35:34 +0000 (19:35 +0300)
interface/js/app/upload.js

index 88b7da4233a56127b5f2d2ae98ff475eae91ae14..39e85640d1f554359e9b57f7ba223aa95fd23e12 100644 (file)
@@ -135,6 +135,15 @@ define(["jquery"],
                 },
                 method: "POST",
                 success: function (neighbours_status) {
+                    function scrollTop(rows_total) {
+                        // Is there a way to get an event when all rows are loaded?
+                        rspamd.waitForRowsDisplayed("scan", rows_total, function () {
+                            $("html, body").animate({
+                                scrollTop: $("#scanResult").offset().top
+                            }, 1000);
+                        });
+                    }
+
                     var json = neighbours_status[0].data;
                     if (json.action) {
                         rspamd.alertMessage("alert-success", "Data successfully scanned");
@@ -146,22 +155,13 @@ define(["jquery"],
 
                         if (Object.prototype.hasOwnProperty.call(tables, "scan")) {
                             tables.scan.rows.load(items, true);
-                            // Is there a way to get an event when all rows are loaded?
-                            rspamd.waitForRowsDisplayed("scan", rows_total, function () {
-                                $("html, body").animate({
-                                    scrollTop: $("#scanResult").offset().top
-                                }, 1000);
-                            });
+                            scrollTop(rows_total);
                         } else {
                             rspamd.destroyTable("scan");
                             // Is there a way to get an event when the table is destroyed?
                             setTimeout(function () {
                                 rspamd.initHistoryTable(rspamd, data, items, "scan", columns_v2(), true);
-                                rspamd.waitForRowsDisplayed("scan", rows_total, function () {
-                                    $("html, body").animate({
-                                        scrollTop: $("#scanResult").offset().top
-                                    }, 1000);
-                                });
+                                scrollTop(rows_total);
                             }, 200);
                         }
                     } else {