comparison develop/js/taggingtext.js @ 13:cc36a20a68ab

automatically decide which rows (what data) should be shown in the exporting table based on the topic.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 17 Feb 2015 15:25:11 +0100
parents e82ca7375e93
children ac77748bb813
comparison
equal deleted inserted replaced
12:e82ca7375e93 13:cc36a20a68ab
615 newselect.id = "loadRegexSelect"; 615 newselect.id = "loadRegexSelect";
616 616
617 617
618 $.ajax({ 618 $.ajax({
619 type: 'POST', 619 type: 'POST',
620 url: '../../models/_extractapp_func.php', 620 url: '../models/_extractapp_func.php',
621 dataType: 'json', 621 dataType: 'json',
622 data: "func=SmartRegexLoad", 622 data: "func=SmartRegexLoad",
623 //cache: false, 623 //cache: false,
624 success: function (data) { 624 success: function (data) {
625 $.each(data, function(index, element) { 625 $.each(data, function(index, element) {
663 // === for exporttable.php === 663 // === for exporttable.php ===
664 function exportTable( range, container ) { 664 function exportTable( range, container ) {
665 //MsgBox("enter function"); 665 //MsgBox("enter function");
666 var form = document.createElement("form"); 666 var form = document.createElement("form");
667 form.setAttribute("method", "post"); 667 form.setAttribute("method", "post");
668 form.setAttribute("action", "exportTable.php"); 668 form.setAttribute("action", "./ExportTable");
669 form.setAttribute("target", "_blank"); 669 form.setAttribute("target", "_blank");
670 670
671 var hiddenField = document.createElement("input"); 671 var hiddenField = document.createElement("input");
672 hiddenField.setAttribute("name", "content"); 672 hiddenField.setAttribute("name", "content");
673 hiddenField.setAttribute("value", container.innerHTML); 673 hiddenField.setAttribute("value", container.innerHTML);
676 var hiddenField = document.createElement("input"); 676 var hiddenField = document.createElement("input");
677 hiddenField.setAttribute("name", "sectionid"); 677 hiddenField.setAttribute("name", "sectionid");
678 hiddenField.setAttribute("value", "<?php echo $section_id; ?>"); 678 hiddenField.setAttribute("value", "<?php echo $section_id; ?>");
679 form.appendChild(hiddenField); 679 form.appendChild(hiddenField);
680 680
681 var hiddenField2 = document.createElement("input");
682 hiddenField2.setAttribute("name", "topic");
683 hiddenField2.setAttribute("value", topic_id);
684 form.appendChild(hiddenField2);
685
681 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { 686 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
682 document.body.appendChild(form); 687 document.body.appendChild(form);
683 form.submit(); 688 form.submit();
684 } else { 689 } else {
685 form.submit(); // works under IE and Chrome, but not FF 690 form.submit(); // works under IE and Chrome, but not FF
695 700
696 var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】"; 701 var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】";
697 702
698 var form = document.createElement("form"); 703 var form = document.createElement("form");
699 form.setAttribute("method", "post"); 704 form.setAttribute("method", "post");
700 form.setAttribute("action", "exportTable.php"); 705 form.setAttribute("action", "./ExportTable");
701 form.setAttribute("target", "_blank"); 706 form.setAttribute("target", "_blank");
702 707
703 var hiddenField = document.createElement("input"); 708 var hiddenField = document.createElement("input");
704 hiddenField.setAttribute("name", "content"); 709 hiddenField.setAttribute("name", "content");
705 hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g"))); 710 hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g")));
716 } else { 721 } else {
717 form.submit(); // works under IE and Chrome, but not FF 722 form.submit(); // works under IE and Chrome, but not FF
718 } 723 }
719 } 724 }
720 725
721 function exportAll(section_id, topic_id) { 726 function exportAll(topic_id) {
722 var el = document.getElementById("editable-area"); 727 var el = document.getElementById("editable-area");
723 var str="" + el.innerHTML; 728 var str= "" + el.innerHTML;
724 var form = document.createElement("form"); 729 var form = document.createElement("form");
725 form.setAttribute("method", "post"); 730 form.setAttribute("method", "post");
726 //form.setAttribute("action", "exportTable.php"); 731 //form.setAttribute("action", "exportTable.php");
727 form.setAttribute("action", "../ExportTable/"+section_id); // hand to controller 732 form.setAttribute("action", "./ExportTable");//+section_id); // hand to controller
728 form.setAttribute("target", "_blank"); 733 form.setAttribute("target", "_blank");
729 734
730 var hiddenField = document.createElement("input"); 735 var hiddenField = document.createElement("input");
731 hiddenField.setAttribute("name", "content"); 736 hiddenField.setAttribute("name", "content");
732 hiddenField.setAttribute("value", str); 737 hiddenField.setAttribute("value", str);
733 form.appendChild(hiddenField); 738 form.appendChild(hiddenField);
734 739
735 var hiddenField2 = document.createElement("input"); 740 var hiddenField = document.createElement("input");
736 hiddenField2.setAttribute("name", "topic"); 741 hiddenField.setAttribute("name", "topic");
737 hiddenField2.setAttribute("value", topic_id); 742 hiddenField.setAttribute("value", topic_id);
738 form.appendChild(hiddenField2); 743 form.appendChild(hiddenField);
744
739 console.log(topic_id); 745 console.log(topic_id);
740 746
741 /* 747 /*
742 var hiddenField = document.createElement("input"); 748 var hiddenField = document.createElement("input");
743 hiddenField.setAttribute("name", "sectionid"); 749 hiddenField.setAttribute("name", "sectionid");