Mercurial > hg > extraction-interface
diff develop/views/Extractapp/taggingtext.php @ 14:ac77748bb813
- Load regex files based on current topic. Only show the regex in this topic.
To do that, it needs to lookup a table called 'topic_regex_relation' which has the relation of topic and regex filename in filesystem.
- Extractapp UI with some layout modification: button, popup window, responsive (by bootstrap now). It was just for quick prototyping.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 19 Feb 2015 11:07:27 +0100 |
parents | cc36a20a68ab |
children | 1f98c92ebbfb |
line wrap: on
line diff
--- a/develop/views/Extractapp/taggingtext.php Tue Feb 17 15:25:11 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Thu Feb 19 11:07:27 2015 +0100 @@ -8,7 +8,8 @@ $default_topic_id = $viewmodel['default_topic_id']; $topic_tag = $viewmodel['topic_tag']; $info = $viewmodel['info']; -var_dump($info); +$messages = $viewmodel['messages']; + ?> @@ -59,7 +60,7 @@ if (_GET['id']) { var info = JSON.parse('<?php echo json_encode($info) ?>'); - var redirectUrl = "http://141.14.239.50:1080/localmonographs/develop/Extractapp/TaggingText"; + var redirectUrl = "http://localhost:1080/localmonographs/develop/Extractapp/TaggingText"; var section_id = info['section_id']; var form = $('<form action="' + redirectUrl + '" method="post">' + @@ -87,6 +88,7 @@ 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 @@ -94,6 +96,8 @@ var finaldestination = windowpos+originalelpos; el.stop().animate({'top':finaldestination},500); }); + */ + }); $(document).on("click", "name", function (e) { @@ -246,118 +250,25 @@ } -function smartRegexSave() { - var x; - var name=prompt("Please enter this Regex name",RegexLoadedName); - if (name!=null){ - $.ajax({ - type : 'POST', - url : '../models/_extractapp_func.php', - async : false, - data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name - }).done(function(result) { - alert("Saved!"); - }); - } -} -function _postForContineTagging(form) { - - - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "text"); - var el = document.getElementById("editable-area"); - var text = el.innerHTML; - hiddenField.setAttribute("value", text); - form.appendChild(hiddenField); - - var info = JSON.parse( '<?php echo json_encode($info) ?>'); - - if (info) { - // TODO: different field info array based on fileId(branchId) existing or not - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "fileId"); - hiddenField.setAttribute("value", info['file_id']); - form.appendChild(hiddenField); - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "branchId"); - hiddenField.setAttribute("value", info['branch_id']); - form.appendChild(hiddenField); - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "userId"); - hiddenField.setAttribute("value", info['user_id']); - form.appendChild(hiddenField); - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "sectionId"); - hiddenField.setAttribute("value", info['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 saveTextToLGService() { + var info = JSON.parse('<?php echo json_encode($info) ?>'); - - -// === for config tags in topic === -function configTagsInTopic(topic_id) { - var form = document.createElement("form"); - - form.setAttribute("method", "post"); - //form.setAttribute("action", "exportTable.php"); - form.setAttribute("action", "./ConfigTagsInTopic"); // hand to controller - form.setAttribute("target", "_blank"); + // if this is a new branch, ask for label + if (info['branch_id'] == 0) { + var label = prompt("Please enter your label for this new branch", "label for section "+info['section_id']); + while (label == null) { + label = prompt("Please enter your label for this new branch (not empty)", "label for section "+info['section_id']); + } + }; - var hiddenField = document.createElement("input"); - hiddenField.setAttribute("name", "topic"); - hiddenField.setAttribute("value", topic_id); - form.appendChild(hiddenField); - - _postForContineTagging(form); - -} - - -function saveTextToLGService(section_id) { - var info = JSON.parse('<?php echo json_encode($info) ?>'); - - var el = document.getElementById("editable-area"); - - /* - $.ajax({ - url : './TaggingText/'+section_id, - async : false, - type : 'POST', - data : 'func=SaveFullTextToLGService'+'&text='+el.innerHTML+'&fileId='+info['file_id']+'&branchId='+info['branch_id']+'&userId='+info['user_id']+'§ionId='+info['section_id'], - success: function (result) { - console.log(result); - }, - error: function (data) { - console.log("error when saving to LGService!"); - } - }).done(function(result) { - alert("Saved!"); - console.log("result: "+result); - }); - - */ - - - var form = document.createElement("form"); form.setAttribute("method", "post"); - // form.setAttribute("action", "./"); // hand to controller + form.setAttribute("action", "./TaggingText"); // hand to controller - form.setAttribute("action", "./"+info['section_id']); // hand to controller + // form.setAttribute("action", "./"+info['section_id']); // hand to controller form.setAttribute("target", "_self"); var hiddenField = document.createElement("input"); @@ -382,12 +293,17 @@ hiddenField.setAttribute("name", "sectionId"); hiddenField.setAttribute("value", info['section_id']); form.appendChild(hiddenField); + } + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "label"); + hiddenField.setAttribute("value", label); + form.appendChild(hiddenField); var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "text"); - //var el = document.getElementById("editable-area"); + var el = document.getElementById("editable-area"); //var text = encodeURIComponent(el.innerHTML); var text = el.innerHTML; hiddenField.setAttribute("value", text); @@ -413,12 +329,14 @@ $('#load_topic_div').html(""); $('#load_topic_div').css("display", "block"); + $('#load_topic_div').css("border", "1px solid black"); $('#load_topic_div').css("background-color", "White"); - $('#load_topic_div').css("width", "200px"); + $('#load_topic_div').css("width", "150px"); $('#load_topic_div').css("height", "50px"); $('#load_topic_div').css("top", "20px"); - $('#load_topic_div').css("left", "-200px"); + $('#load_topic_div').css("left", "-150px"); + var topic_select = document.createElement("select"); topic_select.id = "loadTopiclist"; @@ -468,14 +386,76 @@ } $('#load_topic_div').append(topic_select); + var newbutton = document.createElement("button"); $(newbutton).html("Close"); + $(newbutton).addClass("btn btn-default"); $(newbutton).attr("onclick", "$('#load_topic_div').css(\"display\", \"none\");"); $('#load_topic_div').append(newbutton); } +// --- for config tags in topic --- +function _postForContineTagging(form) { + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "text"); + var el = document.getElementById("editable-area"); + var text = el.innerHTML; + hiddenField.setAttribute("value", text); + form.appendChild(hiddenField); + + var info = JSON.parse( '<?php echo json_encode($info) ?>'); + + if (info) { + // TODO: different field info array based on fileId(branchId) existing or not + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "fileId"); + hiddenField.setAttribute("value", info['file_id']); + form.appendChild(hiddenField); + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "branchId"); + hiddenField.setAttribute("value", info['branch_id']); + form.appendChild(hiddenField); + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "userId"); + hiddenField.setAttribute("value", info['user_id']); + form.appendChild(hiddenField); + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "sectionId"); + hiddenField.setAttribute("value", info['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 configTagsInTopic(topic_id) { + var form = document.createElement("form"); + + form.setAttribute("method", "post"); + //form.setAttribute("action", "exportTable.php"); + form.setAttribute("action", "./ConfigTagsInTopic"); // hand to controller + form.setAttribute("target", "_blank"); + + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("name", "topic"); + hiddenField.setAttribute("value", topic_id); + form.appendChild(hiddenField); + + _postForContineTagging(form); + +} + + $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { @@ -488,9 +468,138 @@ ?> }); +$(function () { + + $('#example').popover({ + //selector: '.has-popover' + content: function () { + return; + }, + //template: output_content, + title: "Load Regex" + }); +}) + + + +// init for popover used in bootstrap +$(function () { + $('[data-toggle="popover"]').popover() +}) </script> +<div class="container-fluid"> + <div class="row"> + <div class="col-xs-12 col-sm-12 col-md-12 col-lg-10 col-lg-offset-1"> + <p class="bg-primary"> <?php echo $messages; ?> </p> + </div> + </div> + + <div class="row"> + <div id="editable-area" class="col-xs-8 col-sm-8 col-md-8 col-lg-7 col-lg-offset-1"><?php echo $stringInput; ?> + </div> + <div id="follow-scroll" class="col-xs-4 col-sm-4 col-md-4 col-lg-4"> + <div id="load_topic_div" style="position: absolute; display: none"></div> + <div id="load_regex_div" style="position: absolute; display: none"></div> + <div id="smartRegexPopUpDiv" style="position: absolute; display: none"> + Name: <input id="smartRegexPopUpName"></input><br><br> + Word List: + <select id="smartRegexPopUpSelectWord"> + <option value="NULL" selected>無</option> + <?php + foreach ( $wordlistArray as $wordlistValue ) { + echo "<option value=\"".$wordlistValue[0]."\">".$wordlistValue[1]."</option>\n"; + } + ?> + </select> + <br> + OR (USE "|" TO SEPARATE WORDS):<br> + <TEXTAREA id="smartRegexPopUpText" COLS=30 ROWS=4></TEXTAREA><br><br> + Tag: + <select id="smartRegexPopUpSelectTag"> + <?php + foreach ( $taglistArray as $taglistValue ) { + echo "<option value=\"".$taglistValue[2]."\">".$taglistValue[1]."</option>\n"; + } + echo "<option value=\"title\">Title</option>\n"; + ?> + <option value="NOTAG">不標記</option> + </select><br> + <button id="smartRegexPopUpAdd" onclick="replaceSmartAdd()" class="btn btn-info" style="">Add</button> + <button id="smartRegexPopUpEdit" onclick="replaceSmartEdit()" class="btn btn-success" style="">Edit</button> + <button id="smartRegexPopUpDel" onclick="replaceSmartDel()" class="btn btn-warning" style="">Delete</button> + <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" class="btn btn-default" style=""><<</button> + <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" class="btn btn-default" style="">>></button> + <button onclick="replaceSmartClose()" class="btn btn-default" style="">Close</button> + </div> + + <form action="javascript:void(0);"> + + <h4 class="text-success"> Config Topic</h4> + <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn-">Choose Topic</button> + + <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" style="">Config Tags</button></br> + + <fieldset> + <legend><h4 class="text-success"> Replace By <i><b>Smart Regex</b></i>©: </h4></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()" 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><h4 class="text-success"> Tag by rule:</h4></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><h4 class="text-success"> Edit:</h4></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> + </fieldset> + + <fieldset> + <legend><h4 class="text-success"> Export:</h4></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><h4 class="text-success"> Replace By <i><b>Regex</b></i>: </h4></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> + + <table width="1250" border="1"> <tr> <td width="980"> @@ -542,7 +651,7 @@ <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()" style="height: 30px; width: 70px">Save</button> - <button onclick="smartRegexLoad(<?php echo $section_id;?>)" style="height: 30px; width: 70px">Load</button> + <button onclick="smartRegexLoad()" style="height: 30px; width: 70px">Load</button> <button onclick="smartRegexEmpty()" style="height: 30px; width: 70px">Clear</button></br> </fieldset> @@ -557,14 +666,14 @@ <fieldset> <legend>Edit:</legend> - <button onclick="saveTextToLGService(<?php echo $section_id;?>)" style="height: 30px; width: 220px">Save to LGService</button></br> + <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/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Word List</button></br> - <button onclick="window.open('./EditTaglist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Tag List</button></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> </fieldset> <fieldset> @@ -586,6 +695,9 @@ </td> </tr> </table> + + + </body> </html>