Today I worked with adding a button on simple editor of wordpress which will take your input using javascript prompt function, process it and then add it to the editor itself. While searching in net, I got it working very cool. All you have to do is run a javascript query which will do some DOM operation on wordpresse’s admin section. This one helped a lot, I just simplified it in my code below
<? add_action('admin_footer', 'wpaq_addsome'); function wpaq_addsome(){ echo <<<EOT <script type="text/javascript"> <!-- if(wpaqToolbar = document.getElementById("ed_toolbar")){ var wpaqNr, wpaqBut, wpaqStart, wpaqEnd; EOT; echo <<<EOT wpaqNr = edButtons.length; edButtons[wpaqNr] = new edButton('ed_wpaqNew','New','', '',''); var wpaqBut = wpaqToolbar.lastChild; while (wpaqBut.nodeType != 1){ wpaqBut = wpaqBut.previousSibling; } wpaqBut = wpaqBut.cloneNode(true); wpaqToolbar.appendChild(wpaqBut); wpaqBut.value = 'Add some Value'; wpaqBut.title = wpaqNr; wpaqBut.onclick = someFunction; wpaqBut.id = "ed_wpaqFlake"; EOT; echo function someFunction() { myField = document.getElementById('content'); var myValue = prompt('Enter the value:', ''); if (myValue) { edInsertContent(myField, myValue); } } </script> EOT; } ?>