summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJayaram R Pai2014-08-12 12:27:33 +0530
committerJayaram R Pai2014-08-12 12:27:33 +0530
commit107d64f7166cca11233a690ee127838bade6108d (patch)
tree70d6f35cce794ff8a4199025c2c08a0b6e2c9c39
parent416556f05904077f08103254ec9da28d6d7fcb83 (diff)
downloadtextbook_companion_fixer-107d64f7166cca11233a690ee127838bade6108d.tar.gz
textbook_companion_fixer-107d64f7166cca11233a690ee127838bade6108d.tar.bz2
textbook_companion_fixer-107d64f7166cca11233a690ee127838bade6108d.zip
added page to mark indian edition aicte books
-rw-r--r--css/scilab_fixer.css3
-rw-r--r--js/scilab_fixer.js26
-rwxr-xr-xscilab_fixer.module55
3 files changed, 84 insertions, 0 deletions
diff --git a/css/scilab_fixer.css b/css/scilab_fixer.css
index 964317f..4047749 100644
--- a/css/scilab_fixer.css
+++ b/css/scilab_fixer.css
@@ -36,3 +36,6 @@ textarea#edit-code {
height: 300px;
width: 650px;
}
+.orange {
+ background: #FF9933 !important;
+}
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();
+ });
+
});
diff --git a/scilab_fixer.module b/scilab_fixer.module
index 27bb6d5..5e210f4 100755
--- a/scilab_fixer.module
+++ b/scilab_fixer.module
@@ -29,6 +29,12 @@
"weight" => 2,
"type" => MENU_LOCAL_TASK
);
+ $items["fix/aicte/in"] = array(
+ "title" => "Mark Indian edition books",
+ "page callback" => "scilab_fixer_aicte_in_all",
+ "access arguments" => array("fix scilab"),
+ "type" => MENU_CALLBACK
+ );
$items["fix/code"] = array(
"title" => "Edit TBC code",
"page callback" => "scilab_fixer_code_all",
@@ -194,6 +200,14 @@
$example_path = $uploads_dir . $row->filepath;
file_put_contents($example_path, $code);
$data .= "updated";
+ } else if($item == "ind-ed" && $key) {
+ $query = "
+ UPDATE textbook_companion_aicte
+ SET ind = !ind
+ WHERE id = %d
+ ";
+ db_query($query, $key);
+ $data .= "updated";
} else {
$data = "Nothing to display.";
}
@@ -356,6 +370,47 @@
return $page_content;
}
+ function scilab_fixer_aicte_in_all(){
+ $page_content = "";
+ $query = "
+ SELECT * FROM textbook_companion_aicte
+ ";
+ $result = db_query($query);
+ $headers = array(
+ "Book", "Publisher", "Action"
+ );
+ $rows = array();
+ while($row = db_fetch_object($result)) {
+ $item = array(
+ "data" => array(
+ "{$row->book}<br>by{$row->author}",
+ $row->publisher,
+ ),
+ );
+ $ind_options = array(
+ /* # linking in drupal l() */
+ "fragment" => " ",
+ "external" => TRUE,
+ "attributes" => array(
+ "class" => "ind-ed",
+ "data-aicte" => "{$row->id}",
+ )
+ );
+ /* ind-ed link */
+ if($row->ind) {
+ array_push($item["data"], l("Unmark", "", $ind_options));
+ } else {
+ array_push($item["data"], l("Mark", "", $ind_options));
+ }
+ if($row->ind) {
+ $item["class"] .= " orange";
+ }
+ array_push($rows, $item);
+ }
+ $page_content .= theme("table", $headers, $rows);
+ return $page_content;
+ }
+
function scilab_fixer_code_form($form_state) {
$form = array();
$form["wrapper"] = array(