Browse Source

reset channel list state when navigating back to page

Byron Jones 6 years ago
parent
commit
7dadda8d36
2 changed files with 39 additions and 31 deletions
  1. 39 31
      web/logbot.js
  2. 0 0
      web/public/static/logbot.min.js

+ 39 - 31
web/logbot.js

@@ -244,40 +244,43 @@ $(function() {
 
     // channel list filter
 
-    if ($('#channel-list').length) {
+    function update_filtered() {
+        var filter = $('#filter').val().trim().toLowerCase();
+        if (filter === '') {
+            $('#archived-channels').show();
+        } else {
+            $('#archived-channels').hide();
+        }
+
+        var filter_words = filter.split(/ +/);
+        $('#active-channels li').each(function() {
+            var $this = $(this);
+            var this_text = $this.data('text');
+            var match = true;
+            for (var i = 0, l = filter_words.length; i < l; i++) {
+                if (this_text.indexOf(filter_words[i]) === -1) {
+                    match = false;
+                    break;
+                }
+            }
+            if (match) {
+                $this.show();
+            } else {
+                $this.hide();
+            }
+        });
+        if ($('#active-channels li:visible').length === 0) {
+            $('#no-results').show();
+        } else {
+            $('#no-results').hide();
+        }
+    }
+
+    if ($('body').hasClass('list')) {
         $('#filter')
             .focus()
             .select()
-            .keyup(function(e) {
-                var filter = this.value.trim().toLowerCase();
-                if (filter === '') {
-                    $('#archived-channels').show();
-                } else {
-                    $('#archived-channels').hide();
-                }
-                var filter_words = filter.split(/ +/);
-                $('#active-channels li').each(function() {
-                    var $this = $(this);
-                    var this_text = $this.data('text');
-                    var match = true;
-                    for (var i = 0, l = filter_words.length; i < l; i++) {
-                        if (this_text.indexOf(filter_words[i]) === -1) {
-                            match = false;
-                            break;
-                        }
-                    }
-                    if (match) {
-                        $this.show();
-                    } else {
-                        $this.hide();
-                    }
-                });
-                if ($('#active-channels li:visible').length === 0) {
-                    $('#no-results').show();
-                } else {
-                    $('#no-results').hide();
-                }
-            })
+            .keyup(update_filtered)
             .keypress(function(e) {
                 if (e.which === 13) {
                     e.preventDefault();
@@ -286,6 +289,11 @@ $(function() {
                     }
                 }
             });
+
+        $(window).on('pageshow', function(e) {
+            update_filtered();
+            $('#filter').focus();
+        });
     }
 
     // highlight

File diff suppressed because it is too large
+ 0 - 0
web/public/static/logbot.min.js


Some files were not shown because too many files changed in this diff