diff options
author | Greg ORIOL <greg@gregoriol.net> | 2016-04-22 16:29:48 +0300 |
---|---|---|
committer | Greg ORIOL <greg@gregoriol.net> | 2016-04-22 16:29:48 +0300 |
commit | c7d38e1b234ccd1f6a1b8aee01649c74eaf8fd25 (patch) | |
tree | 1c0c374dd1766fb6027580183a7ca36554989af7 | |
parent | d2207d359527a053bedba27c3878cdabaea072b1 (diff) |
Fixed "click" binding on redis databases with a lot of keys (#93)
-rw-r--r-- | js/index.js | 96 |
1 files changed, 43 insertions, 53 deletions
diff --git a/js/index.js b/js/index.js index 0b4d924..4a4ed6a 100644 --- a/js/index.js +++ b/js/index.js @@ -1,43 +1,57 @@ $(function() { - $('#sidebar a').click(function(e) { - if (e.currentTarget.href.indexOf('/?') == -1) { - return; - } - - e.preventDefault(); + $('#sidebar').on('click', 'a', function(e) { + if (e.currentTarget.className.indexOf('deltree') !== -1) { + e.preventDefault(); - var href; - - if ((e.currentTarget.href.indexOf('?') == -1) || - (e.currentTarget.href.indexOf('?') == (e.currentTarget.href.length - 1))) { - href = 'overview.php'; - } else { - href = e.currentTarget.href.substr(e.currentTarget.href.indexOf('?') + 1); - - if (href.indexOf('&') != -1) { - href = href.replace('&', '.php?'); - } else { - href += '.php'; - } - } - - if (href.indexOf('flush.php') == 0) { - if (confirm('Are you sure you want to delete this key and all it\'s values?')) { + if (confirm('Are you sure you want to delete this whole tree and all it\'s keys?')) { $.ajax({ type: "POST", - url: href, + url: this.href, data: 'post=1', - success: function() { - window.location.reload(); + success: function(url) { + top.location.href = top.location.pathname+url; } }); } } else { - $('#iframe').attr('src', href); + if (e.currentTarget.href.indexOf('/?') == -1) { + return; + } + + e.preventDefault(); + + var href; + + if ((e.currentTarget.href.indexOf('?') == -1) || + (e.currentTarget.href.indexOf('?') == (e.currentTarget.href.length - 1))) { + href = 'overview.php'; + } else { + href = e.currentTarget.href.substr(e.currentTarget.href.indexOf('?') + 1); + + if (href.indexOf('&') != -1) { + href = href.replace('&', '.php?'); + } else { + href += '.php'; + } + } + + if (href.indexOf('flush.php') == 0) { + if (confirm('Are you sure you want to delete this key and all it\'s values?')) { + $.ajax({ + type: "POST", + url: href, + data: 'post=1', + success: function() { + window.location.reload(); + } + }); + } + } else { + $('#iframe').attr('src', href); + } } }); - $('#server').change(function(e) { if (location.href.indexOf('?') == -1) { location.href = location.href+'?s='+e.target.value; @@ -62,7 +76,7 @@ $(function() { $('li.current').parents('li.folder').removeClass('collapsed'); - $('li.folder').click(function(e) { + $('#sidebar').on('click', 'li.folder', function(e) { var t = $(this); if ((e.pageY >= t.offset().top) && @@ -72,14 +86,6 @@ $(function() { } }); - $('a').click(function() { - $('li.current').removeClass('current'); - }); - - $('li a').click(function() { - $(this).parent().addClass('current'); - }); - $('#btn_server_filter').click(function() { var filter = $('#server_filter').val(); location.href = top.location.pathname + '?overview&s=' + $('#server').val() + '&d=' + ($('#database').val() || '') + '&filter=' + filter; @@ -118,22 +124,6 @@ $(function() { }); }); - $('.deltree').click(function(e) { - e.preventDefault(); - - if (confirm('Are you sure you want to delete this whole tree and all it\'s keys?')) { - $.ajax({ - type: "POST", - url: this.href, - data: 'post=1', - success: function(url) { - top.location.href = top.location.pathname+url; - } - }); - } - }); - - var isResizing = false; var lastDownX = 0; var lastWidth = 0; |