comparison 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
comparison
equal deleted inserted replaced
46:b3ca5d2b4d3f 47:886f43b26ee2
1 <?php
2 // --- initialize ---
3 //$taglistArray = $viewmodel['taglistArray'];
4 $topic = $viewmodel['topic'];
5 $topic_name = $viewmodel['topic_name'];
6 $tag_intopic = $viewmodel['tag_intopic'];
7 $tag_others = $viewmodel['tag_others'];
8
9 ?>
10
11 <html>
12 <head>
13 <title></title>
14 </head>
15
16 <body>
17 <script type="text/javascript">
18 function SelectMoveRows(s1, s2)
19 {
20 var selId = '';
21 var selText = '';
22 // Move rows from s1 to s2 from bottom to top
23 for (i = s1.options.length - 1; i >= 0; i--)
24 {
25 if (s1.options[i].selected == true)
26 {
27 selId = s1.options[i].value;
28 selText = s1.options[i].text;
29 var newRow = new Option(selText,selId);
30 s2.options[s2.length] = newRow;
31 s1.options[i] = null;
32 }
33 }
34 SelectSort(s2);
35 }
36 function SelectSort(selList)
37 {
38 var id = '';
39 var t = '';
40 for (x = 0; x < selList.length - 1; x++)
41 {
42 for (y = x+1; y < selList.length; y++)
43 {
44 if (selList[x].text > selList[y].text)
45 {
46 // Swap rows
47 id = selList[x].value;
48 t = selList[x].text;
49 selList[x].value = selList[y].value;
50 selList[x].text = selList[y].text;
51 selList[y].value = id;
52 selList[y].text = t;
53 }
54 }
55 }
56 }
57
58 function checkTopic(t) {
59 var ids = [];
60
61 for (var i = 0; i < t.options.length; i++) {
62 ids.push(t.options[i].value);
63 console.log(t.options[i].text);
64 }
65
66 console.log(ids);
67 var ids_json = JSON.stringify(ids);
68 var topic_id = JSON.parse('<?php echo json_encode($topic) ?>');
69
70 $.ajax({
71 url : './ConfigTagsInTopic',
72 async : false,
73 type : 'POST',
74 data : 'func=Update'+'&ids='+ids_json+'&topic_id='+topic_id,
75 error: function (e) {
76 console.log("error when update tags in topic"+ e );
77 },
78 success: function (e) {
79 alert("Updated!");
80 }
81 }).done(function(result) {
82 });
83
84 }
85
86 </script>
87
88 <div class="container-fluid" style="margin-left:30%;">
89
90 <form name="config" autocomplete='off' action="Javascript:checkTopic(document.config.InTopic)">
91 <h3>Topic: <?php echo $topic_name;?> </h3>
92
93 <table class="table">
94 <thead>
95 <tr>
96 <td class="text-warning"> Selected tags </td>
97 <td></td>
98 <td class="text-warning"> Other tags </td>
99 </tr>
100 </thead>
101 <tbody>
102 <tr>
103 <td>
104 <select name="InTopic" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple>
105 <?php
106 foreach ($tag_intopic as $taglistValue) {
107 echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
108 }
109 ?>
110 </select>
111 </td>
112 <td align="center" valign="middle">
113 <input type="button" value="<< Add" class="btn btn-primary" onClick="SelectMoveRows(document.config.Others, document.config.InTopic)"><br>
114 <br>
115 <input type="button" value="Remove >>" class="btn btn-warning" onClick="SelectMoveRows(document.config.InTopic, document.config.Others)"><br>
116 </td>
117 <td >
118 <select name="Others" size="<?php echo (count($tag_others)+count($tag_intopic))*0.8; ?>" class="form-control" multiple>
119 <?php
120 foreach ($tag_others as $taglistValue) {
121 echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
122 }
123 ?>
124 </select>
125 </td>
126 </tr>
127 <tr>
128 <td></td>
129 <td><input type="submit" value="Submit" class="btn btn-lg btn-success"></td>
130 <td></td>
131 </tr>
132 </tbody>
133 </table>
134
135 </form>
136 </div>
137
138 </body>
139 </html>