Mercurial > hg > extraction-interface
view views/Extractapp/ConfigTagsInTopic.php @ 97:c1bb174a22f3 extractapp
Topic synchronization with LGServices. Adaption for moving table from Gazetteer to LGService.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 16 Feb 2016 15:07:43 +0100 |
parents | 9a29e9d28ece |
children | 71b611a676c3 |
line wrap: on
line source
<?php /* * ConfigTagsInTopic.php * This file is part of Extraction-interface. * * Extraction-interface is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Extraction-interface is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>. */ /*! \file * This is a view for ConfigTagsInTopic. * It shows tags in the current topic, and the other tags that are in our database but not in this topic. * User can add/remove the tags in/out of this topic. */ // --- initialize --- //$taglistArray = $viewmodel['taglistArray']; $topic = $viewmodel['topic']; $topic_name = $viewmodel['topic_name']; // array of names $tag_intopic = $viewmodel['tag_intopic']; $tag_others = $viewmodel['tag_others']; ?> <html> <head> <title></title> </head> <body> <script type="text/javascript"> function SelectMoveRows(s1, s2) { var selId = ''; var selText = ''; // Move rows from s1 to s2 from bottom to top for (i = s1.options.length - 1; i >= 0; i--) { if (s1.options[i].selected == true) { selId = s1.options[i].value; selText = s1.options[i].text; var newRow = new Option(selText,selId); s2.options[s2.length] = newRow; s1.options[i] = null; } } SelectSort(s2); } function SelectSort(selList) { var id = ''; var t = ''; for (x = 0; x < selList.length - 1; x++) { for (y = x+1; y < selList.length; y++) { if (selList[x].text > selList[y].text) { // Swap rows id = selList[x].value; t = selList[x].text; selList[x].value = selList[y].value; selList[x].text = selList[y].text; selList[y].value = id; selList[y].text = t; } } } } function checkTopic(t) { var ids = []; for (var i = 0; i < t.options.length; i++) { ids.push(t.options[i].value); console.log(t.options[i].text); } console.log(ids); var ids_json = JSON.stringify(ids); var topic_id = JSON.parse('<?php echo json_encode($topic) ?>'); $.ajax({ url : './ConfigTagsInTopic', async : false, type : 'POST', data : 'func=Update'+'&ids='+ids_json+'&topic_id='+topic_id, error: function (e) { console.log("error when update tags in topic"+ e ); }, success: function (e) { alert("Updated!"); } }).done(function(result) { }); } </script> <div class="container-fluid" style="margin-left:10%; margin-right:10%"> <form name="config" autocomplete='off' action="Javascript:checkTopic(document.config.InTopic)"> <h3>Topic: <?php echo $topic_name['name_en'];?> (<?php echo $topic_name['name_ch'];?>, <?php echo $topic_name['name_pinyin'];?>) </h3> <table class="table"> <thead> <tr> <td class="text-warning"> Selected tags </td> <td></td> <td class="text-warning"> Other tags </td> </tr> </thead> <tbody> <tr> <td> <select name="InTopic" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple> <?php foreach ($tag_intopic as $taglistValue) { echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>"; } ?> </select> </td> <td align="center" valign="middle"> <input type="button" value="<< Add" class="btn btn-primary" onClick="SelectMoveRows(document.config.Others, document.config.InTopic)"><br> <br> <input type="button" value="Remove >>" class="btn btn-warning" onClick="SelectMoveRows(document.config.InTopic, document.config.Others)"><br> </td> <td > <select name="Others" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple> <?php foreach ($tag_others as $taglistValue) { echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>"; } ?> </select> </td> </tr> <tr> <td></td> <td align="center" valign="middle"> <input type="submit" value="Submit" class="btn btn-success"> </td> <td></td> </tr> </tbody> </table> </form> <!-- <input type="button" id="contTagging" value="Continue Tagging" class="btn btn-default"> --> </div> </body> </html>