// used by select links function GoURL (select) { var val = select.options[select.options.selectedIndex].value; if (val == "") { select.form.reset(); } else { top.location.href = val; } } // -- javascript helper functions for modifying textarea -- // set cursor to position function set_cursor(txtarea, pos, length ) { if(txtarea.createTextRange) { // the IE way var range = txtarea.createTextRange(); range.collapse( true ); range.moveStart( "character", pos ); range.moveEnd( "character", length ); range.select(); } else if(txtarea.selectionStart) { // Standard (Firefox etc.) txtarea.focus(); txtarea.setSelectionRange( pos, pos + length ); } } // Get selected Text function get_selected(txtarea) { if ( document.selection ) { // the IE way return document.selection.createRange().text; } else { // the standard way return (txtarea.value).substring( txtarea.selectionStart, txtarea.selectionEnd ); } } // replace selected text in a txtarea with phrase and select the new text function replace_selected(txtarea, phrase) { if ( document.selection ) { // the IE way var range = document.selection.createRange(); range.text = phrase; range.moveStart( "character", -phrase.length ); range.select(); } else { var pos = txtarea.selectionStart; txtarea.value = (txtarea.value).substring( 0, txtarea.selectionStart ) + phrase + (txtarea.value).substring( txtarea.selectionEnd, txtarea.value.length ); txtarea.focus(); set_cursor( txtarea, pos, phrase.length ); } } // +++ Use these functions in html_output.php: +++ // put selected text in a HTML tag: SELECTED TEXT // attributes is optional function tag(txtarea, tagname, attributes) { if ( attributes ) { var attribstr = " " + attributes; } else { var attribstr = ""; } replace_selected( txtarea, "<" + tagname + attribstr + ">" + get_selected( txtarea ) + "" ); } // Add a hyperlink to textarea function hlink(txtarea) { url = prompt( "Enter the URL the link should point to", "http://www." ); caption = get_selected( txtarea ); if ( url ) { if (!( caption )) { caption = prompt( "Caption of the hyperlink", "Link" ); } replace_selected( txtarea, "" + caption + "" ); } } // Add a link to another page with pageid function rlink(txtarea, pageid ) { replace_selected( txtarea, "" + get_selected( txtarea ) + "" ); } // Add an image tag to textarea function imgtag(txtarea, pictid, align) { if (! align ) align = "LEFT"; replace_selected( txtarea, "" ); } // open an image window function open_imgwindow( pageid, parameters ) { window.open( '?npage=' + pageid + '&mode=upload_picture&direct=1&' + parameters, 'imgwindow', 'dependent=yes,menubar=no,location=no,innerWidth=650,innerHeight=450'); } // open an reflink window (create a link to another page on this site) function open_reflinkwindow( pageid ) { window.open( '?npage=' + pageid + '&mode=edit_addreflink&direct=1', 'imgwindow', 'dependent=yes,menubar=no,location=no,innerWidth=300,innerHeight=800'); }