Mercurial > hg > extraction-interface
view develop/views/Extractapp/configtagsintopic.php @ 20:04db1dd9d10d
update topic_regex_relation table when saving (new) regex file
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 23 Feb 2015 14:34:43 +0100 |
parents | f60969462226 |
children | c805470cefee |
line wrap: on
line source
<?php // --- initialize --- $taglistArray = $viewmodel['taglistArray']; $topic = $viewmodel['topic']; $topic_name = $viewmodel['topic_name']; ?> <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"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3"> <form name="config" autocomplete='off' action="Javascript:checkTopic(document.config.InTopic)"> <h3>Topic: <?php echo $topic_name;?> </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($taglistArray)*0.8; ?>" class="form-control" multiple> <?php foreach ($taglistArray as $taglistValue) { if ($taglistValue['topic_id'] == $topic) { 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($taglistArray)*0.8; ?>" class="form-control" multiple> <?php foreach ($taglistArray as $taglistValue) { if ($taglistValue['topic_id'] != $topic) { echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>"; } } ?> </select> </td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" class="btn btn-lg btn-success"></td> <td></td> </tr> </tbody> </table> </form> </div> </div> </div> <!-- <form name="config" autocomplete='off' action="Javascript:checkTopic(this)"> <h3>Topic: <?php echo $topic_name;?> </h3> <div> Select/Unselect the following tags for the topic. </div> <input type="submit" value="Submit"> <table style="" border="1"> <thead> <tr> <td>Name</td> <td>Tag</td> <td>Select/Unselect</td> </tr> </thead> <tbody> <?php // list the tags with topic foreach ($taglistArray as $taglistValue) { echo "<tr>"; echo "<td>".$taglistValue['name']."</td>"; echo "<td>".$taglistValue['tag']."</td>"; // checkbox for topic if ($taglistValue['topic_id'] == $topic) { echo "<td> <input type='checkbox' name='".$taglistValue['id']."' checked='true'/> </td>"; } else { echo "<td> <input type='checkbox' name='".$taglistValue['id']."'/> </td>"; } echo "</tr>"; } ?> </tbody> </table> </form> --> </body> </html>