Mercurial > hg > extraction-interface
comparison develop/views/Extractapp/taggingtext.php @ 24:b55f5d3564c4
add some regular expressions and wordlist for topic ??
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 27 Feb 2015 16:35:59 +0100 |
parents | a879f6b9d166 |
children | 4b6d2d7e706e |
comparison
equal
deleted
inserted
replaced
23:a879f6b9d166 | 24:b55f5d3564c4 |
---|---|
145 $(document).on("mouseup", '#editable-area', function (e) { | 145 $(document).on("mouseup", '#editable-area', function (e) { |
146 $('.questionMarkClass').remove(); | 146 $('.questionMarkClass').remove(); |
147 $('.tagItemDivClass').remove(); | 147 $('.tagItemDivClass').remove(); |
148 | 148 |
149 if ( $("#editTextId").html() != "Edit the text" ) return 0; | 149 if ( $("#editTextId").html() != "Edit the text" ) return 0; |
150 | |
151 var selection = getSelected(); | 150 var selection = getSelected(); |
152 range = getSelected().getRangeAt(0); | 151 range = getSelected().getRangeAt(0); |
153 | 152 |
154 container = document.createElement("div"); | 153 container = document.createElement("div"); |
155 container.appendChild(selection.getRangeAt(0).cloneContents()); | 154 container.appendChild(selection.getRangeAt(0).cloneContents()); |
158 | 157 |
159 var newdiv = document.createElement("div"); | 158 var newdiv = document.createElement("div"); |
160 newdiv.id = "tagItemDivId"; | 159 newdiv.id = "tagItemDivId"; |
161 newdiv.setAttribute("class", "tagItemDivClass"); | 160 newdiv.setAttribute("class", "tagItemDivClass"); |
162 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px'; | 161 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px'; |
162 | |
163 newdiv.style.backgroundColor = "white"; | 163 newdiv.style.backgroundColor = "white"; |
164 newdiv.style.zIndex = 2; | 164 newdiv.style.zIndex = 2; |
165 | 165 |
166 //console.log(selection.getRangeAt(0).cloneContents()); | 166 //console.log(selection.getRangeAt(0).cloneContents()); |
167 if ( container.innerHTML.indexOf( "br" ) != -1 ) { | 167 if ( container.innerHTML.indexOf( "br" ) != -1 ) { |
181 if ( matchValue != null ) { | 181 if ( matchValue != null ) { |
182 newdiv.innerHTML += "<input id=\"TitletagName\" value=\""+ matchValue[1] +"\"></br>"; | 182 newdiv.innerHTML += "<input id=\"TitletagName\" value=\""+ matchValue[1] +"\"></br>"; |
183 } else { | 183 } else { |
184 newdiv.innerHTML += "<input id=\"TitletagName\" value=\"\"></br>"; | 184 newdiv.innerHTML += "<input id=\"TitletagName\" value=\"\"></br>"; |
185 } | 185 } |
186 | |
187 console.log(" container innerHTML: "+ container.innerHTML ); | |
188 | |
186 newdiv.innerHTML += "<button onclick=\"addTagTitle( range, container )\">Add Title Tag To Each Line</button></br>"; | 189 newdiv.innerHTML += "<button onclick=\"addTagTitle( range, container )\">Add Title Tag To Each Line</button></br>"; |
187 | 190 |
188 newdiv.innerHTML += "<button onclick=\"exportTable( range, container )\">Export As A Table</button></br></br>"; | 191 newdiv.innerHTML += "<button onclick=\"exportTable( range, container )\">Export As A Table</button></br></br>"; |
189 | 192 |
190 var newselect = document.createElement("select"); | 193 var newselect = document.createElement("select"); |
202 // for pop up window on edit-area for tag list | 205 // for pop up window on edit-area for tag list |
203 newdiv.innerHTML = "Tag: "+String(selection)+"<br>"; | 206 newdiv.innerHTML = "Tag: "+String(selection)+"<br>"; |
204 | 207 |
205 <?php | 208 <?php |
206 foreach ( $taglistArray as $taglistValue ) { | 209 foreach ( $taglistArray as $taglistValue ) { |
210 | |
207 if ($taglistValue[2] == $topic_tag) { | 211 if ($taglistValue[2] == $topic_tag) { |
208 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\" class='btn btn-xs btn-primary'>[TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)</button>\";\n"; | 212 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">[TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)</button>\";\n"; |
209 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; | 213 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; |
210 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | 214 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; |
211 break; | 215 |
216 /* | |
217 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; | |
218 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
219 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
220 */ | |
221 break; | |
212 } | 222 } |
213 } | 223 } |
214 ?> | 224 ?> |
215 | 225 |
216 newdiv.innerHTML += "<button accesskey=\"2\" onclick=\"tagwithtitle( range, '"+String(selection)+"' )\">Tag As Title</button></br>"; | 226 newdiv.innerHTML += "<button accesskey=\"2\" onclick=\"tagwithtitle( range, '"+String(selection)+"' )\">Tag As Title</button></br>"; |
222 if ( $taglistValue[2] == "person") { | 232 if ( $taglistValue[2] == "person") { |
223 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; | 233 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; |
224 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | 234 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; |
225 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | 235 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; |
226 } else */ | 236 } else */ |
227 if ($taglistValue[2] == $topic_tag) { | 237 if ($taglistValue[2] == $topic_tag) { |
228 // pass | 238 // pass |
229 } else if ($taglistValue[2] == "post_time") { | 239 } else if ($taglistValue[2] == "post_time") { |
230 echo "newdiv.innerHTML += \"<button accesskey=\\\"3\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | 240 echo "newdiv.innerHTML += \"<button accesskey=\\\"3\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; |
231 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | 241 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; |
232 } else if ($taglistValue[2] == "office") { | 242 } else if ($taglistValue[2] == "office") { |
239 | 249 |
240 } | 250 } |
241 ?> | 251 ?> |
242 } | 252 } |
243 | 253 |
244 $('#tagItemDivId').addClass(); // tagItemDivId is newdiv's id | 254 //$('#tagItemDivId').addClass(); // tagItemDivId is newdiv's id |
245 $('body').append(newdiv); | 255 $('body').append(newdiv); |
246 | 256 |
247 $('#TitletagType').val(lastAddTag); | 257 $('#TitletagType').val(lastAddTag); |
258 | |
248 } | 259 } |
249 //e.stopPropagation(); | 260 //e.stopPropagation(); |
250 }); | 261 }); |
251 | 262 |
252 | 263 |
319 form.submit(); | 330 form.submit(); |
320 } else { | 331 } else { |
321 form.submit(); // works under IE and Chrome, but not FF | 332 form.submit(); // works under IE and Chrome, but not FF |
322 } | 333 } |
323 } | 334 } |
335 | |
336 | |
337 | |
324 | 338 |
325 function exportAll(topic_id) { | 339 function exportAll(topic_id) { |
326 var el = document.getElementById("editable-area"); | 340 var el = document.getElementById("editable-area"); |
327 var str= "" + el.innerHTML; | 341 var str= "" + el.innerHTML; |
328 var form = document.createElement("form"); | 342 var form = document.createElement("form"); |
357 } | 371 } |
358 | 372 |
359 | 373 |
360 } | 374 } |
361 // =========== | 375 // =========== |
376 | |
377 | |
378 function tagwithOnlytag( range, stringSelection, tag ) { | |
379 saveUndoText(); | |
380 var topic_tag = JSON.parse('<?php echo json_encode($topic_tag) ?>'); | |
381 var topic_tag2 = topic_tag+"2"; | |
382 | |
383 range.deleteContents(); | |
384 | |
385 | |
386 if ( tag==topic_tag2) { | |
387 var newdiv = document.createElement(topic_tag); | |
388 newdiv.innerHTML = stringSelection; | |
389 range.insertNode(newdiv); | |
390 var newdiv = document.createElement("br"); | |
391 range.insertNode(newdiv); | |
392 | |
393 } else { | |
394 var newdiv = document.createElement(tag); | |
395 newdiv.innerHTML = stringSelection; | |
396 range.insertNode(newdiv); | |
397 } | |
398 | |
399 /* | |
400 if ( tag=="person2") { | |
401 var newdiv = document.createElement("person"); | |
402 newdiv.innerHTML = stringSelection; | |
403 range.insertNode(newdiv); | |
404 var newdiv = document.createElement("br"); | |
405 range.insertNode(newdiv); | |
406 } else if (tag=="object2") { | |
407 var newdiv = document.createElement("object"); | |
408 newdiv.innerHTML = stringSelection; | |
409 range.insertNode(newdiv); | |
410 var newdiv = document.createElement("br"); | |
411 range.insertNode(newdiv); | |
412 | |
413 } else { | |
414 var newdiv = document.createElement(tag); | |
415 newdiv.innerHTML = stringSelection; | |
416 range.insertNode(newdiv); | |
417 } | |
418 */ | |
419 | |
420 $('.tagItemDivClass').remove(); | |
421 } | |
422 | |
423 | |
424 | |
362 | 425 |
363 function replaceSmartRegex() { | 426 function replaceSmartRegex() { |
364 saveUndoText(); | 427 saveUndoText(); |
365 var startPage = $('#regexPageStart2').val(); | 428 var startPage = $('#regexPageStart2').val(); |
366 var endPage = $('#regexPageEnd2').val(); | 429 var endPage = $('#regexPageEnd2').val(); |
584 | 647 |
585 function configTagsInTopic(topic_id) { | 648 function configTagsInTopic(topic_id) { |
586 var form = document.createElement("form"); | 649 var form = document.createElement("form"); |
587 | 650 |
588 form.setAttribute("method", "post"); | 651 form.setAttribute("method", "post"); |
589 //form.setAttribute("action", "exportTable.php"); | |
590 form.setAttribute("action", "./ConfigTagsInTopic"); // hand to controller | 652 form.setAttribute("action", "./ConfigTagsInTopic"); // hand to controller |
591 form.setAttribute("target", "_blank"); | 653 form.setAttribute("target", "_blank"); |
592 | 654 |
593 | |
594 var hiddenField = document.createElement("input"); | 655 var hiddenField = document.createElement("input"); |
595 hiddenField.setAttribute("name", "topic"); | 656 hiddenField.setAttribute("name", "topic"); |
596 hiddenField.setAttribute("value", topic_id); | 657 hiddenField.setAttribute("value", topic_id); |
597 form.appendChild(hiddenField); | 658 form.appendChild(hiddenField); |
598 | 659 |
614 }); | 675 }); |
615 | 676 |
616 | 677 |
617 | 678 |
618 </script> | 679 </script> |
619 | |
620 | 680 |
621 <div id="popup-window" style="display: none; background-color:white; height:300px; width:300px; margin:200 0 0 200;position:fixed; z-index:2"> | 681 <div id="dialog-form" title="config tags for topic" style="position:fixed; top: 30px; "> |
622 </div> | 682 </div> |
623 | 683 |
624 | 684 |
625 <p class="bg-info" style="margin:10 30 10 30; max-width:1250"> <?php echo $messages; ?> </p> | 685 <p class="bg-info" style="margin:10 30 10 30; max-width:1250"> <?php echo $messages; ?> </p> |
626 | 686 |
664 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button> | 724 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button> |
665 <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button> | 725 <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button> |
666 </div> | 726 </div> |
667 </div> | 727 </div> |
668 | 728 |
669 <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 5 5; max-width:270px"> | 729 <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 15 5; max-width:270px"> |
670 <form action="javascript:void(0);"> | 730 <form action="javascript:void(0);"> |
671 <fieldset> | 731 <fieldset> |
672 <legend><h5 class="text-success"> Config Topic: </h5></legend> | 732 <legend><h5 class="text-success"> Config Topic: </h5></legend> |
673 <div> current topic is <?php echo $topic_name; ?> | 733 <div> current topic is <?php echo $topic_name; ?> |
674 <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button> | 734 <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button> |
679 <fieldset> | 739 <fieldset> |
680 <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend> | 740 <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend> |
681 <div id="smartRegexShowDiv"></div><br> | 741 <div id="smartRegexShowDiv"></div><br> |
682 <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br> | 742 <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br> |
683 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> | 743 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> |
684 <button onclick="replaceSmartRun()" style="height: 30px; width: 220px">Run</button></br> | 744 <button onclick="replaceSmartRun()" style="height: 30px; width: 100px">Run</button> |
745 <button onclick="replaceSmartRunWithBr()" style="height: 30px; width: 100px">Run(with Br)</button></br> | |
685 <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br> | 746 <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br> |
686 <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button> | 747 <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button> |
687 <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button> | 748 <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button> |
688 <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br> | 749 <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br> |
689 <!-- | 750 <!-- |
703 <fieldset> | 764 <fieldset> |
704 <legend><h5 class="text-success"> Edit:</h5></legend> | 765 <legend><h5 class="text-success"> Edit:</h5></legend> |
705 <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br> | 766 <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br> |
706 | 767 |
707 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>--> | 768 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>--> |
708 <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage | 769 <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage --> |
709 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br> | 770 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br> |
710 --> | |
711 <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br> | 771 <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br> |
712 </br> | 772 </br> |
713 <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br> | 773 <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br> |
714 <!-- | 774 <!-- |
715 <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br> | 775 <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br> |