Mercurial > hg > extraction-interface
comparison develop/views/Extractapp/taggingtext.php @ 12:e82ca7375e93
Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 16 Feb 2015 16:51:39 +0100 |
parents | 3d6fba07bfbd |
children | cc36a20a68ab |
comparison
equal
deleted
inserted
replaced
11:3d6fba07bfbd | 12:e82ca7375e93 |
---|---|
5 $taglistArray = $viewmodel['taglistArray']; | 5 $taglistArray = $viewmodel['taglistArray']; |
6 $section_id = $viewmodel['section_id']; | 6 $section_id = $viewmodel['section_id']; |
7 $topiclistArray = $viewmodel['topiclistArray']; | 7 $topiclistArray = $viewmodel['topiclistArray']; |
8 $default_topic_id = $viewmodel['default_topic_id']; | 8 $default_topic_id = $viewmodel['default_topic_id']; |
9 $topic_tag = $viewmodel['topic_tag']; | 9 $topic_tag = $viewmodel['topic_tag']; |
10 $info = $viewmodel['info']; | |
11 var_dump($info); | |
10 | 12 |
11 ?> | 13 ?> |
12 | 14 |
13 <html> | 15 <html> |
14 <head> | 16 <head> |
49 </head> | 51 </head> |
50 | 52 |
51 <body> | 53 <body> |
52 | 54 |
53 <script type="text/javascript"> | 55 <script type="text/javascript"> |
56 | |
57 | |
54 | 58 |
55 <?php | 59 <?php |
56 foreach ( $taglistArray as $taglistValue ) { | 60 foreach ( $taglistArray as $taglistValue ) { |
57 echo '$(document).on("click", "'.$taglistValue[2].'", function (e) {'."\n"; | 61 echo '$(document).on("click", "'.$taglistValue[2].'", function (e) {'."\n"; |
58 echo "\t".'if ( $(this).prop("tagName").toLowerCase() != "'.$taglistValue[2].'" ) return 0;'."\n"; | 62 echo "\t".'if ( $(this).prop("tagName").toLowerCase() != "'.$taglistValue[2].'" ) return 0;'."\n"; |
240 alert("Saved!"); | 244 alert("Saved!"); |
241 }); | 245 }); |
242 } | 246 } |
243 } | 247 } |
244 | 248 |
245 | 249 function _postForContineTagging(form) { |
246 function chooseTopic(section_id, default_topic_id) { | 250 |
251 | |
252 var hiddenField = document.createElement("input"); | |
253 hiddenField.setAttribute("name", "text"); | |
254 var el = document.getElementById("editable-area"); | |
255 var text = el.innerHTML; | |
256 hiddenField.setAttribute("value", text); | |
257 form.appendChild(hiddenField); | |
258 | |
259 var info = JSON.parse( '<?php echo json_encode($info) ?>'); | |
260 | |
261 if (info) { | |
262 // TODO: different field info array based on fileId(branchId) existing or not | |
263 var hiddenField = document.createElement("input"); | |
264 hiddenField.setAttribute("name", "fileId"); | |
265 hiddenField.setAttribute("value", info['file_id']); | |
266 form.appendChild(hiddenField); | |
267 var hiddenField = document.createElement("input"); | |
268 hiddenField.setAttribute("name", "branchId"); | |
269 hiddenField.setAttribute("value", info['branch_id']); | |
270 form.appendChild(hiddenField); | |
271 var hiddenField = document.createElement("input"); | |
272 hiddenField.setAttribute("name", "userId"); | |
273 hiddenField.setAttribute("value", info['user_id']); | |
274 form.appendChild(hiddenField); | |
275 var hiddenField = document.createElement("input"); | |
276 hiddenField.setAttribute("name", "sectionId"); | |
277 hiddenField.setAttribute("value", info['section_id']); | |
278 form.appendChild(hiddenField); | |
279 | |
280 | |
281 } | |
282 | |
283 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | |
284 document.body.appendChild(form); | |
285 form.submit(); | |
286 } else { | |
287 form.submit(); // works under IE and Chrome, but not FF | |
288 } | |
289 | |
290 } | |
291 | |
292 | |
293 // === for config tags in topic === | |
294 function configTagsInTopic(topic_id) { | |
295 var form = document.createElement("form"); | |
296 | |
297 form.setAttribute("method", "post"); | |
298 //form.setAttribute("action", "exportTable.php"); | |
299 form.setAttribute("action", "../ConfigTagsInTopic"); // hand to controller | |
300 form.setAttribute("target", "_blank"); | |
301 | |
302 | |
303 var hiddenField = document.createElement("input"); | |
304 hiddenField.setAttribute("name", "topic"); | |
305 hiddenField.setAttribute("value", topic_id); | |
306 form.appendChild(hiddenField); | |
307 | |
308 _postForContineTagging(form); | |
309 | |
310 } | |
311 | |
312 | |
313 function saveTextToLGService(section_id) { | |
314 var info = JSON.parse('<?php echo json_encode($info) ?>'); | |
315 | |
316 var el = document.getElementById("editable-area"); | |
317 | |
318 /* | |
319 $.ajax({ | |
320 url : './TaggingText/'+section_id, | |
321 async : false, | |
322 type : 'POST', | |
323 data : 'func=SaveFullTextToLGService'+'&text='+el.innerHTML+'&fileId='+info['file_id']+'&branchId='+info['branch_id']+'&userId='+info['user_id']+'§ionId='+info['section_id'], | |
324 success: function (result) { | |
325 console.log(result); | |
326 }, | |
327 error: function (data) { | |
328 console.log("error when saving to LGService!"); | |
329 } | |
330 }).done(function(result) { | |
331 alert("Saved!"); | |
332 console.log("result: "+result); | |
333 }); | |
334 | |
335 */ | |
336 | |
337 | |
338 | |
339 var form = document.createElement("form"); | |
340 form.setAttribute("method", "post"); | |
341 // form.setAttribute("action", "./"); // hand to controller | |
342 | |
343 form.setAttribute("action", "./"+info['section_id']); // hand to controller | |
344 form.setAttribute("target", "_self"); | |
345 | |
346 var hiddenField = document.createElement("input"); | |
347 hiddenField.setAttribute("name", "func"); | |
348 hiddenField.setAttribute("value", "SaveFullTextToLGService"); | |
349 form.appendChild(hiddenField); | |
350 | |
351 if (info) { | |
352 var hiddenField = document.createElement("input"); | |
353 hiddenField.setAttribute("name", "fileId"); | |
354 hiddenField.setAttribute("value", info['file_id']); | |
355 form.appendChild(hiddenField); | |
356 var hiddenField = document.createElement("input"); | |
357 hiddenField.setAttribute("name", "branchId"); | |
358 hiddenField.setAttribute("value", info['branch_id']); | |
359 form.appendChild(hiddenField); | |
360 var hiddenField = document.createElement("input"); | |
361 hiddenField.setAttribute("name", "userId"); | |
362 hiddenField.setAttribute("value", info['user_id']); | |
363 form.appendChild(hiddenField); | |
364 var hiddenField = document.createElement("input"); | |
365 hiddenField.setAttribute("name", "sectionId"); | |
366 hiddenField.setAttribute("value", info['section_id']); | |
367 form.appendChild(hiddenField); | |
368 | |
369 } | |
370 | |
371 var hiddenField = document.createElement("input"); | |
372 hiddenField.setAttribute("name", "text"); | |
373 //var el = document.getElementById("editable-area"); | |
374 //var text = encodeURIComponent(el.innerHTML); | |
375 var text = el.innerHTML; | |
376 hiddenField.setAttribute("value", text); | |
377 form.appendChild(hiddenField); | |
378 | |
379 | |
380 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | |
381 document.body.appendChild(form); | |
382 form.submit(); | |
383 } else { | |
384 form.submit(); // works under IE and Chrome, but not FF | |
385 } | |
386 | |
387 } | |
388 | |
389 | |
390 | |
391 function chooseTopic(default_topic_id) { | |
247 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); | 392 var t = JSON.parse( '<?php echo json_encode($topiclistArray) ?>' ); |
248 | 393 |
394 var info = JSON.parse('<?php echo json_encode($info) ?>'); | |
395 | |
396 | |
249 $('#load_topic_div').html(""); | 397 $('#load_topic_div').html(""); |
250 $('#load_topic_div').css("display", "block"); | 398 $('#load_topic_div').css("display", "block"); |
251 $('#load_topic_div').css("border", "1px solid black"); | 399 $('#load_topic_div').css("border", "1px solid black"); |
252 $('#load_topic_div').css("background-color", "White"); | 400 $('#load_topic_div').css("background-color", "White"); |
253 $('#load_topic_div').css("width", "200px"); | 401 $('#load_topic_div').css("width", "200px"); |
258 var topic_select = document.createElement("select"); | 406 var topic_select = document.createElement("select"); |
259 topic_select.id = "loadTopiclist"; | 407 topic_select.id = "loadTopiclist"; |
260 var selected_topic = t[0]; | 408 var selected_topic = t[0]; |
261 topic_select.onchange = function(){ | 409 topic_select.onchange = function(){ |
262 | 410 |
411 | |
263 selected_topic = topic_select.options[topic_select.selectedIndex]; | 412 selected_topic = topic_select.options[topic_select.selectedIndex]; |
264 console.log(selected_topic.text); | 413 console.log(selected_topic.text); |
265 | 414 |
266 var topic_id = selected_topic.value; | 415 var topic_id = selected_topic.value; |
267 var topic_name = selected_topic.text; | 416 // var topic_name = selected_topic.text; |
417 | |
268 | 418 |
269 var form = document.createElement("form"); | 419 var form = document.createElement("form"); |
270 form.setAttribute("method", "post"); | 420 form.setAttribute("method", "post"); |
271 form.setAttribute("action", "./"+section_id); // hand to controller | 421 form.setAttribute("action", "./"+info['section_id']); // hand to controller |
272 form.setAttribute("target", "_self"); | 422 //form.setAttribute("action", "./"+section_id); // hand to controller |
273 | 423 form.setAttribute("target", "_self"); |
274 var hiddenField = document.createElement("input"); | 424 |
275 hiddenField.setAttribute("name", "topic"); | 425 var hiddenField = document.createElement("input"); |
276 hiddenField.setAttribute("value", topic_id); | 426 hiddenField.setAttribute("name", "topic"); |
277 form.appendChild(hiddenField); | 427 hiddenField.setAttribute("value", topic_id); |
278 | 428 form.appendChild(hiddenField); |
279 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { | 429 |
280 document.body.appendChild(form); | 430 var hiddenField = document.createElement("input"); |
281 form.submit(); | 431 hiddenField.setAttribute("name", "func"); |
282 } else { | 432 hiddenField.setAttribute("value", "ContinueTagging"); |
283 form.submit(); // works under IE and Chrome, but not FF | 433 form.appendChild(hiddenField); |
284 } | 434 |
285 | 435 _postForContineTagging(form); |
286 | 436 |
287 | 437 |
288 }; | 438 }; |
289 | 439 |
290 | 440 |
363 <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" style="height: 30px; width: 50px"><<</button> | 513 <button id="smartRegexPopUpBack" onclick="replaceSmartBack()" style="height: 30px; width: 50px"><<</button> |
364 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" style="height: 30px; width: 50px">>></button> | 514 <button id="smartRegexPopUpFor" onclick="replaceSmartFor()" style="height: 30px; width: 50px">>></button> |
365 <button onclick="replaceSmartClose()" style="height: 30px; width: 50px">Close</button> | 515 <button onclick="replaceSmartClose()" style="height: 30px; width: 50px">Close</button> |
366 </div> | 516 </div> |
367 <form action="javascript:void(0);"> | 517 <form action="javascript:void(0);"> |
368 <button onclick="chooseTopic(<?php echo $section_id;?>, <?php echo $default_topic_id; ?>)">Choose Topic</button> | 518 <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)">Choose Topic</button> |
369 <button onclick="window.open('../ConfigTagsInTopic/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Config Tag List For Topic</button></br> | 519 <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" style="height: 30px; width: 220px">Config Tag List for Topic</button></br> |
370 <fieldset> | 520 <fieldset> |
371 <legend>Replace By <i><b>Smart Regex</b></i>©:</legend> | 521 <legend>Replace By <i><b>Smart Regex</b></i>©:</legend> |
372 <div id="smartRegexShowDiv"></div><br> | 522 <div id="smartRegexShowDiv"></div><br> |
373 <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br> | 523 <button onclick="smartRegexNew()" style="height: 30px; width: 220px">Add Regex Group</button></br> |
374 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> | 524 Range: <input type="text" size="5" id="regexPageStart">to<input type="text" size="5" id="regexPageEnd"><br> |
388 <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button> | 538 <button onclick="Undo()" style="height: 30px; width: 220px" id="buttonUndo" disabled="true">Undo</button> |
389 </fieldset> | 539 </fieldset> |
390 | 540 |
391 <fieldset> | 541 <fieldset> |
392 <legend>Edit:</legend> | 542 <legend>Edit:</legend> |
393 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>--> | 543 <button onclick="saveTextToLGService(<?php echo $section_id;?>)" style="height: 30px; width: 220px">Save to LGService</button></br> |
544 | |
545 <!--<button onclick="cleanUpTextArea()" style="height: 30px; width: 220px">Reform the text</button></br>--> | |
394 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br> | 546 <button onclick="saveText(<?php echo $section_id; ?>)" style="height: 30px; width: 220px">Save the text</button></br> |
395 <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br> | 547 <button onclick="editText()" id="editTextId" style="height: 30px; width: 220px">Edit the text</button></br> |
396 </br> | 548 </br> |
397 <button onclick="window.open('../EditWordlist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Word List</button></br> | 549 <button onclick="window.open('../EditWordlist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Word List</button></br> |
398 <button onclick="window.open('../EditTaglist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Tag List</button></br> | 550 <button onclick="window.open('../EditTaglist/<?php echo $section_id;?>')" style="height: 30px; width: 220px">Manage Tag List</button></br> |