function trim(str) { return str.replace(/^\s+/,'').replace(/\s+$/,''); } function editSelected() { if (window.getSelection) { txt = window.getSelection(); } else if (document.getSelection) { txt = document.getSelection(); } else if (document.selection) { txt = document.selection.createRange().text; } if(!txt){ void(txt=prompt('Please enter the title of the page you wish to create','')) } if(txt){ window.location = '/edit/'+escape(trim(txt)) } } function hotkey( event ) { event = (event) ? event : ((window.event) ? event : null); if (event) { if (event.ctrlKey ) { var charCode = (event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode); if (charCode == 14 ) { editSelected(); } } } }