summaryrefslogtreecommitdiff
path: root/website/static/website/js/cloud.js
diff options
context:
space:
mode:
authorPrashant S2020-01-21 17:05:37 +0530
committerGitHub2020-01-21 17:05:37 +0530
commitc21b2a1ea7da8acef0a20a038f15242c1a92b96e (patch)
tree67cdadfa8003f50cec54e9f0dbf52f6658775adb /website/static/website/js/cloud.js
parent70b858a38b53c23bca3c905822f70dc37a14dbb9 (diff)
parentb28d11ad794c3ed438e42a232dc1bd42ab1691ff (diff)
downloadR_on_Cloud_Web_Interface-c21b2a1ea7da8acef0a20a038f15242c1a92b96e.tar.gz
R_on_Cloud_Web_Interface-c21b2a1ea7da8acef0a20a038f15242c1a92b96e.tar.bz2
R_on_Cloud_Web_Interface-c21b2a1ea7da8acef0a20a038f15242c1a92b96e.zip
Merge pull request #9 from prashantsinalkar/master
added solr code search
Diffstat (limited to 'website/static/website/js/cloud.js')
-rw-r--r--website/static/website/js/cloud.js72
1 files changed, 58 insertions, 14 deletions
diff --git a/website/static/website/js/cloud.js b/website/static/website/js/cloud.js
index 43f035f..9a632e7 100644
--- a/website/static/website/js/cloud.js
+++ b/website/static/website/js/cloud.js
@@ -905,10 +905,27 @@ $(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('');
var search_string = jQuery.trim($("#search-input").val());
+ if(search_string != ''){
+ if($("input[name='optradio']:checked").val() == 'bybook'){
+ $("#relevant").html('');
if (search_string == '') {
search_string = 'Null';
}
@@ -920,13 +937,17 @@ $(document.body).ready(function() {
search_string: search_string,
},
success: function(data) {
+ if(data.length > 0 ){
$("#relevant").html('<h2>Relevant</h2><hr>');
for (var i = 0; i < data.length; i++) {
$("#relevant").append(
- '<a href="?book_id=' + data[i].ids + '" class="">' + data[i].book +
+ '<a href="?book_id=' + data[i].id + '" class="">' + data[i].book +
' (Author: ' + data[i].author + ')</a><hr>');
}
+ }else{
+ $("#relevant").append('Oops! This book is not availabe!');
+ }
ajax_loader("clear");
}
}),
@@ -946,7 +967,6 @@ $(document.body).ready(function() {
}
ajax_loader("clear");
}
-
}),
$.ajax({
url: 'search_book/recent/',
@@ -962,9 +982,33 @@ $(document.body).ready(function() {
'<a href="?book_id=' + data[i].ids + '" class="">' + data[i].book +
' (Author: ' + data[i].author + ')</a><hr>');
}
- ajax_loader("clear");
}
});
+ } else{
+ ajax_loader(this);
+ $.ajax({
+ url: 'search_in_code/',
+ dataType: 'JSON',
+ type: 'GET',
+ data: {
+ search_string: search_string,
+ },
+ success: function(data) {
+ if(data.error != 'True'){
+ console.log(data.data);
+ $("#searched_code_data").html("");
+ $("#searched_code").html(data.data);
+ }else{
+ alert("Oops! Search engine is away, please try after some time!")
+ }
+ }
+ });
+ ajax_loader("clear");
+ }
+ }else{
+ alert("Please enter the search string!");
+ }
+ ajax_loader("clear");
});
$(document).on("click", "#search_book", function(e) {
@@ -986,7 +1030,7 @@ $(document.body).ready(function() {
$("#popular").html('<h2>Popular</h2><hr>');
for (var i = 0; i < data.length; i++) {
$("#popular").append(
- '<a href="?book_id=' + data[i].ids + '" class="">' + data[i].book +
+ '<a href="?book_id=' + data[i].id + '" class="">' + data[i].book +
' (Author: ' + data[i].author + ')</a><hr>');
}
ajax_loader("clear");
@@ -1003,7 +1047,7 @@ $(document.body).ready(function() {
$("#recent").html('<h2>Recent</h2><hr>');
for (var i = 0; i < data.length; i++) {
$("#recent").append(
- '<a href="?book_id=' + data[i].ids + '" class="">' + data[i].book +
+ '<a href="?book_id=' + data[i].id + '" class="">' + data[i].book +
' (Author: ' + data[i].author + ')</a><hr>');
}
ajax_loader("clear");
@@ -1068,14 +1112,14 @@ function doSubmit(){
}
function checkserver(){
-
- $.ajax({url: api_url,
- dataType: "jsonp",
- statusCode: {
- 404: function (response) {
- alert("Oops! R cloud server is not available, please try after some time");
- }
- }
+ $.ajax({url: 'check_server/',
+ dataType: "json",
+ success : function (data) {
+ if((data.status == 200) || (data.error != 'True')){
+ }else{
+ alert("R cloud server is not available, please try after some time");
+ }
+ }
});
}