changeset 46:b3ca5d2b4d3f extractapp

bug fix: edit and save regex. But a jquery issue in Chrome
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 16 Mar 2015 15:49:39 +0100
parents 3d6b8fb7335d
children 886f43b26ee2
files develop/classes/basemodel.php develop/data/regex_files/product_name.txt develop/data/regex_files/product_name_started_with_space.txt develop/data/regex_files/zhishu.txt develop/js/taggingtext.js develop/models/extractapp.php develop/views/Extractapp/TaggingText.php develop/views/maintemplate.php develop/views/maintemplate_local.php
diffstat 9 files changed, 49 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/develop/classes/basemodel.php	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/classes/basemodel.php	Mon Mar 16 15:49:39 2015 +0100
@@ -34,7 +34,7 @@
 
             die ('Can\'t use foo : ' . mysql_error());
         }
-        $this->topic = 1;   // set the default topic to person (人物)
+        $this->topic = 2;   // set the default topic to product_name (物產)
 	}
     
     protected function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
--- a/develop/data/regex_files/product_name.txt	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/data/regex_files/product_name.txt	Mon Mar 16 15:49:39 2015 +0100
@@ -1,1 +1,1 @@
-<span class="span_product_name" id="span_物產名" regextext="[^○如>〈]{1,2}[稻|麥|豆|瓜|竹|菜|魚]" regexreplace="product_name" style="border: 1px solid black; width: 100px;"> 物產名 </span>
\ No newline at end of file
+<span class="span_product_name" id="span_物產名" regextext="[^○如&gt;〈】]{1,2}[稻|麥|豆|瓜|竹|菜|魚]" regexreplace="product_name" style="border: 1px solid black; width: 100px;">物產</span>
\ No newline at end of file
--- a/develop/data/regex_files/product_name_started_with_space.txt	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/data/regex_files/product_name_started_with_space.txt	Mon Mar 16 15:49:39 2015 +0100
@@ -1,1 +1,1 @@
-<span regexreplace="NOTAG" regextext="○" id="span_空白" class="span_NOTAG" style="border: 1px solid black; width: 100px;"> 空白 </span><span class="span_product_name" id="span_物產" regextext="[^○<【]{1,3}" regexreplace="product_name" style="border: 1px solid black; width: 100px;"> 物產 </span><span class="span_NOTAG" id="span_空白 " regextext="○" regexreplace="NOTAG" style="border: 1px solid black; width: 100px;"> 空白  </span>
\ No newline at end of file
+<span regexreplace="NOTAG" regextext="○" id="span_空白" class="span_NOTAG" style="border: 1px solid black; width: 100px;"> 空白 </span><span class="span_product_name" id="span_物產名" regextext="[^○<【]{1,3}" regexreplace="product_name" style="border: 1px solid black; width: 100px;"> 物產名 </span><span class="span_NOTAG" id="span_空白 " regextext="○" regexreplace="NOTAG" style="border: 1px solid black; width: 100px;"> 空白  </span>
\ No newline at end of file
--- a/develop/data/regex_files/zhishu.txt	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/data/regex_files/zhishu.txt	Mon Mar 16 15:49:39 2015 +0100
@@ -1,1 +1,1 @@
-<span regexreplace="NOTAG" regextext="○" id="span_空白" class="span_NOTAG" style="border: 1px solid black; width: 100px;"> 空白 </span><span regexreplace="title" regextext="[^○]{1,2}之屬" id="span_之屬" class="span_title" style="border: 1px solid black; width: 100px;"> 之屬 </span>
\ No newline at end of file
+<span regexreplace="NOTAG" regextext="[○】]" id="span_空白" class="span_NOTAG" style="border: 1px solid black; width: 100px;">空白</span><span regexreplace="title" regextext="[^○]{1,2}之屬" id="span_某之屬" class="span_title" style="border: 1px solid black; width: 100px;">某之屬</span>
\ No newline at end of file
--- a/develop/js/taggingtext.js	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/js/taggingtext.js	Mon Mar 16 15:49:39 2015 +0100
@@ -428,7 +428,10 @@
     $('#smartRegexShowDiv > #'+thisObject).attr("class", "span_"+$("#smartRegexPopUpSelectTag").val());
     $('#smartRegexShowDiv > #'+thisObject).attr("regexText", $("#smartRegexPopUpText").val());
     $('#smartRegexShowDiv > #'+thisObject).attr("regexReplace", $("#smartRegexPopUpSelectTag").val());
-}
+    // using .text() to modify the change of the name also // not work on chrome?
+    $('#smartRegexShowDiv > #'+thisObject).text($("#smartRegexPopUpName").val());  // smartRgextPopUpName.val() is the name of this regex
+
+}   
 
 function replaceSmartDel() {
     thisObject = $('#smartRegexPopUpDiv').attr("editID");
@@ -639,8 +642,9 @@
 }
 
 function smartRegexSave(topic_id) {
-    console.log(topic_id);
+    console.log("topic_id"+topic_id);
     var name=prompt("Please enter this Regex name",RegexLoadedName);
+
     if (name!=null){
         $.ajax({
             type : 'POST',
--- a/develop/models/extractapp.php	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/models/extractapp.php	Mon Mar 16 15:49:39 2015 +0100
@@ -9,7 +9,7 @@
 	}
     
     protected $section_id = 0, $data_path, $file_id = 0, $current_fileId=0, 
-        $branch_id = 0, $user_id = 0, $lg_text = "", $topic = 0, $taglist_infile = "", $book_meta = "";
+        $branch_id = 0, $user_id = 0, $lg_text = "", $topic, $taglist_infile = "", $book_meta = "";
     public $messages = "";
 
     private function Initialize($_urlvalues) {
@@ -411,7 +411,7 @@
             $require = $this->AppendMetaData($require);
                 
             //saving in my local machine in developing phrase
-            //file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require);
+            file_put_contents("data/parsing_files/".$_postdata['sectionId'].".txt", $require);
         } 
 
         // ------
@@ -459,7 +459,7 @@
 
         // execute the request
         // **** commended to DEBUG ***
-        $output = curl_exec($ch);
+        //$output = curl_exec($ch);
         // *****
 
         // output the profile information - includes the header
--- a/develop/views/Extractapp/TaggingText.php	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/views/Extractapp/TaggingText.php	Mon Mar 16 15:49:39 2015 +0100
@@ -216,7 +216,9 @@
             '</form>');
             $('body').append(form);
             $(form).submit();
-    } else {
+    } 
+       
+
         // --- TODO: check if taglist in file is up-to-date ---
         /*
         var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>');
@@ -237,18 +239,22 @@
             <?php $taglist_infile = ""; ?>
         }
         */
+    
+    var info = JSON.parse('<?php echo json_encode($info) ?>');
+
+    // the first time to this section. without branch_id and file_id
+    if (info['file_id'] == 0) {  // or info['branch_id'] == 0, means new file
+        $( "#saveTextToLGService_id").text( "Create(Save) Branch to LGService" );
+
     }
 
 
-
     handleFileVersionConflict();
 
-    
 
     /*
-
-    // Popup choosing topic if first time to this section. without branchId
-    if (info['file_id'] == 0) {  // or info['branchId'] == 0, means new file
+    // Popup choosing topic if first time to this section. without branch_id
+    if (info['file_id'] == 0) {  // or info['branch_id'] == 0, means new file
         // ask to choose topic
         $.ajax({
 
@@ -258,6 +264,8 @@
         // alert('choose topic!');
     }
     */
+    
+
 
 });
 $(document).on("click", "name", function (e) {
@@ -662,21 +670,33 @@
 
 
 function saveTextToLGService() {
+
     var info = JSON.parse('<?php echo json_encode($info) ?>');
     var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
 
     // if this is a new branch, ask for label
     if (info['branch_id'] == 0) {
-        var cnt = 0;
-        var label = prompt("Please enter your label for this new branch", "section"+info['section_id']);
-        while (label == null && cnt <= 3) {
-            cnt ++;
-            label = prompt("Please enter your label for this new branch (not empty)", "section"+info['section_id']);
+        //var label = prompt("Please enter your label for this new branch", "section"+info['section_id']);
+        var today = new Date();
+        var dd = today.getDate();
+        var mm = today.getMonth()+1; //January is 0!
+        var yyyy = today.getFullYear();
+
+        if(dd<10) {
+            dd='0'+dd
+        } 
+        if(mm<10) {
+            mm='0'+mm
+        } 
+        today = dd+'/'+mm+'/'+yyyy;
+        var label = prompt("Please enter your label for this new branch", today);
+        while (label == null) {
+            alert("You haven't saved your editing.");
+            return;
+            // label = prompt("Please enter your label for this new branch (not empty)", "section"+info['section_id']);
         }    
     };
     
-    
-
     var form = document.createElement("form");
     form.setAttribute("method", "post");
     form.setAttribute("action", "./TaggingText");  // hand to controller
@@ -998,7 +1018,7 @@
                     <option value="NOTAG">不標記</option>
                     </select><br>
                     <button id="smartRegexPopUpAdd" onclick="replaceSmartAdd()" class="btn btn-info" style="">Add</button>
-                    <button id="smartRegexPopUpEdit" onclick="replaceSmartEdit()" class="btn btn-success" style="">Edit</button>
+                    <button id="smartRegexPopUpEdit" onclick="replaceSmartEdit()" class="btn btn-success" style="">Edit/Update</button>
                     <button id="smartRegexPopUpDel" onclick="replaceSmartDel()" class="btn btn-danger" style="">Delete</button>
                     <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" class="btn btn-default" style=""><<</button>
                     <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button>
@@ -1043,7 +1063,8 @@
                 
                     <fieldset>
                         <legend><h5 class="text-success"> Edit:</h5></legend>
-                        <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
+
+                        <button onclick="saveTextToLGService()" id="saveTextToLGService_id" style="height: 30px; width: 220px">Save to LGService</button></br>
                     
                         <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
                         <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage -->
--- a/develop/views/maintemplate.php	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/views/maintemplate.php	Mon Mar 16 15:49:39 2015 +0100
@@ -1,7 +1,6 @@
 <html>
 <head>
 <title></title>
-
 <script src="../js/jquery-1.10.2.min.js"></script>
 <script src="../js/jquery-ui.js"></script>
 <script src="../js/taggingtext.js"></script>
--- a/develop/views/maintemplate_local.php	Fri Mar 13 14:47:23 2015 +0100
+++ b/develop/views/maintemplate_local.php	Mon Mar 16 15:49:39 2015 +0100
@@ -2,7 +2,6 @@
 <head>
 <title></title>
 
-
 <script src="../../js/jquery-1.10.2.min.js"></script>
 <script src="../../js/jquery-ui.js"></script>
 <script src="../../js/taggingtext.js"></script>