comparison views/Extractapp/TaggingText.php @ 57:5cf9720a2e25 extractapp

New: add reloadText to load the latest version
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 30 Mar 2015 17:23:47 +0200
parents f9e7119339b2
children a11f9103b8db
comparison
equal deleted inserted replaced
56:95f929d7b318 57:5cf9720a2e25
77 } 77 }
78 */ 78 */
79 } 79 }
80 } 80 }
81 81
82 function reloadText() {
83 // confirm to reload
84 var r = confirm("Your editing will be discarded. Are you sure you want to reload?");
85 if (r != true) {
86 return;
87 }
88
89 var form = document.createElement("form");
90 form.setAttribute("method", "post");
91 form.setAttribute("action", "./TaggingText"); // hand to controller
92 //form.setAttribute("target", "_self");
93 form.setAttribute("target", "_blank");
94
95 var hiddenField = document.createElement("input");
96 hiddenField.setAttribute("name", "topic");
97 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
98 hiddenField.setAttribute("value", topic_id);
99 form.appendChild(hiddenField);
100
101 var hiddenField = document.createElement("input");
102 hiddenField.setAttribute("name", "func");
103 hiddenField.setAttribute("value", "ReloadText");
104 form.appendChild(hiddenField);
105
106 _postForContineTagging(form);
107
108 }
109
82 // TODO: Popup to proceeding the saving situations 110 // TODO: Popup to proceeding the saving situations
83 function handleFileVersionConflict() { 111 function handleFileVersionConflict() {
84 var info = JSON.parse('<?php echo json_encode($info) ?>'); 112 var info = JSON.parse('<?php echo json_encode($info) ?>');
85 console.log("currentFileId="+info['current_fileId']); 113 console.log("currentFileId="+info['current_fileId']);
86 114
87 if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ 115 if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){
88 // -- there might be conflicts between different version 116 // -- there might be conflicts between different version
89 alert("Someone edited this file and saved before you."); 117 alert("Your saving failed! Someone edited this file and saved before you.");
90 return; 118 return;
91
92 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.)');
93 if( retVal == true ){
94 // TODO: force saving with currentFileId
95 alert("You do the force saving!");
96 //saveTextToLGService();
97
98 }else{
99 var loadLastest = confirm("Do you want to reload for the lastest version? (Your current editing will lost.)");
100
101 console.log("loadLastest="+loadLastest);
102 /*
103 var form = document.createElement("form");
104 form.setAttribute("method", "post");
105 form.setAttribute("action", "./TaggingText"); // hand to controller
106 form.setAttribute("target", "_blank");
107
108 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
109
110 var hiddenField = document.createElement("input");
111 hiddenField.setAttribute("name", "topic");
112 hiddenField.setAttribute("value", topic_id);
113 form.appendChild(hiddenField);
114
115 var hiddenField = document.createElement("input");
116 hiddenField.setAttribute("name", "func");
117 hiddenField.setAttribute("value", "Reload"); // reload
118 form.appendChild(hiddenField);
119
120 _postForContineTagging(form);
121
122 alert("You will reload the latest version.");
123 */
124 /*
125 if (loadLastest == true) {
126 // TODO: reload page with the currentFileId
127 console.log('loadLastest is true');
128 $.ajax({
129 type : 'POST',
130 url : './TaggingText',
131 async : false,
132 data : 'func=Reload',
133 success: function (result) {
134 //var lastest_editing = jQuery.parseJSON(result);
135 console.log("lastest_editing string:"+result);
136 // change text to the new one
137 //var el = document.getElementById("editable-area");
138 //el.innerHTML = lastest_editing;
139 //alert("Reload the page!");
140 },
141 error: function (result) {
142 alert("Reload Fails!");
143 }
144 }).done(function(result) {
145 // reload page
146 //document.location.reload(true);
147
148 });
149
150 } else {
151 alert("Just a reminder, there is a new version for this branch.");
152 }
153 */
154
155 }
156
157 } 119 }
158 return; 120 return;
159 121
160 } 122 }
161 123
514 form.submit(); // works under IE and Chrome, but not FF 476 form.submit(); // works under IE and Chrome, but not FF
515 } 477 }
516 */ 478 */
517 } 479 }
518 480
519
520
521
522 function exportAll(topic_id) { 481 function exportAll(topic_id) {
523 var el = document.getElementById("editable-area"); 482 var el = document.getElementById("editable-area");
524 var str= "" + el.innerHTML; 483 var str= "" + el.innerHTML;
525 var form = document.createElement("form"); 484 var form = document.createElement("form");
526 form.setAttribute("method", "post"); 485 form.setAttribute("method", "post");
576 } 535 }
577 */ 536 */
578 537
579 } 538 }
580 // =========== 539 // ===========
581
582 540
583 function tagwithOnlytag( range, stringSelection, tag ) { 541 function tagwithOnlytag( range, stringSelection, tag ) {
584 saveUndoText(); 542 saveUndoText();
585 var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>'); 543 var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>');
586 var topic_tag2 = topic_tag+"2"; 544 var topic_tag2 = topic_tag+"2";
623 */ 581 */
624 582
625 $('.tagItemDivClass').remove(); 583 $('.tagItemDivClass').remove();
626 } 584 }
627 585
628
629
630
631 function replaceSmartRegex() { 586 function replaceSmartRegex() {
632 saveUndoText(); 587 saveUndoText();
633 var startPage = $('#regexPageStart2').val(); 588 var startPage = $('#regexPageStart2').val();
634 var endPage = $('#regexPageEnd2').val(); 589 var endPage = $('#regexPageEnd2').val();
635 590
662 str="" + el.innerHTML; 617 str="" + el.innerHTML;
663 el.innerHTML = str.replace(new RegExp(regexText2, "g"), resultString); 618 el.innerHTML = str.replace(new RegExp(regexText2, "g"), resultString);
664 } 619 }
665 //document.styleSheets[0].addRule("tag001", "color:green;") 620 //document.styleSheets[0].addRule("tag001", "color:green;")
666 } 621 }
667
668
669 622
670 function saveTextToLGService() { 623 function saveTextToLGService() {
671 624
672 // ------------- 625 // -------------
673 var info = JSON.parse('<?php echo json_encode($info) ?>'); 626 var info = JSON.parse('<?php echo json_encode($info) ?>');
772 form.submit(); // works under IE and Chrome, but not FF 725 form.submit(); // works under IE and Chrome, but not FF
773 } 726 }
774 */ 727 */
775 } 728 }
776 729
777
778
779 function chooseTopic(default_topic_id) { 730 function chooseTopic(default_topic_id) {
780 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); 731 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' );
781 var info = JSON.parse('<?php echo json_encode($info) ?>'); 732 var info = JSON.parse('<?php echo json_encode($info) ?>');
782 733
783 $('#load_topic_div').html(""); 734 $('#load_topic_div').html("");
873 824
874 825
875 var info = JSON.parse( '<?php echo json_encode($info) ?>'); 826 var info = JSON.parse( '<?php echo json_encode($info) ?>');
876 827
877 if (info) { 828 if (info) {
878 // TODO: different field info array based on fileId(branchId) existing or not
879 if (info['file_id']) { 829 if (info['file_id']) {
880 var hiddenField = document.createElement("input"); 830 var hiddenField = document.createElement("input");
881 hiddenField.setAttribute("name", "fileId"); 831 hiddenField.setAttribute("name", "fileId");
882 hiddenField.setAttribute("value", info['file_id']); 832 hiddenField.setAttribute("value", info['file_id']);
883 form.appendChild(hiddenField); 833 form.appendChild(hiddenField);
959 */ 909 */
960 910
961 } 911 }
962 912
963 913
964
965 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { 914 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) {
966 915
967 <?php 916 <?php
968 foreach ( $wordlistArray as $wordlistValue ) { 917 foreach ( $wordlistArray as $wordlistValue ) {
969 echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {"; 918 echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {";
1026 </div> 975 </div>
1027 976
1028 <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 15 5; max-width:270px"> 977 <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 15 5; max-width:270px">
1029 <form action="javascript:void(0);"> 978 <form action="javascript:void(0);">
1030 <fieldset> 979 <fieldset>
980 <button onclick="reloadText(<?php echo $default_topic_id; ?>)">Reload</button>
981 </fieldset>
982 <fieldset>
1031 <legend><h5 class="text-success"> Config Topic: </h5></legend> 983 <legend><h5 class="text-success"> Config Topic: </h5></legend>
1032 <div> current topic is <?php echo $topic_name; ?> 984 <div> current topic is <?php echo $topic_name; ?>
1033 <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button> 985 <button onclick="chooseTopic()" class="btn btn-xs btn-default">Change</button>
1034 </div> 986 </div>
1035 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br> 987 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br>
1036 </fieldset> 988 </fieldset>
1037 989
1038 <fieldset> 990 <fieldset>