comparison 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
comparison
equal deleted inserted replaced
85:966a36752c34 86:0141df465205
38 $section_id = $viewmodel['section_id']; 38 $section_id = $viewmodel['section_id'];
39 $topiclistArray = $viewmodel['topiclistArray']; 39 $topiclistArray = $viewmodel['topiclistArray'];
40 $default_topic_id = $viewmodel['default_topic_id']; 40 $default_topic_id = $viewmodel['default_topic_id'];
41 $topic_name = $viewmodel['topic_name']; // array of names 41 $topic_name = $viewmodel['topic_name']; // array of names
42 $topic_tag = $viewmodel['topic_tag']; 42 $topic_tag = $viewmodel['topic_tag'];
43 $topic_tag_ch = $viewmodel['topic_tag_ch'];
43 $info = $viewmodel['info']; 44 $info = $viewmodel['info'];
44 $messages = $viewmodel['messages']; 45 $messages = $viewmodel['messages'];
45 46
46 $taglist_infile = $viewmodel['taglist_infile']; 47 $taglist_infile = $viewmodel['taglist_infile'];
47 $book_meta = $viewmodel['book_meta']; 48 $book_meta = $viewmodel['book_meta'];
51 52
52 <html> 53 <html>
53 <head> 54 <head>
54 <meta charset="UTF-8"> 55 <meta charset="UTF-8">
55 <title>Extraction Interface</title> 56 <title>Extraction Interface</title>
56 57 <meta http-equiv="no-cache">
58 <meta http-equiv="Expires" content="-1">
59 <meta http-equiv="Cache-Control" content="no-cache">
57 <style> 60 <style>
58 dynasty 61 dynasty
59 { 62 {
60 color:red; 63 color:red;
61 } 64 }
88 </head> 91 </head>
89 92
90 <body> 93 <body>
91 94
92 <script type="text/javascript"> 95 <script type="text/javascript">
96
97 var cjst = window.cjst; // for pinyin from cjst.js
93 98
94 // not use this for now 99 // not use this for now
95 function _showTagColor(up_to_date) { 100 function _showTagColor(up_to_date) {
96 var taglistArray = ""; 101 var taglistArray = "";
97 if (up_to_date) { 102 if (up_to_date) {
333 338
334 newdiv.innerHTML += "<input id=\"RemoveTitletagName\" value=\"\"></br>"; 339 newdiv.innerHTML += "<input id=\"RemoveTitletagName\" value=\"\"></br>";
335 newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>"; 340 newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>";
336 } else { 341 } else {
337 // for pop up window on edit-area for tag list 342 // for pop up window on edit-area for tag list
338 newdiv.innerHTML = "Tag: "+String(selection)+"<br>"; 343 newdiv.innerHTML = "Tagging word: "+String(selection)+"<br>";
339 344
340 <?php 345 <?php
341 foreach ( $taglistArray as $taglistValue ) { 346 foreach ( $taglistArray as $taglistValue ) {
342 347
343 if ($taglistValue[2] == $topic_tag) { 348 if ($taglistValue[2] == $topic_tag) {
344 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"; 349 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
345 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; 350 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(without new line)</button>\";\n";
346 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; 351 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n";
347 352
348 /* 353 /*
349 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; 354 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n";
350 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; 355 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n";
635 // ------------- 640 // -------------
636 var info = JSON.parse('<?php echo json_encode($info) ?>'); 641 var info = JSON.parse('<?php echo json_encode($info) ?>');
637 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); 642 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
638 643
639 // if this is a new branch, ask for label 644 // if this is a new branch, ask for label
645 // if (info['branch_id'] == 0) {
640 if (info['branch_id'] == 0) { 646 if (info['branch_id'] == 0) {
641 //var label = prompt("Please enter your label for this new branch", "section"+info['section_id']); 647 //var label = prompt("Please enter your label for this new branch", "section"+info['section_id']);
642 var today = new Date(); 648 var today = new Date();
643 var dd = today.getDate(); 649 var dd = today.getDate();
644 var mm = today.getMonth()+1; //January is 0! 650 var mm = today.getMonth()+1; //January is 0!
649 } 655 }
650 if(mm<10) { 656 if(mm<10) {
651 mm='0'+mm 657 mm='0'+mm
652 } 658 }
653 today = dd+'.'+mm+'.'+yyyy; 659 today = dd+'.'+mm+'.'+yyyy;
654 var label = prompt("Please enter your label for this new branch", today); 660 var book_name = info['book_name'];
661 var section_name = info['section_name'];
662 var period = info['period'];
663
664 var default_label = "";
665 if (book_name == "" || section_name == "" || period == "") {
666 default_label = today;
667 } else {
668 default_label = book_name+"("+cjst.chineseToPinyin(book_name).join(' ')+")_"+period+ "_"+section_name
669 + "("+ cjst.chineseToPinyin(section_name).join(' ') + ")_" + today;
670 }
671
672
673 var label = prompt("Please enter your label for this new branch", default_label);
655 while (label == null) { 674 while (label == null) {
656 alert("You haven't saved your editing."); 675 alert("You haven't saved your editing.");
657 return; 676 return;
658 // label = prompt("Please enter your label for this new branch (not empty)", "section"+info['section_id']);
659 } 677 }
660 }; 678 };
661 679
662 var form = document.createElement("form"); 680 var form = document.createElement("form");
663 form.setAttribute("method", "post"); 681 form.setAttribute("method", "post");
778 // pass book_meta 796 // pass book_meta
779 var hiddenField = document.createElement("input"); 797 var hiddenField = document.createElement("input");
780 hiddenField.setAttribute("name", "book_meta"); 798 hiddenField.setAttribute("name", "book_meta");
781 var book_metaObj = JSON.parse('<?php echo json_encode($book_meta) ?>'); 799 var book_metaObj = JSON.parse('<?php echo json_encode($book_meta) ?>');
782 book_metaArray = JSON.stringify(book_metaObj); 800 book_metaArray = JSON.stringify(book_metaObj);
801
783 hiddenField.setAttribute("value", book_metaArray); 802 hiddenField.setAttribute("value", book_metaArray);
784 form.appendChild(hiddenField); 803 form.appendChild(hiddenField);
785 804
786 805
787 var info = JSON.parse( '<?php echo json_encode($info) ?>'); 806 var info = JSON.parse( '<?php echo json_encode($info) ?>');
880 $('#smartRegexPopUpText').val( text_before_cursor+"["+wordlistValue[2]+"]{1,1}"+text_after_cursor); 899 $('#smartRegexPopUpText').val( text_before_cursor+"["+wordlistValue[2]+"]{1,1}"+text_after_cursor);
881 } 900 }
882 } 901 }
883 }); 902 });
884 903
904
885 </script> 905 </script>
886 906
887 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; "> 907 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; ">
888 </div> 908 </div>
889 909
894 </div> 914 </div>
895 <div class="bg-info"> <?php echo $messages['info']; ?> </div> 915 <div class="bg-info"> <?php echo $messages['info']; ?> </div>
896 <div class="bg-default"> <?php echo $messages['debug']; ?> </div> 916 <div class="bg-default"> <?php echo $messages['debug']; ?> </div>
897 </div> 917 </div>
898 918
899 <table border="1" style="margin:10 30 30 30; width:100%; max-width:1270px"> 919 <table border="1" style="margin:10 30 30 30; width:100%; max-width:1270px; min-width:680px">
900 <tr> 920 <tr>
901 <td style="padding:0 5 0 5; margin: 0 5 0 5;"> 921 <td style="padding:0 5 0 5; margin: 0 5 0 5;">
902 <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div> 922 <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div>
903 </td> 923 </td>
904 <td valign="top" style="min-width:280px; padding:0 5 0 5; margin:0 5 0 5;"> 924 <td valign="top" style="min-width:280px; padding:0 5 0 5; margin:0 5 0 5;">
939 </div> 959 </div>
940 960
941 <div id="follow-scroll"> 961 <div id="follow-scroll">
942 <form action="javascript:void(0);"> 962 <form action="javascript:void(0);">
943 <fieldset> 963 <fieldset>
944 <legend><h5 class="text-success"> Config Topic: </h5></legend> 964 <legend><h5 class="text-success"> Topic: </h5></legend>
945 <div> current topic is: <?php echo $topic_name['name_en']; ?> <br> 965 <div> Current topic is: <br>
966 <?php echo $topic_name['name_en']; ?>
946 (<?php echo $topic_name['name_ch']; ?>, <?php echo $topic_name['name_pinyin']; ?>) 967 (<?php echo $topic_name['name_ch']; ?>, <?php echo $topic_name['name_pinyin']; ?>)
947 <button onclick="chooseTopic(<?php echo $default_topic_id;?>)" class="btn btn-xs btn-default">Change</button> 968 <button onclick="chooseTopic(<?php echo $default_topic_id;?>)" class="btn-xs">Change</button>
948 </div> 969 </div>
949 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br> 970 <div>The topic tag is: <?php echo $topic_tag_ch;?>(<?php echo $topic_tag;?>)</div>
950 </fieldset> 971 </fieldset>
951 972
952 <fieldset> 973 <fieldset>
953 <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend> 974 <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
954 <div id="smartRegexShowDiv"></div><br> 975 <div id="smartRegexShowDiv"></div><br>
955 <button onclick="smartRegexNew()" style="height: 35px; width: 220px">Add Regex Group</button></br> 976 <!-- <button onclick="smartRegexNew()" class="btn-lg">Add Regex Group</button></br>
977 -->
978 <button onclick="smartRegexNew()" class="btn-lg">Search by Patterns (Smart Regex)</button></br>
956 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> 979 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br>
957 <button onclick="replaceSmartRun()" style="height: 35px; width: 100px">Run</button> 980 <button onclick="replaceSmartRun()" class="btn-sm">Run</button>
958 <button onclick="replaceSmartRunWithBr()" style="height: 35px; width: 100px">Run(with Br)</button></br> 981 <button onclick="replaceSmartRunWithBr()" class="btn-md">Run(in new line)</button></br>
959 <button onclick="replaceSmartRunSpace()" style="height: 35px; width: 220px">Run(Allow space between Group)</button></br> 982 <!-- <button onclick="replaceSmartRunSpace()" class="btn-lg">Run(Allow space between Group)</button></br>
960 <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Save</button> 983 -->
961 <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Load</button> 984 <button onclick="replaceSmartRunSpace()" class="btn-lg">Run(Allow space between block)</button></br>
962 <button onclick="smartRegexEmpty()" style="height: 35px; width: 70px">Clear</button></br> 985 <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" class="btn-sm">Save</button>
986 <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" class="btn-sm">Load</button>
987 <button onclick="smartRegexEmpty()" class="btn-sm">Clear</button></br>
963 </fieldset> 988 </fieldset>
964 989
965 <fieldset> 990 <fieldset>
966 <legend><h5 class="text-success"> Tag by rule:</h5></legend> 991 <legend><h5 class="text-success"> Tag by rule:</h5></legend>
967 <button onclick="tagNameWithLastName()" style="height: 35px; width: 220px">Tag Word Begin With Surname</button></br> 992 <button onclick="tagNameWithLastName()" class="btn-lg">Tag Word Begin With Surname</button></br>
968 <button onclick="tagNameWithLastName2()" style="height: 35px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br> 993 <button onclick="tagNameWithLastName2()" style="height: 35px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
969 <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>--> 994 <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
970 <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>--> 995 <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
971 <button onclick="Undo()" style="height: 35px; width: 220px" id="buttonUndo" disabled="true">Undo</button> 996 <button onclick="Undo()" class="btn-lg" id="buttonUndo" disabled="true">Undo</button>
972 </fieldset> 997 </fieldset>
973 998
999 <fieldset>
1000 <legend><h5 class="text-success"> Save:</h5></legend>
1001 <button onclick="saveTextToLGService()" id="saveTextToLGService_id" class="btn-lg">Save to LGService</button></br>
1002 </fieldset>
1003
974 <fieldset> 1004 <fieldset>
975 <legend><h5 class="text-success"> Edit:</h5></legend> 1005 <legend><h5 class="text-success"> Edit:</h5></legend>
976
977 <button onclick="saveTextToLGService()" id="saveTextToLGService_id" style="height: 35px; width: 220px">Save to LGService</button></br>
978
979 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>--> 1006 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
980 <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage --> 1007 <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage -->
981 <!-- 1008 <!--
982 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br> 1009 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
983 --> 1010 -->
984 1011
985 <button onclick="editText()" id="editTextId" style="height: 35px; width: 220px">Edit the text</button></br> 1012 <button onclick="editText()" id="editTextId" class="btn-lg">Edit the text</button></br>
986 </br> 1013 </br>
987 <button onclick="window.open('./EditWordlist')" style="height: 35px; width: 220px">Manage Word List</button></br> 1014 <button onclick="window.open('./EditWordlist')" class="btn-lg">Edit Word List</button></br>
988 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 220px">Manage Tag List</button></br> 1015 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" class="btn-lg">Edit Tag List</button></br>
1016 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn-lg">Select Existing Tags</button></br>
989 </fieldset> 1017 </fieldset>
990 1018
991 <fieldset> 1019 <fieldset>
992 <legend><h5 class="text-success"> Export:</h5></legend> 1020 <legend><h5 class="text-success"> Export:</h5></legend>
993 Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br> 1021 Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd">
994 <button onclick="exportPage(<?php echo $default_topic_id;?>)" style="height: 35px; width: 220px">Export</button></br> 1022 <button onclick="exportPage(<?php echo $default_topic_id;?>)" class="btn-sm">Export</button></br>
995 <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 35px; width: 220px">Export All</button></br> 1023 <button onclick="exportAll(<?php echo $default_topic_id;?>)" class="btn-lg">Export All</button></br>
996 </fieldset> 1024 </fieldset>
997 1025
998 <fieldset> 1026 <fieldset>
999 <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend> 1027 <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend>
1000 Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br> 1028 Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br>