diff views/Extractapp/TaggingText.php @ 86:0141df465205 extractapp_dev

New: add chinese characters to pinyin
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 30 Apr 2015 10:52:05 +0200
parents f1f849d31272
children fb5049fc5dd7
line wrap: on
line diff
--- a/views/Extractapp/TaggingText.php	Thu Apr 23 17:08:31 2015 +0200
+++ b/views/Extractapp/TaggingText.php	Thu Apr 30 10:52:05 2015 +0200
@@ -40,6 +40,7 @@
 $default_topic_id = $viewmodel['default_topic_id'];
 $topic_name = $viewmodel['topic_name']; // array of names
 $topic_tag = $viewmodel['topic_tag'];
+$topic_tag_ch = $viewmodel['topic_tag_ch'];
 $info = $viewmodel['info']; 
 $messages = $viewmodel['messages'];
 
@@ -53,7 +54,9 @@
 <head>
     <meta charset="UTF-8">
     <title>Extraction Interface</title>
-
+    <meta http-equiv="no-cache">
+    <meta http-equiv="Expires" content="-1">
+    <meta http-equiv="Cache-Control" content="no-cache">
 <style>
 dynasty
 {
@@ -91,6 +94,8 @@
 
 <script type="text/javascript">
 
+var cjst = window.cjst; // for pinyin from cjst.js
+
 // not use this for now
 function _showTagColor(up_to_date) {
     var taglistArray = "";
@@ -335,14 +340,14 @@
                 newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>";
             } else {
      			// for pop up window on edit-area for tag list
-                newdiv.innerHTML = "Tag: "+String(selection)+"<br>";
+                newdiv.innerHTML = "Tagging word: "+String(selection)+"<br>";
                 
                 <?php 
                 foreach ( $taglistArray as $taglistValue ) {
 
                     if ($taglistValue[2] == $topic_tag) {
-                    	echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">[TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)</button>\";\n";
-                        echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
+                    	echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
+                        echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(without new line)</button>\";\n";
                         echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
                         
                         /*
@@ -637,6 +642,7 @@
     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) {
     if (info['branch_id'] == 0) {
         //var label = prompt("Please enter your label for this new branch", "section"+info['section_id']);
         var today = new Date();
@@ -651,11 +657,23 @@
             mm='0'+mm
         } 
         today = dd+'.'+mm+'.'+yyyy;
-        var label = prompt("Please enter your label for this new branch", today);
+        var book_name = info['book_name'];
+        var section_name = info['section_name'];
+        var period = info['period'];
+
+        var default_label = "";
+        if (book_name == "" || section_name == "" || period == "") {
+            default_label = today;
+        } else {
+            default_label = book_name+"("+cjst.chineseToPinyin(book_name).join(' ')+")_"+period+ "_"+section_name
+                        + "("+ cjst.chineseToPinyin(section_name).join(' ') + ")_" + today;
+        }
+        
+
+        var label = prompt("Please enter your label for this new branch", default_label);
         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']);
         }    
     };
     
@@ -780,6 +798,7 @@
     hiddenField.setAttribute("name", "book_meta");
     var book_metaObj = JSON.parse('<?php echo json_encode($book_meta) ?>');
     book_metaArray = JSON.stringify(book_metaObj);
+
     hiddenField.setAttribute("value", book_metaArray);
     form.appendChild(hiddenField);    
 
@@ -882,6 +901,7 @@
     }
 });
 
+
 </script>
  
 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; ">
@@ -896,7 +916,7 @@
     <div class="bg-default"> <?php echo $messages['debug']; ?> </div>
 </div>
 
-<table border="1" style="margin:10 30 30 30; width:100%; max-width:1270px">
+<table border="1" style="margin:10 30 30 30; width:100%; max-width:1270px; min-width:680px">
     <tr>
         <td style="padding:0 5 0 5; margin: 0 5 0 5;">
             <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div>
@@ -941,58 +961,66 @@
             <div id="follow-scroll">
                 <form action="javascript:void(0);">   
                     <fieldset>
-                        <legend><h5 class="text-success"> Config Topic: </h5></legend>
-                        <div> current topic is: <?php echo $topic_name['name_en']; ?> <br>
+                        <legend><h5 class="text-success"> Topic: </h5></legend>
+                        <div> Current topic is: <br> 
+                            <?php echo $topic_name['name_en']; ?> 
                             (<?php echo $topic_name['name_ch']; ?>, <?php echo $topic_name['name_pinyin']; ?>)
-                            <button onclick="chooseTopic(<?php echo $default_topic_id;?>)" class="btn btn-xs btn-default">Change</button>
+                            <button onclick="chooseTopic(<?php echo $default_topic_id;?>)" class="btn-xs">Change</button>
                         </div>
-                        <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br>
+                        <div>The topic tag is: <?php echo $topic_tag_ch;?>(<?php echo $topic_tag;?>)</div>
                     </fieldset>
 
                     <fieldset>
                         <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
                         <div id="smartRegexShowDiv"></div><br>
-                        <button onclick="smartRegexNew()" style="height: 35px; width: 220px">Add Regex Group</button></br>
+                        <!-- <button onclick="smartRegexNew()" class="btn-lg">Add Regex Group</button></br>
+                        -->
+                        <button onclick="smartRegexNew()" class="btn-lg">Search by Patterns (Smart Regex)</button></br>
                         Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br>
-                        <button onclick="replaceSmartRun()" style="height: 35px; width: 100px">Run</button>
-                        <button onclick="replaceSmartRunWithBr()" style="height: 35px; width: 100px">Run(with Br)</button></br>
-                        <button onclick="replaceSmartRunSpace()" style="height: 35px; width: 220px">Run(Allow space between Group)</button></br>
-                        <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Save</button>
-                        <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Load</button>
-                        <button onclick="smartRegexEmpty()" style="height: 35px; width: 70px">Clear</button></br>
+                        <button onclick="replaceSmartRun()" class="btn-sm">Run</button>
+                        <button onclick="replaceSmartRunWithBr()" class="btn-md">Run(in new line)</button></br>
+                        <!-- <button onclick="replaceSmartRunSpace()" class="btn-lg">Run(Allow space between Group)</button></br>
+                        -->
+                        <button onclick="replaceSmartRunSpace()" class="btn-lg">Run(Allow space between block)</button></br>
+                        <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" class="btn-sm">Save</button>
+                        <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" class="btn-sm">Load</button>
+                        <button onclick="smartRegexEmpty()" class="btn-sm">Clear</button></br>
                     </fieldset>
                     
                     <fieldset>
                         <legend><h5 class="text-success"> Tag by rule:</h5></legend>
-                        <button onclick="tagNameWithLastName()" style="height: 35px; width: 220px">Tag Word Begin With Surname</button></br>
+                        <button onclick="tagNameWithLastName()" class="btn-lg">Tag Word Begin With Surname</button></br>
                         <button onclick="tagNameWithLastName2()" style="height: 35px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
                         <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
                         <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
-                        <button onclick="Undo()" style="height: 35px; width: 220px" id="buttonUndo" disabled="true">Undo</button>
+                        <button onclick="Undo()" class="btn-lg" id="buttonUndo" disabled="true">Undo</button>
                     </fieldset>
-                
+                                    
+                    <fieldset>
+                        <legend><h5 class="text-success"> Save:</h5></legend>
+                        <button onclick="saveTextToLGService()" id="saveTextToLGService_id" class="btn-lg">Save to LGService</button></br>
+                    </fieldset>
+                                    
                     <fieldset>
                         <legend><h5 class="text-success"> Edit:</h5></legend>
-
-                        <button onclick="saveTextToLGService()" id="saveTextToLGService_id" style="height: 35px; 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 -->
                         <!-- 
                         <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
                         -->
 
-                        <button onclick="editText()" id="editTextId" style="height: 35px; width: 220px">Edit the text</button></br>
+                        <button onclick="editText()" id="editTextId" class="btn-lg">Edit the text</button></br>
                         </br>
-                        <button onclick="window.open('./EditWordlist')" style="height: 35px; width: 220px">Manage Word List</button></br>
-                        <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 220px">Manage Tag List</button></br>
+                        <button onclick="window.open('./EditWordlist')" class="btn-lg">Edit Word List</button></br>
+                        <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" class="btn-lg">Edit Tag List</button></br>
+                        <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn-lg">Select Existing Tags</button></br>
                     </fieldset>
                     
                     <fieldset>
                         <legend><h5 class="text-success"> Export:</h5></legend>
-                        Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br>
-                        <button onclick="exportPage(<?php echo $default_topic_id;?>)" style="height: 35px; width: 220px">Export</button></br>
-                        <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 35px; width: 220px">Export All</button></br>
+                        Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd">
+                        <button onclick="exportPage(<?php echo $default_topic_id;?>)" class="btn-sm">Export</button></br>
+                        <button onclick="exportAll(<?php echo $default_topic_id;?>)" class="btn-lg">Export All</button></br>
                     </fieldset>
                 
                     <fieldset>