changeset 22:a8ae5cbc3364

update topic_tag_relation table when adding new tag
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 24 Feb 2015 17:29:56 +0100
parents c805470cefee
children a879f6b9d166
files develop/models/extractapp.php develop/views/Extractapp/edittaglist.php develop/views/maintemplate.php
diffstat 3 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/develop/models/extractapp.php	Tue Feb 24 16:09:59 2015 +0100
+++ b/develop/models/extractapp.php	Tue Feb 24 17:29:56 2015 +0100
@@ -494,9 +494,14 @@
     
     // === for manage tag list ===
     public function EditTaglist($_postdata) {
-        
-        $query = "SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'taglist'";
-        $largest_id = mysql_query($query);
+        $query = "SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='taglist'";
+        $result = mysql_query($query);
+        if (!$result) {
+            echo json_encode(mysql_error());
+        }
+        $row = mysql_fetch_assoc($result);
+        $largest_id = $row['AUTO_INCREMENT'];
+
 
         $topic_id = $_postdata['topic_id'];
         $result = $this->GetTaglistByTopicID($topic_id);
--- a/develop/views/Extractapp/edittaglist.php	Tue Feb 24 16:09:59 2015 +0100
+++ b/develop/views/Extractapp/edittaglist.php	Tue Feb 24 17:29:56 2015 +0100
@@ -3,7 +3,6 @@
 $taglistArray = $viewmodel['taglistArray'];
 $topic_id = $viewmodel['topic_id'];
 $largestId = $viewmodel['largest_id'];
-var_dump($largestId);
 
 ?>
 
@@ -25,7 +24,8 @@
 
 <script type="text/javascript">
 
-var largestId = 0;
+// var largestId = 0;
+var largestId = JSON.parse('<?php echo json_encode($largestId) ?>');
 
 function addTag( ) {
 	largestId++;
@@ -85,7 +85,7 @@
 	*/
 
 	// insertRule works in IE9, FF, Saf, Chrome, Opera
-	var x = document.styleSheets[1];
+	var x = document.styleSheets[0];
 	var selector1 = "#colorSelector"+largestId;
 	var selector2 = "#colorSelector"+largestId+" div";
 
@@ -103,7 +103,8 @@
 
 
 function addNode( id, name, tag, color ) {
-	if ( parseInt(id) > largestId ) largestId=parseInt(id);
+	// if ( parseInt(id) > largestId ) largestId=parseInt(id);
+	
 	var tableMain=document.getElementById("tableMain");
 	
 	if ( id == "AddTag" ) {
@@ -118,7 +119,6 @@
 		
 		return 0;
 	}
-	
 	var row = tableMain.appendChild(document.createElement("tr"));
 	row.setAttribute("height","50");
 	row.id = "tr"+id;
@@ -189,7 +189,7 @@
 
 	*/
 	// insertRule works in IE9, FF, Saf, Chrome, Opera
-	var x = document.styleSheets[1];
+	var x = document.styleSheets[0];
 	var selector1 = "#colorSelector"+id;
 	var selector2 = "#colorSelector"+id+" div";
 
@@ -344,9 +344,9 @@
 addNode( "AddTag","","","" );
 addNode( "ID","Name","Tag","Color" );
 
-
 <?php 
 foreach ( $taglistArray as $tagId => $tagArray ) {
+
 	echo "addNode( \"".$tagId."\",\"".$tagArray[0]."\",\"".$tagArray[1]."\",\"".$tagArray[2]."\" );\n";
 }
 ?>
--- a/develop/views/maintemplate.php	Tue Feb 24 16:09:59 2015 +0100
+++ b/develop/views/maintemplate.php	Tue Feb 24 17:29:56 2015 +0100
@@ -7,7 +7,6 @@
 <script src="../../js/taggingtext.js"></script>
 -->
 <script src="../js/jquery-1.10.2.min.js"></script>
-<script src="../js/bootstrap.min.js"></script>
 <script src="../js/taggingtext.js"></script>
 
 <!-- Bootstrap -->