diff options
author | Jayaram Pai | 2014-05-03 18:22:10 +0530 |
---|---|---|
committer | Jayaram Pai | 2014-05-03 18:22:10 +0530 |
commit | 0a8b9fd4976f5d67c2b9701eb52ac4c6a309eec7 (patch) | |
tree | 98b04670483694ab7a5e6eb044902957eda8b273 /static/website/js/custom.js | |
parent | 0e54a7e22115e1d6437c5be6991a08054dfc052a (diff) | |
download | FOSSEE-Forum-0a8b9fd4976f5d67c2b9701eb52ac4c6a309eec7.tar.gz FOSSEE-Forum-0a8b9fd4976f5d67c2b9701eb52ac4c6a309eec7.tar.bz2 FOSSEE-Forum-0a8b9fd4976f5d67c2b9701eb52ac4c6a309eec7.zip |
added General FOSS category, fixed user-login
Diffstat (limited to 'static/website/js/custom.js')
-rw-r--r-- | static/website/js/custom.js | 100 |
1 files changed, 70 insertions, 30 deletions
diff --git a/static/website/js/custom.js b/static/website/js/custom.js index 49b4053..5565683 100644 --- a/static/website/js/custom.js +++ b/static/website/js/custom.js @@ -4,45 +4,86 @@ $(document).ready(function() { $minute_range = $("#id_minute_range"); $second_range = $("#id_second_range"); + function reset() { + for (var i = 0, l = arguments.length; i < l; i ++) { + switch(arguments[i]) { + case "tutorial": + $tutorial.html("<option value='None'>Select a Tutorial</option>"); + $tutorial.attr("disabled", true); + break; + + case "minute_range": + $minute_range.html("<option value='None'>min</option>"); + $minute_range.attr("disabled", true); + break; + + case "second_range": + $second_range.html("<option value='None'>sec</option>"); + $second_range.attr("disabled", true); + break; + + } + } + } + $category.change(function() { $("#similar-link").hide(); - var category = $(this).val(); + /* resetting dropdowns */ + reset("tutorial", "minute_range", "second_range"); /* see thread-user.js */ $("#question-details-ok").show(); - $.ajax({ - url: "/ajax-tutorials/", - type: "POST", - data: { - category: category - }, - success: function(data) { - $("#id_tutorial").html(data); - $("#id_tutorial").removeAttr("disabled"); - console.log("response = " + data); - } - }); + var category = $(this).val(); + if(category == "General") { + /* disabling all other fields */ + $tutorial.html("<option value='None'>Not required</option>"); + $tutorial.removeAttr("disabled"); + $minute_range.html("<option value='None'>Not required</option>"); + $minute_range.removeAttr("disabled"); + $second_range.html("<option value='None'>Not required</option>"); + $second_range.removeAttr("disabled"); + } else { + $.ajax({ + url: "/ajax-tutorials/", + type: "POST", + data: { + category: category + }, + success: function(data) { + $("#id_tutorial").html(data); + $("#id_tutorial").removeAttr("disabled"); + } + }); + } }); $tutorial.change(function() { - console.log("tut changed"); + /* resetting dropdowns */ + reset("minute_range", "second_range"); var category = $category.val(); var tutorial = $(this).val(); - $.ajax({ - url: "/ajax-duration/", - type: "POST", - data: { - category: category, + if(tutorial == "General") { + /* disabling all other fields */ + $minute_range.html("<option value='None'>Not required</option>"); + $minute_range.removeAttr("disabled"); + $second_range.html("<option value='None'>Not required</option>"); + $second_range.removeAttr("disabled"); + } else { + $.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"); - } - }); + }, + success: function(data){ + var $response = $(data); + $minute_range.html($response.find("#minutes").html()) + $minute_range.removeAttr("disabled"); + $second_range.html($response.find("#seconds").html()) + $second_range.removeAttr("disabled"); + } + }); + } }); $second_range.change(function() { @@ -57,7 +98,6 @@ $(document).ready(function() { }, dataType: "html", success: function(data) { - console.log(data); $response = $(data); var similar_count= $response.find("#similar-count").text(); $("#similar-link").show().html(similar_count); |