Mercurial > hg > extraction-interface
comparison develop/views/Extractapp/taggingtext.php @ 10:54a235d43694
add topic choosing in the TaggingText page
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 10 Feb 2015 16:20:29 +0100 |
parents | 584b1623e9ef |
children | 3d6fba07bfbd |
comparison
equal
deleted
inserted
replaced
9:584b1623e9ef | 10:54a235d43694 |
---|---|
2 // --- initialize config file and input text --- | 2 // --- initialize config file and input text --- |
3 $stringInput = $viewmodel['stringInput']; | 3 $stringInput = $viewmodel['stringInput']; |
4 $wordlistArray = $viewmodel['wordlistArray']; | 4 $wordlistArray = $viewmodel['wordlistArray']; |
5 $taglistArray = $viewmodel['taglistArray']; | 5 $taglistArray = $viewmodel['taglistArray']; |
6 $section_id = $viewmodel['section_id']; | 6 $section_id = $viewmodel['section_id']; |
7 | 7 $topiclistArray = $viewmodel['topiclistArray']; |
8 | 8 $default_topic_id = $viewmodel['default_topic_id']; |
9 var_dump($taglistArray); | |
10 | 9 |
11 ?> | 10 ?> |
12 | 11 |
13 <html> | 12 <html> |
14 <head> | 13 <head> |
224 }); | 223 }); |
225 } | 224 } |
226 } | 225 } |
227 | 226 |
228 | 227 |
228 function chooseTopic(section_id, default_topic_id) { | |
229 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); | |
230 | |
231 $('#load_topic_div').html(""); | |
232 $('#load_topic_div').css("display", "block"); | |
233 $('#load_topic_div').css("border", "1px solid black"); | |
234 $('#load_topic_div').css("background-color", "White"); | |
235 $('#load_topic_div').css("width", "200px"); | |
236 $('#load_topic_div').css("height", "50px"); | |
237 $('#load_topic_div').css("top", "20px"); | |
238 $('#load_topic_div').css("left", "-200px"); | |
239 | |
240 var topic_select = document.createElement("select"); | |
241 topic_select.id = "loadTopiclist"; | |
242 var selected_topic = t[0]; | |
243 topic_select.onchange = function(){ | |
244 | |
245 selected_topic = topic_select.options[topic_select.selectedIndex]; | |
246 console.log(selected_topic.text); | |
247 | |
248 var topic_id = selected_topic.value; | |
249 var topic_name = selected_topic.text; | |
250 | |
251 var form = document.createElement("form"); | |
252 form.setAttribute("method", "post"); | |
253 form.setAttribute("action", "./"+section_id); // hand to controller | |
254 form.setAttribute("target", "_self"); | |
255 | |
256 var hiddenField = document.createElement("input"); | |
257 hiddenField.setAttribute("name", "topic"); | |
258 hiddenField.setAttribute("value", topic_id); | |
259 form.appendChild(hiddenField); | |
260 | |
261 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | |
262 document.body.appendChild(form); | |
263 form.submit(); | |
264 } else { | |
265 form.submit(); // works under IE and Chrome, but not FF | |
266 } | |
267 | |
268 | |
269 | |
270 }; | |
271 | |
272 | |
273 //Create and append the options | |
274 for (var i = 0; i < t.length; i++) { | |
275 console.log(t[i]['id']+","+t[i]['name']); | |
276 var option = document.createElement("option"); | |
277 option.value = t[i]['id']; | |
278 option.text = t[i]['name']; | |
279 if (option.value == default_topic_id) { | |
280 option.selected = true; | |
281 }; | |
282 topic_select.appendChild(option); | |
283 } | |
284 | |
285 $('#load_topic_div').append(topic_select); | |
286 | |
287 var newbutton = document.createElement("button"); | |
288 $(newbutton).html("Close"); | |
289 $(newbutton).attr("onclick", "$('#load_topic_div').css(\"display\", \"none\");"); | |
290 $('#load_topic_div').append(newbutton); | |
291 | |
292 } | |
293 | |
294 | |
229 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { | 295 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) { |
230 | 296 |
231 <?php | 297 <?php |
232 foreach ( $wordlistArray as $wordlistValue ) { | 298 foreach ( $wordlistArray as $wordlistValue ) { |
233 echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {"; | 299 echo "if ( $('#smartRegexPopUpSelectWord').val() == \"".$wordlistValue[0]."\") {"; |
246 <div id="editable-area" class="area" style="max-width: 980"><?php echo $stringInput; ?></div> | 312 <div id="editable-area" class="area" style="max-width: 980"><?php echo $stringInput; ?></div> |
247 </td> | 313 </td> |
248 <td width="270" valign="top"> | 314 <td width="270" valign="top"> |
249 <div id="follow-scroll" style="position:absolute; width: 220" width="220"> | 315 <div id="follow-scroll" style="position:absolute; width: 220" width="220"> |
250 <div id="load_regex_div" style="position: absolute; display: none"></div> | 316 <div id="load_regex_div" style="position: absolute; display: none"></div> |
317 <div id="load_topic_div" style="position: absolute; display: none"></div> | |
251 <div id="smartRegexPopUpDiv" style="position: absolute; display: none"> | 318 <div id="smartRegexPopUpDiv" style="position: absolute; display: none"> |
252 Name: <input id="smartRegexPopUpName"></input><br><br> | 319 Name: <input id="smartRegexPopUpName"></input><br><br> |
253 Word List: | 320 Word List: |
254 <select id="smartRegexPopUpSelectWord"> | 321 <select id="smartRegexPopUpSelectWord"> |
255 <option value="NULL" selected>無</option> | 322 <option value="NULL" selected>無</option> |
278 <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" style="height: 30px; width: 50px"><<</button> | 345 <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" style="height: 30px; width: 50px"><<</button> |
279 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" style="height: 30px; width: 50px">>></button> | 346 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" style="height: 30px; width: 50px">>></button> |
280 <button onclick="replaceSmartClose()" style="height: 30px; width: 50px">Close</button> | 347 <button onclick="replaceSmartClose()" style="height: 30px; width: 50px">Close</button> |
281 </div> | 348 </div> |
282 <form action="javascript:void(0);"> | 349 <form action="javascript:void(0);"> |
350 <button onclick="chooseTopic(<?php echo $section_id;?>, <?php echo $default_topic_id; ?>)">Choose Topic</button> | |
351 | |
283 <fieldset> | 352 <fieldset> |
284 <legend>Replace By <i><b>Smart Regex</b></i>©:</legend> | 353 <legend>Replace By <i><b>Smart Regex</b></i>©:</legend> |
285 <div id="smartRegexShowDiv"></div><br> | 354 <div id="smartRegexShowDiv"></div><br> |
286 <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br> | 355 <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br> |
287 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> | 356 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> |
329 </div> | 398 </div> |
330 </td> | 399 </td> |
331 </tr> | 400 </tr> |
332 </table> | 401 </table> |
333 </body> | 402 </body> |
403 | |
334 </html> | 404 </html> |