1/**
2 * JavaScript for the Typewriter Popup for the IPA Plugin
3 *
4 * @author     Anika Henke <anika@selfthinker.org>
5 * @author     http://de.wikipedia.org/wiki/Wikipedia:Helferlein/IPA_Typewriter
6 */
7
8window.onload = function(){
9    // if the popup was opened from the toolbar, don't display the 'copy to clipboard' tools
10    if(opener) document.getElementById("copyIpa").style.display = 'none';
11}
12
13function InsertChar(sUnicodeCode) {
14    if(!opener){
15        // if the popup was NOT opened from the toolbar, insert each selected char into the 'copy to clipboard' text box
16        document.getElementById("txtIpa").focus();
17        document.getElementById("txtIpa").value += String.fromCharCode(parseInt(sUnicodeCode, 16));
18    } else {
19        // if the popup was opened from the toolbar, insert each selected char into the wiki text
20        opener.insertTags('wiki__text',String.fromCharCode(parseInt(sUnicodeCode, 16)),'','');
21    }
22}
23
24// copy text into clipboard (if possible, else select the text)
25function CopyIpaToClipboard() {
26    if (window.clipboardData) {
27        window.clipboardData.setData('Text', document.getElementById("txtIpa").value);
28    } else {
29        document.getElementById("txtIpa").focus();
30        document.getElementById("txtIpa").select();
31    }
32}
33