comparison develop/views/Extractapp/taggingtext.php @ 21:c805470cefee

Remove bootstrap.TaggingText UI layout modification
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 24 Feb 2015 16:09:59 +0100
parents 04db1dd9d10d
children a879f6b9d166
comparison
equal deleted inserted replaced
20:04db1dd9d10d 21:c805470cefee
82 echo "});\n"; 82 echo "});\n";
83 } 83 }
84 ?> 84 ?>
85 85
86 $(document).ready(function(){ 86 $(document).ready(function(){
87
88 // --- for sidebar---
87 //run once 89 //run once
88 /* no need, fixed sidebar
89 var el=$('#follow-scroll'); 90 var el=$('#follow-scroll');
90 var originalelpos=el.offset().top; // take it where it originally is on the page 91 var originalelpos=el.offset().top; // take it where it originally is on the page
91 */ 92
92 93
93 //run on scroll 94 //run on scroll
94 /*
95 $(window).scroll(function(){ 95 $(window).scroll(function(){
96 var el = $('#follow-scroll'); // important! (local) 96 var el = $('#follow-scroll'); // important! (local)
97 var elpos = el.offset().top; // take current situation 97 var elpos = el.offset().top; // take current situation
98 var windowpos = $(window).scrollTop(); 98 var windowpos = $(window).scrollTop();
99 var finaldestination = windowpos+originalelpos; 99 var finaldestination = windowpos+originalelpos;
100 el.stop().animate({'top':finaldestination},500); 100 //el.stop().animate({'top':finaldestination},500);
101 el.stop().animate({'top':finaldestination},0);
101 }); 102 });
102 */ 103
104 //--- for popups ---
105 //run once
106 var el=$('#popups');
107 var originalelpos=el.offset().top; // take it where it originally is on the page
108
109 //run on scroll
110 $(window).scroll(function(){
111 var el = $('#popups'); // important! (local)
112 var elpos = el.offset().top; // take current situation
113 var windowpos = $(window).scrollTop();
114 var finaldestination = windowpos+originalelpos;
115 //el.stop().animate({'top':finaldestination},500);
116 el.stop().animate({'top':finaldestination},0);
117 });
118
119
120
121
122
103 123
104 // Popup choosing topic if first time to this section. without branchId 124 // Popup choosing topic if first time to this section. without branchId
105 var info = JSON.parse('<?php echo json_encode($info) ?>'); 125 var info = JSON.parse('<?php echo json_encode($info) ?>');
106 if (info['file_id'] == 0) { // or info['branchId'] == 0, means new file 126 if (info['file_id'] == 0) { // or info['branchId'] == 0, means new file
107 // ask to choose topic 127 // ask to choose topic
228 } 248 }
229 //e.stopPropagation(); 249 //e.stopPropagation();
230 }); 250 });
231 251
232 252
253 // === for exporttable.php ===
254 function exportTable( range, container ) {
255 //MsgBox("enter function");
256 var form = document.createElement("form");
257 form.setAttribute("method", "post");
258 form.setAttribute("action", "./ExportTable");
259 form.setAttribute("target", "_blank");
260
261 var hiddenField = document.createElement("input");
262 hiddenField.setAttribute("name", "content");
263 hiddenField.setAttribute("value", container.innerHTML);
264 form.appendChild(hiddenField);
265
266 var hiddenField = document.createElement("input");
267 hiddenField.setAttribute("name", "sectionid");
268 hiddenField.setAttribute("value", "<?php echo $section_id; ?>");
269 form.appendChild(hiddenField);
270
271 var hiddenField2 = document.createElement("input");
272 hiddenField2.setAttribute("name", "topic");
273 hiddenField2.setAttribute("value", topic_id);
274 form.appendChild(hiddenField2);
275
276 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
277 document.body.appendChild(form);
278 form.submit();
279 } else {
280 form.submit(); // works under IE and Chrome, but not FF
281 }
282 }
283
284 function exportPage(topic_id) {
285 var startPage = $('#exportPageStart').val();
286 var endPage = $('#exportPageEnd').val();
287
288 var el = document.getElementById("editable-area");
289 var str="" + el.innerHTML;
290
291 var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】";
292
293 var form = document.createElement("form");
294 form.setAttribute("method", "post");
295 form.setAttribute("action", "./ExportTable");
296 form.setAttribute("target", "_blank");
297
298 var hiddenField = document.createElement("input");
299 hiddenField.setAttribute("name", "content");
300 hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g")));
301 form.appendChild(hiddenField);
302
303 var hiddenField = document.createElement("input");
304 hiddenField.setAttribute("name", "topic");
305 hiddenField.setAttribute("value", topic_id);
306 form.appendChild(hiddenField);
307
308 var section_id = JSON.parse('<?php echo json_encode($section_id) ?>');
309 console.log("section_id: "+section_id+", topic_id: "+topic_id);
310
311 var hiddenField = document.createElement("input");
312 hiddenField.setAttribute("name", "sectionId");
313 hiddenField.setAttribute("value", section_id);
314 form.appendChild(hiddenField);
315
316
317 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
318 document.body.appendChild(form);
319 form.submit();
320 } else {
321 form.submit(); // works under IE and Chrome, but not FF
322 }
323 }
324
325 function exportAll(topic_id) {
326 var el = document.getElementById("editable-area");
327 var str= "" + el.innerHTML;
328 var form = document.createElement("form");
329 form.setAttribute("method", "post");
330 //form.setAttribute("action", "exportTable.php");
331 form.setAttribute("action", "./ExportTable");//+section_id); // hand to controller
332 form.setAttribute("target", "_blank");
333
334 var hiddenField = document.createElement("input");
335 hiddenField.setAttribute("name", "content");
336 hiddenField.setAttribute("value", str);
337 form.appendChild(hiddenField);
338
339 var hiddenField = document.createElement("input");
340 hiddenField.setAttribute("name", "topic");
341 hiddenField.setAttribute("value", topic_id);
342 form.appendChild(hiddenField);
343
344 var section_id = JSON.parse('<?php echo json_encode($section_id) ?>');
345 console.log("section_id: "+section_id+", topic_id: "+topic_id);
346
347 var hiddenField = document.createElement("input");
348 hiddenField.setAttribute("name", "sectionId");
349 hiddenField.setAttribute("value", section_id);
350 form.appendChild(hiddenField);
351
352 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
353 document.body.appendChild(form);
354 form.submit();
355 } else {
356 form.submit(); // works under IE and Chrome, but not FF
357 }
358
359
360 }
361 // ===========
233 362
234 function replaceSmartRegex() { 363 function replaceSmartRegex() {
235 saveUndoText(); 364 saveUndoText();
236 var startPage = $('#regexPageStart2').val(); 365 var startPage = $('#regexPageStart2').val();
237 var endPage = $('#regexPageEnd2').val(); 366 var endPage = $('#regexPageEnd2').val();
270 399
271 400
272 401
273 function saveTextToLGService() { 402 function saveTextToLGService() {
274 var info = JSON.parse('<?php echo json_encode($info) ?>'); 403 var info = JSON.parse('<?php echo json_encode($info) ?>');
275 404 var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
276 405
277 // if this is a new branch, ask for label 406 // if this is a new branch, ask for label
278 if (info['branch_id'] == 0) { 407 if (info['branch_id'] == 0) {
408 var cnt = 0;
279 var label = prompt("Please enter your label for this new branch", "label for section "+info['section_id']); 409 var label = prompt("Please enter your label for this new branch", "label for section "+info['section_id']);
280 while (label == null) { 410 while (label == null && cnt <= 3) {
411 cnt ++;
281 label = prompt("Please enter your label for this new branch (not empty)", "label for section "+info['section_id']); 412 label = prompt("Please enter your label for this new branch (not empty)", "label for section "+info['section_id']);
282 } 413 }
283 }; 414 };
284 415
285 416
326 //var text = encodeURIComponent(el.innerHTML); 457 //var text = encodeURIComponent(el.innerHTML);
327 var text = el.innerHTML; 458 var text = el.innerHTML;
328 hiddenField.setAttribute("value", text); 459 hiddenField.setAttribute("value", text);
329 form.appendChild(hiddenField); 460 form.appendChild(hiddenField);
330 461
462 var hiddenField = document.createElement("input");
463 hiddenField.setAttribute("name", "topic_id");
464 hiddenField.setAttribute("value", topic_id);
465 form.appendChild(hiddenField);
331 466
332 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { 467 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
333 document.body.appendChild(form); 468 document.body.appendChild(form);
334 form.submit(); 469 form.submit();
335 } else { 470 } else {
477 } 612 }
478 ?> 613 ?>
479 }); 614 });
480 615
481 616
482 // init for popover used in bootstrap
483 $(function () {
484 $('[data-toggle="popover"]').popover()
485 })
486
487
488 617
489 </script> 618 </script>
619
490 620
491 <div id="popup-window" style="display: none; background-color:white; height:300px; width:300px; margin:200 0 0 200;position:fixed; z-index:2"> 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">
492 </div> 622 </div>
493 623
494 <div class="container-fluid"> 624
495 <div class="row"> 625 <p class="bg-info" style="margin:10 30 10 30; max-width:1250"> <?php echo $messages; ?> </p>
496 <div class="col-xs-8 col-sm-8 col-md-8 col-lg-7 col-lg-offset-1" style="position:fixed; height:30px; z-index:99"> 626
497 <p class="bg-info"> <?php echo $messages; ?> </p> 627 <table width="1270" border="1" style="margin:10 30 10 30;">
498 <div id="popups" style="position:relative; width:300px; margin-left: 100%"> 628 <tr>
629 <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;">
630 <div id="editable-area" class="area" style="max-width: 980"><?php echo $stringInput; ?></div>
631 </td>
632 <td width="290" valign="top">
633 <div id="popups" style="position:absolute; width:300px; ">
499 <div id="load_topic_div" style="position: absolute; display: none; z-index:2"></div> 634 <div id="load_topic_div" style="position: absolute; display: none; z-index:2"></div>
500 <div id="load_regex_div" style="position: absolute; display: none; z-index:2;"></div> 635 <div id="load_regex_div" style="position: absolute; display: none; z-index:2;"></div>
501 <div id="smartRegexPopUpDiv" style="position: absolute; display: none; z-index:2"> 636 <div id="smartRegexPopUpDiv" style="position: absolute; display: none; z-index:2">
502 Name: <input id="smartRegexPopUpName"></input><br><br> 637 Name: <input id="smartRegexPopUpName"></input><br><br>
503 Word List: 638 Word List:
527 <button id="smartRegexPopUpDel" onclick="replaceSmartDel()" class="btn btn-danger" style="">Delete</button> 662 <button id="smartRegexPopUpDel" onclick="replaceSmartDel()" class="btn btn-danger" style="">Delete</button>
528 <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" class="btn btn-default" style=""><<</button> 663 <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" class="btn btn-default" style=""><<</button>
529 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button> 664 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button>
530 <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button> 665 <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button>
531 </div> 666 </div>
667 </div>
668
669 <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll;margin:0 5 5 5; max-width:270px">
670 <form action="javascript:void(0);">
671 <fieldset>
672 <legend><h5 class="text-success"> Config Topic: </h5></legend>
673 <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>
675 </div>
676 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Config Tags</button></br>
677 </fieldset>
678
679 <fieldset>
680 <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
681 <div id="smartRegexShowDiv"></div><br>
682 <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>
684 <button onclick="replaceSmartRun()" style="height: 30px; width: 220px">Run</button></br>
685 <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>
687 <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>
689 <!--
690 <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button>
691 -->
692 </fieldset>
693
694 <fieldset>
695 <legend><h5 class="text-success"> Tag by rule:</h5></legend>
696 <button onclick="tagNameWithLastName()" style="height: 30px; width: 220px">Tag Word Begin With Surname</button></br>
697 <button onclick="tagNameWithLastName2()" style="height: 30px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
698 <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
699 <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
700 <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button>
701 </fieldset>
532 702
703 <fieldset>
704 <legend><h5 class="text-success"> Edit:</h5></legend>
705 <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
706
707 <!--<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
709 <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>
712 </br>
713 <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br>
714 <!--
715 <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>
716 -->
717 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 220px">Manage Tag List</button></br>
718 </fieldset>
719
720 <fieldset>
721 <legend><h5 class="text-success"> Export:</h5></legend>
722 Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br>
723 <button onclick="exportPage(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export</button></br>
724 <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br>
725 </fieldset>
726
727 <fieldset>
728 <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend>
729 Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br>
730 Regex: <input type="text" size="23" id="regexText"></br>
731 Replace: <input type="text" size="23" id="replaceText"><br>
732 <button onclick="replaceSmartRegex()">Replace!</button>
733 </fieldset>
734 </form>
533 </div> 735 </div>
534 </div> 736 </td>
535 737 </tr>
536 <div id="follow-scroll" class="col-xs-4 col-xs-offset-8 col-sm-4 col-sm-offset-8 col-md-4 col-md-offset-8 col-lg-3 col-lg-offset-8" style="position:fixed; width:100%; height:700px; overflow:scroll;"> 738
537 <form action="javascript:void(0);"> 739 </table>
538 <fieldset> 740
539 <legend><h5 class="text-success"> Config Topic: </h5></legend> 741
540 <div> current topic is <?php echo $topic_name; ?>
541 <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button>
542 </div>
543 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Config Tags</button></br>
544 </fieldset>
545
546 <fieldset>
547 <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
548 <div id="smartRegexShowDiv"></div><br>
549 <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br>
550 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br>
551 <button onclick="replaceSmartRun()" style="height: 30px; width: 220px">Run</button></br>
552 <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br>
553 <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button>
554 <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button>
555 <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br>
556 <!--
557 <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button>
558 -->
559 </fieldset>
560
561 <fieldset>
562 <legend><h5 class="text-success"> Tag by rule:</h5></legend>
563 <button onclick="tagNameWithLastName()" style="height: 30px; width: 220px">Tag Word Begin With Surname</button></br>
564 <button onclick="tagNameWithLastName2()" style="height: 30px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
565 <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
566 <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
567 <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button>
568 </fieldset>
569
570 <fieldset>
571 <legend><h5 class="text-success"> Edit:</h5></legend>
572 <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
573
574 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
575 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
576 <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br>
577 </br>
578 <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br>
579 <!--
580 <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>
581 -->
582 <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 220px">Manage Tag List</button></br>
583 </fieldset>
584
585 <fieldset>
586 <legend><h5 class="text-success"> Export:</h5></legend>
587 Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br>
588 <button onclick="exportPage()" style="height: 30px; width: 220px">Export</button></br>
589 <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br>
590 </fieldset>
591
592 <fieldset>
593 <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend>
594 Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br>
595 Regex: <input type="text" size="30" id="regexText"></br>
596 Replace: <input type="text" size="30" id="replaceText"><br>
597 <button onclick="replaceSmartRegex()">Replace!</button>
598 </fieldset>
599 </form>
600 </div>
601 </div>
602
603 <div class="row" style="margin-top:30px;">
604 <div id="editable-area" class="col-xs-8 col-sm-8 col-md-8 col-lg-7 col-lg-offset-1" style="z-index:1">
605 <?php echo $stringInput; ?>
606 </div>
607 </div>
608
609 </div>
610 742
611 743
612 </body> 744 </body>
613 745
614 </html> 746 </html>