Mercurial > hg > extraction-interface
comparison views/Extractapp/TaggingText.php @ 67:3ada9334ebfc extractapp
New: check taglist is deprecated or not
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 07 Apr 2015 14:45:31 +0200 |
parents | e71a437ae49f |
children | 6676ca451dcc |
comparison
equal
deleted
inserted
replaced
66:e71a437ae49f | 67:3ada9334ebfc |
---|---|
108 | 108 |
109 } | 109 } |
110 | 110 |
111 function handleFileVersionConflict() { | 111 function handleFileVersionConflict() { |
112 var info = JSON.parse('<?php echo json_encode($info) ?>'); | 112 var info = JSON.parse('<?php echo json_encode($info) ?>'); |
113 console.log("currentFileId="+info['current_fileId']); | |
114 | |
115 // if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ | 113 // if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ |
116 if (info['current_fileId'] != 0){ | 114 if (info['current_fileId'] != 0){ |
117 // -- there might be conflicts between different version | 115 // -- there might be conflicts between different version |
118 alert("Your saving failed! Someone edited this file and saved before you."); | 116 alert("Your saving failed! Someone edited this file and saved before you."); |
119 $('#reloadTextButton').css("display", "block"); | 117 $('#reloadTextButton').css("display", "block"); |
148 var windowpos = $(window).scrollTop(); | 146 var windowpos = $(window).scrollTop(); |
149 var finaldestination = windowpos+originalelpos; | 147 var finaldestination = windowpos+originalelpos; |
150 //el.stop().animate({'top':finaldestination},500); | 148 //el.stop().animate({'top':finaldestination},500); |
151 el.stop().animate({'top':finaldestination},0); | 149 el.stop().animate({'top':finaldestination},0); |
152 }); | 150 }); |
151 // --- | |
153 | 152 |
154 //--- for popups --- | 153 //--- for popups --- |
155 //run once | 154 //run once |
156 var el=$('#popups'); | 155 var el=$('#popups'); |
157 var originalelpos=el.offset().top; // take it where it originally is on the page | 156 var originalelpos=el.offset().top; // take it where it originally is on the page |
163 var windowpos = $(window).scrollTop(); | 162 var windowpos = $(window).scrollTop(); |
164 var finaldestination = windowpos+originalelpos; | 163 var finaldestination = windowpos+originalelpos; |
165 //el.stop().animate({'top':finaldestination},500); | 164 //el.stop().animate({'top':finaldestination},500); |
166 el.stop().animate({'top':finaldestination},0); | 165 el.stop().animate({'top':finaldestination},0); |
167 }); | 166 }); |
168 | 167 // --- |
169 | 168 |
169 | |
170 // === This case only be possible for developing on local machine ==== | |
170 var _GET = JSON.parse('<?php echo json_encode($_GET) ?>'); | 171 var _GET = JSON.parse('<?php echo json_encode($_GET) ?>'); |
171 if (_GET['id']) { | 172 if (_GET['id']) { |
172 // === This case should only be possible for developing on local machine ==== | |
173 var info = JSON.parse('<?php echo json_encode($info) ?>'); | 173 var info = JSON.parse('<?php echo json_encode($info) ?>'); |
174 var redirectUrl = "http://localhost:1080/localgazetteers-dev/extraction-interface/Extractapp/TaggingText"; | 174 var redirectUrl = "http://localhost:1080/localgazetteers-dev/extraction-interface/Extractapp/TaggingText"; |
175 var section_id = info['section_id']; | 175 var section_id = info['section_id']; |
176 | 176 |
177 var form = $('<form action="' + redirectUrl + '" method="post">' + | 177 var form = $('<form action="' + redirectUrl + '" method="post">' + |
178 '<input type="hidden" name="sectionId" value="'+section_id+'" />' + | 178 '<input type="hidden" name="sectionId" value="'+section_id+'" />' + |
179 '</form>'); | 179 '</form>'); |
180 $('body').append(form); | 180 $('body').append(form); |
181 $(form).submit(); | 181 $(form).submit(); |
182 } | 182 } |
183 | 183 // -------- |
184 | |
185 // --- handle file version conflict --- | |
186 var info = JSON.parse('<?php echo json_encode($info) ?>'); | |
187 // the first time to this section. without branch_id and file_id | |
188 if (info['file_id'] == 0) { // or info['branch_id'] == 0, means new file | |
189 $( "#saveTextToLGService_id").text( "Create(Save) Branch to LGService" ); | |
190 | |
191 } | |
192 handleFileVersionConflict(); | |
193 | |
194 // --- handle taglist deprecation --- | |
195 var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); | |
196 var taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>'); | |
197 | |
198 if (taglist_infile == "") { | |
199 console.log("Debug: taglist_infile is empty which means taglist_infile is equal to taglist in db."); | |
200 } else { | |
201 console.log("Debug: taglist_infile length=" + taglist_infile.length); | |
202 console.log(taglist_infile); | |
203 console.log("Debug: taglistArray length=" + taglistArray.length); | |
204 console.log(taglistArray); | |
205 | |
206 // TOOD: ask user to modify/decide tags | |
207 // showing taglist_infile and taglistArray | |
208 alert("taglist is deprecated in the current file."); | |
209 | |
210 } | |
184 | 211 |
185 // --- handle old version taglist --- | 212 // --- handle old version taglist --- |
186 // --- TODO: check if taglist in file is up-to-date --- | 213 // --- TODO: check if taglist in file is up-to-date --- |
187 /* | 214 /* |
188 var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); | 215 var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); |
202 //_showTagColor(retVal); | 229 //_showTagColor(retVal); |
203 <?php $taglist_infile = ""; ?> | 230 <?php $taglist_infile = ""; ?> |
204 } | 231 } |
205 */ | 232 */ |
206 | 233 |
207 var info = JSON.parse('<?php echo json_encode($info) ?>'); | 234 |
208 | |
209 // the first time to this section. without branch_id and file_id | |
210 if (info['file_id'] == 0) { // or info['branch_id'] == 0, means new file | |
211 $( "#saveTextToLGService_id").text( "Create(Save) Branch to LGService" ); | |
212 | |
213 } | |
214 | |
215 handleFileVersionConflict(); | |
216 | |
217 | 235 |
218 }); | 236 }); |
219 | 237 |
220 $(document).on("mouseup", '#editable-area', function (e) { | 238 $(document).on("mouseup", '#editable-area', function (e) { |
221 | 239 |
477 hiddenField.setAttribute("name", "topic"); | 495 hiddenField.setAttribute("name", "topic"); |
478 hiddenField.setAttribute("value", topic_id); | 496 hiddenField.setAttribute("value", topic_id); |
479 form.appendChild(hiddenField); | 497 form.appendChild(hiddenField); |
480 | 498 |
481 _postForContineTagging(form); | 499 _postForContineTagging(form); |
482 /* | |
483 var section_id = JSON.parse('<?php echo json_encode($section_id) ?>'); | |
484 console.log("section_id: "+section_id+", topic_id: "+topic_id); | |
485 | |
486 var hiddenField = document.createElement("input"); | |
487 hiddenField.setAttribute("name", "sectionId"); | |
488 hiddenField.setAttribute("value", section_id); | |
489 form.appendChild(hiddenField); | |
490 | |
491 var info = JSON.parse( '<?php echo json_encode($info) ?>'); | |
492 | |
493 if (info) { | |
494 var hiddenField = document.createElement("input"); | |
495 hiddenField.setAttribute("name", "bookId"); | |
496 hiddenField.setAttribute("value", info['book_id']); | |
497 form.appendChild(hiddenField); | |
498 | |
499 var hiddenField = document.createElement("input"); | |
500 hiddenField.setAttribute("name", "bookName"); | |
501 hiddenField.setAttribute("value", info['book_name']); | |
502 form.appendChild(hiddenField); | |
503 | |
504 var hiddenField = document.createElement("input"); | |
505 hiddenField.setAttribute("name", "sectionName"); | |
506 hiddenField.setAttribute("value", info['section_name']); | |
507 form.appendChild(hiddenField); | |
508 | |
509 }; | |
510 | |
511 | |
512 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | |
513 document.body.appendChild(form); | |
514 form.submit(); | |
515 } else { | |
516 form.submit(); // works under IE and Chrome, but not FF | |
517 } | |
518 */ | |
519 | 500 |
520 } | 501 } |
521 // =========== | 502 // =========== |
522 | 503 |
523 function tagwithOnlytag( range, stringSelection, tag ) { | 504 function tagwithOnlytag( range, stringSelection, tag ) { |
524 saveUndoText(); | 505 saveUndoText(); |
525 var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>'); | 506 var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>'); |
526 var topic_tag2 = topic_tag+"2"; | 507 var topic_tag2 = topic_tag+"2"; |
527 | 508 |
528 range.deleteContents(); | 509 range.deleteContents(); |
529 | |
530 | 510 |
531 if ( tag==topic_tag2) { | 511 if ( tag==topic_tag2) { |
532 var newdiv = document.createElement(topic_tag); | 512 var newdiv = document.createElement(topic_tag); |
533 newdiv.innerHTML = stringSelection; | 513 newdiv.innerHTML = stringSelection; |
534 range.insertNode(newdiv); | 514 range.insertNode(newdiv); |
539 var newdiv = document.createElement(tag); | 519 var newdiv = document.createElement(tag); |
540 newdiv.innerHTML = stringSelection; | 520 newdiv.innerHTML = stringSelection; |
541 range.insertNode(newdiv); | 521 range.insertNode(newdiv); |
542 } | 522 } |
543 | 523 |
544 /* | |
545 if ( tag=="person2") { | |
546 var newdiv = document.createElement("person"); | |
547 newdiv.innerHTML = stringSelection; | |
548 range.insertNode(newdiv); | |
549 var newdiv = document.createElement("br"); | |
550 range.insertNode(newdiv); | |
551 } else if (tag=="object2") { | |
552 var newdiv = document.createElement("object"); | |
553 newdiv.innerHTML = stringSelection; | |
554 range.insertNode(newdiv); | |
555 var newdiv = document.createElement("br"); | |
556 range.insertNode(newdiv); | |
557 | |
558 } else { | |
559 var newdiv = document.createElement(tag); | |
560 newdiv.innerHTML = stringSelection; | |
561 range.insertNode(newdiv); | |
562 } | |
563 */ | |
564 | 524 |
565 $('.tagItemDivClass').remove(); | 525 $('.tagItemDivClass').remove(); |
566 } | 526 } |
567 | 527 |
568 function replaceSmartRegex() { | 528 function replaceSmartRegex() { |
707 }; | 667 }; |
708 | 668 |
709 | 669 |
710 //Create and append the options | 670 //Create and append the options |
711 for (var i = 0; i < t.length; i++) { | 671 for (var i = 0; i < t.length; i++) { |
712 console.log(t[i]['id']+","+t[i]['name_ch']+","+t[i]['name_pinyin']+","+t[i]['name_en']); | |
713 var option = document.createElement("option"); | 672 var option = document.createElement("option"); |
714 option.value = t[i]['id']; | 673 option.value = t[i]['id']; |
715 option.text = t[i]['name_en']+" ("+t[i]['name_ch']+", "+t[i]['name_pinyin']+")"; | 674 option.text = t[i]['name_en']+" ("+t[i]['name_ch']+", "+t[i]['name_pinyin']+")"; |
716 if (option.value == default_topic_id) { | 675 if (option.value == default_topic_id) { |
717 option.selected = true; | 676 option.selected = true; |
739 | 698 |
740 // pass taglist | 699 // pass taglist |
741 var hiddenField = document.createElement("input"); | 700 var hiddenField = document.createElement("input"); |
742 hiddenField.setAttribute("name", "taglistArray"); | 701 hiddenField.setAttribute("name", "taglistArray"); |
743 var taglistObj = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); | 702 var taglistObj = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); |
703 // if taglist_infile == "" means the taglist in db is up-to-date, will use taglistArray to save to file | |
704 | |
744 if (!taglistObj) { | 705 if (!taglistObj) { |
706 // TODO: should pass the user-decided taglist to post['taglistArray'] | |
745 taglistObj = JSON.parse('<?php echo json_encode($taglistArray) ?>'); | 707 taglistObj = JSON.parse('<?php echo json_encode($taglistArray) ?>'); |
746 } | 708 } |
747 taglistArray = JSON.stringify(taglistObj); | 709 taglistArray = JSON.stringify(taglistObj); |
748 hiddenField.setAttribute("value", taglistArray); | 710 hiddenField.setAttribute("value", taglistArray); |
749 form.appendChild(hiddenField); | 711 form.appendChild(hiddenField); |
867 </div> | 829 </div> |
868 <div class="bg-info"> <?php echo $messages['info']; ?> </div> | 830 <div class="bg-info"> <?php echo $messages['info']; ?> </div> |
869 <div class="bg-default"> <?php echo $messages['debug']; ?> </div> | 831 <div class="bg-default"> <?php echo $messages['debug']; ?> </div> |
870 </div> | 832 </div> |
871 | 833 |
872 <table width="1270" border="1" style="margin:10 30 30 30; width:100%; max-width:1270px"> | 834 <table border="1" style="margin:10 30 30 30; width:100%; max-width:1270px"> |
873 <tr> | 835 <tr> |
874 <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;"> | 836 <td style="padding:0 5 0 5; margin: 0 5 0 5;"> |
875 <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div> | 837 <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div> |
876 </td> | 838 </td> |
877 <td width="290" valign="top" style="min-width:280px"> | 839 <td valign="top" style="min-width:280px; padding:0 5 0 5; margin:0 5 0 5;"> |
878 <div id="popups" style="position:absolute; width:300px; "> | 840 <div id="popups" style="position:absolute; width:300px; "> |
879 <div id="load_topic_div" class="popup-topic popup-frame"></div> | 841 <div id="load_topic_div" class="popup-topic popup-frame"></div> |
880 <div id="load_regex_div" class="popup-loadregex popup-frame"></div> | 842 <div id="load_regex_div" class="popup-loadregex popup-frame"></div> |
881 <div id="smartRegexPopUpDiv" class="popup-regex popup-frame"> | 843 <div id="smartRegexPopUpDiv" class="popup-regex popup-frame"> |
882 Name: <input id="smartRegexPopUpName"></input><br><br> | 844 Name: <input id="smartRegexPopUpName"></input><br><br> |