HTML beginner |
|
//--------------------------------------------
// GENERAL INSERT FUNCTION
//--------------------------------------------
// ibTag: opening tag
// ibClsTag: closing tag, used if we have selected text
// isSingle: true if we do not close the tag right now
// return value: true if the tag needs to be closed later
//
function doInsert(ibTag, ibClsTag, isSingle)
{
var isClose = false;
var obj_ta = fombj.Post;
//----------------------------------------
// It's IE!
//----------------------------------------
if ( (ua_vers >= 4) && is_ie && is_win)
{
if (obj_ta.isTextEdit)
{
obj_ta.focus();
var sel = document.selection;
var rng = sel.createRange();
rng.colapse;
if((sel.type == "Text" || sel.type == "None") && rng != null)
{
if(ibClsTag != "" && rng.text.length > 0)
ibTag += rng.text + ibClsTag;
else if(isSingle)
isClose = true;
rng.text = ibTag;
}
}
else
{
if(isSingle)
{
isClose = true;
}
obj_ta.value += ibTag;
}
}
//----------------------------------------
// It's MOZZY!
//----------------------------------------
else if ( obj_ta.selectionEnd )
{
var ss = obj_ta.selectionStart;
var st = obj_ta.scrollTop;
var es = obj_ta.selectionEnd;
if (es <= 2)
{
es = obj_ta.textLength;
}
var start = (obj_ta.value).substring(0, ss);
var middle = (obj_ta.value).substring(ss, es);
var end = (obj_ta.value).substring(es, obj_ta.textLength);
//-----------------------------------
// text range?
//-----------------------------------
if (obj_ta.selectionEnd - obj_ta.selectionStart > 0)
{
middle = ibTag + middle + ibClsTag;
}
else
{
middle = ibTag + middle;
if (isSingle)
{
isClose = true;
}
}
obj_ta.value = start + middle + end;
var cpos = ss + (middle.length);
obj_ta.selectionStart = cpos;
obj_ta.selectionEnd = cpos;
obj_ta.scrollTop = st;
}
//----------------------------------------
// It's CRAPPY!
//----------------------------------------
else
{
if (isSingle)
{
isClose = true;
}
obj_ta.value += ibTag;
}
obj_ta.focus();
return isClose;
}
//-------------------------------------------- // GENERAL INSERT FUNCTION //-------------------------------------------- // ibTag: opening tag // ibClsTag: closing tag, used if we have selected text // isSingle: true if we do not close the tag right now // return value: true if the tag needs to be closed later // function doInsert(ibTag, ibClsTag, isSingle) { var isClose = false; var obj_ta = fombj.Post; //---------------------------------------- // It's IE! //---------------------------------------- if ( (ua_vers >= 4) && is_ie && is_win) { if (obj_ta.isTextEdit) { obj_ta.focus(); var sel = document.selection; var rng = sel.createRange(); rng.colapse; if((sel.type == "Text" || sel.type == "None") && rng != null) { if(ibClsTag != "" && rng.text.length > 0) ibTag += rng.text + ibClsTag; else if(isSingle) isClose = true; rng.text = ibTag; } } else { if(isSingle) { isClose = true; } obj_ta.value += ibTag; } } //---------------------------------------- // It's MOZZY! //---------------------------------------- else if ( obj_ta.selectionEnd ) { var ss = obj_ta.selectionStart; var st = obj_ta.scrollTop; var es = obj_ta.selectionEnd; if (es <= 2) { es = obj_ta.textLength; } var start = (obj_ta.value).substring(0, ss); var middle = (obj_ta.value).substring(ss, es); var end = (obj_ta .value ).substring (es , obj_ta .textLength ); //----------------------------------- // text range? //----------------------------------- if (obj_ta.selectionEnd - obj_ta.selectionStart > 0) { middle = ibTag + middle + ibClsTag; } else { middle = ibTag + middle; if (isSingle) { isClose = true; } } obj_ta .value = start + middle + end; var cpos = ss + (middle.length); obj_ta.selectionStart = cpos; obj_ta.selectionEnd = cpos; obj_ta.scrollTop = st; } //---------------------------------------- // It's CRAPPY! //---------------------------------------- else { if (isSingle) { isClose = true; } obj_ta.value += ibTag; } obj_ta.focus(); return isClose; }
Dit is de bbcode functie van invisionboard
Let op het "Mozzy" gedeelte |