ok. cala funkcja
Kod
//Function to format text in the text box
function FormatText(rte, command, option) {
var oRTE;
if (document.all) {
oRTE = frames[rte];
//get current selected range
var selection = oRTE.document.selection;
if (selection != null) {
rng = selection.createRange();
}
} else {
oRTE = document.getElementById(rte).contentWindow;
//get currently selected range
var selection = oRTE.getSelection();
rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
}
try {
if ((command == "forecolor") || (command == "hilitecolor")) {
//save current values
parent.command = command;
currentRTE = rte;
//position and show color palette
buttonElement = document.getElementById(command + '_' + rte);
// Ernst de Moor: Fix the amount of digging parents up, in case the RTE editor itself is displayed in a div.
document.getElementById('cp' + rte).style.left = getOffsetLeft(buttonElement, 4) + "px";
document.getElementById('cp' + rte).style.top = (getOffsetTop(buttonElement, 4) + buttonElement.offsetHeight + 4) + "px";
if (document.getElementById('cp' + rte).style.visibility == "hidden") {
document.getElementById('cp' + rte).style.visibility = "visible";
document.getElementById('cp' + rte).style.display = "inline";
} else {
document.getElementById('cp' + rte).style.visibility = "hidden";
document.getElementById('cp' + rte).style.display = "none";
}
} else if (command == "createlink") {
var szURL = prompt("Wpisz adres strony:", "http://");
try {
//ignore error for blank urls
oRTE.document.execCommand("Unlink", false, null);
oRTE.document.execCommand("CreateLink", false, szURL);
} catch (e) {
//do nothing
}
} else if (command == "createemail") {
var szEMAIL = prompt("Wpisz adres email:", "mailto:");
try {
//ignore error for blank urls
oRTE.document.execCommand("Unlink", false, null);
oRTE.document.execCommand("CreateLink", false, szEMAIL);
} catch (e) {
//do nothing
}
} else if (command == "uzyjstylu") {
//////////////////////////////////////////////////////////////////////////////////////////
oRTE.document.selection.createRange().text.fontsize("20");
/////////////////////////////////////////////////////////////////////////////////////////
} else if (command == "usunstyl") {
oRTE.focus();
//oRTE.document.getSelection().style.visibility = "hidden";
var html=oRTE.document.body.innerHTML;
var html_male=html.toLowerCase();
start_div_open = html_male.indexOf( "\<div style" ); //zwraca poczatek otwarcia div'a
//alert(start_div_open);
end_div_open = html_male.indexOf( "\"\>", start_div_open);
end_div_open += 2;
start_div_close = html_male.lastIndexOf("</div>");
//alert(start_div_close);
if (start_div_open!=-1 && start_div_close!=-1)
{
html=html.substring(end_div_open, start_div_close);
oRTE.document.body.innerHTML=html;
}
oRTE.focus();
} else {
oRTE.focus();
oRTE.document.execCommand(command, false, option);
oRTE.focus();
}
} catch (e) {
alert(e);
}
}