summaryrefslogtreecommitdiff
path: root/static/website/js/custom.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/website/js/custom.js')
-rw-r--r--static/website/js/custom.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/static/website/js/custom.js b/static/website/js/custom.js
new file mode 100644
index 0000000..20801f6
--- /dev/null
+++ b/static/website/js/custom.js
@@ -0,0 +1,44 @@
+$(document).ready(function() {
+ $category = $("#id_category");
+ $tutorial = $("#id_tutorial");
+ $minute_range = $("#id_minute_range");
+ $second_range = $("#id_second_range");
+
+ $category.change(function() {
+ var category = $(this).val();
+ $.ajax({
+ url: "/ajax-tutorials/",
+ type: "POST",
+ data: {
+ category: category
+ },
+ success: function(data) {
+ $("#id_tutorial").html(data);
+ $("#id_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");
+ }
+ });
+ });
+});