Mercurial > hg > extraction-interface
diff views/Extractapp/ConfigTagsInTopic.php @ 47:886f43b26ee2 extractapp
move/remove develop folder
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 17 Mar 2015 10:54:13 +0100 |
parents | |
children | a11f9103b8db |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/views/Extractapp/ConfigTagsInTopic.php Tue Mar 17 10:54:13 2015 +0100 @@ -0,0 +1,139 @@ +<?php +// --- initialize --- +//$taglistArray = $viewmodel['taglistArray']; +$topic = $viewmodel['topic']; +$topic_name = $viewmodel['topic_name']; +$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:30%;"> + + <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($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><input type="submit" value="Submit" class="btn btn-lg btn-success"></td> + <td></td> + </tr> + </tbody> + </table> + + </form> +</div> + +</body> +</html>