|
35 | 35 | echo '<h3>' . $titeltext . '</h3>'; |
36 | 36 | echo '<p>(Click on <img src="icn/tick-button.png" title="Choose" alt="Choose" /> to copy word(s) into above term)<br /> </p>'; |
37 | 37 |
|
| 38 | +?> |
| 39 | +<script type="text/javascript"> |
| 40 | +//<![CDATA[ |
| 41 | +function addTranslation (s) { |
| 42 | + var w = window.parent.frames['ro']; |
| 43 | + if (typeof w == 'undefined') w = window.opener; |
| 44 | + if (typeof w == 'undefined') { |
| 45 | + alert ('Translation can not be copied!'); |
| 46 | + return; |
| 47 | + } |
| 48 | + var c = w.document.forms[0].WoTranslation; |
| 49 | + if (typeof c != 'object') { |
| 50 | + alert ('Translation can not be copied!'); |
| 51 | + return; |
| 52 | + } |
| 53 | + var oldValue = c.value; |
| 54 | + if (oldValue.trim() == '') |
| 55 | + c.value = s; |
| 56 | + else |
| 57 | + c.value = oldValue + ' / ' + s; |
| 58 | +} |
| 59 | +//]]> |
| 60 | +</script> |
| 61 | +<?php |
| 62 | + |
38 | 63 | if ($from != '' && $dest != '' && $phrase != '') { |
39 | 64 |
|
40 | 65 | $glosbe_data = file_get_contents('http://glosbe.com/gapi/translate?from=' . urlencode($from) . '&dest=' . urlencode($dest) . '&format=json&phrase=' . urlencode($phrase)); |
|
64 | 89 | $word = $value['phrase']['text']; |
65 | 90 | } else if (isset($value['meanings'])) { |
66 | 91 | if (isset($value['meanings'][0]['text'])) |
67 | | - $word = $value['meanings'][0]['text']; |
| 92 | + $word = "(" . $value['meanings'][0]['text'] . ")"; |
68 | 93 | } |
69 | 94 | if ($word != '') { |
70 | | - echo '<span class="click" onclick=""><img src="icn/tick-button.png" title="Copy" alt="Copy" /></span> ' . $word . '<br />' . "\n"; |
| 95 | + echo '<span class="click" onclick="addTranslation(' . prepare_textdata_js($word) . ');"><img src="icn/tick-button.png" title="Copy" alt="Copy" /></span> ' . $word . '<br />' . "\n"; |
71 | 96 | $i++; |
72 | 97 | } |
73 | 98 | } |
|
118 | 143 | $word = $value['phrase']['text']; |
119 | 144 | } else if (isset($value['meanings'])) { |
120 | 145 | if (isset($value['meanings'][0]['text'])) |
121 | | - $word = $value['meanings'][0]['text']; |
| 146 | + $word = "(" . $value['meanings'][0]['text'] . ")"; |
122 | 147 | } |
123 | 148 | if ($word != '') { |
124 | | - echo '<span class="click" onclick=""><img src="icn/tick-button.png" title="Copy" alt="Copy" /></span> ' . $word . '<br />' . "\n"; |
| 149 | + echo '<span class="click" onclick="addTranslation(' . prepare_textdata_js($word) . ');"><img src="icn/tick-button.png" title="Copy" alt="Copy" /></span> ' . $word . '<br />' . "\n"; |
125 | 150 | $i++; |
126 | 151 | } |
127 | 152 | } |
|
0 commit comments