diff options
author | Jayaram Pai | 2013-12-17 12:02:11 +0530 |
---|---|---|
committer | Jayaram Pai | 2013-12-17 12:02:11 +0530 |
commit | 2dbeb37d3b4ff113a2bfb881b5d1df6787bc8157 (patch) | |
tree | c3dc0f2b632f5be704a3ecf4d0d2bcc1cce6e849 /static/website/js/search.js | |
parent | 3a680b5d2442268ab117c0f98f21a039d4544bd8 (diff) | |
download | FOSSEE-Forum-2dbeb37d3b4ff113a2bfb881b5d1df6787bc8157.tar.gz FOSSEE-Forum-2dbeb37d3b4ff113a2bfb881b5d1df6787bc8157.tar.bz2 FOSSEE-Forum-2dbeb37d3b4ff113a2bfb881b5d1df6787bc8157.zip |
basic keyword/time search implemented
Diffstat (limited to 'static/website/js/search.js')
-rw-r--r-- | static/website/js/search.js | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/static/website/js/search.js b/static/website/js/search.js new file mode 100644 index 0000000..5973e79 --- /dev/null +++ b/static/website/js/search.js @@ -0,0 +1,91 @@ +$(document).ready(function() { + $search_key = $("#search-key"); + $search_key_submit = $("#search-key-submit"); + $keyword_search_results = $("#keyword-search-results"); + + $search_key.keyup(function(e) { + if(e.keyCode == 13) { + $search_key_submit.click(); + } + }); + + $search_key_submit.click(function() { + var key = $search_key.val(); + $.ajax({ + url: "/ajax-keyword-search/", + type: "POST", + data: { + key: key + }, + dataType: "html", + success: function(data) { + $keyword_search_results.html(data); + console.log(data); + } + }); + }); + + $search_time_submit = $("#search-time-submit"); + $category = $("#search-category"); + $tutorial = $("#search-tutorial"); + $minute_range = $("#search-minute-range"); + $second_range = $("#search-second-range"); + $time_search_results = $("#time-search-results"); + + $category.change(function() { + var category = $(this).val(); + $.ajax({ + url: "/ajax-tutorials/", + type: "POST", + data: { + category: category + }, + success: function(data) { + $tutorial.html(data); + $tutorial.removeAttr("disabled"); + console.log("response = " + data); + } + }); + }); + + $tutorial.change(function() { + console.log("tut changed"); + var category = $category.val(); + var tutorial = $(this).val(); + $.ajax({ + url: "/ajax-duration/", + type: "POST", + data: { + category: category, + tutorial: tutorial + }, + success: function(data){ + var $response = $(data); + console.log($response.html()); + $minute_range.html($response.find("#minutes").html()) + $minute_range.removeAttr("disabled"); + $second_range.html($response.find("#seconds").html()) + $second_range.removeAttr("disabled"); + } + }); + }); + + $search_time_submit.click(function() { + $.ajax({ + url: "/ajax-time-search/", + type: "POST", + data: { + category: $category.val(), + tutorial: $tutorial.val(), + minute_range: $minute_range.val(), + second_range: $second_range.val() + }, + dataType: "html", + success: function(data) { + console.log(data); + $time_search_results.html(data); + } + }); + }); + +}); |