Mercurial > hg > extraction-interface
diff 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 |
line wrap: on
line diff
--- a/views/Extractapp/TaggingText.php Thu Apr 02 16:33:46 2015 +0200 +++ b/views/Extractapp/TaggingText.php Tue Apr 07 14:45:31 2015 +0200 @@ -110,8 +110,6 @@ function handleFileVersionConflict() { var info = JSON.parse('<?php echo json_encode($info) ?>'); - console.log("currentFileId="+info['current_fileId']); - // if (info['current_fileId'] != 0 && info['current_fileId'] != info['file_id']){ if (info['current_fileId'] != 0){ // -- there might be conflicts between different version @@ -150,6 +148,7 @@ //el.stop().animate({'top':finaldestination},500); el.stop().animate({'top':finaldestination},0); }); + // --- //--- for popups --- //run once @@ -165,11 +164,12 @@ //el.stop().animate({'top':finaldestination},500); el.stop().animate({'top':finaldestination},0); }); + // --- + // === This case only be possible for developing on local machine ==== var _GET = JSON.parse('<?php echo json_encode($_GET) ?>'); if (_GET['id']) { - // === This case should only be possible for developing on local machine ==== var info = JSON.parse('<?php echo json_encode($info) ?>'); var redirectUrl = "http://localhost:1080/localgazetteers-dev/extraction-interface/Extractapp/TaggingText"; var section_id = info['section_id']; @@ -180,7 +180,34 @@ $('body').append(form); $(form).submit(); } - + // -------- + + // --- handle file version conflict --- + var info = JSON.parse('<?php echo json_encode($info) ?>'); + // the first time to this section. without branch_id and file_id + if (info['file_id'] == 0) { // or info['branch_id'] == 0, means new file + $( "#saveTextToLGService_id").text( "Create(Save) Branch to LGService" ); + + } + handleFileVersionConflict(); + + // --- handle taglist deprecation --- + var taglist_infile = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); + var taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>'); + + if (taglist_infile == "") { + console.log("Debug: taglist_infile is empty which means taglist_infile is equal to taglist in db."); + } else { + console.log("Debug: taglist_infile length=" + taglist_infile.length); + console.log(taglist_infile); + console.log("Debug: taglistArray length=" + taglistArray.length); + console.log(taglistArray); + + // TOOD: ask user to modify/decide tags + // showing taglist_infile and taglistArray + alert("taglist is deprecated in the current file."); + + } // --- handle old version taglist --- // --- TODO: check if taglist in file is up-to-date --- @@ -204,16 +231,7 @@ } */ - var info = JSON.parse('<?php echo json_encode($info) ?>'); - - // the first time to this section. without branch_id and file_id - if (info['file_id'] == 0) { // or info['branch_id'] == 0, means new file - $( "#saveTextToLGService_id").text( "Create(Save) Branch to LGService" ); - - } - - handleFileVersionConflict(); - + }); @@ -479,43 +497,6 @@ form.appendChild(hiddenField); _postForContineTagging(form); -/* - var section_id = JSON.parse('<?php echo json_encode($section_id) ?>'); - console.log("section_id: "+section_id+", topic_id: "+topic_id); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionId"); - hiddenField.setAttribute("value", section_id); - form.appendChild(hiddenField); - - var info = JSON.parse( '<?php echo json_encode($info) ?>'); - - if (info) { - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "bookId"); - hiddenField.setAttribute("value", info['book_id']); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "bookName"); - hiddenField.setAttribute("value", info['book_name']); - form.appendChild(hiddenField); - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionName"); - hiddenField.setAttribute("value", info['section_name']); - form.appendChild(hiddenField); - - }; - - - if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { - document.body.appendChild(form); - form.submit(); - } else { - form.submit(); // works under IE and Chrome, but not FF - } - */ } // =========== @@ -527,7 +508,6 @@ range.deleteContents(); - if ( tag==topic_tag2) { var newdiv = document.createElement(topic_tag); newdiv.innerHTML = stringSelection; @@ -541,26 +521,6 @@ range.insertNode(newdiv); } - /* - if ( tag=="person2") { - var newdiv = document.createElement("person"); - newdiv.innerHTML = stringSelection; - range.insertNode(newdiv); - var newdiv = document.createElement("br"); - range.insertNode(newdiv); - } else if (tag=="object2") { - var newdiv = document.createElement("object"); - newdiv.innerHTML = stringSelection; - range.insertNode(newdiv); - var newdiv = document.createElement("br"); - range.insertNode(newdiv); - - } else { - var newdiv = document.createElement(tag); - newdiv.innerHTML = stringSelection; - range.insertNode(newdiv); - } - */ $('.tagItemDivClass').remove(); } @@ -709,7 +669,6 @@ //Create and append the options for (var i = 0; i < t.length; i++) { - console.log(t[i]['id']+","+t[i]['name_ch']+","+t[i]['name_pinyin']+","+t[i]['name_en']); var option = document.createElement("option"); option.value = t[i]['id']; option.text = t[i]['name_en']+" ("+t[i]['name_ch']+", "+t[i]['name_pinyin']+")"; @@ -741,7 +700,10 @@ var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "taglistArray"); var taglistObj = JSON.parse('<?php echo json_encode($taglist_infile) ?>'); + // if taglist_infile == "" means the taglist in db is up-to-date, will use taglistArray to save to file + if (!taglistObj) { + // TODO: should pass the user-decided taglist to post['taglistArray'] taglistObj = JSON.parse('<?php echo json_encode($taglistArray) ?>'); } taglistArray = JSON.stringify(taglistObj); @@ -869,12 +831,12 @@ <div class="bg-default"> <?php echo $messages['debug']; ?> </div> </div> -<table width="1270" border="1" style="margin:10 30 30 30; width:100%; max-width:1270px"> +<table border="1" style="margin:10 30 30 30; width:100%; max-width:1270px"> <tr> - <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;"> + <td style="padding:0 5 0 5; margin: 0 5 0 5;"> <div id="editable-area" class="area" style="max-width:980px; min-width:400px"><?php echo $stringInput; ?></div> </td> - <td width="290" valign="top" style="min-width:280px"> + <td valign="top" style="min-width:280px; padding:0 5 0 5; margin:0 5 0 5;"> <div id="popups" style="position:absolute; width:300px; "> <div id="load_topic_div" class="popup-topic popup-frame"></div> <div id="load_regex_div" class="popup-loadregex popup-frame"></div>