diff 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
line wrap: on
line diff
--- a/develop/views/Extractapp/taggingtext.php	Mon Feb 23 14:34:43 2015 +0100
+++ b/develop/views/Extractapp/taggingtext.php	Tue Feb 24 16:09:59 2015 +0100
@@ -84,22 +84,42 @@
 ?>
 
 $(document).ready(function(){
+    
+    // --- for sidebar--- 
     //run once
-    /* no need, fixed sidebar
     var el=$('#follow-scroll');
     var originalelpos=el.offset().top; // take it where it originally is on the page
-    */
+    
 
     //run on scroll
-    /*
     $(window).scroll(function(){
         var el = $('#follow-scroll'); // important! (local)
         var elpos = el.offset().top; // take current situation
         var windowpos = $(window).scrollTop();
         var finaldestination = windowpos+originalelpos;
-        el.stop().animate({'top':finaldestination},500);
+        //el.stop().animate({'top':finaldestination},500);
+        el.stop().animate({'top':finaldestination},0);
     });
-    */
+
+    //--- for popups ---
+    //run once
+    var el=$('#popups');
+    var originalelpos=el.offset().top; // take it where it originally is on the page
+    
+    //run on scroll
+    $(window).scroll(function(){
+        var el = $('#popups'); // important! (local)
+        var elpos = el.offset().top; // take current situation
+        var windowpos = $(window).scrollTop();
+        var finaldestination = windowpos+originalelpos;
+        //el.stop().animate({'top':finaldestination},500);
+        el.stop().animate({'top':finaldestination},0);
+    });
+
+
+
+
+
 
     // Popup choosing topic if first time to this section. without branchId
     var info = JSON.parse('<?php echo json_encode($info) ?>');
@@ -230,6 +250,115 @@
 });
 
 
+// === for exporttable.php ===
+function exportTable( range, container ) {
+    //MsgBox("enter function");
+    var form = document.createElement("form");
+    form.setAttribute("method", "post");
+    form.setAttribute("action", "./ExportTable");
+    form.setAttribute("target", "_blank");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "content");
+    hiddenField.setAttribute("value", container.innerHTML);
+    form.appendChild(hiddenField);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "sectionid");
+    hiddenField.setAttribute("value", "<?php echo $section_id; ?>");
+    form.appendChild(hiddenField);
+    
+    var hiddenField2 = document.createElement("input");      
+    hiddenField2.setAttribute("name", "topic");
+    hiddenField2.setAttribute("value", topic_id);
+    form.appendChild(hiddenField2);
+
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+}
+
+function exportPage(topic_id) {
+    var startPage = $('#exportPageStart').val();
+    var endPage = $('#exportPageEnd').val();
+
+    var el = document.getElementById("editable-area");
+    var str="" + el.innerHTML;
+
+    var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】";
+    
+    var form = document.createElement("form");
+    form.setAttribute("method", "post");
+    form.setAttribute("action", "./ExportTable");
+    form.setAttribute("target", "_blank");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "content");
+    hiddenField.setAttribute("value", str.match(new RegExp(regexText, "g")));
+    form.appendChild(hiddenField);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "topic");
+    hiddenField.setAttribute("value", topic_id);
+    form.appendChild(hiddenField);
+
+    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);   
+ 
+
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+}
+
+function exportAll(topic_id) {
+    var el = document.getElementById("editable-area");
+    var str= "" + el.innerHTML;
+    var form = document.createElement("form");
+    form.setAttribute("method", "post");
+    //form.setAttribute("action", "exportTable.php");
+    form.setAttribute("action", "./ExportTable");//+section_id);  // hand to controller
+    form.setAttribute("target", "_blank");
+    
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "content");
+    hiddenField.setAttribute("value", str);
+    form.appendChild(hiddenField);
+
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "topic");
+    hiddenField.setAttribute("value", topic_id);
+    form.appendChild(hiddenField);
+
+    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);   
+    
+    if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
+        document.body.appendChild(form);
+        form.submit();
+    } else {
+        form.submit(); // works under IE and Chrome, but not FF  
+    }
+
+
+}
+// ===========
 
 function replaceSmartRegex() {
     saveUndoText();
@@ -272,12 +401,14 @@
 
 function saveTextToLGService() {
     var info = JSON.parse('<?php echo json_encode($info) ?>');
-
+    var topic_id = JSON.parse('<?php echo json_encode($default_topic_id) ?>');
 
     // if this is a new branch, ask for label
     if (info['branch_id'] == 0) {
+        var cnt = 0;
         var label = prompt("Please enter your label for this new branch", "label for section "+info['section_id']);
-        while (label == null) {
+        while (label == null && cnt <= 3) {
+            cnt ++;
             label = prompt("Please enter your label for this new branch (not empty)", "label for section "+info['section_id']);
         }    
     };
@@ -328,6 +459,10 @@
     hiddenField.setAttribute("value", text);
     form.appendChild(hiddenField);
 
+    var hiddenField = document.createElement("input");      
+    hiddenField.setAttribute("name", "topic_id");
+    hiddenField.setAttribute("value", topic_id);
+    form.appendChild(hiddenField); 
     
     if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
         document.body.appendChild(form);
@@ -479,23 +614,23 @@
 });
 
 
-// init for popover used in bootstrap
-$(function () {
-  $('[data-toggle="popover"]').popover()
-})
-
-
 
 </script>
+
  
 <div id="popup-window" style="display: none; background-color:white; height:300px; width:300px; margin:200 0 0 200;position:fixed; z-index:2">
 </div>
 
-<div class="container-fluid">
-    <div class="row">
-        <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"> 
-            <p class="bg-info"> <?php echo $messages; ?> </p>
-            <div id="popups" style="position:relative; width:300px; margin-left: 100%">
+
+<p class="bg-info" style="margin:10 30 10 30; max-width:1250"> <?php echo $messages; ?> </p>
+
+<table width="1270" border="1" style="margin:10 30 10 30;">
+    <tr>
+        <td width="980" style="padding:0 5 0 5; margin: 0 5 0 5;">
+            <div id="editable-area" class="area" style="max-width: 980"><?php echo $stringInput; ?></div>
+        </td>
+        <td width="290" valign="top">
+            <div id="popups" style="position:absolute; width:300px; ">
                 <div id="load_topic_div" style="position: absolute; display: none; z-index:2"></div>
                 <div id="load_regex_div" style="position: absolute; display: none; z-index:2;"></div>
                 <div id="smartRegexPopUpDiv" style="position: absolute; display: none; z-index:2">
@@ -529,84 +664,81 @@
                     <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button>
                     <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button>
                 </div>
-                
             </div>
-        </div>
-        
-        <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;">
-            <form action="javascript:void(0);">   
-                <fieldset>
-                    <legend><h5 class="text-success"> Config Topic: </h5></legend>
-                    <div> current topic is <?php echo $topic_name; ?> 
-                        <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button>
-                    </div>
-                    <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Config Tags</button></br>
-                </fieldset>
+
+            <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll;margin:0 5 5 5; max-width:270px">
+                <form action="javascript:void(0);">   
+                    <fieldset>
+                        <legend><h5 class="text-success"> Config Topic: </h5></legend>
+                        <div> current topic is <?php echo $topic_name; ?> 
+                            <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button>
+                        </div>
+                        <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Config Tags</button></br>
+                    </fieldset>
 
-                <fieldset>
-                    <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
-                    <div id="smartRegexShowDiv"></div><br>
-                    <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br>
-                    Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br>
-                    <button onclick="replaceSmartRun()" style="height: 30px; width: 220px">Run</button></br>
-                    <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br>
-                    <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button>
-                    <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button>
-                    <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br>
-                    <!--
-                    <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button>
-                    -->
-                </fieldset>
+                    <fieldset>
+                        <legend><h5 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h5></legend>
+                        <div id="smartRegexShowDiv"></div><br>
+                        <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br>
+                        Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br>
+                        <button onclick="replaceSmartRun()" style="height: 30px; width: 220px">Run</button></br>
+                        <button onclick="replaceSmartRunSpace()" style="height: 30px; width: 220px">Run(Allow space between Group)</button></br>
+                        <button onclick="smartRegexSave(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Save</button>
+                        <button onclick="smartRegexLoad(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 70px">Load</button>
+                        <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br>
+                        <!--
+                        <button id="example" type="button" class="btn btn-sm btn-default" data-toggle="popover">Load</button>
+                        -->
+                    </fieldset>
+                    
+                    <fieldset>
+                        <legend><h5 class="text-success"> Tag by rule:</h5></legend>
+                        <button onclick="tagNameWithLastName()" style="height: 30px; width: 220px">Tag Word Begin With Surname</button></br>
+                        <button onclick="tagNameWithLastName2()" style="height: 30px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
+                        <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
+                        <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
+                        <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button>
+                    </fieldset>
                 
-                <fieldset>
-                    <legend><h5 class="text-success"> Tag by rule:</h5></legend>
-                    <button onclick="tagNameWithLastName()" style="height: 30px; width: 220px">Tag Word Begin With Surname</button></br>
-                    <button onclick="tagNameWithLastName2()" style="height: 30px; width: 170px">Tag Word Begin With</button><input type="text" size="2" id="surname"></br>
-                    <!--<button onclick="tagTime()" style="height: 30px; width: 220px">Tag Time</button></br>-->
-                    <!--<button onclick="tagBiogAddr()" style="height: 30px; width: 220px">Tag BiogAddr</button></br>-->
-                    <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button>
-                </fieldset>
-            
-                <fieldset>
-                    <legend><h5 class="text-success"> Edit:</h5></legend>
-                    <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
-                
-                    <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
-                    <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
-                    <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br>
-                    </br>
-                    <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br>
-                    <!--
-                    <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>
-                    -->
-                    <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 220px">Manage Tag List</button></br>
-                </fieldset>
+                    <fieldset>
+                        <legend><h5 class="text-success"> Edit:</h5></legend>
+                        <button onclick="saveTextToLGService()" style="height: 30px; width: 220px">Save to LGService</button></br>
+                    
+                        <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>-->
+                        <!-- save text in local. replaced by saveTextToLGService, which is also saving on copy in local in development stage
+                        <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br>
+                        -->
+                        <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br>
+                        </br>
+                        <button onclick="window.open('./EditWordlist')" style="height: 30px; width: 220px">Manage Word List</button></br>
+                        <!--
+                        <button onclick="window.open('./EditTaglist')" style="height: 30px; width: 220px">Manage Tag List</button></br>
+                        -->
+                        <button onclick="editTaglist(<?php echo $default_topic_id; ?>)" style="height: 30px; width: 220px">Manage Tag List</button></br>
+                    </fieldset>
+                    
+                    <fieldset>
+                        <legend><h5 class="text-success"> Export:</h5></legend>
+                        Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br>
+                        <button onclick="exportPage(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export</button></br>
+                        <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br>
+                    </fieldset>
                 
-                <fieldset>
-                    <legend><h5 class="text-success"> Export:</h5></legend>
-                    Page: <input type="text" size="5" id="exportPageStart">to<input type="text" size="5" id="exportPageEnd"><br>
-                    <button onclick="exportPage()" style="height: 30px; width: 220px">Export</button></br>
-                    <button onclick="exportAll(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Export All</button></br>
-                </fieldset>
-            
-                <fieldset>
-                    <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend>
-                    Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br>
-                    Regex: <input type="text" size="30" id="regexText"></br>
-                    Replace: <input type="text" size="30" id="replaceText"><br>
-                    <button onclick="replaceSmartRegex()">Replace!</button>
-                </fieldset>
-            </form>
-        </div>
-    </div>
-    
-    <div class="row" style="margin-top:30px;">
-        <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">
-            <?php echo $stringInput; ?>
-        </div>
-    </div>
+                    <fieldset>
+                        <legend><h5 class="text-success"> Replace By <i><b>Regex</b></i>: </h5></legend>
+                        Range: <input type="text" size="5" id="regexPageStart2">to<input type="text" size="5" id="regexPageEnd2"><br>
+                        Regex: <input type="text" size="23" id="regexText"></br>
+                        Replace: <input type="text" size="23" id="replaceText"><br>
+                        <button onclick="replaceSmartRegex()">Replace!</button>
+                    </fieldset>
+                </form>
+            </div>
+        </td>
+    </tr>
 
-</div>
+</table>
+
+
 
 
 </body>