summaryrefslogtreecommitdiff
path: root/js/tbc-download.js
diff options
context:
space:
mode:
authorSanmugasundaram K2015-05-05 15:49:04 +0530
committertslee2015-05-05 15:49:15 +0530
commit15607e40125914b1aede981fea9c587e6a136e21 (patch)
tree99bc583ff334098f9a249d106e788d8b51ab3d7c /js/tbc-download.js
parent1a548df4a2ec5a1ad6a8d4aa7a1d1afff63cd036 (diff)
downloadscilab_textbook_companion-15607e40125914b1aede981fea9c587e6a136e21.tar.gz
scilab_textbook_companion-15607e40125914b1aede981fea9c587e6a136e21.tar.bz2
scilab_textbook_companion-15607e40125914b1aede981fea9c587e6a136e21.zip
removed ahah helper and updated code with jquery
Diffstat (limited to 'js/tbc-download.js')
-rw-r--r--js/tbc-download.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/js/tbc-download.js b/js/tbc-download.js
new file mode 100644
index 0000000..04b7633
--- /dev/null
+++ b/js/tbc-download.js
@@ -0,0 +1,117 @@
+$(document).ready(function(){
+ //webroot = "http://"+location.hostname+"/";
+ webroot = Drupal.settings.basePath;
+ $('.tbc-category').live('change', function(){
+ tbc_category = $('.tbc-category').val();
+ $('.tbc-book-overall').css({'display' : 'none'});
+ if(tbc_category != 0) {
+ $.ajax({
+ type : 'POST',
+ url : webroot + "textbook_run_ajax",
+ data : {
+ 'category' : tbc_category
+ },
+ beforeSend: function() {
+ },
+ success : function(data) {
+ output = JSON.parse(data);
+ console.log(output['books']);
+ html_data = '';
+ $.each( output['books'], function( key, value ) {
+ html_data += "<option value='"+ key +"'>" + value + "</option>";
+ });
+ $('.tbc-book').html(html_data);
+ $('.tbc-book-main').css({'display' : 'block'});
+ }
+ });
+ }
+ });
+
+ $('.tbc-book').live('change', function(){
+ tbc_category = $('.tbc-category').val();
+ tbc_book = $('.tbc-book').val();
+ $('.tbc-after-book').css({'display' : 'none'});
+ if(tbc_category != 0 && tbc_book != 0) {
+ $.ajax({
+ type : 'POST',
+ url : webroot + "textbook_run_ajax",
+ data : {
+ 'category' : tbc_category,
+ 'book' : tbc_book
+ },
+ beforeSend: function() {
+ },
+ success : function(data){
+ output = JSON.parse(data);
+ $('.tbc-book-details').html(output['details']);
+ $('.tbc-book-download').html(output['download']);
+ $('.tbc-book-download-pdf').html(output['downloadpdf']);
+ html_data = '';
+ $.each( output['chapters'], function( key, value ) {
+ html_data += "<option value='"+ key +"'>" + value + "</option>";
+ });
+ $('.tbc-chapter').html(html_data);
+ $('.tbc-book-block').css({'display' : 'block'});
+ }
+ });
+ }
+ });
+
+ $('.tbc-chapter').live('change', function(){
+ tbc_category = $('.tbc-category').val();
+ tbc_book = $('.tbc-book').val();
+ tbc_chapter = $('.tbc-chapter').val();
+ $('.tbc-after-chapter').css({'display' : 'none'});
+ if(tbc_category != 0 && tbc_book != 0 && tbc_chapter != 0) {
+ $.ajax({
+ type : 'POST',
+ url : webroot + "textbook_run_ajax",
+ data : {
+ 'category' : tbc_category,
+ 'book' : tbc_book,
+ 'chapter': tbc_chapter
+ },
+ beforeSend: function() {
+ },
+ success : function(data){
+ output = JSON.parse(data);
+ $('.tbc-chapter-download').html(output['download']);
+ html_data = '';
+ $.each( output['examples'], function( key, value ) {
+ html_data += "<option value='"+ key +"'>" + value + "</option>";
+ });
+ $('.tbc-example').html(html_data);
+ $('.tbc-chapter-block').css({'display' : 'block'});
+ }
+ });
+ }
+ });
+
+ $('.tbc-example').live('change', function(){
+ tbc_category = $('.tbc-category').val();
+ tbc_book = $('.tbc-book').val();
+ tbc_chapter = $('.tbc-chapter').val();
+ tbc_example = $('.tbc-example').val();
+ $('.tbc-after-example').css({'display' : 'none'});
+ if(tbc_category != 0 && tbc_book != 0 && tbc_chapter != 0 && tbc_example != 0) {
+ $.ajax({
+ type : 'POST',
+ url : webroot + "textbook_run_ajax",
+ data : {
+ 'category' : tbc_category,
+ 'book' : tbc_book,
+ 'chapter': tbc_chapter,
+ 'example': tbc_example
+ },
+ beforeSend: function() {
+ },
+ success : function(data){
+ output = JSON.parse(data);
+ $('.tbc-example-download').html(output['download']);
+ $('.tbc-example-files').html(output['files']);
+ $('.tbc-after-example').css({'display' : 'block'});
+ }
+ });
+ }
+ });
+});