comparison views/Extractapp/TaggingText.php @ 94:b0cecc104639 extractapp

new: modified tags can work on tagged text
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 09 Nov 2015 12:00:24 +0100
parents a05491461199
children 9a29e9d28ece
comparison
equal deleted inserted replaced
93:a05491461199 94:b0cecc104639
78 } 78 }
79 79
80 <?php 80 <?php
81 // color on the tags 81 // color on the tags
82 foreach ( $taglistArray as $taglistValue ) { 82 foreach ( $taglistArray as $taglistValue ) {
83 echo $taglistValue[2]."\n{\ncolor:".$taglistValue[3]."\n}\n"; 83 echo $taglistValue[2]."\n{\ncolor:".$taglistValue[3]."; cursor: hand;\n}\n";
84 84
85 echo ".span_".$taglistValue[2]."\n{\nbackground-color:".$taglistValue[3]."\n}\n"; 85 echo ".span_".$taglistValue[2]."\n{\nbackground-color:".$taglistValue[3]."\n}\n";
86 } 86 }
87 87
88 ?> 88 ?>
170 var taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>'); 170 var taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>');
171 for (var i = 0; i < taglistArray.length; i++) { 171 for (var i = 0; i < taglistArray.length; i++) {
172 var taglistValue = taglistArray[i]; 172 var taglistValue = taglistArray[i];
173 173
174 174
175 $(document).on("click", taglistValue[2], function (e) { 175 $(document).on("click", taglistValue[2], function (e, taglistValue) {
176 if ($("#editTextId").html() != "Edit the text") return 0; 176 if ($("#editTextId").html() != "Edit the text") return 0;
177 var tagName = $(this).prop("tagName").toLowerCase(); 177 var tag = $(this).prop("tagName").toLowerCase();
178 //if (tagName != taglistValue[2]) return 0; 178 //if (tagName != taglistValue[2]) return 0;
179 179
180 // pop_remove_tag_window is a global variable which indicates if to show the remove-popup-window 180 // pop_remove_tag_window is a global variable which indicates if to show the remove-popup-window
181 if (pop_remove_tag_window) { 181 if (pop_remove_tag_window) {
182 removeTagNewDiv( e, tagName , $(this)); 182 removeTagNewDiv( e, tag , $(this));
183
183 }; 184 };
184 return false; 185 return false;
185 }); 186 });
186 187
187 188
264 var taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>'); 265 var taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>');
265 266
266 if (taglist_infile == "") { 267 if (taglist_infile == "") {
267 console.log("Debug: taglist_infile is empty which means taglist_infile is equal to taglist in db."); 268 console.log("Debug: taglist_infile is empty which means taglist_infile is equal to taglist in db.");
268 } else { 269 } else {
269 console.log("Debug: taglist_infile length=" + taglist_infile.length); 270 console.log("Debug: taglist in file, length=" + taglist_infile.length);
270 console.log(taglist_infile); 271 console.log(taglist_infile);
271 console.log("Debug: taglistArray length=" + taglistArray.length); 272 console.log("Debug: taglist in db, length=" + taglistArray.length);
272 console.log(taglistArray); 273 console.log(taglistArray);
273 274
274 // TOOD: ask user to modify/decide tags 275 // TOOD: ask user to modify/decide tags (?)
275 // showing taglist_infile and taglistArray 276 // showing taglist_infile and taglistArray
276 //alert("Warning: taglist is deprecated in the current file."); 277 }
277
278 }
279
280 278
281 }); 279 });
282 280
283 $(document).on("mouseup", '#editable-area', function (e) { 281 $(document).on("mouseup", '#editable-area', function (e) {
284 $('.questionMarkClass').remove(); 282 $('.questionMarkClass').remove();
382 } 380 }
383 } 381 }
384 ?> 382 ?>
385 383
386 newdiv.appendChild(tagging_tags); 384 newdiv.appendChild(tagging_tags);
385
387 // add selected words to generator regex 386 // add selected words to generator regex
388 genRegexBySelection(newdiv, selection); // append button to newdiv and handle the selection words 387 genRegexBySelection(newdiv, selection); // append button to newdiv and handle the selection words
389 388
390 } 389 }
391 390
658 657
659 var default_label = ""; 658 var default_label = "";
660 if (book_name == "" || section_name == "" || period == "") { 659 if (book_name == "" || section_name == "" || period == "") {
661 default_label = today; 660 default_label = today;
662 } else { 661 } else {
663 default_label = book_name+"("+cjst.chineseToPinyin(book_name).join(' ')+")_"+period+ "_"+section_name 662 default_label = book_name + "(" + cjst.chineseToPinyin(book_name).join(' ') + ")_"
664 + "("+ cjst.chineseToPinyin(section_name).join(' ') + ")_" + today; 663 + period + "(" + cjst.chineseToPinyin(period).join(' ') + ")_"
664 + section_name + "(" + cjst.chineseToPinyin(section_name).join(' ') + ")_"
665 + today;
665 } 666 }
666 667
667 668
668 var label = prompt("Please enter your label for this new branch", default_label); 669 var label = prompt("Please enter your label for this new branch", default_label);
669 while (label == null) { 670 while (label == null) {
694 form.appendChild(hiddenField); 695 form.appendChild(hiddenField);
695 696
696 _postForContineTagging(form); 697 _postForContineTagging(form);
697 698
698 console.log("complete saving to LGService"); 699 console.log("complete saving to LGService");
700
701 }
702
703 function createTopic(default_topic_id) {
704 var popup_status = $('#new_topic_div').css("display");
705 if (popup_status == "block") {
706 $('#new_topic_div').css("display", "none");
707 } else {
708 $('#new_topic_div').css("display", "block");
709 }
710
711
712
713
714 // TODO input new topic
715 /* In table:
716 taglist: name, tag, color (default, user can change later in the editing page)
717 topics: tag, name_en, name_ch, name_pinyin
718
719 need transaction for the following actions:
720 taglist.name: topic_tag name in chinese
721 taglist.tag: topic_tag name in eng
722 topics.tag: (the same a taglist.tag)
723 topics.name_en:
724 topics.name_ch:
725 topics.name_pinyin:
726 add a new record in topic_tag_relation: topic_id, tag_id
727 */
728
729
730
731 var newtopic = document.getElementById("newTopicSubmit");
732
733 newtopic.onclick = function(){
734 var form = document.createElement("form");
735 form.setAttribute("method", "post");
736 form.setAttribute("action", "./ConfigTagsInTopic"); // hand to controller
737 form.setAttribute("target", "_self"); // TODO self here?
738
739 // TODO
740 var hiddenField = document.createElement("input");
741 hiddenField.setAttribute("name", "func");
742 hiddenField.setAttribute("value", "CreateNewTopic");
743 form.appendChild(hiddenField);
744
745
746 var hiddenField = document.createElement("input");
747 hiddenField.setAttribute("name", "new_topic_name_en");
748 hiddenField.setAttribute("value", $("#newTopicNameEn").val());
749 form.appendChild(hiddenField);
750 var hiddenField = document.createElement("input");
751 hiddenField.setAttribute("name", "new_topic_name_ch");
752 hiddenField.setAttribute("value", $("#newTopicNameCh").val());
753 form.appendChild(hiddenField);
754 var hiddenField = document.createElement("input");
755 hiddenField.setAttribute("name", "new_topic_name_pi");
756 hiddenField.setAttribute("value", $("#newTopicNamePi").val());
757 form.appendChild(hiddenField);
758 var hiddenField = document.createElement("input");
759 hiddenField.setAttribute("name", "new_topic_tag");
760 hiddenField.setAttribute("value", $("#newTopicTag").val());
761 form.appendChild(hiddenField);
762 var hiddenField = document.createElement("input");
763 hiddenField.setAttribute("name", "new_topic_tag_name");
764 hiddenField.setAttribute("value", $("#newTopicTagName").val());
765 form.appendChild(hiddenField);
766
767
768
769 _postForContineTagging(form);
770
771 }
772
773 $("#newTopicCancel").attr("onclick", "$('#new_topic_div').css(\"display\", \"none\");");
699 774
700 } 775 }
701 776
702 function chooseTopic(default_topic_id) { 777 function chooseTopic(default_topic_id) {
703 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); 778 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' );
937 <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div> 1012 <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div>
938 </td> 1013 </td>
939 <td valign="top" style="min-width:280px; padding:0 5 0 5; margin:0 5 0 5;"> 1014 <td valign="top" style="min-width:280px; padding:0 5 0 5; margin:0 5 0 5;">
940 <div id="popups" style="position:absolute; width:300px; "> 1015 <div id="popups" style="position:absolute; width:300px; ">
941 <div id="load_topic_div" class="popup-topic popup-frame"></div> 1016 <div id="load_topic_div" class="popup-topic popup-frame"></div>
1017 <div id="new_topic_div" class="popup-newtopic popup-frame">
1018 <div class="form-horizontal">
1019 <h4 class="text-info">New topic name:</h4>
1020 <div class="form-group form-group-sm">
1021 <label for="newTopicNameEn" class="col-sm-4 control-label">name (en)</label>
1022 <div class="col-sm-8">
1023 <input type="text" class="form-control" id="newTopicNameEn" placeholder="name in English">
1024 </div>
1025 </div>
1026 <div class="form-group form-group-sm">
1027 <label for="newTopicNameCh" class="col-sm-4 control-label">name (ch)</label>
1028 <div class="col-sm-8">
1029 <input type="text" class="form-control" id="newTopicNameCh" placeholder="name in Chinese">
1030 </div>
1031 </div>
1032 <div class="form-group form-group-sm">
1033 <label for="newTopicNamePi" class="col-sm-4 control-label">name (pi)</label>
1034 <div class="col-sm-8">
1035 <input type="text" class="form-control" id="newTopicNameCh" placeholder="name in Pinyin">
1036 </div>
1037 </div>
1038
1039
1040 <h4 class="text-info">New topic tag:</h4>
1041 <div class="form-group form-group-sm">
1042 <label for="newTopicTag" class="col-sm-4 control-label">tag (en)</label>
1043 <div class="col-sm-8">
1044 <input type="text" class="form-control" id="newTopicTag" placeholder="tag in English">
1045 </div>
1046 </div>
1047
1048 <div class="form-group form-group-sm">
1049 <label for="newTopicTagName" class="col-sm-4 control-label">tag (ch)</label>
1050 <div class="col-sm-8">
1051 <input type="text" class="form-control" id="newTopicTag" placeholder="tag in Chinese">
1052 </div>
1053 </div>
1054
1055
1056 <div class="form-group form-group-sm">
1057 <div class="col-sm-offset-4 col-sm-8">
1058 <button type="submit" id="newTopicSubmit" class="btn btn-primary btn-xs">Submit</button>
1059 <button id="newTopicCancel" class="btn btn-default btn-xs">Cancel</button>
1060 </div>
1061 </div>
1062 </div>
1063
1064 </div>
942 <div id="load_regex_div" class="popup-loadregex popup-frame"></div> 1065 <div id="load_regex_div" class="popup-loadregex popup-frame"></div>
943 <div id="regex_generator" class="popup-frame"> 1066 <div id="regex_generator" class="popup-frame">
944 <h3>Gen Regex</h3> 1067 <h3>Gen Regex</h3>
945 <div>Pattern 1: 1068 <div>Pattern 1:
946 <div id="regex_pattern1" class="bg-info"></div> 1069 <div id="regex_pattern1" class="bg-info"></div>
991 <div id="follow-scroll"> 1114 <div id="follow-scroll">
992 <form action="javascript:void(0);"> 1115 <form action="javascript:void(0);">
993 <fieldset class="tool-frame"> 1116 <fieldset class="tool-frame">
994 <legend><h5 class="tool-topic" data-toggle="collapse" data-target="#tool_topic"> Topic: <span class="caret"></span></h5></legend> 1117 <legend><h5 class="tool-topic" data-toggle="collapse" data-target="#tool_topic"> Topic: <span class="caret"></span></h5></legend>
995 <div id="tool_topic" class="collapse in"> 1118 <div id="tool_topic" class="collapse in">
996 <div> Current topic is: <br> 1119 <div> Current topic is:
997 <?php echo $topic_name['name_en']; ?> 1120 <?php echo $topic_name['name_en']; ?> (<?php echo $topic_name['name_ch']; ?>, <?php echo $topic_name['name_pinyin']; ?>)
998 (<?php echo $topic_name['name_ch']; ?>, <?php echo $topic_name['name_pinyin']; ?>) 1121 <button onclick="chooseTopic(<?php echo $default_topic_id;?>)" class="btn btn-default btn-block">Change Topic</button>
999 <button onclick="chooseTopic(<?php echo $default_topic_id;?>)" class="btn btn-default btn-xs">Change</button> 1122 <button onclick="createTopic(<?php echo $default_topic_id;?>)" class="btn btn-default btn-block">Create a New Topic (TODO)</button>
1000 </div> 1123 </div>
1001 <div>The topic tag is: <?php echo $topic_tag_ch;?>(<?php echo $topic_tag;?>)</div> 1124 </div>
1125 </fieldset>
1126 <fieldset class="tool-frame">
1127 <legend><h5 class="tool-topic" data-toggle="collapse" data-target="#tool_tag"> Tag: <span class="caret"></span></h5></legend>
1128 <div id="tool_tag" class="collapse in">
1129 <div>The topic tag is: <?php echo $topic_tag_ch;?>
1130 <p class="text-muted">(Only the lines with the tag will be in the exported table.)</p>
1131 <!-- (<?php echo $topic_tag;?>) -->
1132 </div>
1002 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" class="btn btn-default btn-block">Edit Tag List</button> 1133 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" class="btn btn-default btn-block">Edit Tag List</button>
1003 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-default btn-block">Select Existing Tags</button> 1134 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-default btn-block">Select Existing Tags</button>
1135
1004 </div> 1136 </div>
1005 </fieldset> 1137 </fieldset>
1006 1138
1007 <fieldset class="tool-frame"> 1139 <fieldset class="tool-frame">
1008 <legend><h5 class="tool-topic" data-toggle="collapse" data-target="#tool_regex"> Replace By <i><b>Smart Regex</b></i>©: <span class="caret"></span></h5></legend> 1140 <legend><h5 class="tool-topic" data-toggle="collapse" data-target="#tool_regex"> Replace By <i><b>Smart Regex</b></i>©: <span class="caret"></span></h5></legend>
1023 <button onclick="replaceSmartRunWithBr()" class="btn btn-default btn-block">Run(in new line)</button> 1155 <button onclick="replaceSmartRunWithBr()" class="btn btn-default btn-block">Run(in new line)</button>
1024 <!-- <button onclick="replaceSmartRunSpace()" class="btn-lg">Run(Allow space between Group)</button></br> 1156 <!-- <button onclick="replaceSmartRunSpace()" class="btn-lg">Run(Allow space between Group)</button></br>
1025 --> 1157 -->
1026 <button onclick="replaceSmartRunSpace()" class="btn btn-default btn-block">Run(Allow space between block)</button></br> 1158 <button onclick="replaceSmartRunSpace()" class="btn btn-default btn-block">Run(Allow space between block)</button></br>
1027 1159
1028 <button onclick="window.open('./EditWordlist')" class="btn btn-default btn-block">Edit WordList</button> 1160 <button onclick="window.open('./EditWordlist')" class="btn btn-default btn-block">Edit WordList</button></br>
1029 1161
1030 <!-- developing...--> 1162 <!-- developing...-->
1031 <button onclick="genRegexWindowOpen()" id="gen_regex_window_open_id" class="btn btn-default">Open GenRegex (test)</button></br> 1163 <button onclick="genRegexWindowOpen()" id="gen_regex_window_open_id" class="btn btn-default btn-block btn-xs">Open GenRegex (developing...)</button></br>
1032 </div> 1164 </div>
1033 </fieldset> 1165 </fieldset>
1034 1166
1035 1167
1036 <?php 1168 <?php
1061 </div> 1193 </div>
1062 </fieldset> 1194 </fieldset>
1063 1195
1064 <fieldset class="tool-frame"> 1196 <fieldset class="tool-frame">
1065 <legend><h5 class="tool-topic" data-toggle="collapse" data-target="#tool_save"> Save and Export: <span class="caret"></span></h5></legend> 1197 <legend><h5 class="tool-topic" data-toggle="collapse" data-target="#tool_save"> Save and Export: <span class="caret"></span></h5></legend>
1066 <div class="collapse out" id="tool_save"> 1198 <div class="collapse in" id="tool_save">
1067 <button onclick="saveTextToLGService()" id="save_text_to_LGService_id" class="btn btn-default btn-block">Save to LGService</button> 1199 <button onclick="saveTextToLGService()" id="save_text_to_LGService_id" class="btn btn-default btn-block">Save to LGService</button>
1068 <button onclick="exportAll(<?php echo $default_topic_id;?>)" class="btn btn-default btn-block">Export All</button> 1200 <button onclick="exportAll(<?php echo $default_topic_id;?>)" class="btn btn-default btn-block">Export All</button>
1069 Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"> 1201 Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd">
1070 <button onclick="exportPage(<?php echo $default_topic_id;?>)" class="btn btn-default btn-sm">Export</button></br> 1202 <button onclick="exportPage(<?php echo $default_topic_id;?>)" class="btn btn-default btn-sm">Export</button></br>
1071 </div> 1203 </div>