From 503753cd403617efd79c7c3c42d1fd1b6cad9987 Mon Sep 17 00:00:00 2001 From: ozhozh Date: Thu, 1 Jul 2010 08:36:25 +0000 Subject: [PATCH] Better toggle "No URL found" when no links in DB or when deleting all links git-svn-id: http://yourls.googlecode.com/svn/trunk@437 12232710-3e20-11de-b438-597f59cd7555 --- admin/index.php | 8 ++++++-- js/insert.js | 12 ++++++++++-- js/jquery.tablesorter.min.js | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/admin/index.php b/admin/index.php index 5189b71..ba593b7 100644 --- a/admin/index.php +++ b/admin/index.php @@ -260,7 +260,9 @@ get_results("SELECT * FROM `$table_url` WHERE 1=1 $where ORDER BY `$sort_by_sql` $sort_order_sql LIMIT $offset, $perpage;"); + $found_rows = false; if( $url_results ) { + $found_rows = true; foreach( $url_results as $url_result ) { $keyword = yourls_sanitize_string( $url_result->keyword ); $timestamp = strtotime( $url_result->timestamp ); @@ -271,9 +273,11 @@ echo yourls_table_add_row( $keyword, $url, $title, $ip, $clicks, $timestamp ); } - } else { - echo 'No URL Found'; } + + $display = $found_rows ? 'display:none' : ''; + echo 'No URL'; + ?> diff --git a/js/insert.js b/js/insert.js index d299eaa..a01a435 100644 --- a/js/insert.js +++ b/js/insert.js @@ -26,7 +26,7 @@ function add() { function(data){ if(data.status == 'success') { $('#tblUrl tbody').prepend( data.html ).trigger("update"); - $('.nourl_found').remove(); + $('#nourl_found').css('display', 'none'); zebra_table(); reset_url(); increment(); @@ -78,7 +78,15 @@ function remove(id) { { mode: "delete", keyword: keyword }, function(data){ if (data.success == 1) { - $("#id-" + id).fadeOut(function(){$(this).remove();zebra_table();}); + $("#id-" + id).fadeOut(function(){ + $(this).remove(); + console.log( $('#tblUrl tbody tr').length ); + if( $('#tblUrl tbody tr').length == 1 ) { + $('#nourl_found').css('display', ''); + } + + zebra_table(); + }); decrement(); } else { alert('something wrong happened while deleting :/'); diff --git a/js/jquery.tablesorter.min.js b/js/jquery.tablesorter.min.js index d07c802..4ffbe95 100644 --- a/js/jquery.tablesorter.min.js +++ b/js/jquery.tablesorter.min.js @@ -6,7 +6,7 @@ var yourls_defaultorder = 1; // default order ('asc':0, 'desc':1) to sort on (ov // Initialise the table to sort $(document).ready(function(){ - if ($("#tblUrl").tablesorter && $("#tblUrl tr.nourl_found").length != 1) { + if ($("#tblUrl").tablesorter && $("#tblUrl tr#nourl_found").length != 1) { var order = {'id':0, 'url':1, 'timestamp':2, 'ip':3, 'clicks':4}; var order_by = {'asc':0, 'desc':1}; var s_by = order[query_string('s_by')]; -- 2.45.0