comparison views/Extractapp/TaggingText.php @ 62:3fb9e3884401 extractapp

New: insert selected wordlist into textarea at cursor position when editing regex
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 31 Mar 2015 14:55:58 +0200
parents c6fa7f83c5bf
children 3395385476d1
comparison
equal deleted inserted replaced
61:c6fa7f83c5bf 62:3fb9e3884401
883 hiddenField.setAttribute("value", topic_id); 883 hiddenField.setAttribute("value", topic_id);
884 form.appendChild(hiddenField); 884 form.appendChild(hiddenField);
885 885
886 _postForContineTagging(form); 886 _postForContineTagging(form);
887 887
888 /*
889 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
890 document.body.appendChild(form);
891 form.submit();
892 } else {
893 form.submit(); // works under IE and Chrome, but not FF
894 }
895 */
896 888
897 } 889 }
898 890
899 891
900 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { 892 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) {
901 893 var wordlistArray = JSON.parse('<?php echo json_encode($wordlistArray) ?>');
894
895 for (var i = 0; i < wordlistArray.length; i++) {
896 var wordlistValue = wordlistArray[i];
897 if ($('#smartRegexPopUpSelectWord').val() == wordlistValue[0]) {
898 var textarea_text = $('#smartRegexPopUpText').val();
899 // insert selected wordlist into textarea at cursor position
900 var cursorPosition = $('#smartRegexPopUpText').prop("selectionStart");
901 // cut textarea_text by cursorPosition
902 var text_before_cursor = textarea_text.substring(0,cursorPosition);
903 var text_after_cursor = textarea_text.substring(cursorPosition, textarea_text.length);
904 $('#smartRegexPopUpText').val( text_before_cursor+" ["+wordlistValue[2]+"] "+text_after_cursor);
905 }
906 }
907
908 /*
902 <?php 909 <?php
903 foreach ( $wordlistArray as $wordlistValue ) { 910 foreach ( $wordlistArray as $wordlistValue ) {
904 echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {"; 911 echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {";
905 echo "$('#smartRegexPopUpText').val(\"".$wordlistValue[2]."\");"; 912 echo "$('#smartRegexPopUpText').val(\"".$wordlistValue[2]."\");";
906 echo "}"; 913 echo "}";
907 } 914 }
908 ?> 915 ?>
916 */
909 }); 917 });
910 918
911 919
912 920
913 </script> 921 </script>
914 922
915 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; "> 923 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; ">
916 </div> 924 </div>
917 925
918 926 <!--
919 <div class="" style="margin:10 30 10 30;max-width:1270;height:70px;overflow:scroll;overflow-x:hidden;"> 927 <div class="info-board" style="margin:10 30 10 30;max-width:1270;height:70px;overflow:scroll;overflow-x:hidden;">
920 <p class="bg-danger" style=""> <?php echo $messages['error']; ?> </p> 928 -->
921 <p class="bg-warning" style=""> <?php echo $messages['warning']; ?> 929 <div class="info-board">
922 <button id="reloadTextButton" onclick="reloadText(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default" style="display:none;">Load Latest Version</button> 930 <p class="bg-danger"> <?php echo $messages['error']; ?> </p>
931 <p class="bg-warning"> <?php echo $messages['warning']; ?>
932 <button id="reloadTextButton" onclick="reloadText(<?php echo $default_topic_id; ?>)" style="display:none;">Load Latest Version</button>
923 </p> 933 </p>
924 <p class="bg-info" style=""> <?php echo $messages['info']; ?> </p> 934 <p class="bg-info"> <?php echo $messages['info']; ?> </p>
925 <p class="bg-default" style=""> <?php echo $messages['debug']; ?> </p> 935 <p class="bg-default"> <?php echo $messages['debug']; ?> </p>
926 </div> 936 </div>
927 937
928 <table width="1270" border="1" style="margin:10 30 10 30;"> 938 <table width="1270" border="1" style="margin:10 30 10 30;">
929 <tr> 939 <tr>
930 <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;"> 940 <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;">
986 <button onclick="replaceSmartRunWithBr()" style="height: 35px; width: 100px">Run(with Br)</button></br> 996 <button onclick="replaceSmartRunWithBr()" style="height: 35px; width: 100px">Run(with Br)</button></br>
987 <button onclick="replaceSmartRunSpace()" style="height: 35px; width: 220px">Run(Allow space between Group)</button></br> 997 <button onclick="replaceSmartRunSpace()" style="height: 35px; width: 220px">Run(Allow space between Group)</button></br>
988 <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Save</button> 998 <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Save</button>
989 <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Load</button> 999 <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 70px">Load</button>
990 <button onclick="smartRegexEmpty()" style="height: 35px; width: 70px">Clear</button></br> 1000 <button onclick="smartRegexEmpty()" style="height: 35px; width: 70px">Clear</button></br>
991 <!--
992 <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button>
993 -->
994 </fieldset> 1001 </fieldset>
995 1002
996 <fieldset> 1003 <fieldset>
997 <legend><h5 class="text-success"> Tag by rule:</h5></legend> 1004 <legend><h5 class="text-success"> Tag by rule:</h5></legend>
998 <button onclick="tagNameWithLastName()" style="height: 35px; width: 220px">Tag Word Begin With Surname</button></br> 1005 <button onclick="tagNameWithLastName()" style="height: 35px; width: 220px">Tag Word Begin With Surname</button></br>
1014 --> 1021 -->
1015 1022
1016 <button onclick="editText()" id="editTextId" style="height: 35px; width: 220px">Edit the text</button></br> 1023 <button onclick="editText()" id="editTextId" style="height: 35px; width: 220px">Edit the text</button></br>
1017 </br> 1024 </br>
1018 <button onclick="window.open('./EditWordlist')" style="height: 35px; width: 220px">Manage Word List</button></br> 1025 <button onclick="window.open('./EditWordlist')" style="height: 35px; width: 220px">Manage Word List</button></br>
1019 <!--
1020 <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>
1021 -->
1022 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 220px">Manage Tag List</button></br> 1026 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 35px; width: 220px">Manage Tag List</button></br>
1023 </fieldset> 1027 </fieldset>
1024 1028
1025 <fieldset> 1029 <fieldset>
1026 <legend><h5 class="text-success"> Export:</h5></legend> 1030 <legend><h5 class="text-success"> Export:</h5></legend>