Mercurial > hg > extraction-interface
comparison develop/views/Extractapp/taggingtext.php @ 29:fc7342914cdf
develop_v0
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Thu, 05 Mar 2015 15:08:09 +0100 |
| parents | e6e9bdc4f256 |
| children |
comparison
equal
deleted
inserted
replaced
| 28:e6e9bdc4f256 | 29:fc7342914cdf |
|---|---|
| 71 $(form).submit(); | 71 $(form).submit(); |
| 72 } | 72 } |
| 73 // ==== | 73 // ==== |
| 74 | 74 |
| 75 | 75 |
| 76 handleFileVersionConflict(); | 76 |
| 77 // Popup to proceeding the saving situations | 77 // TODO: Popup to proceeding the saving situations |
| 78 function handleFileVersionConflict() { | 78 function handleFileVersionConflict() { |
| 79 var info = JSON.parse('<?php echo json_encode($info) ?>'); | 79 var info = JSON.parse('<?php echo json_encode($info) ?>'); |
| 80 console.log(info['current_fileId']); | 80 console.log("currentFileId="+info['current_fileId']); |
| 81 | 81 |
| 82 if (info['current_fileId'] != 0){ | 82 if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ |
| 83 // -- there might be conflicts between different version | 83 // -- there might be conflicts between different version |
| 84 var retVal = confirm('There were something happened/someone editing in the between of time.\nDo you want to force saving? (There might be conflicts between two versions.)'); | 84 var retVal = confirm('There were something happened/someone editing in the between of time.\nDo you want to force saving? (There might be conflicts between two versions.)'); |
| 85 if( retVal == true ){ | 85 if( retVal == true ){ |
| 86 // TODO: force saving with currentFileId | 86 // TODO: force saving with currentFileId |
| 87 alert("You do the force saving!"); | 87 alert("You do the force saving!"); |
| 88 //saveTextToLGService(); | 88 //saveTextToLGService(); |
| 89 | 89 |
| 90 }else{ | 90 }else{ |
| 91 var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)"); | 91 var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)"); |
| 92 | |
| 93 console.log("loadLastest="+loadLastest); | |
| 94 /* | |
| 95 var form = document.createElement("form"); | |
| 96 form.setAttribute("method", "post"); | |
| 97 form.setAttribute("action", "./TaggingText"); // hand to controller | |
| 98 form.setAttribute("target", "_blank"); | |
| 99 | |
| 100 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); | |
| 101 | |
| 102 var hiddenField = document.createElement("input"); | |
| 103 hiddenField.setAttribute("name", "topic"); | |
| 104 hiddenField.setAttribute("value", topic_id); | |
| 105 form.appendChild(hiddenField); | |
| 106 | |
| 107 var hiddenField = document.createElement("input"); | |
| 108 hiddenField.setAttribute("name", "func"); | |
| 109 hiddenField.setAttribute("value", "Reload"); // reload | |
| 110 form.appendChild(hiddenField); | |
| 111 | |
| 112 _postForContineTagging(form); | |
| 113 | |
| 114 alert("You will reload the latest version."); | |
| 115 */ | |
| 116 /* | |
| 92 if (loadLastest == true) { | 117 if (loadLastest == true) { |
| 93 // TODO: reload page with the currentFileId | 118 // TODO: reload page with the currentFileId |
| 94 alert("You will reload the latest version."); | 119 console.log('loadLastest is true'); |
| 95 | 120 $.ajax({ |
| 96 var form = document.createElement("form"); | 121 type : 'POST', |
| 97 form.setAttribute("method", "post"); | 122 url : './TaggingText', |
| 98 form.setAttribute("action", "./TaggingText"); // hand to controller | 123 async : false, |
| 99 form.setAttribute("target", "_blank"); | 124 data : 'func=Reload', |
| 100 | 125 success: function (result) { |
| 101 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); | 126 //var lastest_editing = jQuery.parseJSON(result); |
| 102 | 127 console.log("lastest_editing string:"+result); |
| 103 var hiddenField = document.createElement("input"); | 128 // change text to the new one |
| 104 hiddenField.setAttribute("name", "topic"); | 129 //var el = document.getElementById("editable-area"); |
| 105 hiddenField.setAttribute("value", topic_id); | 130 //el.innerHTML = lastest_editing; |
| 106 form.appendChild(hiddenField); | 131 //alert("Reload the page!"); |
| 107 | 132 }, |
| 108 var hiddenField = document.createElement("input"); | 133 error: function (result) { |
| 109 hiddenField.setAttribute("name", "func"); | 134 alert("Reload Fails!"); |
| 110 hiddenField.setAttribute("value", "Reload"); // reload | 135 } |
| 111 form.appendChild(hiddenField); | 136 }).done(function(result) { |
| 112 | 137 // reload page |
| 113 | 138 //document.location.reload(true); |
| 114 | 139 |
| 115 _postForContineTagging(form); | 140 }); |
| 116 | |
| 117 // use the current_fileId to reload the latest version of text | |
| 118 console.log('reloaded'); | |
| 119 | |
| 120 | 141 |
| 121 } else { | 142 } else { |
| 122 alert("Just a reminder, there is a new version for this branch."); | 143 alert("Just a reminder, there is a new version for this branch."); |
| 123 } | 144 } |
| 145 */ | |
| 146 | |
| 124 } | 147 } |
| 125 } | 148 } |
| 126 return; | 149 return; |
| 127 | 150 |
| 128 } | 151 } |
| 169 //el.stop().animate({'top':finaldestination},500); | 192 //el.stop().animate({'top':finaldestination},500); |
| 170 el.stop().animate({'top':finaldestination},0); | 193 el.stop().animate({'top':finaldestination},0); |
| 171 }); | 194 }); |
| 172 | 195 |
| 173 | 196 |
| 197 | |
| 198 handleFileVersionConflict(); | |
| 174 | 199 |
| 175 | 200 |
| 176 | 201 |
| 177 /* | 202 /* |
| 178 | 203 |
| 591 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); | 616 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>'); |
| 592 | 617 |
| 593 // if this is a new branch, ask for label | 618 // if this is a new branch, ask for label |
| 594 if (info['branch_id'] == 0) { | 619 if (info['branch_id'] == 0) { |
| 595 var cnt = 0; | 620 var cnt = 0; |
| 596 var label = prompt("Please enter your label for this new branch", "label for section "+info['section_id']); | 621 var label = prompt("Please enter your label for this new branch", "section"+info['section_id']); |
| 597 while (label == null && cnt <= 3) { | 622 while (label == null && cnt <= 3) { |
| 598 cnt ++; | 623 cnt ++; |
| 599 label = prompt("Please enter your label for this new branch (not empty)", "label for section "+info['section_id']); | 624 label = prompt("Please enter your label for this new branch (not empty)", "section"+info['section_id']); |
| 600 } | 625 } |
| 601 }; | 626 }; |
| 602 | 627 |
| 603 | 628 |
| 604 | 629 |
| 623 hiddenField.setAttribute("value", topic_id); | 648 hiddenField.setAttribute("value", topic_id); |
| 624 form.appendChild(hiddenField); | 649 form.appendChild(hiddenField); |
| 625 | 650 |
| 626 _postForContineTagging(form); | 651 _postForContineTagging(form); |
| 627 | 652 |
| 653 console.log("complete saving to LGService"); | |
| 654 | |
| 655 | |
| 628 /* | 656 /* |
| 629 | 657 |
| 630 if (info) { | 658 if (info) { |
| 631 var hiddenField = document.createElement("input"); | 659 var hiddenField = document.createElement("input"); |
| 632 hiddenField.setAttribute("name", "fileId"); | 660 hiddenField.setAttribute("name", "fileId"); |
| 799 var hiddenField = document.createElement("input"); | 827 var hiddenField = document.createElement("input"); |
| 800 hiddenField.setAttribute("name", "bookName"); | 828 hiddenField.setAttribute("name", "bookName"); |
| 801 hiddenField.setAttribute("value", info['book_name']); | 829 hiddenField.setAttribute("value", info['book_name']); |
| 802 form.appendChild(hiddenField); | 830 form.appendChild(hiddenField); |
| 803 }; | 831 }; |
| 804 /* | |
| 805 if (info['current_fileId']) { | 832 if (info['current_fileId']) { |
| 806 var hiddenField = document.createElement("input"); | 833 var hiddenField = document.createElement("input"); |
| 807 hiddenField.setAttribute("name", "currentFileId"); | 834 hiddenField.setAttribute("name", "currentFileId"); |
| 808 hiddenField.setAttribute("value", info['current_fileId']); | 835 hiddenField.setAttribute("value", info['current_fileId']); |
| 809 form.appendChild(hiddenField); | 836 form.appendChild(hiddenField); |
| 810 }; | 837 }; |
| 811 */ | |
| 812 | 838 |
| 813 } | 839 } |
| 814 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | 840 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { |
| 815 document.body.appendChild(form); | 841 document.body.appendChild(form); |
| 816 form.submit(); | 842 form.submit(); |
| 832 hiddenField.setAttribute("value", topic_id); | 858 hiddenField.setAttribute("value", topic_id); |
| 833 form.appendChild(hiddenField); | 859 form.appendChild(hiddenField); |
| 834 | 860 |
| 835 _postForContineTagging(form); | 861 _postForContineTagging(form); |
| 836 | 862 |
| 863 /* | |
| 837 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | 864 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { |
| 838 document.body.appendChild(form); | 865 document.body.appendChild(form); |
| 839 form.submit(); | 866 form.submit(); |
| 840 } else { | 867 } else { |
| 841 form.submit(); // works under IE and Chrome, but not FF | 868 form.submit(); // works under IE and Chrome, but not FF |
| 842 } | 869 } |
| 870 */ | |
| 871 | |
| 843 } | 872 } |
| 844 | 873 |
| 845 | 874 |
| 846 | 875 |
| 847 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { | 876 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { |
