Skip to content

Instantly share code, notes, and snippets.

@tantalor
Created October 6, 2009 00:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tantalor/202626 to your computer and use it in GitHub Desktop.
Save tantalor/202626 to your computer and use it in GitHub Desktop.
javascript:(function%20()%20{var%20selection%20=%20window.getSelection%20?%20window.getSelection()%20:document.getSelection%20?%20document.getSelection()%20:document.selection%20?%20document.selection.createRange().text%20:%20%27%27;if%20(selection)%20{selection%20=%20String(selection);}if%20(selection)%20{var%20match%20=%20selection.match(%27\/(.*)\/%27);var%20ipa;if%20(match%20&&%20match[1])%20{ipa%20=%20match[1];}if%20(!ipa)%20{ipa%20=%20prompt(%22Couldn%27t%20find%20any%20IPA.%20Type%20it%20in%20instead?%22);}if%20(ipa)%20{ipa%20=%20ipa.replace(/./g,%20function%20(c)%20{if%20(/%u0(...)/.test(escape(c)))%20{return%20escape(c).replace(/%u0(...)/g,%20%27&#x$1;%27);}%20else%20{return%20c;}});var%20request%20=%20{txt:%20%27<phoneme%20alphabet=%22ipa%22%20ph=%22%27+ipa+%27%22>%20</phoneme>%27,voice:%20%27crystal%27};var%20iframe%20=%20document.createElement(%27iframe%27);iframe.name%20=%20iframe.id%20=%20%22iframe%22+new%20Date().getTime();document.body.appendChild(iframe);var%20form%20=%20document.createElement(%27form%27);form.target%20=%20iframe.name;form.method%20=%20%27post%27;form.action%20=%20%27http://192.20.225.55/tts/cgi-bin/nph-talk%27;form.acceptCharset%20=%20%22iso-8859-1%22;form.style.display%20=%20%27none%27;for%20(var%20name%20in%20request)%20{var%20input%20=%20document.createElement(%27input%27);input.name%20=%20name;input.value%20=%20request[name];form.appendChild(input);}document.body.appendChild(form);form.submit();}}%20else%20{alert(%22Select%20some%20IPA.%22);}})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment