comparison develop/views/Extractapp/TaggingText.php @ 40:2e938dc046db extractapp

load,save xml file with topic, etc.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 10 Mar 2015 13:46:16 +0100
parents 8347776a44fc
children c245d54eab9f
comparison
equal deleted inserted replaced
39:8347776a44fc 40:2e938dc046db
10 $topic_tag = $viewmodel['topic_tag']; 10 $topic_tag = $viewmodel['topic_tag'];
11 $info = $viewmodel['info']; 11 $info = $viewmodel['info'];
12 $messages = $viewmodel['messages']; 12 $messages = $viewmodel['messages'];
13 13
14 $taglist_infile = $viewmodel['taglist_infile']; 14 $taglist_infile = $viewmodel['taglist_infile'];
15 $book_meta = $viewmodel['book_meta'];
16
15 17
16 ?> 18 ?>
17 19
18 <html> 20 <html>
19 <head> 21 <head>
36 line-height:160%; 38 line-height:160%;
37 letter-spacing:1.5px; 39 letter-spacing:1.5px;
38 font-size:21px; 40 font-size:21px;
39 } 41 }
40 42
41
42 <?php 43 <?php
43 // color on the tags 44 // color on the tags
44 foreach ( $taglistArray as $taglistValue ) { 45 foreach ( $taglistArray as $taglistValue ) {
45 echo $taglistValue[2]."\n{\ncolor:".$taglistValue[3]."\n}\n"; 46 echo $taglistValue[2]."\n{\ncolor:".$taglistValue[3]."\n}\n";
46 47
47 echo ".span_".$taglistValue[2]."\n{\nbackground-color:".$taglistValue[3]."\n}\n"; 48 echo ".span_".$taglistValue[2]."\n{\nbackground-color:".$taglistValue[3]."\n}\n";
48 } 49 }
49 50
50 ?> 51 ?>
51 </style> 52 </style>
52 53
55 56
56 <body> 57 <body>
57 58
58 <script type="text/javascript"> 59 <script type="text/javascript">
59 60
60 // === This is only for developing on local machine ==== 61 // not use this for now
61 var _GET = JSON.parse('<?php echo json_encode($_GET) ?>'); 62 function _showTagColor(up_to_date) {
62 if (_GET['id']) { 63 var taglistArray = "";
63 64 if (up_to_date) {
64 var info = JSON.parse('<?php echo json_encode($info) ?>'); 65 taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>');
65 var redirectUrl = "http://localhost:1080/extraction-interface/develop/Extractapp/TaggingText"; 66 } else {
66 var section_id = info['section_id']; 67 taglistArray = JSON.parse('<?php echo json_encode($taglist_infile) ?>');
67 68 }
68 var form = $('<form action="' + redirectUrl + '" method="post">' + 69
69 '<input type="hidden" name="sectionId" value="'+section_id+'" />' + 70
70 '</form>'); 71 for (var i = 0; i < taglistArray.length; i++) {
71 $('body').append(form); 72 var taglistValue = taglistArray[i];
72 $(form).submit(); 73
73 } 74 $(taglistValue[2]).css('color', taglistValue[3]);
74 // ==== 75 /*var element = document.querySelectorAll(taglistValue[2]);
75 // --- check if taglist in file is up-to-date --- 76 for (var j = 0; j < element.length; j++) {
76 var check_taglist = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); 77 element[j].style.color = taglistValue[3];
77 if (check_taglist) { 78 }
78 // TODO: pop up to ask if load the latest taglist 79 */
79 var retVal = confirm("The tag list in the file is not up-to-date. \nDo you want to load file with new tag list?"); 80 }
80 if( retVal == true ){ 81 }
81 <?php $$taglistArray = $taglist_infile; ?>
82 alert("Load with new tag list.");
83 }else{
84 alert("You are using the old version of tag list.");
85 }
86 }
87
88
89 82
90 // TODO: Popup to proceeding the saving situations 83 // TODO: Popup to proceeding the saving situations
91 function handleFileVersionConflict() { 84 function handleFileVersionConflict() {
92 var info = JSON.parse('<?php echo json_encode($info) ?>'); 85 var info = JSON.parse('<?php echo json_encode($info) ?>');
93 console.log("currentFileId="+info['current_fileId']); 86 console.log("currentFileId="+info['current_fileId']);
204 var finaldestination = windowpos+originalelpos; 197 var finaldestination = windowpos+originalelpos;
205 //el.stop().animate({'top':finaldestination},500); 198 //el.stop().animate({'top':finaldestination},500);
206 el.stop().animate({'top':finaldestination},0); 199 el.stop().animate({'top':finaldestination},0);
207 }); 200 });
208 201
202 // --- handle old version taglist ---
203 var _GET = JSON.parse('<?php echo json_encode($_GET) ?>');
204 if (_GET['id']) {
205 // === This case should only be possible for developing on local machine ====
206 var info = JSON.parse('<?php echo json_encode($info) ?>');
207 var redirectUrl = "http://localhost:1080/extraction-interface/develop/Extractapp/TaggingText";
208 var section_id = info['section_id'];
209
210 var form = $('<form action="' + redirectUrl + '" method="post">' +
211 '<input type="hidden" name="sectionId" value="'+section_id+'" />' +
212 '</form>');
213 $('body').append(form);
214 $(form).submit();
215 } else {
216 // --- TODO: check if taglist in file is up-to-date ---
217 /*
218 var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>');
219 if (taglist_infile != "") {
220 // TODO: pop up to ask if load the latest taglist
221 var retVal = confirm("Tag list in file is not up-to-date. \nDo you want to load file with new tag list?");
222 if( retVal == true ){
223 // use $taglisArray
224 alert("Load file with new tag list.");
225 }else{
226 // use $taglist_infile as $taglistArray
227 <?php
228 // $taglistArray = $taglist_infile;
229 ?>
230 alert("You are viewing the file with old version of tag list. Please use the up-to-date taglist.");
231 }
232 //_showTagColor(retVal);
233 <?php $taglist_infile = ""; ?>
234 }
235 */
236 }
237
209 238
210 239
211 handleFileVersionConflict(); 240 handleFileVersionConflict();
212 241
213 242
258 287
259 //console.log(selection.getRangeAt(0).cloneContents()); 288 //console.log(selection.getRangeAt(0).cloneContents());
260 if ( container.innerHTML.indexOf( "br" ) != -1 ) { 289 if ( container.innerHTML.indexOf( "br" ) != -1 ) {
261 var newselect = document.createElement("select"); 290 var newselect = document.createElement("select");
262 newselect.id = "TitletagType"; 291 newselect.id = "TitletagType";
292
293
294 console.log(JSON.parse('<?php echo json_encode($taglistArray) ?>'));
295
263 <?php 296 <?php
264 foreach ( $taglistArray as $taglistValue ) { 297 foreach ( $taglistArray as $taglistValue ) {
265 echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n"; 298 echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n";
266 } 299 }
267 ?> 300 ?>
793 hiddenField.setAttribute("name", "text"); 826 hiddenField.setAttribute("name", "text");
794 var el = document.getElementById("editable-area"); 827 var el = document.getElementById("editable-area");
795 var text = el.innerHTML; 828 var text = el.innerHTML;
796 hiddenField.setAttribute("value", text); 829 hiddenField.setAttribute("value", text);
797 form.appendChild(hiddenField); 830 form.appendChild(hiddenField);
831
832 // pass taglist
833 var hiddenField = document.createElement("input");
834 hiddenField.setAttribute("name", "taglistArray");
835 var taglistObj = JSON.parse('<?php echo json_encode($taglist_infile) ?>');
836 if (!taglistObj) {
837 taglistObj = JSON.parse('<?php echo json_encode($taglistArray) ?>');
838 }
839 taglistArray = JSON.stringify(taglistObj);
840 hiddenField.setAttribute("value", taglistArray);
841 form.appendChild(hiddenField);
842
843 // pass book_meta
844 var hiddenField = document.createElement("input");
845 hiddenField.setAttribute("name", "book_meta");
846 var book_metaObj = JSON.parse('<?php echo json_encode($book_meta) ?>');
847 book_metaArray = JSON.stringify(book_metaObj);
848 hiddenField.setAttribute("value", book_metaArray);
849 form.appendChild(hiddenField);
850
798 851
799 var info = JSON.parse( '<?php echo json_encode($info) ?>'); 852 var info = JSON.parse( '<?php echo json_encode($info) ?>');
800 853
801 if (info) { 854 if (info) {
802 // TODO: different field info array based on fileId(branchId) existing or not 855 // TODO: different field info array based on fileId(branchId) existing or not
988 <legend><h5 class="text-success"> Edit:</h5></legend> 1041 <legend><h5 class="text-success"> Edit:</h5></legend>
989 <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br> 1042 <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
990 1043
991 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>--> 1044 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
992 <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage --> 1045 <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage -->
1046 <!--
993 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br> 1047 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
1048 -->
1049
994 <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br> 1050 <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br>
995 </br> 1051 </br>
996 <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br> 1052 <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br>
997 <!-- 1053 <!--
998 <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br> 1054 <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>