Skip to content

Commit b472ab2

Browse files
author
LWT Project
committed
Version 1.5.5 (20-Jun-2013 14:41)
1 parent 9b77463 commit b472ab2

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

‎glosbe_api.php‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,31 @@
3535
echo '<h3>' . $titeltext . '</h3>';
3636
echo '<p>(Click on <img src="icn/tick-button.png" title="Choose" alt="Choose" /> to copy word(s) into above term)<br />&nbsp;</p>';
3737

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+
3863
if ($from != '' && $dest != '' && $phrase != '') {
3964

4065
$glosbe_data = file_get_contents('http://glosbe.com/gapi/translate?from=' . urlencode($from) . '&dest=' . urlencode($dest) . '&format=json&phrase=' . urlencode($phrase));
@@ -64,10 +89,10 @@
6489
$word = $value['phrase']['text'];
6590
} else if (isset($value['meanings'])) {
6691
if (isset($value['meanings'][0]['text']))
67-
$word = $value['meanings'][0]['text'];
92+
$word = "(" . $value['meanings'][0]['text'] . ")";
6893
}
6994
if ($word != '') {
70-
echo '<span class="click" onclick=""><img src="icn/tick-button.png" title="Copy" alt="Copy" /></span> &nbsp;' . $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> &nbsp;' . $word . '<br />' . "\n";
7196
$i++;
7297
}
7398
}
@@ -118,10 +143,10 @@
118143
$word = $value['phrase']['text'];
119144
} else if (isset($value['meanings'])) {
120145
if (isset($value['meanings'][0]['text']))
121-
$word = $value['meanings'][0]['text'];
146+
$word = "(" . $value['meanings'][0]['text'] . ")";
122147
}
123148
if ($word != '') {
124-
echo '<span class="click" onclick=""><img src="icn/tick-button.png" title="Copy" alt="Copy" /></span> &nbsp;' . $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> &nbsp;' . $word . '<br />' . "\n";
125150
$i++;
126151
}
127152
}

0 commit comments

Comments
 (0)