From 8fc6df7a0121ac49750b598de10f0e2d2a323ca3 Mon Sep 17 00:00:00 2001 From: Jayaram Pai Date: Sat, 26 Apr 2014 14:54:09 +0530 Subject: initial commit --- js/scilab_fixer.js | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 js/scilab_fixer.js (limited to 'js') diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js new file mode 100644 index 0000000..43450f3 --- /dev/null +++ b/js/scilab_fixer.js @@ -0,0 +1,117 @@ +$(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "fix/"; + + $category = $("#fix-caption-form #edit-category"); + $book = $("#fix-caption-form #edit-book"); + $chapter = $("#fix-caption-form #edit-chapter"); + $example = $("#fix-caption-form #edit-example"); + $caption = $("#fix-caption-form #edit-caption"); + $code = $("#fix-caption-form #fix-caption-code"); + $form = $("#scilab-fixer-caption-form"); + $updating = $("#fix-caption-page #updating"); + $done = $("#fix-caption-page #done"); + + function reset() { + for (var i = 0, l = arguments.length; i < l; i ++) { + switch(arguments[i]) { + case "book": + $book.html("<option value='0'>Please select a book</option>"); + break; + + case "chapter": + $chapter.html("<option value='0'>Please select a chapter</option>"); + break; + + case "example": + $example.html("<option value='0'>Please select a example</option>"); + break; + + } + } + } + + $category.change(function() { + reset("book", "chapter", "example"); + var category_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/category/" + category_id, + type: "POST", + dataType: "html", + success: function(data) { + $book.html(data); + } + }); + }); + + $book.change(function() { + reset("chapter", "example"); + var book_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/book/" + book_id, + type: "POST", + dataType: "html", + success: function(data) { + $chapter.html(data); + } + }); + }); + + $chapter.change(function() { + reset("example"); + var chapter_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/chapter/" + chapter_id, + type: "POST", + dataType: "html", + success: function(data) { + $example.html(data); + } + }); + }); + + $example.change(function() { + var example_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/example/" + example_id, + type: "POST", + dataType: "html", + success: function(data) { + var code = $(data).filter("#code").html(); + $code.html(code); + var caption = $(data).filter("#caption").html(); + $caption.val(caption); + } + }); + }); + + $form.submit(function(e) { + var example_id = $example.val(); + if(example_id != "0") { + var caption = $caption.val(); + $updating.show(); + $.ajax({ + url: modPath + "ajax/update/", + type: "POST", + data: { + example_id: example_id, + caption: caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); +}); -- cgit From 82d8e9a665e5f1f64a03b4d8e33688d275a74daa Mon Sep 17 00:00:00 2001 From: Jayaram Pai Date: Sat, 26 Apr 2014 16:27:44 +0530 Subject: added caption reset on example change --- js/scilab_fixer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js index 43450f3..ef05611 100644 --- a/js/scilab_fixer.js +++ b/js/scilab_fixer.js @@ -27,12 +27,16 @@ $(document).ready(function() { $example.html("<option value='0'>Please select a example</option>"); break; + case "caption": + $caption.val(""); + break; + } } } $category.change(function() { - reset("book", "chapter", "example"); + reset("book", "chapter", "example", "caption"); var category_id = $(this).val(); $.ajax({ @@ -46,7 +50,7 @@ $(document).ready(function() { }); $book.change(function() { - reset("chapter", "example"); + reset("chapter", "example", "caption"); var book_id = $(this).val(); $.ajax({ @@ -60,7 +64,7 @@ $(document).ready(function() { }); $chapter.change(function() { - reset("example"); + reset("example", "caption"); var chapter_id = $(this).val(); $.ajax({ @@ -75,6 +79,7 @@ $(document).ready(function() { $example.change(function() { var example_id = $(this).val(); + reset("caption"); $.ajax({ url: modPath + "ajax/example/" + example_id, -- cgit From 3c2681e374383438a84009edbe96b9501c67b25f Mon Sep 17 00:00:00 2001 From: Jayaram Pai Date: Tue, 29 Apr 2014 08:38:53 +0530 Subject: added feature to auto populate caption on select code text --- js/scilab_fixer.js | 1 + js/selection.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 js/selection.js (limited to 'js') diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js index ef05611..8236099 100644 --- a/js/scilab_fixer.js +++ b/js/scilab_fixer.js @@ -11,6 +11,7 @@ $(document).ready(function() { $form = $("#scilab-fixer-caption-form"); $updating = $("#fix-caption-page #updating"); $done = $("#fix-caption-page #done"); + $example.attr("multiple", "enabled"); function reset() { for (var i = 0, l = arguments.length; i < l; i ++) { diff --git a/js/selection.js b/js/selection.js new file mode 100644 index 0000000..fcb738b --- /dev/null +++ b/js/selection.js @@ -0,0 +1,26 @@ +function getSelectionText(divID) { + var selectedText = ""; + if (window.getSelection) { + var sel = window.getSelection(); + var div = document.getElementById(divID); + + if (sel.rangeCount) { + // Get the selected range + var range = sel.getRangeAt(0); + // Check that the selection is wholly contained within the div text + // if (range.commonAncestorContainer == div.firstChild) { + var selectedText = range.toString(); + // } + } + } + return selectedText; +} +$(document).ready(function() { + $("#fix-caption-code").mousedown(function() { + $("#edit-caption").val(""); + }); + $("#fix-caption-code").mouseup(function() { + quotedText = getSelectionText("#fix-caption-code"); + $("#edit-caption").val(quotedText); + }); +}); -- cgit From b05847459755de88ad638973d4f351883fd00d51 Mon Sep 17 00:00:00 2001 From: Jayaram R Pai Date: Mon, 4 Aug 2014 16:16:18 +0530 Subject: added page to edit example code --- js/scilab_fixer.js | 62 ++++++++++++++++++++++++++++++++++++++++++------------ js/selection.js | 4 ++-- 2 files changed, 50 insertions(+), 16 deletions(-) (limited to 'js') diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js index 8236099..9148603 100644 --- a/js/scilab_fixer.js +++ b/js/scilab_fixer.js @@ -2,15 +2,16 @@ $(document).ready(function() { var basePath = Drupal.settings.basePath; var modPath = basePath + "fix/"; - $category = $("#fix-caption-form #edit-category"); - $book = $("#fix-caption-form #edit-book"); - $chapter = $("#fix-caption-form #edit-chapter"); - $example = $("#fix-caption-form #edit-example"); - $caption = $("#fix-caption-form #edit-caption"); - $code = $("#fix-caption-form #fix-caption-code"); - $form = $("#scilab-fixer-caption-form"); - $updating = $("#fix-caption-page #updating"); - $done = $("#fix-caption-page #done"); + $category = $("#fix-tbc-form #edit-category"); + $book = $("#fix-tbc-form #edit-book"); + $chapter = $("#fix-tbc-form #edit-chapter"); + $example = $("#fix-tbc-form #edit-example"); + $caption = $("#fix-tbc-form #edit-caption"); + $code = $("#fix-tbc-form #edit-code"); + $caption_form = $("#scilab-fixer-caption-form"); + $code_form = $("#scilab-fixer-code-form"); + $updating = $("#fix-tbc-page #updating"); + $done = $("#fix-tbc-page #done"); $example.attr("multiple", "enabled"); function reset() { @@ -81,21 +82,30 @@ $(document).ready(function() { $example.change(function() { var example_id = $(this).val(); reset("caption"); - + console.log("########" + example_id); $.ajax({ url: modPath + "ajax/example/" + example_id, type: "POST", dataType: "html", success: function(data) { var code = $(data).filter("#code").html(); - $code.html(code); + /* checking whether it is for .well or textarea */ + if($code.hasClass("fix-caption-code")) { + $code.html(code); + } else { + $code.val(code); + } var caption = $(data).filter("#caption").html(); - $caption.val(caption); + try { + $caption.val(caption); + } catch(e) { + return; + } } }); }); - $form.submit(function(e) { + $caption_form.submit(function(e) { var example_id = $example.val(); if(example_id != "0") { var caption = $caption.val(); @@ -105,7 +115,31 @@ $(document).ready(function() { type: "POST", data: { example_id: example_id, - caption: caption + caption: caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + + $code_form.submit(function(e) { + var example_id = $example.val(); + if(example_id != "0") { + var code = $code.val(); + $.ajax({ + url: modPath + "ajax/code/" + example_id, + type: "POST", + data: { + code: code }, dataType: "html", success: function(data) { diff --git a/js/selection.js b/js/selection.js index fcb738b..6834aca 100644 --- a/js/selection.js +++ b/js/selection.js @@ -16,10 +16,10 @@ function getSelectionText(divID) { return selectedText; } $(document).ready(function() { - $("#fix-caption-code").mousedown(function() { + $(".fix-caption-code").mousedown(function() { $("#edit-caption").val(""); }); - $("#fix-caption-code").mouseup(function() { + $(".fix-caption-code").mouseup(function() { quotedText = getSelectionText("#fix-caption-code"); $("#edit-caption").val(quotedText); }); -- cgit From 6ea7167991f5c9a8c87fffbda8a8513e965f15b0 Mon Sep 17 00:00:00 2001 From: Jayaram R Pai Date: Tue, 12 Aug 2014 12:27:33 +0530 Subject: added page to mark indian edition aicte books --- js/scilab_fixer.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'js') diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js index 9148603..b48832e 100644 --- a/js/scilab_fixer.js +++ b/js/scilab_fixer.js @@ -154,4 +154,30 @@ $(document).ready(function() { } e.preventDefault(); }); + + /* toggle in edition */ + $ind_ed = $(".ind-ed"); + + $ind_ed.click(function(e) { + var aicte_id = $(this).attr("data-aicte"); + $t = $(this); + $.ajax({ + url: modPath + "ajax/ind-ed/" + aicte_id, + type: "GET", + dataType: "html", + success: function(data) { + $tr = $t.parents("tr:first"); + if($tr.hasClass("orange")) { + $t.parents("tr:first").removeClass("orange"); + $t.html("Mark"); + } else { + $t.parents("tr:first").addClass("orange"); + $t.html("Unmark"); + } + console.log(data); + }, + }); + e.preventDefault(); + }); + }); -- cgit From 3b4dd560d5b3a763921724ee091382ca2bbaf8ab Mon Sep 17 00:00:00 2001 From: prashant Date: Thu, 25 Sep 2014 15:14:21 +0530 Subject: added aicte book disable eanble functionaty --- js/scilab_fixer.js | 17 +++++++++++++++++ js/selection.js | 0 2 files changed, 17 insertions(+) mode change 100644 => 100755 js/scilab_fixer.js mode change 100644 => 100755 js/selection.js (limited to 'js') diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js old mode 100644 new mode 100755 index b48832e..657cb61 --- a/js/scilab_fixer.js +++ b/js/scilab_fixer.js @@ -1,6 +1,9 @@ $(document).ready(function() { var basePath = Drupal.settings.basePath; var modPath = basePath + "fix/"; + var modPath1 = basePath + "fix/aicte/book/"; + + $category = $("#fix-tbc-form #edit-category"); $book = $("#fix-tbc-form #edit-book"); @@ -155,6 +158,20 @@ $(document).ready(function() { e.preventDefault(); }); +$Selected = $(".selected"); + $Selected.click(function (e) { + $(".sync-msg").remove(); + $(this).after("<span class='sync-msg'>Saving...</span>"); + $.ajax({ + url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), + success: function() { + $(".sync-msg").remove(); + console.log ("success"); + } + }); + + }); + /* toggle in edition */ $ind_ed = $(".ind-ed"); diff --git a/js/selection.js b/js/selection.js old mode 100644 new mode 100755 -- cgit From ff3c6b954dfa626b1261d38227941b27f52a3255 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Thu, 1 Sep 2016 14:38:29 +0530 Subject: changed css and js --- js/scilab_fixer.js | 200 ----------------------------------------------------- 1 file changed, 200 deletions(-) delete mode 100755 js/scilab_fixer.js (limited to 'js') diff --git a/js/scilab_fixer.js b/js/scilab_fixer.js deleted file mode 100755 index 657cb61..0000000 --- a/js/scilab_fixer.js +++ /dev/null @@ -1,200 +0,0 @@ -$(document).ready(function() { - var basePath = Drupal.settings.basePath; - var modPath = basePath + "fix/"; - var modPath1 = basePath + "fix/aicte/book/"; - - - - $category = $("#fix-tbc-form #edit-category"); - $book = $("#fix-tbc-form #edit-book"); - $chapter = $("#fix-tbc-form #edit-chapter"); - $example = $("#fix-tbc-form #edit-example"); - $caption = $("#fix-tbc-form #edit-caption"); - $code = $("#fix-tbc-form #edit-code"); - $caption_form = $("#scilab-fixer-caption-form"); - $code_form = $("#scilab-fixer-code-form"); - $updating = $("#fix-tbc-page #updating"); - $done = $("#fix-tbc-page #done"); - $example.attr("multiple", "enabled"); - - function reset() { - for (var i = 0, l = arguments.length; i < l; i ++) { - switch(arguments[i]) { - case "book": - $book.html("<option value='0'>Please select a book</option>"); - break; - - case "chapter": - $chapter.html("<option value='0'>Please select a chapter</option>"); - break; - - case "example": - $example.html("<option value='0'>Please select a example</option>"); - break; - - case "caption": - $caption.val(""); - break; - - } - } - } - - $category.change(function() { - reset("book", "chapter", "example", "caption"); - var category_id = $(this).val(); - - $.ajax({ - url: modPath + "ajax/category/" + category_id, - type: "POST", - dataType: "html", - success: function(data) { - $book.html(data); - } - }); - }); - - $book.change(function() { - reset("chapter", "example", "caption"); - var book_id = $(this).val(); - - $.ajax({ - url: modPath + "ajax/book/" + book_id, - type: "POST", - dataType: "html", - success: function(data) { - $chapter.html(data); - } - }); - }); - - $chapter.change(function() { - reset("example", "caption"); - var chapter_id = $(this).val(); - - $.ajax({ - url: modPath + "ajax/chapter/" + chapter_id, - type: "POST", - dataType: "html", - success: function(data) { - $example.html(data); - } - }); - }); - - $example.change(function() { - var example_id = $(this).val(); - reset("caption"); - console.log("########" + example_id); - $.ajax({ - url: modPath + "ajax/example/" + example_id, - type: "POST", - dataType: "html", - success: function(data) { - var code = $(data).filter("#code").html(); - /* checking whether it is for .well or textarea */ - if($code.hasClass("fix-caption-code")) { - $code.html(code); - } else { - $code.val(code); - } - var caption = $(data).filter("#caption").html(); - try { - $caption.val(caption); - } catch(e) { - return; - } - } - }); - }); - - $caption_form.submit(function(e) { - var example_id = $example.val(); - if(example_id != "0") { - var caption = $caption.val(); - $updating.show(); - $.ajax({ - url: modPath + "ajax/update/", - type: "POST", - data: { - example_id: example_id, - caption: caption - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - } - }); - } else { - alert("No example selected.") - } - e.preventDefault(); - }); - - $code_form.submit(function(e) { - var example_id = $example.val(); - if(example_id != "0") { - var code = $code.val(); - $.ajax({ - url: modPath + "ajax/code/" + example_id, - type: "POST", - data: { - code: code - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - } - }); - } else { - alert("No example selected.") - } - e.preventDefault(); - }); - -$Selected = $(".selected"); - $Selected.click(function (e) { - $(".sync-msg").remove(); - $(this).after("<span class='sync-msg'>Saving...</span>"); - $.ajax({ - url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), - success: function() { - $(".sync-msg").remove(); - console.log ("success"); - } - }); - - }); - - /* toggle in edition */ - $ind_ed = $(".ind-ed"); - - $ind_ed.click(function(e) { - var aicte_id = $(this).attr("data-aicte"); - $t = $(this); - $.ajax({ - url: modPath + "ajax/ind-ed/" + aicte_id, - type: "GET", - dataType: "html", - success: function(data) { - $tr = $t.parents("tr:first"); - if($tr.hasClass("orange")) { - $t.parents("tr:first").removeClass("orange"); - $t.html("Mark"); - } else { - $t.parents("tr:first").addClass("orange"); - $t.html("Unmark"); - } - console.log(data); - }, - }); - e.preventDefault(); - }); - -}); -- cgit From ca575c7aa48ad85669cf04957d5e4de3d8a27c2c Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Thu, 1 Sep 2016 14:39:48 +0530 Subject: added renamed files --- js/textbook_companion_fixer.js | 202 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100755 js/textbook_companion_fixer.js (limited to 'js') diff --git a/js/textbook_companion_fixer.js b/js/textbook_companion_fixer.js new file mode 100755 index 0000000..7a7e3fe --- /dev/null +++ b/js/textbook_companion_fixer.js @@ -0,0 +1,202 @@ +(function ($) { +$(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "fix/"; + var modPath1 = basePath + "fix/aicte/book/"; + + + + $category = $("#fix-tbc-form #edit-category"); + $book = $("#fix-tbc-form #edit-book"); + $chapter = $("#fix-tbc-form #edit-chapter"); + $example = $("#fix-tbc-form #edit-example"); + $caption = $("#fix-tbc-form #edit-caption"); + $code = $("#fix-tbc-form #edit-code"); + $caption_form = $("#scilab-fixer-caption-form"); + $code_form = $("#scilab-fixer-code-form"); + $updating = $("#fix-tbc-page #updating"); + $done = $("#fix-tbc-page #done"); + $example.attr("multiple", "enabled"); + + function reset() { + for (var i = 0, l = arguments.length; i < l; i ++) { + switch(arguments[i]) { + case "book": + $book.html("<option value='0'>Please select a book</option>"); + break; + + case "chapter": + $chapter.html("<option value='0'>Please select a chapter</option>"); + break; + + case "example": + $example.html("<option value='0'>Please select a example</option>"); + break; + + case "caption": + $caption.val(""); + break; + + } + } + } + + $category.change(function() { + reset("book", "chapter", "example", "caption"); + var category_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/category/" + category_id, + type: "POST", + dataType: "html", + success: function(data) { + $book.html(data); + } + }); + }); + + $book.change(function() { + reset("chapter", "example", "caption"); + var book_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/book/" + book_id, + type: "POST", + dataType: "html", + success: function(data) { + $chapter.html(data); + } + }); + }); + + $chapter.change(function() { + reset("example", "caption"); + var chapter_id = $(this).val(); + + $.ajax({ + url: modPath + "ajax/chapter/" + chapter_id, + type: "POST", + dataType: "html", + success: function(data) { + $example.html(data); + } + }); + }); + + $example.change(function() { + var example_id = $(this).val(); + reset("caption"); + console.log("########" + example_id); + $.ajax({ + url: modPath + "ajax/example/" + example_id, + type: "POST", + dataType: "html", + success: function(data) { + var code = $(data).filter("#code").html(); + /* checking whether it is for .well or textarea */ + if($code.hasClass("fix-caption-code")) { + $code.html(code); + } else { + $code.val(code); + } + var caption = $(data).filter("#caption").html(); + try { + $caption.val(caption); + } catch(e) { + return; + } + } + }); + }); + + $caption_form.submit(function(e) { + var example_id = $example.val(); + if(example_id != "0") { + var caption = $caption.val(); + $updating.show(); + $.ajax({ + url: modPath + "ajax/update/", + type: "POST", + data: { + example_id: example_id, + caption: caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + + $code_form.submit(function(e) { + var example_id = $example.val(); + if(example_id != "0") { + var code = $code.val(); + $.ajax({ + url: modPath + "ajax/code/" + example_id, + type: "POST", + data: { + code: code + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + +$Selected = $(".selected"); + $Selected.click(function (e) { + $(".sync-msg").remove(); + $(this).after("<span class='sync-msg'>Saving...</span>"); + $.ajax({ + url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), + success: function() { + $(".sync-msg").remove(); + console.log ("success"); + } + }); + + }); + + /* toggle in edition */ + $ind_ed = $(".ind-ed"); + + $ind_ed.click(function(e) { + var aicte_id = $(this).attr("data-aicte"); + $t = $(this); + $.ajax({ + url: modPath + "ajax/ind-ed/" + aicte_id, + type: "GET", + dataType: "html", + success: function(data) { + $tr = $t.parents("tr:first"); + if($tr.hasClass("orange")) { + $t.parents("tr:first").removeClass("orange"); + $t.html("Mark"); + } else { + $t.parents("tr:first").addClass("orange"); + $t.html("Unmark"); + } + console.log(data); + }, + }); + e.preventDefault(); + }); + +}); +})(jQuery); -- cgit From 3ae4e7999194b3e22643e352dc59b80368f51165 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 6 Sep 2016 15:54:48 +0530 Subject: fixed dropdown issue and formated the code --- js/textbook_companion_fixer.js | 453 +++++++++++++++++++++++------------------ 1 file changed, 253 insertions(+), 200 deletions(-) (limited to 'js') diff --git a/js/textbook_companion_fixer.js b/js/textbook_companion_fixer.js index 7a7e3fe..0ad82ad 100755 --- a/js/textbook_companion_fixer.js +++ b/js/textbook_companion_fixer.js @@ -1,202 +1,255 @@ -(function ($) { -$(document).ready(function() { - var basePath = Drupal.settings.basePath; - var modPath = basePath + "fix/"; - var modPath1 = basePath + "fix/aicte/book/"; +(function($) { + $(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "textbook_companion_fixer/"; + var modPath1 = basePath + "textbook_companion_fixer/aicte/book/"; + $category = $("#fix-tbc-form #edit-category"); + $book = $("#fix-tbc-form #edit-book"); + $chapter = $("#fix-tbc-form #edit-chapter"); + $example = $("#fix-tbc-form #edit-example"); + $caption = $("#fix-tbc-form #edit-caption"); + $code = $("#fix-tbc-form #edit-code"); + $caption_form = $("#scilab-fixer-caption-form"); + $code_form = $("#scilab-fixer-code-form"); + $updating = $("#fix-tbc-page #updating"); + $done = $("#fix-tbc-page #done"); + $example.attr("multiple", "enabled"); - - - $category = $("#fix-tbc-form #edit-category"); - $book = $("#fix-tbc-form #edit-book"); - $chapter = $("#fix-tbc-form #edit-chapter"); - $example = $("#fix-tbc-form #edit-example"); - $caption = $("#fix-tbc-form #edit-caption"); - $code = $("#fix-tbc-form #edit-code"); - $caption_form = $("#scilab-fixer-caption-form"); - $code_form = $("#scilab-fixer-code-form"); - $updating = $("#fix-tbc-page #updating"); - $done = $("#fix-tbc-page #done"); - $example.attr("multiple", "enabled"); - - function reset() { - for (var i = 0, l = arguments.length; i < l; i ++) { - switch(arguments[i]) { - case "book": - $book.html("<option value='0'>Please select a book</option>"); - break; - - case "chapter": - $chapter.html("<option value='0'>Please select a chapter</option>"); - break; - - case "example": - $example.html("<option value='0'>Please select a example</option>"); - break; - - case "caption": - $caption.val(""); - break; - - } - } - } - - $category.change(function() { - reset("book", "chapter", "example", "caption"); - var category_id = $(this).val(); - - $.ajax({ - url: modPath + "ajax/category/" + category_id, - type: "POST", - dataType: "html", - success: function(data) { - $book.html(data); - } - }); - }); - - $book.change(function() { - reset("chapter", "example", "caption"); - var book_id = $(this).val(); - - $.ajax({ - url: modPath + "ajax/book/" + book_id, - type: "POST", - dataType: "html", - success: function(data) { - $chapter.html(data); - } - }); - }); - - $chapter.change(function() { - reset("example", "caption"); - var chapter_id = $(this).val(); - - $.ajax({ - url: modPath + "ajax/chapter/" + chapter_id, - type: "POST", - dataType: "html", - success: function(data) { - $example.html(data); - } - }); - }); - - $example.change(function() { - var example_id = $(this).val(); - reset("caption"); - console.log("########" + example_id); - $.ajax({ - url: modPath + "ajax/example/" + example_id, - type: "POST", - dataType: "html", - success: function(data) { - var code = $(data).filter("#code").html(); - /* checking whether it is for .well or textarea */ - if($code.hasClass("fix-caption-code")) { - $code.html(code); - } else { - $code.val(code); - } - var caption = $(data).filter("#caption").html(); - try { - $caption.val(caption); - } catch(e) { - return; - } - } - }); - }); - - $caption_form.submit(function(e) { - var example_id = $example.val(); - if(example_id != "0") { - var caption = $caption.val(); - $updating.show(); - $.ajax({ - url: modPath + "ajax/update/", - type: "POST", - data: { - example_id: example_id, - caption: caption - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - } - }); - } else { - alert("No example selected.") - } - e.preventDefault(); - }); - - $code_form.submit(function(e) { - var example_id = $example.val(); - if(example_id != "0") { - var code = $code.val(); - $.ajax({ - url: modPath + "ajax/code/" + example_id, - type: "POST", - data: { - code: code - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - } - }); - } else { - alert("No example selected.") - } - e.preventDefault(); - }); - -$Selected = $(".selected"); - $Selected.click(function (e) { - $(".sync-msg").remove(); - $(this).after("<span class='sync-msg'>Saving...</span>"); - $.ajax({ - url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), - success: function() { - $(".sync-msg").remove(); - console.log ("success"); - } - }); - - }); - - /* toggle in edition */ - $ind_ed = $(".ind-ed"); - - $ind_ed.click(function(e) { - var aicte_id = $(this).attr("data-aicte"); - $t = $(this); - $.ajax({ - url: modPath + "ajax/ind-ed/" + aicte_id, - type: "GET", - dataType: "html", - success: function(data) { - $tr = $t.parents("tr:first"); - if($tr.hasClass("orange")) { - $t.parents("tr:first").removeClass("orange"); - $t.html("Mark"); - } else { - $t.parents("tr:first").addClass("orange"); - $t.html("Unmark"); - } - console.log(data); - }, - }); - e.preventDefault(); - }); - -}); + function reset() { + for (var i = 0, l = arguments.length; i < l; i++) { + switch (arguments[i]) { + case "book": + $book.html("<option value='0'>Please select a book</option>"); + break; + case "chapter": + $chapter.html("<option value='0'>Please select a chapter</option>"); + break; + case "example": + $example.html("<option value='0'>Please select a example</option>"); + break; + case "caption": + $caption.val(""); + break; + } + } + } + $(".select-book").hide(); + $(".select-chapter").hide(); + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + $category.change(function() { + reset("book", "chapter", "example", "caption"); + var category_id = $(this).val(); + if (category_id < 1) { + $(".select-book").hide(); + $(".select-chapter").hide(); + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + (".well").hide(); + $(".update-button").hide(); + } else { + $(".select-book").show(); + $(".select-chapter").hide(); + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } + $.ajax({ + url: modPath + "ajax/category/" + category_id, + type: "POST", + dataType: "html", + success: function(data) { + $book.html(data); + } + }); + }); + $book.change(function() { + reset("chapter", "example", "caption"); + var book_id = $(this).val(); + if (book_id < 1) { + $(".select-chapter").hide(); + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } else { + $(".select-chapter").show(); + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } + $.ajax({ + url: modPath + "ajax/book/" + book_id, + type: "POST", + dataType: "html", + success: function(data) { + $chapter.html(data); + } + }); + }); + $chapter.change(function() { + reset("example", "caption"); + var chapter_id = $(this).val(); + if (chapter_id < 1) { + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } else { + $(".select-example").show(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".update-button").hide(); + } + $.ajax({ + url: modPath + "ajax/chapter/" + chapter_id, + type: "POST", + dataType: "html", + success: function(data) { + $example.html(data); + } + }); + }); + $example.change(function() { + var example_id = $(this).val(); + var example_caption = $(this).text(); + reset("caption"); + if (example_id < 1) { + $(".enter-caption").hide(); + // $("#edit-caption").val(""); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } else { + $(".enter-caption").show(); + // $("#edit-caption").val(example_caption); + $(".example-code-edit").show(); + $(".well").show(); + $(".update-button").show(); + } + $.ajax({ + url: modPath + "ajax/example/" + example_id, + type: "POST", + dataType: "html", + success: function(data) { + var code = $(data).filter("#code").html(); + /* checking whether it is for .well or textarea */ + if ($code.hasClass("fix-caption-code")) { + $code.html(code); + } else { + $code.val(code); + } + var caption = $(data).filter("#caption").html(); + try { + $caption.val(caption); + } catch (e) { + return; + } + } + }); + }); + $caption_form.submit(function(e) { + var example_id = $example.val(); + if (example_id != "0") { + var caption = $caption.val(); + caption = caption.trim(); + if (caption == '') { + alert('Please enter new caption '); + return false; + } + $updating.show(); + $.ajax({ + url: modPath + "ajax/update/", + type: "POST", + data: { + example_id: example_id, + caption: caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + $code_form.submit(function(e) { + var example_id = $example.val(); + if (example_id != "0") { + var code = $code.val(); + code = code.trim(); + if (code == '') { + alert('Please enter new code'); + return false; + } + $.ajax({ + url: modPath + "ajax/code/" + example_id, + type: "POST", + data: { + code: code + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + $(".example-code-edit").show(); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + $Selected = $(".selected"); + $Selected.click(function(e) { + $(".sync-msg").remove(); + $(this).after("<span class='sync-msg'>Saving...</span>"); + $.ajax({ + url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), + success: function() { + $(".sync-msg").remove(); + console.log("success"); + } + }); + }); + /* toggle in edition */ + $ind_ed = $(".ind-ed"); + $ind_ed.click(function(e) { + var aicte_id = $(this).attr("data-aicte"); + $t = $(this); + $.ajax({ + url: modPath + "ajax/ind-ed/" + aicte_id, + type: "GET", + dataType: "html", + success: function(data) { + $tr = $t.parents("tr:first"); + if ($tr.hasClass("orange")) { + $t.parents("tr:first").removeClass("orange"); + $t.html("Mark"); + } else { + $t.parents("tr:first").addClass("orange"); + $t.html("Unmark"); + } + }, + }); + e.preventDefault(); + }); + }); })(jQuery); -- cgit From 521d9ca9ffd6ff78b9549fb8727b747517196adb Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 6 Sep 2016 15:56:53 +0530 Subject: formated the code --- js/selection.js | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'js') diff --git a/js/selection.js b/js/selection.js index 6834aca..639afe5 100755 --- a/js/selection.js +++ b/js/selection.js @@ -1,26 +1,27 @@ function getSelectionText(divID) { - var selectedText = ""; - if (window.getSelection) { - var sel = window.getSelection(); - var div = document.getElementById(divID); - - if (sel.rangeCount) { - // Get the selected range - var range = sel.getRangeAt(0); - // Check that the selection is wholly contained within the div text - // if (range.commonAncestorContainer == div.firstChild) { - var selectedText = range.toString(); - // } - } - } - return selectedText; + var selectedText = ""; + if (window.getSelection) { + var sel = window.getSelection(); + var div = document.getElementById(divID); + if (sel.rangeCount) { + // Get the selected range + var range = sel.getRangeAt(0); + // Check that the selection is wholly contained within the div text + // if (range.commonAncestorContainer == div.firstChild) { + var selectedText = range.toString(); + // } + } + } + return selectedText; } -$(document).ready(function() { - $(".fix-caption-code").mousedown(function() { - $("#edit-caption").val(""); - }); - $(".fix-caption-code").mouseup(function() { - quotedText = getSelectionText("#fix-caption-code"); - $("#edit-caption").val(quotedText); - }); -}); +(function($) { + $(document).ready(function() { + $(".fix-caption-code").mousedown(function() { + $("#edit-caption").val(""); + }); + $(".fix-caption-code").mouseup(function() { + quotedText = getSelectionText("#fix-caption-code"); + $("#edit-caption").val(quotedText); + }); + }); +})(jQuery); -- cgit From 89ef9d359b29352e8c22ee8642cf203ae2f0c84b Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Fri, 20 Jan 2017 15:28:14 +0530 Subject: added the chapter name edit option and traker mail for every edit --- js/selection.js | 9 +++ js/textbook_companion_fixer.js | 134 +++++++++++++++++++++++++++++++++-------- 2 files changed, 118 insertions(+), 25 deletions(-) (limited to 'js') diff --git a/js/selection.js b/js/selection.js index 639afe5..6488c73 100755 --- a/js/selection.js +++ b/js/selection.js @@ -14,6 +14,8 @@ function getSelectionText(divID) { } return selectedText; } + + (function($) { $(document).ready(function() { $(".fix-caption-code").mousedown(function() { @@ -23,5 +25,12 @@ function getSelectionText(divID) { quotedText = getSelectionText("#fix-caption-code"); $("#edit-caption").val(quotedText); }); + $("#edit-example").mousedown(function() { + $("#edit-caption").val(""); + }); + $("#edit-example").mouseup(function() { + quotedText = $('option:selected', this).attr("data-exampleid"); + $("#edit-caption").val(quotedText); + }); }); })(jQuery); diff --git a/js/textbook_companion_fixer.js b/js/textbook_companion_fixer.js index 0ad82ad..d7b617e 100755 --- a/js/textbook_companion_fixer.js +++ b/js/textbook_companion_fixer.js @@ -35,6 +35,8 @@ } $(".select-book").hide(); $(".select-chapter").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); $(".select-example").hide(); $(".enter-caption").hide(); $(".example-code-edit").hide(); @@ -46,14 +48,18 @@ if (category_id < 1) { $(".select-book").hide(); $(".select-chapter").hide(); + $(".enter-chapter-name").hide(); $(".select-example").hide(); $(".enter-caption").hide(); + $(".chapter-example-chk").hide(); $(".example-code-edit").hide(); (".well").hide(); $(".update-button").hide(); } else { $(".select-book").show(); $(".select-chapter").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); $(".select-example").hide(); $(".enter-caption").hide(); $(".example-code-edit").hide(); @@ -76,12 +82,16 @@ $(".select-chapter").hide(); $(".select-example").hide(); $(".enter-caption").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); $(".example-code-edit").hide(); $(".well").hide(); $(".update-button").hide(); } else { $(".select-chapter").show(); $(".select-example").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); $(".enter-caption").hide(); $(".example-code-edit").hide(); $(".well").hide(); @@ -98,18 +108,24 @@ }); $chapter.change(function() { reset("example", "caption"); + var chapter_name = $('option:selected', this).attr("data-chaptername"); var chapter_id = $(this).val(); if (chapter_id < 1) { $(".select-example").hide(); $(".enter-caption").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); $(".example-code-edit").hide(); $(".well").hide(); $(".update-button").hide(); } else { $(".select-example").show(); + $(".enter-chapter-name").show(); + $(".chapter-example-chk").show(); + $("#edit-chapter-name").val(chapter_name); $(".enter-caption").hide(); $(".example-code-edit").hide(); - $(".update-button").hide(); + $(".update-button").show(); } $.ajax({ url: modPath + "ajax/chapter/" + chapter_id, @@ -121,9 +137,10 @@ }); }); $example.change(function() { + reset("caption"); var example_id = $(this).val(); + var example_name = $('option:selected', this).attr("data-exampleid"); var example_caption = $(this).text(); - reset("caption"); if (example_id < 1) { $(".enter-caption").hide(); // $("#edit-caption").val(""); @@ -132,7 +149,7 @@ $(".update-button").hide(); } else { $(".enter-caption").show(); - // $("#edit-caption").val(example_caption); + $("#edit-caption").val(example_name); $(".example-code-edit").show(); $(".well").show(); $(".update-button").show(); @@ -158,33 +175,100 @@ } }); }); + //edit caption form submit $caption_form.submit(function(e) { var example_id = $example.val(); - if (example_id != "0") { - var caption = $caption.val(); - caption = caption.trim(); - if (caption == '') { - alert('Please enter new caption '); - return false; + var chapter_id = $('option:selected', $chapter).attr("data-chapterid"); + if ($('.chapter-caption-chk').prop('checked') == true && $( + '.example-caption-chk').prop('checked') == true) { + if (example_id != "0" && chapter_id != "0") { + var caption = $caption.val(); + caption = caption.trim(); + var chapter_caption = $("#edit-chapter-name").val(); + chapter_caption = chapter_caption.trim(); + if (caption == '' || chapter_caption =='') { + alert('Please enter new caption '); + return false; + } + $updating.show(); + $.ajax({ + url: modPath + "ajax/update-both/", + type: "POST", + data: { + example_id: example_id, + caption: caption, + chapter_id: chapter_id, + chapter_caption: chapter_caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $book.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No entry is selected.") } - $updating.show(); - $.ajax({ - url: modPath + "ajax/update/", - type: "POST", - data: { - example_id: example_id, - caption: caption - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); + } else if ($('.example-caption-chk').prop('checked') == true) { + if (example_id != "0") { + var caption = $caption.val(); + caption = caption.trim(); + if (caption == '') { + alert('Please enter new caption '); + return false; } - }); + $updating.show(); + $.ajax({ + url: modPath + "ajax/update-example/", + type: "POST", + data: { + example_id: example_id, + caption: caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + } else if ($('.chapter-caption-chk').prop('checked') == true) { + if (chapter_id != "0") { + var chapter_caption = $("#edit-chapter-name").val(); + chapter_caption = chapter_caption.trim(); + if (chapter_caption == '') { + alert('Please enter new caption '); + return false; + } + $updating.show(); + $.ajax({ + url: modPath + "ajax/update-chapter/", + type: "POST", + data: { + chapter_id: chapter_id, + chapter_caption: chapter_caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $book.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } } else { - alert("No example selected.") + alert("Please select the checkbox option") } e.preventDefault(); }); -- cgit From 2007de8e1386121d536ce6d7b3d0ad328826f326 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 24 Jan 2017 11:07:47 +0530 Subject: aaded new validation for captions --- js/textbook_companion_fixer.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/textbook_companion_fixer.js b/js/textbook_companion_fixer.js index d7b617e..b655b05 100755 --- a/js/textbook_companion_fixer.js +++ b/js/textbook_companion_fixer.js @@ -184,8 +184,18 @@ if (example_id != "0" && chapter_id != "0") { var caption = $caption.val(); caption = caption.trim(); + caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(caption) == true) { + alert('Enter valid text for example caption'); + return false; + } var chapter_caption = $("#edit-chapter-name").val(); - chapter_caption = chapter_caption.trim(); + chapter_caption = chapter_caption.trim(); + chapter_caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(chapter_caption) == true) { + alert('Enter valid text for chapter caption'); + return false; + } if (caption == '' || chapter_caption =='') { alert('Please enter new caption '); return false; @@ -216,6 +226,11 @@ if (example_id != "0") { var caption = $caption.val(); caption = caption.trim(); + caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(caption) == true) { + alert('Enter valid text'); + return false; + } if (caption == '') { alert('Please enter new caption '); return false; @@ -242,7 +257,12 @@ } else if ($('.chapter-caption-chk').prop('checked') == true) { if (chapter_id != "0") { var chapter_caption = $("#edit-chapter-name").val(); - chapter_caption = chapter_caption.trim(); + chapter_caption = chapter_caption.trim(); + chapter_caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(chapter_caption) == true) { + alert('Enter valid text for chapter caption'); + return false; + } if (chapter_caption == '') { alert('Please enter new caption '); return false; @@ -313,6 +333,10 @@ } }); }); + function validateCaption(text){ + var re = /([a-zA-Z|*|_|.|+|-|\\|?|/|!|~|!|@|#|$|%|^|&|(|)|<|>|{|}|;|:|\"|\'|,])\1{2,}/; + return re.test(text); + } /* toggle in edition */ $ind_ed = $(".ind-ed"); $ind_ed.click(function(e) { -- cgit From 40561078713460ec77b2e7fe260edf86d089e0fc Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Sat, 28 Jan 2017 21:38:46 +0530 Subject: added js for edit category --- js/textbook_companion_fixer_edit_category.js | 84 ++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 js/textbook_companion_fixer_edit_category.js (limited to 'js') diff --git a/js/textbook_companion_fixer_edit_category.js b/js/textbook_companion_fixer_edit_category.js new file mode 100644 index 0000000..9c2c4f7 --- /dev/null +++ b/js/textbook_companion_fixer_edit_category.js @@ -0,0 +1,84 @@ +(function($) { + $(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "textbook_companion_fixer/ajax/edit-book-category/"; + $category_form = $("#fix-tbc-category-form"); + $main_category1 = $(".main-category-1"); + $main_category2 = $(".main-category-2"); + $main_category3 = $(".main-category-3"); + $main_category4 = $(".main-category-4"); + $main_category5 = $(".main-category-5"); + $main_category6 = $(".main-category-6"); + $main_category7 = $(".main-category-7"); + $(".main-subcategory-1").hide(); + $(".main-subcategory-2").hide(); + $(".main-subcategory-3").hide(); + $(".main-subcategory-4").hide(); + $(".main-subcategory-5").hide(); + $(".main-subcategory-6").hide(); + $(".main-subcategory-7").hide(); + prop = $('.main-category-chk-1').prop('checked'); + console.log(prop); + $('.main-category-chk-1').change(function() { + if (!this.checked) { + $('.main-subcategory-1').hide(); + $('.main-subcategory-1').prop('selectedIndex', 0); + } else { + $('.main-subcategory-1').show(); + } + }); + $('.main-category-chk-2').change(function() { + if (!this.checked) { + $('.main-subcategory-2').hide(); + $('.main-subcategory-2').prop('selectedIndex', 0); + } else { + $('.main-subcategory-2').show(); + } + }); + $('.main-category-chk-3').change(function() { + if (!this.checked) { + $('.main-subcategory-3').hide(); + $('.main-subcategory-3').prop('selectedIndex', 0); + } else { + $('.main-subcategory-3').show(); + } + }); + $('.main-category-chk-4').change(function() { + if (!this.checked) { + $('.main-subcategory-4').hide(); + $('.main-subcategory-4').prop('selectedIndex', 0); + } else { + $('.main-subcategory-4').show(); + } + }); + $('.main-category-chk-5').change(function() { + if (!this.checked) { + $('.main-subcategory-5').hide(); + $('.main-subcategory-5').prop('selectedIndex', 0); + } else { + $('.main-subcategory-5').show(); + } + }); + $('.main-category-chk-6').change(function() { + if (!this.checked) { + $('.main-subcategory-6').hide(); + $('.main-subcategory-6').prop('selectedIndex', 0); + } else { + $('.main-subcategory-6').show(); + } + }); + $('.main-category-chk-7').change(function() { + if (!this.checked) { + $('.main-subcategory-7').hide(); + $('.main-subcategory-7').prop('selectedIndex', 0); + } else { + $('.main-subcategory-7').show(); + } + }); + //edit category form submit + $category_form.submit(function(e) { + e.preventDefault(); + }); + + }); +})(jQuery); -- cgit From 8ffe399aa099cb67bed1611873cf655693f00521 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 31 Jan 2017 17:43:07 +0530 Subject: added submit function --- js/textbook_companion_fixer_edit_category.js | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'js') diff --git a/js/textbook_companion_fixer_edit_category.js b/js/textbook_companion_fixer_edit_category.js index 9c2c4f7..2821382 100644 --- a/js/textbook_companion_fixer_edit_category.js +++ b/js/textbook_companion_fixer_edit_category.js @@ -1,15 +1,9 @@ (function($) { $(document).ready(function() { var basePath = Drupal.settings.basePath; + //var modPath = basePath + "textbook_companion_fixer/"; var modPath = basePath + "textbook_companion_fixer/ajax/edit-book-category/"; $category_form = $("#fix-tbc-category-form"); - $main_category1 = $(".main-category-1"); - $main_category2 = $(".main-category-2"); - $main_category3 = $(".main-category-3"); - $main_category4 = $(".main-category-4"); - $main_category5 = $(".main-category-5"); - $main_category6 = $(".main-category-6"); - $main_category7 = $(".main-category-7"); $(".main-subcategory-1").hide(); $(".main-subcategory-2").hide(); $(".main-subcategory-3").hide(); @@ -18,7 +12,6 @@ $(".main-subcategory-6").hide(); $(".main-subcategory-7").hide(); prop = $('.main-category-chk-1').prop('checked'); - console.log(prop); $('.main-category-chk-1').change(function() { if (!this.checked) { $('.main-subcategory-1').hide(); @@ -76,7 +69,29 @@ } }); //edit category form submit - $category_form.submit(function(e) { + $("#submit-button-category").click(function(e) { + var main_cat_chk_value = []; + $("input[name='ids[]']:checked").each(function (){ + main_cat_chk_value.push(parseInt($(this).val())); + }); + console.log(modPath); + $.ajax({ + url: modPath, + type: "POST", + data: { + pref_id: pref_id, + main_category: main_cat_chk_value, + subcategory: "" + }, + dataType: "html", + success: function(data) { + $updating.hide(); + $done.show(); + console.log("data: +" + main_cat_chk_value); + $done.fadeOut("slow"); + //alert("ok"); + } + }); e.preventDefault(); }); -- cgit From 0f227125f2c6d996d1528048d00f3e9a23e08df0 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Thu, 2 Feb 2017 17:39:17 +0530 Subject: added some minor changes --- js/textbook_companion_fixer_edit_category.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/textbook_companion_fixer_edit_category.js b/js/textbook_companion_fixer_edit_category.js index 2821382..f10973b 100644 --- a/js/textbook_companion_fixer_edit_category.js +++ b/js/textbook_companion_fixer_edit_category.js @@ -74,20 +74,28 @@ $("input[name='ids[]']:checked").each(function (){ main_cat_chk_value.push(parseInt($(this).val())); }); - console.log(modPath); + var sub_cat_select_value = $.map($('select[name="subcats"] :selected'), function (val, _) { + var newObj = {}; + if(val.value > '0'){ + newObj.subcats = val.value; + } + return newObj; + }); + var pref_id = $('.prefrence_id').val(); + console.log(pref_id); $.ajax({ url: modPath, type: "POST", data: { pref_id: pref_id, main_category: main_cat_chk_value, - subcategory: "" + sub_category: sub_cat_select_value }, dataType: "html", success: function(data) { $updating.hide(); $done.show(); - console.log("data: +" + main_cat_chk_value); + console.log("data1: " + main_cat_chk_value + " data2: "+ sub_cat_select_value); $done.fadeOut("slow"); //alert("ok"); } -- cgit From c8b0bd4ef8f3eb26d006fcd792ce628ac0b5f14b Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Mon, 8 May 2017 15:17:01 +0530 Subject: added new interface to edit the categories --- js/textbook_companion_fixer_edit_category.js | 206 +++++++++++++++++---------- 1 file changed, 128 insertions(+), 78 deletions(-) (limited to 'js') diff --git a/js/textbook_companion_fixer_edit_category.js b/js/textbook_companion_fixer_edit_category.js index f10973b..545f689 100644 --- a/js/textbook_companion_fixer_edit_category.js +++ b/js/textbook_companion_fixer_edit_category.js @@ -2,106 +2,156 @@ $(document).ready(function() { var basePath = Drupal.settings.basePath; //var modPath = basePath + "textbook_companion_fixer/"; - var modPath = basePath + "textbook_companion_fixer/ajax/edit-book-category/"; + var modPath = basePath + + "textbook_companion_fixer/ajax/edit-book-category/"; $category_form = $("#fix-tbc-category-form"); - $(".main-subcategory-1").hide(); - $(".main-subcategory-2").hide(); - $(".main-subcategory-3").hide(); - $(".main-subcategory-4").hide(); - $(".main-subcategory-5").hide(); - $(".main-subcategory-6").hide(); - $(".main-subcategory-7").hide(); - prop = $('.main-category-chk-1').prop('checked'); - $('.main-category-chk-1').change(function() { - if (!this.checked) { - $('.main-subcategory-1').hide(); - $('.main-subcategory-1').prop('selectedIndex', 0); - } else { - $('.main-subcategory-1').show(); - } - }); - $('.main-category-chk-2').change(function() { - if (!this.checked) { - $('.main-subcategory-2').hide(); - $('.main-subcategory-2').prop('selectedIndex', 0); - } else { - $('.main-subcategory-2').show(); - } - }); - $('.main-category-chk-3').change(function() { - if (!this.checked) { - $('.main-subcategory-3').hide(); - $('.main-subcategory-3').prop('selectedIndex', 0); - } else { - $('.main-subcategory-3').show(); - } - }); - $('.main-category-chk-4').change(function() { - if (!this.checked) { - $('.main-subcategory-4').hide(); - $('.main-subcategory-4').prop('selectedIndex', 0); - } else { - $('.main-subcategory-4').show(); - } - }); - $('.main-category-chk-5').change(function() { - if (!this.checked) { - $('.main-subcategory-5').hide(); - $('.main-subcategory-5').prop('selectedIndex', 0); - } else { - $('.main-subcategory-5').show(); - } - }); - $('.main-category-chk-6').change(function() { - if (!this.checked) { - $('.main-subcategory-6').hide(); - $('.main-subcategory-6').prop('selectedIndex', 0); + $(".main-subcategory-table-div").hide(); + + /*********************************************/ + //$('#main-subcategory-table-'+ 1).show(); + //var main_cat_chk_value = []; + $("input[name='ids[]']:checked").each(function() { + main_cat_chk_value = $(this).val(); + console.log('ooo' + main_cat_chk_value); + if (main_cat_chk_value) { + $('#main-subcategory-table-div-id-' + main_cat_chk_value).show(); } else { - $('.main-subcategory-6').show(); + $('#main-subcategory-table-div-id-' + main_cat_chk_value).hide(); } }); - $('.main-category-chk-7').change(function() { - if (!this.checked) { - $('.main-subcategory-7').hide(); - $('.main-subcategory-7').prop('selectedIndex', 0); - } else { - $('.main-subcategory-7').show(); - } + + $('.main-category-checkbox').change(function() { + main_cat_chk_value = $(this).val(); + if (!this.checked) + $('#main-subcategory-table-div-id-' + main_cat_chk_value).hide(); + else + $('#main-subcategory-table-div-id-' + main_cat_chk_value).show(); }); - //edit category form submit - $("#submit-button-category").click(function(e) { - var main_cat_chk_value = []; - $("input[name='ids[]']:checked").each(function (){ - main_cat_chk_value.push(parseInt($(this).val())); - }); - var sub_cat_select_value = $.map($('select[name="subcats"] :selected'), function (val, _) { - var newObj = {}; - if(val.value > '0'){ - newObj.subcats = val.value; - } - return newObj; + + $("#fix-tbc-category-form").on('click', '#btn-add', function() { + //$('#btn-add').click(function(){ + var selectID = $(this).attr("data-cid"); + console.log(selectID); + $('#subcats-' + selectID + ' option:selected').each(function() { + $('#selected-subcats-' + selectID).append("<option value='" + $(this) + .val() + "'>" + $(this).text() + "</option>"); + + /**********************/ + console.log($('.main-subcategory-' + selectID).attr('data-cid')); + var pref_id = $('.prefrence_id').val(); + var main_cat_chk_value = selectID; + var sub_cat_select_value = $(this).val(); + $.ajax({ + url: modPath, + type: "POST", + data: { + pref_id: pref_id, + main_category: main_cat_chk_value, + sub_category: sub_cat_select_value, + action: "add" + }, + dataType: "html", + success: function(data) { + //alert("Updated"); + console.log("My data:" + data); + $updating.hide(); + $done.show(); + console.log("data1: " + main_cat_chk_value + " data2: " + + sub_cat_select_value + " data3: " + pref_id); + $done.fadeOut("slow"); + //alert("ok"); + } + }); + /**********************/ + + $(this).remove(); }); - var pref_id = $('.prefrence_id').val(); - console.log(pref_id); + }); + $("#fix-tbc-category-form").on('click', '#btn-remove', function() { + //$('#btn-remove').click(function(){ + var selectID = $(this).attr("data-cid"); + $('#selected-subcats-' + selectID + ' option:selected').each(function() { + $('#subcats-' + selectID).append("<option value='" + $(this).val() + + "'>" + $(this).text() + "</option>"); + var action = "delete"; + /**********************/ + var pref_id = $('.prefrence_id').val(); + var main_cat_chk_value = selectID; + var sub_cat_select_value = $(this).val(); $.ajax({ url: modPath, type: "POST", data: { pref_id: pref_id, main_category: main_cat_chk_value, - sub_category: sub_cat_select_value + sub_category: sub_cat_select_value, + action: action }, dataType: "html", success: function(data) { + //alert("Updated"); + console.log("My data:" + data); $updating.hide(); $done.show(); - console.log("data1: " + main_cat_chk_value + " data2: "+ sub_cat_select_value); + console.log(action + "data1: " + main_cat_chk_value + + " data2: " + sub_cat_select_value + " data3: " + pref_id); $done.fadeOut("slow"); //alert("ok"); } }); - e.preventDefault(); + /**********************/ + $(this).remove(); + }); }); + //$("#main_cat_checkbox").change(function() { + $("#fix-tbc-category-form").on('change', '.main-category-checkbox', + function() { + var selectID = $(this).val(); + prop = $(this).prop('checked'); + if (prop) { + $('main-subcategory-table-' + selectID).show(); + } else { + if (confirm('Are you sure?')) { + alert('Thanks for confirming'); + var action = "delete-main-with-ub-category"; + var pref_id = $('.prefrence_id').val(); + var main_cat_chk_value = selectID; + console.log(action + "data1: " + main_cat_chk_value + " data2: " + + action + " data3: " + pref_id); + //ConfirmFunction(); + $.ajax({ + url: modPath, + type: "POST", + data: { + pref_id: pref_id, + main_category: main_cat_chk_value, + action: action + }, + dataType: "html", + success: function(data) { + //alert("Updated"); + location.reload(); + $('main-subcategory-table-' + selectID).hide(); + console.log("My data:" + data); + $updating.hide(); + $done.show(); + console.log(action + "data1: " + main_cat_chk_value + " data2: " + + action + " data3: " + pref_id); + $done.fadeOut("slow"); + //alert("ok"); + } + }); + } else { + alert('You have not confirmed the action'); + location.reload(); + } + } + }); + /**********************************************************************/ }); })(jQuery); + +function ConfirmFunction() { + confirm("Are you sure?"); +} -- cgit From ab36969972e8f1f0c0078089bbbd2055028480c9 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 8 Jan 2019 10:32:27 +0530 Subject: fixed argument issue --- js/textbook_companion_fixer_edit_category.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js') diff --git a/js/textbook_companion_fixer_edit_category.js b/js/textbook_companion_fixer_edit_category.js index 545f689..bad5ec7 100644 --- a/js/textbook_companion_fixer_edit_category.js +++ b/js/textbook_companion_fixer_edit_category.js @@ -37,7 +37,6 @@ .val() + "'>" + $(this).text() + "</option>"); /**********************/ - console.log($('.main-subcategory-' + selectID).attr('data-cid')); var pref_id = $('.prefrence_id').val(); var main_cat_chk_value = selectID; var sub_cat_select_value = $(this).val(); -- cgit From 9079093f5ace76555b15e613ca9b8e473aa8461d Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Sat, 31 Aug 2019 15:31:32 +0530 Subject: updated the code for R TBC --- js/r_tbc_fixer.js | 330 ++++++++++++++++++++++++ js/r_tbc_fixer_edit_category.js | 156 ++++++++++++ js/textbook_companion_fixer.js | 363 --------------------------- js/textbook_companion_fixer_edit_category.js | 156 ------------ 4 files changed, 486 insertions(+), 519 deletions(-) create mode 100755 js/r_tbc_fixer.js create mode 100755 js/r_tbc_fixer_edit_category.js delete mode 100755 js/textbook_companion_fixer.js delete mode 100644 js/textbook_companion_fixer_edit_category.js (limited to 'js') diff --git a/js/r_tbc_fixer.js b/js/r_tbc_fixer.js new file mode 100755 index 0000000..dbb20d7 --- /dev/null +++ b/js/r_tbc_fixer.js @@ -0,0 +1,330 @@ +(function($) { + $(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "r_tbc_fixer/"; + var modPath1 = basePath + "textbook_companion_fixer/aicte/book/"; + $category = $("#fix-tbc-form #edit-category"); + $book = $("#fix-tbc-form #edit-book"); + $chapter = $("#fix-tbc-form #edit-chapter"); + $example = $("#fix-tbc-form #edit-example"); + $caption = $("#fix-tbc-form #edit-caption"); + $code = $("#fix-tbc-form #edit-code"); + $caption_form = $("#scilab-fixer-caption-form"); + $code_form = $("#scilab-fixer-code-form"); + $updating = $("#fix-tbc-page #updating"); + $done = $("#fix-tbc-page #done"); + $example.attr("multiple", "enabled"); + + function reset() { + for (var i = 0, l = arguments.length; i < l; i++) { + switch (arguments[i]) { + case "book": + $book.html("<option value='0'>Please select a book</option>"); + break; + case "chapter": + $chapter.html("<option value='0'>Please select a chapter</option>"); + break; + case "example": + $example.html("<option value='0'>Please select a example</option>"); + break; + case "caption": + $caption.val(""); + break; + } + } + } + $(".select-book").hide(); + $(".select-chapter").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + $book.change(function() { + reset("chapter", "example", "caption"); + var book_id = $(this).val(); + if (book_id < 1) { + $(".select-chapter").hide(); + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } else { + $(".select-chapter").show(); + $(".select-example").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } + $.ajax({ + url: modPath + "ajax/book/" + book_id, + type: "POST", + dataType: "html", + success: function(data) { + $chapter.html(data); + } + }); + }); + $chapter.change(function() { + reset("example", "caption"); + var chapter_name = $('option:selected', this).attr("data-chaptername"); + var chapter_id = $(this).val(); + if (chapter_id < 1) { + $(".select-example").hide(); + $(".enter-caption").hide(); + $(".enter-chapter-name").hide(); + $(".chapter-example-chk").hide(); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } else { + $(".select-example").show(); + $(".enter-chapter-name").show(); + $(".chapter-example-chk").show(); + $("#edit-chapter-name").val(chapter_name); + $(".enter-caption").hide(); + $(".example-code-edit").hide(); + $(".update-button").show(); + } + $.ajax({ + url: modPath + "ajax/chapter/" + chapter_id, + type: "POST", + dataType: "html", + success: function(data) { + $example.html(data); + } + }); + }); + $example.change(function() { + reset("caption"); + var example_id = $(this).val(); + var example_name = $('option:selected', this).attr("data-exampleid"); + var example_caption = $(this).text(); + if (example_id < 1) { + $(".enter-caption").hide(); + // $("#edit-caption").val(""); + $(".example-code-edit").hide(); + $(".well").hide(); + $(".update-button").hide(); + } else { + $(".enter-caption").show(); + $("#edit-caption").val(example_name); + $(".example-code-edit").show(); + $(".well").show(); + $(".update-button").show(); + } + $.ajax({ + url: modPath + "ajax/example/" + example_id, + type: "POST", + dataType: "html", + success: function(data) { + var code = $(data).filter("#code").html(); + /* checking whether it is for .well or textarea */ + if ($code.hasClass("fix-caption-code")) { + $code.html(code); + } else { + $code.val(code); + } + var caption = $(data).filter("#caption").html(); + try { + $caption.val(caption); + } catch (e) { + return; + } + } + }); + }); + //edit caption form submit + $caption_form.submit(function(e) { + var example_id = $example.val(); + var chapter_id = $('option:selected', $chapter).attr("data-chapterid"); + if ($('.chapter-caption-chk').prop('checked') == true && $( + '.example-caption-chk').prop('checked') == true) { + if (example_id != "0" && chapter_id != "0") { + var caption = $caption.val(); + caption = caption.trim(); + caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(caption) == true) { + alert('Enter valid text for example caption'); + return false; + } + var chapter_caption = $("#edit-chapter-name").val(); + chapter_caption = chapter_caption.trim(); + chapter_caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(chapter_caption) == true) { + alert('Enter valid text for chapter caption'); + return false; + } + if (caption == '' || chapter_caption =='') { + alert('Please enter new caption '); + return false; + } + $updating.show(); + $.ajax({ + url: modPath + "ajax/update-both/", + type: "POST", + data: { + example_id: example_id, + caption: caption, + chapter_id: chapter_id, + chapter_caption: chapter_caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $book.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No entry is selected.") + } + } else if ($('.example-caption-chk').prop('checked') == true) { + if (example_id != "0") { + var caption = $caption.val(); + caption = caption.trim(); + caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(caption) == true) { + alert('Enter valid text'); + return false; + } + if (caption == '') { + alert('Please enter new caption '); + return false; + } + $updating.show(); + $.ajax({ + url: modPath + "ajax/update-example/", + type: "POST", + data: { + example_id: example_id, + caption: caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + } else if ($('.chapter-caption-chk').prop('checked') == true) { + if (chapter_id != "0") { + var chapter_caption = $("#edit-chapter-name").val(); + chapter_caption = chapter_caption.trim(); + chapter_caption = caption.replace(/\s\s+/g, ' '); + if(validateCaption(chapter_caption) == true) { + alert('Enter valid text for chapter caption'); + return false; + } + if (chapter_caption == '') { + alert('Please enter new caption '); + return false; + } + $updating.show(); + $.ajax({ + url: modPath + "ajax/update-chapter/", + type: "POST", + data: { + chapter_id: chapter_id, + chapter_caption: chapter_caption + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $book.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + } + }); + } else { + alert("No example selected.") + } + } else { + alert("Please select the checkbox option") + } + e.preventDefault(); + }); + $code_form.submit(function(e) { + var example_id = $example.val(); + if (example_id != "0") { + var code = $code.val(); + code = code.trim(); + if (code == '') { + alert('Please enter new code'); + return false; + } + $.ajax({ + url: modPath + "ajax/code/" + example_id, + type: "POST", + data: { + code: code + }, + dataType: "html", + success: function(data) { + $chapter.trigger("change"); + $updating.hide(); + $done.show(); + $done.fadeOut("slow"); + $(".example-code-edit").show(); + } + }); + } else { + alert("No example selected.") + } + e.preventDefault(); + }); + $Selected = $(".selected"); + $Selected.click(function(e) { + $(".sync-msg").remove(); + $(this).after("<span class='sync-msg'>Saving...</span>"); + $.ajax({ + url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), + success: function() { + $(".sync-msg").remove(); + console.log("success"); + } + }); + }); + function validateCaption(text){ + var re = /([a-zA-Z|*|_|.|+|-|\\|?|/|!|~|!|@|#|$|%|^|&|(|)|<|>|{|}|;|:|\"|\'|,])\1{2,}/; + return re.test(text); + } + /* toggle in edition */ + $ind_ed = $(".ind-ed"); + $ind_ed.click(function(e) { + var aicte_id = $(this).attr("data-aicte"); + $t = $(this); + $.ajax({ + url: modPath + "ajax/ind-ed/" + aicte_id, + type: "GET", + dataType: "html", + success: function(data) { + $tr = $t.parents("tr:first"); + if ($tr.hasClass("orange")) { + $t.parents("tr:first").removeClass("orange"); + $t.html("Mark"); + } else { + $t.parents("tr:first").addClass("orange"); + $t.html("Unmark"); + } + }, + }); + e.preventDefault(); + }); + }); +})(jQuery); diff --git a/js/r_tbc_fixer_edit_category.js b/js/r_tbc_fixer_edit_category.js new file mode 100755 index 0000000..bad5ec7 --- /dev/null +++ b/js/r_tbc_fixer_edit_category.js @@ -0,0 +1,156 @@ +(function($) { + $(document).ready(function() { + var basePath = Drupal.settings.basePath; + //var modPath = basePath + "textbook_companion_fixer/"; + var modPath = basePath + + "textbook_companion_fixer/ajax/edit-book-category/"; + $category_form = $("#fix-tbc-category-form"); + $(".main-subcategory-table-div").hide(); + + /*********************************************/ + //$('#main-subcategory-table-'+ 1).show(); + //var main_cat_chk_value = []; + $("input[name='ids[]']:checked").each(function() { + main_cat_chk_value = $(this).val(); + console.log('ooo' + main_cat_chk_value); + if (main_cat_chk_value) { + $('#main-subcategory-table-div-id-' + main_cat_chk_value).show(); + } else { + $('#main-subcategory-table-div-id-' + main_cat_chk_value).hide(); + } + }); + + $('.main-category-checkbox').change(function() { + main_cat_chk_value = $(this).val(); + if (!this.checked) + $('#main-subcategory-table-div-id-' + main_cat_chk_value).hide(); + else + $('#main-subcategory-table-div-id-' + main_cat_chk_value).show(); + }); + + $("#fix-tbc-category-form").on('click', '#btn-add', function() { + //$('#btn-add').click(function(){ + var selectID = $(this).attr("data-cid"); + console.log(selectID); + $('#subcats-' + selectID + ' option:selected').each(function() { + $('#selected-subcats-' + selectID).append("<option value='" + $(this) + .val() + "'>" + $(this).text() + "</option>"); + + /**********************/ + var pref_id = $('.prefrence_id').val(); + var main_cat_chk_value = selectID; + var sub_cat_select_value = $(this).val(); + $.ajax({ + url: modPath, + type: "POST", + data: { + pref_id: pref_id, + main_category: main_cat_chk_value, + sub_category: sub_cat_select_value, + action: "add" + }, + dataType: "html", + success: function(data) { + //alert("Updated"); + console.log("My data:" + data); + $updating.hide(); + $done.show(); + console.log("data1: " + main_cat_chk_value + " data2: " + + sub_cat_select_value + " data3: " + pref_id); + $done.fadeOut("slow"); + //alert("ok"); + } + }); + /**********************/ + + $(this).remove(); + }); + }); + $("#fix-tbc-category-form").on('click', '#btn-remove', function() { + //$('#btn-remove').click(function(){ + var selectID = $(this).attr("data-cid"); + $('#selected-subcats-' + selectID + ' option:selected').each(function() { + $('#subcats-' + selectID).append("<option value='" + $(this).val() + + "'>" + $(this).text() + "</option>"); + var action = "delete"; + /**********************/ + var pref_id = $('.prefrence_id').val(); + var main_cat_chk_value = selectID; + var sub_cat_select_value = $(this).val(); + $.ajax({ + url: modPath, + type: "POST", + data: { + pref_id: pref_id, + main_category: main_cat_chk_value, + sub_category: sub_cat_select_value, + action: action + }, + dataType: "html", + success: function(data) { + //alert("Updated"); + console.log("My data:" + data); + $updating.hide(); + $done.show(); + console.log(action + "data1: " + main_cat_chk_value + + " data2: " + sub_cat_select_value + " data3: " + pref_id); + $done.fadeOut("slow"); + //alert("ok"); + } + }); + /**********************/ + $(this).remove(); + }); + }); + + //$("#main_cat_checkbox").change(function() { + $("#fix-tbc-category-form").on('change', '.main-category-checkbox', + function() { + var selectID = $(this).val(); + prop = $(this).prop('checked'); + if (prop) { + $('main-subcategory-table-' + selectID).show(); + } else { + if (confirm('Are you sure?')) { + alert('Thanks for confirming'); + var action = "delete-main-with-ub-category"; + var pref_id = $('.prefrence_id').val(); + var main_cat_chk_value = selectID; + console.log(action + "data1: " + main_cat_chk_value + " data2: " + + action + " data3: " + pref_id); + //ConfirmFunction(); + $.ajax({ + url: modPath, + type: "POST", + data: { + pref_id: pref_id, + main_category: main_cat_chk_value, + action: action + }, + dataType: "html", + success: function(data) { + //alert("Updated"); + location.reload(); + $('main-subcategory-table-' + selectID).hide(); + console.log("My data:" + data); + $updating.hide(); + $done.show(); + console.log(action + "data1: " + main_cat_chk_value + " data2: " + + action + " data3: " + pref_id); + $done.fadeOut("slow"); + //alert("ok"); + } + }); + } else { + alert('You have not confirmed the action'); + location.reload(); + } + } + }); + /**********************************************************************/ + }); +})(jQuery); + +function ConfirmFunction() { + confirm("Are you sure?"); +} diff --git a/js/textbook_companion_fixer.js b/js/textbook_companion_fixer.js deleted file mode 100755 index b655b05..0000000 --- a/js/textbook_companion_fixer.js +++ /dev/null @@ -1,363 +0,0 @@ -(function($) { - $(document).ready(function() { - var basePath = Drupal.settings.basePath; - var modPath = basePath + "textbook_companion_fixer/"; - var modPath1 = basePath + "textbook_companion_fixer/aicte/book/"; - $category = $("#fix-tbc-form #edit-category"); - $book = $("#fix-tbc-form #edit-book"); - $chapter = $("#fix-tbc-form #edit-chapter"); - $example = $("#fix-tbc-form #edit-example"); - $caption = $("#fix-tbc-form #edit-caption"); - $code = $("#fix-tbc-form #edit-code"); - $caption_form = $("#scilab-fixer-caption-form"); - $code_form = $("#scilab-fixer-code-form"); - $updating = $("#fix-tbc-page #updating"); - $done = $("#fix-tbc-page #done"); - $example.attr("multiple", "enabled"); - - function reset() { - for (var i = 0, l = arguments.length; i < l; i++) { - switch (arguments[i]) { - case "book": - $book.html("<option value='0'>Please select a book</option>"); - break; - case "chapter": - $chapter.html("<option value='0'>Please select a chapter</option>"); - break; - case "example": - $example.html("<option value='0'>Please select a example</option>"); - break; - case "caption": - $caption.val(""); - break; - } - } - } - $(".select-book").hide(); - $(".select-chapter").hide(); - $(".enter-chapter-name").hide(); - $(".chapter-example-chk").hide(); - $(".select-example").hide(); - $(".enter-caption").hide(); - $(".example-code-edit").hide(); - $(".well").hide(); - $(".update-button").hide(); - $category.change(function() { - reset("book", "chapter", "example", "caption"); - var category_id = $(this).val(); - if (category_id < 1) { - $(".select-book").hide(); - $(".select-chapter").hide(); - $(".enter-chapter-name").hide(); - $(".select-example").hide(); - $(".enter-caption").hide(); - $(".chapter-example-chk").hide(); - $(".example-code-edit").hide(); - (".well").hide(); - $(".update-button").hide(); - } else { - $(".select-book").show(); - $(".select-chapter").hide(); - $(".enter-chapter-name").hide(); - $(".chapter-example-chk").hide(); - $(".select-example").hide(); - $(".enter-caption").hide(); - $(".example-code-edit").hide(); - $(".well").hide(); - $(".update-button").hide(); - } - $.ajax({ - url: modPath + "ajax/category/" + category_id, - type: "POST", - dataType: "html", - success: function(data) { - $book.html(data); - } - }); - }); - $book.change(function() { - reset("chapter", "example", "caption"); - var book_id = $(this).val(); - if (book_id < 1) { - $(".select-chapter").hide(); - $(".select-example").hide(); - $(".enter-caption").hide(); - $(".enter-chapter-name").hide(); - $(".chapter-example-chk").hide(); - $(".example-code-edit").hide(); - $(".well").hide(); - $(".update-button").hide(); - } else { - $(".select-chapter").show(); - $(".select-example").hide(); - $(".enter-chapter-name").hide(); - $(".chapter-example-chk").hide(); - $(".enter-caption").hide(); - $(".example-code-edit").hide(); - $(".well").hide(); - $(".update-button").hide(); - } - $.ajax({ - url: modPath + "ajax/book/" + book_id, - type: "POST", - dataType: "html", - success: function(data) { - $chapter.html(data); - } - }); - }); - $chapter.change(function() { - reset("example", "caption"); - var chapter_name = $('option:selected', this).attr("data-chaptername"); - var chapter_id = $(this).val(); - if (chapter_id < 1) { - $(".select-example").hide(); - $(".enter-caption").hide(); - $(".enter-chapter-name").hide(); - $(".chapter-example-chk").hide(); - $(".example-code-edit").hide(); - $(".well").hide(); - $(".update-button").hide(); - } else { - $(".select-example").show(); - $(".enter-chapter-name").show(); - $(".chapter-example-chk").show(); - $("#edit-chapter-name").val(chapter_name); - $(".enter-caption").hide(); - $(".example-code-edit").hide(); - $(".update-button").show(); - } - $.ajax({ - url: modPath + "ajax/chapter/" + chapter_id, - type: "POST", - dataType: "html", - success: function(data) { - $example.html(data); - } - }); - }); - $example.change(function() { - reset("caption"); - var example_id = $(this).val(); - var example_name = $('option:selected', this).attr("data-exampleid"); - var example_caption = $(this).text(); - if (example_id < 1) { - $(".enter-caption").hide(); - // $("#edit-caption").val(""); - $(".example-code-edit").hide(); - $(".well").hide(); - $(".update-button").hide(); - } else { - $(".enter-caption").show(); - $("#edit-caption").val(example_name); - $(".example-code-edit").show(); - $(".well").show(); - $(".update-button").show(); - } - $.ajax({ - url: modPath + "ajax/example/" + example_id, - type: "POST", - dataType: "html", - success: function(data) { - var code = $(data).filter("#code").html(); - /* checking whether it is for .well or textarea */ - if ($code.hasClass("fix-caption-code")) { - $code.html(code); - } else { - $code.val(code); - } - var caption = $(data).filter("#caption").html(); - try { - $caption.val(caption); - } catch (e) { - return; - } - } - }); - }); - //edit caption form submit - $caption_form.submit(function(e) { - var example_id = $example.val(); - var chapter_id = $('option:selected', $chapter).attr("data-chapterid"); - if ($('.chapter-caption-chk').prop('checked') == true && $( - '.example-caption-chk').prop('checked') == true) { - if (example_id != "0" && chapter_id != "0") { - var caption = $caption.val(); - caption = caption.trim(); - caption = caption.replace(/\s\s+/g, ' '); - if(validateCaption(caption) == true) { - alert('Enter valid text for example caption'); - return false; - } - var chapter_caption = $("#edit-chapter-name").val(); - chapter_caption = chapter_caption.trim(); - chapter_caption = caption.replace(/\s\s+/g, ' '); - if(validateCaption(chapter_caption) == true) { - alert('Enter valid text for chapter caption'); - return false; - } - if (caption == '' || chapter_caption =='') { - alert('Please enter new caption '); - return false; - } - $updating.show(); - $.ajax({ - url: modPath + "ajax/update-both/", - type: "POST", - data: { - example_id: example_id, - caption: caption, - chapter_id: chapter_id, - chapter_caption: chapter_caption - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $book.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - } - }); - } else { - alert("No entry is selected.") - } - } else if ($('.example-caption-chk').prop('checked') == true) { - if (example_id != "0") { - var caption = $caption.val(); - caption = caption.trim(); - caption = caption.replace(/\s\s+/g, ' '); - if(validateCaption(caption) == true) { - alert('Enter valid text'); - return false; - } - if (caption == '') { - alert('Please enter new caption '); - return false; - } - $updating.show(); - $.ajax({ - url: modPath + "ajax/update-example/", - type: "POST", - data: { - example_id: example_id, - caption: caption - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - } - }); - } else { - alert("No example selected.") - } - } else if ($('.chapter-caption-chk').prop('checked') == true) { - if (chapter_id != "0") { - var chapter_caption = $("#edit-chapter-name").val(); - chapter_caption = chapter_caption.trim(); - chapter_caption = caption.replace(/\s\s+/g, ' '); - if(validateCaption(chapter_caption) == true) { - alert('Enter valid text for chapter caption'); - return false; - } - if (chapter_caption == '') { - alert('Please enter new caption '); - return false; - } - $updating.show(); - $.ajax({ - url: modPath + "ajax/update-chapter/", - type: "POST", - data: { - chapter_id: chapter_id, - chapter_caption: chapter_caption - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $book.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - } - }); - } else { - alert("No example selected.") - } - } else { - alert("Please select the checkbox option") - } - e.preventDefault(); - }); - $code_form.submit(function(e) { - var example_id = $example.val(); - if (example_id != "0") { - var code = $code.val(); - code = code.trim(); - if (code == '') { - alert('Please enter new code'); - return false; - } - $.ajax({ - url: modPath + "ajax/code/" + example_id, - type: "POST", - data: { - code: code - }, - dataType: "html", - success: function(data) { - $chapter.trigger("change"); - $updating.hide(); - $done.show(); - $done.fadeOut("slow"); - $(".example-code-edit").show(); - } - }); - } else { - alert("No example selected.") - } - e.preventDefault(); - }); - $Selected = $(".selected"); - $Selected.click(function(e) { - $(".sync-msg").remove(); - $(this).after("<span class='sync-msg'>Saving...</span>"); - $.ajax({ - url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"), - success: function() { - $(".sync-msg").remove(); - console.log("success"); - } - }); - }); - function validateCaption(text){ - var re = /([a-zA-Z|*|_|.|+|-|\\|?|/|!|~|!|@|#|$|%|^|&|(|)|<|>|{|}|;|:|\"|\'|,])\1{2,}/; - return re.test(text); - } - /* toggle in edition */ - $ind_ed = $(".ind-ed"); - $ind_ed.click(function(e) { - var aicte_id = $(this).attr("data-aicte"); - $t = $(this); - $.ajax({ - url: modPath + "ajax/ind-ed/" + aicte_id, - type: "GET", - dataType: "html", - success: function(data) { - $tr = $t.parents("tr:first"); - if ($tr.hasClass("orange")) { - $t.parents("tr:first").removeClass("orange"); - $t.html("Mark"); - } else { - $t.parents("tr:first").addClass("orange"); - $t.html("Unmark"); - } - }, - }); - e.preventDefault(); - }); - }); -})(jQuery); diff --git a/js/textbook_companion_fixer_edit_category.js b/js/textbook_companion_fixer_edit_category.js deleted file mode 100644 index bad5ec7..0000000 --- a/js/textbook_companion_fixer_edit_category.js +++ /dev/null @@ -1,156 +0,0 @@ -(function($) { - $(document).ready(function() { - var basePath = Drupal.settings.basePath; - //var modPath = basePath + "textbook_companion_fixer/"; - var modPath = basePath + - "textbook_companion_fixer/ajax/edit-book-category/"; - $category_form = $("#fix-tbc-category-form"); - $(".main-subcategory-table-div").hide(); - - /*********************************************/ - //$('#main-subcategory-table-'+ 1).show(); - //var main_cat_chk_value = []; - $("input[name='ids[]']:checked").each(function() { - main_cat_chk_value = $(this).val(); - console.log('ooo' + main_cat_chk_value); - if (main_cat_chk_value) { - $('#main-subcategory-table-div-id-' + main_cat_chk_value).show(); - } else { - $('#main-subcategory-table-div-id-' + main_cat_chk_value).hide(); - } - }); - - $('.main-category-checkbox').change(function() { - main_cat_chk_value = $(this).val(); - if (!this.checked) - $('#main-subcategory-table-div-id-' + main_cat_chk_value).hide(); - else - $('#main-subcategory-table-div-id-' + main_cat_chk_value).show(); - }); - - $("#fix-tbc-category-form").on('click', '#btn-add', function() { - //$('#btn-add').click(function(){ - var selectID = $(this).attr("data-cid"); - console.log(selectID); - $('#subcats-' + selectID + ' option:selected').each(function() { - $('#selected-subcats-' + selectID).append("<option value='" + $(this) - .val() + "'>" + $(this).text() + "</option>"); - - /**********************/ - var pref_id = $('.prefrence_id').val(); - var main_cat_chk_value = selectID; - var sub_cat_select_value = $(this).val(); - $.ajax({ - url: modPath, - type: "POST", - data: { - pref_id: pref_id, - main_category: main_cat_chk_value, - sub_category: sub_cat_select_value, - action: "add" - }, - dataType: "html", - success: function(data) { - //alert("Updated"); - console.log("My data:" + data); - $updating.hide(); - $done.show(); - console.log("data1: " + main_cat_chk_value + " data2: " + - sub_cat_select_value + " data3: " + pref_id); - $done.fadeOut("slow"); - //alert("ok"); - } - }); - /**********************/ - - $(this).remove(); - }); - }); - $("#fix-tbc-category-form").on('click', '#btn-remove', function() { - //$('#btn-remove').click(function(){ - var selectID = $(this).attr("data-cid"); - $('#selected-subcats-' + selectID + ' option:selected').each(function() { - $('#subcats-' + selectID).append("<option value='" + $(this).val() + - "'>" + $(this).text() + "</option>"); - var action = "delete"; - /**********************/ - var pref_id = $('.prefrence_id').val(); - var main_cat_chk_value = selectID; - var sub_cat_select_value = $(this).val(); - $.ajax({ - url: modPath, - type: "POST", - data: { - pref_id: pref_id, - main_category: main_cat_chk_value, - sub_category: sub_cat_select_value, - action: action - }, - dataType: "html", - success: function(data) { - //alert("Updated"); - console.log("My data:" + data); - $updating.hide(); - $done.show(); - console.log(action + "data1: " + main_cat_chk_value + - " data2: " + sub_cat_select_value + " data3: " + pref_id); - $done.fadeOut("slow"); - //alert("ok"); - } - }); - /**********************/ - $(this).remove(); - }); - }); - - //$("#main_cat_checkbox").change(function() { - $("#fix-tbc-category-form").on('change', '.main-category-checkbox', - function() { - var selectID = $(this).val(); - prop = $(this).prop('checked'); - if (prop) { - $('main-subcategory-table-' + selectID).show(); - } else { - if (confirm('Are you sure?')) { - alert('Thanks for confirming'); - var action = "delete-main-with-ub-category"; - var pref_id = $('.prefrence_id').val(); - var main_cat_chk_value = selectID; - console.log(action + "data1: " + main_cat_chk_value + " data2: " + - action + " data3: " + pref_id); - //ConfirmFunction(); - $.ajax({ - url: modPath, - type: "POST", - data: { - pref_id: pref_id, - main_category: main_cat_chk_value, - action: action - }, - dataType: "html", - success: function(data) { - //alert("Updated"); - location.reload(); - $('main-subcategory-table-' + selectID).hide(); - console.log("My data:" + data); - $updating.hide(); - $done.show(); - console.log(action + "data1: " + main_cat_chk_value + " data2: " + - action + " data3: " + pref_id); - $done.fadeOut("slow"); - //alert("ok"); - } - }); - } else { - alert('You have not confirmed the action'); - location.reload(); - } - } - }); - /**********************************************************************/ - }); -})(jQuery); - -function ConfirmFunction() { - confirm("Are you sure?"); -} -- cgit From 9d7ea3e909c40eec3c078f03c8209ae9b1261c38 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Sun, 1 Sep 2019 21:51:58 +0530 Subject: modifed the code for R tbc --- js/r_tbc_fixer.js | 7 +++++-- js/r_tbc_fixer_edit_category.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/r_tbc_fixer.js b/js/r_tbc_fixer.js index dbb20d7..92830b6 100755 --- a/js/r_tbc_fixer.js +++ b/js/r_tbc_fixer.js @@ -1,4 +1,4 @@ -(function($) { + (function($) { $(document).ready(function() { var basePath = Drupal.settings.basePath; var modPath = basePath + "r_tbc_fixer/"; @@ -15,6 +15,7 @@ $done = $("#fix-tbc-page #done"); $example.attr("multiple", "enabled"); + function reset() { for (var i = 0, l = arguments.length; i < l; i++) { switch (arguments[i]) { @@ -45,7 +46,7 @@ $book.change(function() { reset("chapter", "example", "caption"); var book_id = $(this).val(); - if (book_id < 1) { + if (book_id < 0) { $(".select-chapter").hide(); $(".select-example").hide(); $(".enter-caption").hide(); @@ -100,6 +101,7 @@ dataType: "html", success: function(data) { $example.html(data); + $example.attr("size", $("#fix-tbc-form #edit-example option").length); } }); }); @@ -115,6 +117,7 @@ $(".well").hide(); $(".update-button").hide(); } else { + $(".enter-caption").show(); $("#edit-caption").val(example_name); $(".example-code-edit").show(); diff --git a/js/r_tbc_fixer_edit_category.js b/js/r_tbc_fixer_edit_category.js index bad5ec7..b141363 100755 --- a/js/r_tbc_fixer_edit_category.js +++ b/js/r_tbc_fixer_edit_category.js @@ -3,7 +3,7 @@ var basePath = Drupal.settings.basePath; //var modPath = basePath + "textbook_companion_fixer/"; var modPath = basePath + - "textbook_companion_fixer/ajax/edit-book-category/"; + "r_tbc_fixer/ajax/edit-book-category/"; $category_form = $("#fix-tbc-category-form"); $(".main-subcategory-table-div").hide(); -- cgit