diff --git a/static/index.html b/static/index.html
index 2608ba1..3012276 100644
--- a/static/index.html
+++ b/static/index.html
@@ -1881,6 +1881,13 @@
get_search_channel(1)
})
+ $('#input_search').on('keypress', function(e){
+ if (e.which === 13) {
+ e.preventDefault();
+ get_search_channel(1);
+ }
+ })
+
$('#btn_initdb').click(function(){
$.get('init_db').done(function(data){
window.location.href = "/"
@@ -2065,17 +2072,26 @@
function get_search_channel(num_page) {
var keyword = $('#input_search').val()
if (keyword.length>0) {
+ $('#pagination-container').empty();
+ $('#listChannels').show().html('
Searching...
');
$.post('list_channel', {keyword:encodeURIComponent(keyword), num_page:num_page}).done(function(payload){
- $('#list_channels').html('')
- var html =''
num_total_page = payload.num_total_page
current_page = payload.current_page
result_search = payload.data
console.log(num_total_page, current_page)
- renderPagination(num_total_page, current_page);
+ if (!result_search || result_search.length === 0) {
+ $('#pagination-container').empty();
+ $('#listChannels').html('No channels found.
');
+ return;
+ }
+
+ renderPagination(num_total_page, current_page);
displayResult()
- lazyLoad();
+ lazyLoad();
+ }).fail(function(){
+ $('#pagination-container').empty();
+ $('#listChannels').html('Search failed. Please try again.
');
})
}
}