From da2dbe899c90a77372a62c7795d4a0f4f15742a3 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Wed, 1 Jan 2020 18:22:22 +0530 Subject: added book search feature --- website/static/website/js/cloud.js | 21 ++++++-- website/static/website/templates/index.html | 29 +++++++--- website/views.py | 82 +++++++++++++++++++++-------- 3 files changed, 99 insertions(+), 33 deletions(-) diff --git a/website/static/website/js/cloud.js b/website/static/website/js/cloud.js index 43f035f..f2f7f19 100644 --- a/website/static/website/js/cloud.js +++ b/website/static/website/js/cloud.js @@ -905,6 +905,21 @@ $(document.body).ready(function() { }); }); /********************************************/ + /********************************************/ + /********************************************/ + /********* search feature *******************/ + /********************************************/ + $(document).on("change", "input[type=radio][name=optradio]", function() { + if (this.value == 'bybook') { + $("#searched_code").hide(); + $("#searched_book").show(); + } + else if (this.value == 'bycode') { + $("#searched_code").show(); + $("#searched_book").hide(); + } + }); + /********************************************/ $(document).on("click", "#search", function() { ajax_loader(this); $("#relevant").html(''); @@ -923,7 +938,7 @@ $(document.body).ready(function() { $("#relevant").html('

Relevant


'); for (var i = 0; i < data.length; i++) { $("#relevant").append( - '' + data[i].book + + '' + data[i].book + ' (Author: ' + data[i].author + ')
'); } @@ -986,7 +1001,7 @@ $(document.body).ready(function() { $("#popular").html('

Popular


'); for (var i = 0; i < data.length; i++) { $("#popular").append( - '' + data[i].book + + '' + data[i].book + ' (Author: ' + data[i].author + ')
'); } ajax_loader("clear"); @@ -1003,7 +1018,7 @@ $(document.body).ready(function() { $("#recent").html('

Recent


'); for (var i = 0; i < data.length; i++) { $("#recent").append( - '' + data[i].book + + '' + data[i].book + ' (Author: ' + data[i].author + ')
'); } ajax_loader("clear"); diff --git a/website/static/website/templates/index.html b/website/static/website/templates/index.html index 18dd01b..27dbca9 100644 --- a/website/static/website/templates/index.html +++ b/website/static/website/templates/index.html @@ -45,9 +45,9 @@