Mercurial > hg > extraction-interface
comparison views/Extractapp/TaggingText.php @ 63:3395385476d1 extractapp
bug fixed: popup tag window is closed automatically when saving text file
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Wed, 01 Apr 2015 15:10:35 +0200 |
| parents | 3fb9e3884401 |
| children | f9ae94a9b041 |
comparison
equal
deleted
inserted
replaced
| 62:3fb9e3884401 | 63:3395385476d1 |
|---|---|
| 14 $taglist_infile = $viewmodel['taglist_infile']; | 14 $taglist_infile = $viewmodel['taglist_infile']; |
| 15 $book_meta = $viewmodel['book_meta']; | 15 $book_meta = $viewmodel['book_meta']; |
| 16 | 16 |
| 17 ?> | 17 ?> |
| 18 | 18 |
| 19 | |
| 19 <html> | 20 <html> |
| 20 <head> | 21 <head> |
| 21 <title></title> | 22 <meta charset="UTF-8"> |
| 23 <title>Extraction Interface</title> | |
| 22 | 24 |
| 23 <style> | 25 <style> |
| 24 dynasty | 26 dynasty |
| 25 { | 27 { |
| 26 color:red; | 28 color:red; |
| 79 } | 81 } |
| 80 } | 82 } |
| 81 | 83 |
| 82 function reloadText() { | 84 function reloadText() { |
| 83 // confirm to reload | 85 // confirm to reload |
| 84 var r = confirm("Your editing will be discarded. Are you sure you want to reload?"); | 86 var r = confirm("Are you sure you want to load the latest version (in a new tab)?"); |
| 85 if (r != true) { | 87 if (r != true) { |
| 86 return; | 88 return; |
| 87 } | 89 } |
| 88 | 90 |
| 89 var form = document.createElement("form"); | 91 var form = document.createElement("form"); |
| 90 form.setAttribute("method", "post"); | 92 form.setAttribute("method", "post"); |
| 91 form.setAttribute("action", "./TaggingText"); // hand to controller | 93 form.setAttribute("action", "./TaggingText"); // hand to controller |
| 92 //form.setAttribute("target", "_self"); | |
| 93 form.setAttribute("target", "_blank"); | 94 form.setAttribute("target", "_blank"); |
| 94 | 95 |
| 95 var hiddenField = document.createElement("input"); | 96 var hiddenField = document.createElement("input"); |
| 96 hiddenField.setAttribute("name", "topic"); | 97 hiddenField.setAttribute("name", "topic"); |
| 97 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); | 98 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); |
| 165 //el.stop().animate({'top':finaldestination},500); | 166 //el.stop().animate({'top':finaldestination},500); |
| 166 el.stop().animate({'top':finaldestination},0); | 167 el.stop().animate({'top':finaldestination},0); |
| 167 }); | 168 }); |
| 168 | 169 |
| 169 | 170 |
| 170 // --- handle old version taglist --- | |
| 171 var _GET = JSON.parse('<?php echo json_encode($_GET) ?>'); | 171 var _GET = JSON.parse('<?php echo json_encode($_GET) ?>'); |
| 172 if (_GET['id']) { | 172 if (_GET['id']) { |
| 173 // === This case should only be possible for developing on local machine ==== | 173 // === This case should only be possible for developing on local machine ==== |
| 174 var info = JSON.parse('<?php echo json_encode($info) ?>'); | 174 var info = JSON.parse('<?php echo json_encode($info) ?>'); |
| 175 var redirectUrl = "http://localhost:1080/localgazetteers-dev/extraction-interface/Extractapp/TaggingText"; | 175 var redirectUrl = "http://localhost:1080/localgazetteers-dev/extraction-interface/Extractapp/TaggingText"; |
| 181 $('body').append(form); | 181 $('body').append(form); |
| 182 $(form).submit(); | 182 $(form).submit(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 // --- handle old version taglist --- | |
| 186 // --- TODO: check if taglist in file is up-to-date --- | 187 // --- TODO: check if taglist in file is up-to-date --- |
| 187 /* | 188 /* |
| 188 var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); | 189 var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); |
| 189 if (taglist_infile != "") { | 190 if (taglist_infile != "") { |
| 190 // TODO: pop up to ask if load the latest taglist | 191 // TODO: pop up to ask if load the latest taglist |
| 214 | 215 |
| 215 handleFileVersionConflict(); | 216 handleFileVersionConflict(); |
| 216 | 217 |
| 217 | 218 |
| 218 }); | 219 }); |
| 219 $(document).on("click", "name", function (e) { | |
| 220 | |
| 221 if ( $("#editTextId").html() != "Edit the text" ) return 0; | |
| 222 if ( $(this).prop("tagName").toLowerCase() != "name" ) return 0; | |
| 223 | |
| 224 removeTagNewDiv( e, "name", $(this) ); | |
| 225 }); | |
| 226 | 220 |
| 227 $(document).on("mouseup", '#editable-area', function (e) { | 221 $(document).on("mouseup", '#editable-area', function (e) { |
| 222 | |
| 228 $('.questionMarkClass').remove(); | 223 $('.questionMarkClass').remove(); |
| 229 $('.tagItemDivClass').remove(); | 224 $('.tagItemDivClass').remove(); |
| 230 | 225 |
| 231 if ( $("#editTextId").html() != "Edit the text" ) return 0; | 226 if ( $("#editTextId").html() != "Edit the text" ) return 0; |
| 232 var selection = getSelected(); | 227 var selection = getSelected(); |
| 242 newdiv.id = "tagItemDivId"; | 237 newdiv.id = "tagItemDivId"; |
| 243 newdiv.setAttribute("class", "tagItemDivClass"); | 238 newdiv.setAttribute("class", "tagItemDivClass"); |
| 244 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px'; | 239 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px'; |
| 245 | 240 |
| 246 newdiv.style.backgroundColor = "white"; | 241 newdiv.style.backgroundColor = "white"; |
| 247 newdiv.style.zIndex = 2; | 242 newdiv.style.zIndex = "3"; |
| 248 | 243 |
| 249 //console.log(selection.getRangeAt(0).cloneContents()); | 244 //console.log(selection.getRangeAt(0).cloneContents()); |
| 250 if ( container.innerHTML.indexOf( "br" ) != -1 ) { | 245 if ( container.innerHTML.indexOf( "br" ) != -1 ) { |
| 251 var newselect = document.createElement("select"); | 246 var newselect = document.createElement("select"); |
| 252 newselect.id = "TitletagType"; | 247 newselect.id = "TitletagType"; |
| 606 } | 601 } |
| 607 //document.styleSheets[0].addRule("tag001", "color:green;") | 602 //document.styleSheets[0].addRule("tag001", "color:green;") |
| 608 } | 603 } |
| 609 | 604 |
| 610 function saveTextToLGService() { | 605 function saveTextToLGService() { |
| 611 | 606 // clean editable-area |
| 607 $('.questionMarkClass').remove(); | |
| 608 $('.tagItemDivClass').remove(); | |
| 609 | |
| 612 // ------------- | 610 // ------------- |
| 613 var info = JSON.parse('<?php echo json_encode($info) ?>'); | 611 var info = JSON.parse('<?php echo json_encode($info) ?>'); |
| 614 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); | 612 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); |
| 615 | 613 |
| 616 // if this is a new branch, ask for label | 614 // if this is a new branch, ask for label |
| 659 | 657 |
| 660 _postForContineTagging(form); | 658 _postForContineTagging(form); |
| 661 | 659 |
| 662 console.log("complete saving to LGService"); | 660 console.log("complete saving to LGService"); |
| 663 | 661 |
| 664 | |
| 665 /* | |
| 666 | |
| 667 if (info) { | |
| 668 var hiddenField = document.createElement("input"); | |
| 669 hiddenField.setAttribute("name", "fileId"); | |
| 670 hiddenField.setAttribute("value", info['file_id']); | |
| 671 form.appendChild(hiddenField); | |
| 672 var hiddenField = document.createElement("input"); | |
| 673 hiddenField.setAttribute("name", "branchId"); | |
| 674 hiddenField.setAttribute("value", info['branch_id']); | |
| 675 form.appendChild(hiddenField); | |
| 676 var hiddenField = document.createElement("input"); | |
| 677 hiddenField.setAttribute("name", "userId"); | |
| 678 hiddenField.setAttribute("value", info['user_id']); | |
| 679 form.appendChild(hiddenField); | |
| 680 var hiddenField = document.createElement("input"); | |
| 681 hiddenField.setAttribute("name", "sectionId"); | |
| 682 hiddenField.setAttribute("value", info['section_id']); | |
| 683 form.appendChild(hiddenField); | |
| 684 | |
| 685 var hiddenField = document.createElement("input"); | |
| 686 hiddenField.setAttribute("name", "bookId"); | |
| 687 hiddenField.setAttribute("value", info['book_id']); | |
| 688 form.appendChild(hiddenField); | |
| 689 var hiddenField = document.createElement("input"); | |
| 690 hiddenField.setAttribute("name", "sectionName"); | |
| 691 hiddenField.setAttribute("value", info['section_name']); | |
| 692 form.appendChild(hiddenField); | |
| 693 var hiddenField = document.createElement("input"); | |
| 694 hiddenField.setAttribute("name", "bookName"); | |
| 695 hiddenField.setAttribute("value", info['book_name']); | |
| 696 form.appendChild(hiddenField); | |
| 697 | |
| 698 } | |
| 699 | |
| 700 var hiddenField = document.createElement("input"); | |
| 701 hiddenField.setAttribute("name", "text"); | |
| 702 var el = document.getElementById("editable-area"); | |
| 703 //var text = encodeURIComponent(el.innerHTML); | |
| 704 var text = el.innerHTML; | |
| 705 hiddenField.setAttribute("value", text); | |
| 706 form.appendChild(hiddenField); | |
| 707 | |
| 708 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | |
| 709 document.body.appendChild(form); | |
| 710 form.submit(); | |
| 711 } else { | |
| 712 form.submit(); // works under IE and Chrome, but not FF | |
| 713 } | |
| 714 */ | |
| 715 } | 662 } |
| 716 | 663 |
| 717 function chooseTopic(default_topic_id) { | 664 function chooseTopic(default_topic_id) { |
| 718 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); | 665 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); |
| 719 var info = JSON.parse('<?php echo json_encode($info) ?>'); | 666 var info = JSON.parse('<?php echo json_encode($info) ?>'); |
| 667 | |
| 720 | 668 |
| 721 $('#load_topic_div').html(""); | 669 $('#load_topic_div').html(""); |
| 722 $('#load_topic_div').css("display", "block"); | 670 $('#load_topic_div').css("display", "block"); |
| 723 | 671 |
| 724 $('#load_topic_div').css("border", "1px solid black"); | 672 $('#load_topic_div').css("border", "1px solid black"); |
| 899 // insert selected wordlist into textarea at cursor position | 847 // insert selected wordlist into textarea at cursor position |
| 900 var cursorPosition = $('#smartRegexPopUpText').prop("selectionStart"); | 848 var cursorPosition = $('#smartRegexPopUpText').prop("selectionStart"); |
| 901 // cut textarea_text by cursorPosition | 849 // cut textarea_text by cursorPosition |
| 902 var text_before_cursor = textarea_text.substring(0,cursorPosition); | 850 var text_before_cursor = textarea_text.substring(0,cursorPosition); |
| 903 var text_after_cursor = textarea_text.substring(cursorPosition, textarea_text.length); | 851 var text_after_cursor = textarea_text.substring(cursorPosition, textarea_text.length); |
| 904 $('#smartRegexPopUpText').val( text_before_cursor+" ["+wordlistValue[2]+"] "+text_after_cursor); | 852 |
| 853 // default length is 1, which means {1,1} | |
| 854 $('#smartRegexPopUpText').val( text_before_cursor+"["+wordlistValue[2]+"]{1,1}"+text_after_cursor); | |
| 905 } | 855 } |
| 906 } | 856 } |
| 907 | 857 |
| 908 /* | |
| 909 <?php | |
| 910 foreach ( $wordlistArray as $wordlistValue ) { | |
| 911 echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {"; | |
| 912 echo "$('#smartRegexPopUpText').val(\"".$wordlistValue[2]."\");"; | |
| 913 echo "}"; | |
| 914 } | |
| 915 ?> | |
| 916 */ | |
| 917 }); | 858 }); |
| 918 | 859 |
| 919 | 860 |
| 920 | 861 |
| 921 </script> | 862 </script> |
| 922 | 863 |
| 923 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; "> | 864 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; "> |
| 924 </div> | 865 </div> |
| 925 | 866 |
| 926 <!-- | |
| 927 <div class="info-board" style="margin:10 30 10 30;max-width:1270;height:70px;overflow:scroll;overflow-x:hidden;"> | |
| 928 --> | |
| 929 <div class="info-board"> | 867 <div class="info-board"> |
| 930 <p class="bg-danger"> <?php echo $messages['error']; ?> </p> | 868 <p class="bg-danger"><strong><?php echo $messages['error']; ?> </strong></p> |
| 931 <p class="bg-warning"> <?php echo $messages['warning']; ?> | 869 <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> | 870 <button id="reloadTextButton" onclick="reloadText(<?php echo $default_topic_id; ?>)" style="display:none;">Load Latest Version</button> |
| 933 </p> | 871 </p> |
| 934 <p class="bg-info"> <?php echo $messages['info']; ?> </p> | 872 <p class="bg-info"> <?php echo $messages['info']; ?> </p> |
| 935 <p class="bg-default"> <?php echo $messages['debug']; ?> </p> | 873 <p class="bg-default"> <?php echo $messages['debug']; ?> </p> |
