Cursor an MAUSPOS: In Mozilla
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.1, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.1, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
ah jetzt habe ich es, habe das phpbb ja zwei mal installiert (benutzt aber die gleiche db)
bis vor kurtzen war ich ja noch in der dev version unterwegs, an der ich gearbeitet habe
deswegen kann ich dir keine demo zeigen, aber hier der code
/edit
ich habe mir noch mal angekuckt was unter http://www.c-plusplus.de/forum/posting. ... topic&f=15 für ein code ist, das ist der neue code und er funktioniert auch.
außer das er mir vorhin am ende eingefügt hatt, das kann ich mir zwar jetzt nicht erklären aber normaler weisse geht es
bis vor kurtzen war ich ja noch in der dev version unterwegs, an der ich gearbeitet habe
deswegen kann ich dir keine demo zeigen, aber hier der code
/edit
ich habe mir noch mal angekuckt was unter http://www.c-plusplus.de/forum/posting. ... topic&f=15 für ein code ist, das ist der neue code und er funktioniert auch.
außer das er mir vorhin am ende eingefügt hatt, das kann ich mir zwar jetzt nicht erklären aber normaler weisse geht es
-
- Mitglied
- Beiträge: 41
- Registriert: 29.12.2001 01:00
- Wohnort: Mülheim a.d. Ruhr
- Kontaktdaten:
RE...
Also, ich muss Dich enttäuschen, der BBCode und die Smilies werden am Ende eingefügt...
Da ist der Code von mir schon weiter, bis auf die Tatsache, dass nach dem Einfügen von BBCode der Cursor ans Ende des Textes gesetzt wird.
Da ist der Code von mir schon weiter, bis auf die Tatsache, dass nach dem Einfügen von BBCode der Cursor ans Ende des Textes gesetzt wird.
M.f.G.
thl1000
thl1000
wahrscheinlich arbeites du mit einer andern version als ich, ist auch egal
der fette teil ist intersant für dich
Code: Alles auswählen
// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
[b]var scroll_pos = txtarea.scrollTop;[/b]
txtarea.focus();
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
if (selEnd == 1 || selEnd == 2)
selEnd = selLength;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3;
[b]setCaretToPos(txtarea, s1.length + open.length + s2.length + close.length);
txtarea.scrollTop = scroll_pos;[/b]
return;
}
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function setSelectionRange(input, selectionStart, selectionEnd)
{
if (input.setSelectionRange)
{
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange)
{
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
}
function setCaretToPos (input, pos)
{
setSelectionRange(input, pos, pos);
}
-
- Mitglied
- Beiträge: 41
- Registriert: 29.12.2001 01:00
- Wohnort: Mülheim a.d. Ruhr
- Kontaktdaten:
RE...
Moin,
@ Gast:
hier mal meine komplette bbcode.js: (alt+c)";
//d_help = "{L_BBCODE_D_HELP}";
//e_help = "{L_BBCODE_E_HELP}";
f_help = "Schriftgröße: [size=x-small]Kleiner Text[/size]";
//g_help = "{L_BBCODE_G_HELP}";
h_help = "Quellennachweis einfügen (alt+h)";
i_help = "Text in kursiv: Text (alt+i)";
j_help = "Glühender Text: [glow=Farbe]Text[/glow] Tipp: Sie können ebenfalls glow=#FF0000 benutzen";
k_help = "Scrollender Text: [scroll]text[/scroll] (alt+k)";
l_help = "Liste:
m_help = "Schattierter Text: [shadow=Farbe]Text[/shadow] Tipp: Sie können ebenfalls shadow=#FF0000 benutzen";
n_help = "Flash: [flash width=699 height=499 loop=true] url [/flash]";
o_help = "Geordnete Liste:
p_help = "Bild einfügen: [img]http://URL_des_Bildes[/img] (alt+p)";
q_help = "Zitat: [quote]Text[/quote] (alt+q)";
r_help = "Zeile: [row]text[/row] (alt+r)";
s_help = "Schriftfarbe: Text Tip: Du kannst ebenfalls color=#FF0000 benutzen";
t_help = "Tabelle: [table]text[/table] (alt+t)";
u_help = "Unterstrichener Text: Text (alt+u)";
v_help = "Cutposition einfügen (alt+v)";
w_help = "URL einfügen: http://URL oder URL Text (alt+w)";
x_help = "Ausrichtung: [align=left | center | right]text[/align] (alt+x)";
y_help = "Listenpunkt: [*] (alt+y)";
z_help = "Spalte: [col]text[/col] (alt+z)";
// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('','','','','','','[quote]','[/quote]','','
imageTag = false;
// Shows the help messages in the helpline window
function helpline(help)
{
document.post.helpbox.value = eval(help + "_help");
}
// Replacement for arrayname.length property
function getarraysize(thearray)
{
for (i = 0; i < thearray.length; i++)
{
if ((thearray == "undefined") || (thearray == "") || (thearray == null))
{
return i;
}
}
return thearray.length;
}
// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value)
{
thearray[ getarraysize(thearray) ] = value;
}
// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray)
{
thearraysize = getarraysize(thearray);
retval = thearray[thearraysize - 1];
delete thearray[thearraysize - 1];
return retval;
}
function checkForm()
{
formErrors = false;
if (document.post.message.value.length < 2)
{
formErrors = "{L_EMPTY_MESSAGE}";
}
if (formErrors)
{
alert(formErrors);
return false;
}
else
{
bbstyle(-1);
//formObj.preview.disabled = true;
//formObj.submit.disabled = true;
return true;
}
}
function emoticon(text)
{
var txtarea = document.post.message;
text = ' ' + text + ' ';
if (is_ie)
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
}
else
{
txtarea.focus();
txtarea.value += text;
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
mozWrap(txtarea, text, '');
return;
}
else // Other browsers
{
txtarea.focus();
txtarea.value += text;
}
}
function bbfontstyle(bbopen, bbclose)
{
var txtarea = document.post.message;
if ((clientVer >= 4) && is_ie && is_win)
{
theSelection = document.selection.createRange().text;
if (!theSelection)
{
// IE Cursor Fix
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbopen + bbclose + ' ' : bbopen + bbclose;
txtarea.focus();
return;
}
document.selection.createRange().text = bbopen + theSelection + bbclose;
txtarea.focus();
return;
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
mozWrap(txtarea, bbopen, bbclose);
return;
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
mozWrap(txtarea, bbopen, bbclose);
return;
}
else // Other browsers
{
txtarea.value += bbopen + bbclose;
txtarea.focus();
}
storeCaret(txtarea);
}
function bbstyle(bbnumber)
{
var txtarea = document.post.message;
txtarea.focus();
donotinsert = false;
theSelection = false;
bblast = 0;
if (bbnumber == -1)
{
// Close all open tags & default button names
while (bbcode[0])
{
if(is_ie) // IE cursor fix
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
butnumber = arraypop(bbcode) - 1;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[butnumber + 1] + ' ' : bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
else
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
butnumber = arraypop(bbcode) - 1;
mozWrap(txtarea, bbtags[butnumber + 1], '');
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
else // Other browsers
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
imageTag = false; // All tags are closed including image tags
return;
}
if ((clientVer >= 4) && is_ie && is_win)
{
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection)
{
// Add tags around selection
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
txtarea.focus();
theSelection = '';
return;
}
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
return;
}
// Find last occurance of an open tag the same as the one just clicked
for (i = 0; i < bbcode.length; i++) {
if (bbcode == bbnumber+1) {
bblast = i;
donotinsert = true;
}
}
if (donotinsert)
{
// Close all open tags up to the one just clicked & default button names
while (bbcode[bblast])
{
if (is_ie) // IE cursor fix
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
butnumber = arraypop(bbcode) - 1;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[butnumber + 1] + ' ' : bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
else
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
butnumber = arraypop(bbcode) - 1;
mozWrap(txtarea, bbtags[butnumber + 1], '');
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
else // Other browsers
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
imageTag = false;
return;
}
else
{
// Open tags
if (is_ie) // IE cursor fix
{
if (imageTag && (bbnumber != 14))
{
// Close image tag before adding another
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[15] + ' ' : bbtags[15];
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.post.addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
}
// Open tag
if (txtarea.createTextRange && document.post.message.caretPos)
{
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[bbnumber] + ' ' : bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
txtarea.focus();
return;
}
else
{
txtarea.value += bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
txtarea.focus();
return;
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
// Open tags
if (imageTag && (bbnumber != 14))
{
// Close image tag before adding another
mozWrap(txtarea, bbtags[15], bbtags[bbnumber]);
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.post.addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
}
else
{
// Open tag
mozWrap(txtarea, bbtags[bbnumber], '');
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
return;
}
}
else // Other browsers
{
if (imageTag && (bbnumber != 14))
{
// Close image tag before adding another
txtarea.value += bbtags[15];
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.post.addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
}
else
{
// Open tag
txtarea.value += bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
txtarea.focus();
return;
}
}
}
storeCaret(txtarea);
}
function setbutton(text)
{
var txtarea = document.post.message;
text = '' + text + ' ';
if (is_ie)
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
}
else
{
txtarea.focus();
txtarea.value += text;
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
mozWrap(txtarea, text, '');
return;
}
else // Other browsers
{
txtarea.focus();
txtarea.value += text;
}
}
// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
if (selEnd == 1 || selEnd == 2)
selEnd = selLength;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3;
txtarea.blur();
return;
}
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/vie ... 52/fid/130
function storeCaret(textEl) {
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
[/code]
Es wäre nett, wenn Du mal Deinen kompletten Code posten würdest...
@ Gast:
hier mal meine komplette bbcode.js:
Code: Alles auswählen
// bbCode control by
// subBlue design
// www.subBlue.com
// modified by TL Networks
// http://www.tl-networks.com
// Startup variables
var imageTag = false;
var theSelection = false;
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
&& (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
// Helpline messages
a_help = "Alle offenen BBCodes schließen";
b_help = "Text in fett: [b]Text[/b] (alt+b)";
c_help = "Code anzeigen: [code]Code
//d_help = "{L_BBCODE_D_HELP}";
//e_help = "{L_BBCODE_E_HELP}";
f_help = "Schriftgröße: [size=x-small]Kleiner Text[/size]";
//g_help = "{L_BBCODE_G_HELP}";
h_help = "Quellennachweis einfügen (alt+h)";
i_help = "Text in kursiv: Text (alt+i)";
j_help = "Glühender Text: [glow=Farbe]Text[/glow] Tipp: Sie können ebenfalls glow=#FF0000 benutzen";
k_help = "Scrollender Text: [scroll]text[/scroll] (alt+k)";
l_help = "Liste:
- Text
m_help = "Schattierter Text: [shadow=Farbe]Text[/shadow] Tipp: Sie können ebenfalls shadow=#FF0000 benutzen";
n_help = "Flash: [flash width=699 height=499 loop=true] url [/flash]";
o_help = "Geordnete Liste:
- Text
p_help = "Bild einfügen: [img]http://URL_des_Bildes[/img] (alt+p)";
q_help = "Zitat: [quote]Text[/quote] (alt+q)";
r_help = "Zeile: [row]text[/row] (alt+r)";
s_help = "Schriftfarbe: Text Tip: Du kannst ebenfalls color=#FF0000 benutzen";
t_help = "Tabelle: [table]text[/table] (alt+t)";
u_help = "Unterstrichener Text: Text (alt+u)";
v_help = "Cutposition einfügen (alt+v)";
w_help = "URL einfügen: http://URL oder URL Text (alt+w)";
x_help = "Ausrichtung: [align=left | center | right]text[/align] (alt+x)";
y_help = "Listenpunkt: [*] (alt+y)";
z_help = "Spalte: [col]text[/col] (alt+z)";
// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('','','','','','','[quote]','[/quote]','
Code: Alles auswählen
','
- ','
- ','
imageTag = false;
// Shows the help messages in the helpline window
function helpline(help)
{
document.post.helpbox.value = eval(help + "_help");
}
// Replacement for arrayname.length property
function getarraysize(thearray)
{
for (i = 0; i < thearray.length; i++)
{
if ((thearray == "undefined") || (thearray == "") || (thearray == null))
{
return i;
}
}
return thearray.length;
}
// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value)
{
thearray[ getarraysize(thearray) ] = value;
}
// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray)
{
thearraysize = getarraysize(thearray);
retval = thearray[thearraysize - 1];
delete thearray[thearraysize - 1];
return retval;
}
function checkForm()
{
formErrors = false;
if (document.post.message.value.length < 2)
{
formErrors = "{L_EMPTY_MESSAGE}";
}
if (formErrors)
{
alert(formErrors);
return false;
}
else
{
bbstyle(-1);
//formObj.preview.disabled = true;
//formObj.submit.disabled = true;
return true;
}
}
function emoticon(text)
{
var txtarea = document.post.message;
text = ' ' + text + ' ';
if (is_ie)
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
}
else
{
txtarea.focus();
txtarea.value += text;
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
mozWrap(txtarea, text, '');
return;
}
else // Other browsers
{
txtarea.focus();
txtarea.value += text;
}
}
function bbfontstyle(bbopen, bbclose)
{
var txtarea = document.post.message;
if ((clientVer >= 4) && is_ie && is_win)
{
theSelection = document.selection.createRange().text;
if (!theSelection)
{
// IE Cursor Fix
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbopen + bbclose + ' ' : bbopen + bbclose;
txtarea.focus();
return;
}
document.selection.createRange().text = bbopen + theSelection + bbclose;
txtarea.focus();
return;
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
mozWrap(txtarea, bbopen, bbclose);
return;
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
mozWrap(txtarea, bbopen, bbclose);
return;
}
else // Other browsers
{
txtarea.value += bbopen + bbclose;
txtarea.focus();
}
storeCaret(txtarea);
}
function bbstyle(bbnumber)
{
var txtarea = document.post.message;
txtarea.focus();
donotinsert = false;
theSelection = false;
bblast = 0;
if (bbnumber == -1)
{
// Close all open tags & default button names
while (bbcode[0])
{
if(is_ie) // IE cursor fix
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
butnumber = arraypop(bbcode) - 1;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[butnumber + 1] + ' ' : bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
else
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
butnumber = arraypop(bbcode) - 1;
mozWrap(txtarea, bbtags[butnumber + 1], '');
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
else // Other browsers
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
imageTag = false; // All tags are closed including image tags

return;
}
if ((clientVer >= 4) && is_ie && is_win)
{
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection)
{
// Add tags around selection
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
txtarea.focus();
theSelection = '';
return;
}
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
return;
}
// Find last occurance of an open tag the same as the one just clicked
for (i = 0; i < bbcode.length; i++) {
if (bbcode == bbnumber+1) {
bblast = i;
donotinsert = true;
}
}
if (donotinsert)
{
// Close all open tags up to the one just clicked & default button names
while (bbcode[bblast])
{
if (is_ie) // IE cursor fix
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
butnumber = arraypop(bbcode) - 1;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[butnumber + 1] + ' ' : bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
else
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
butnumber = arraypop(bbcode) - 1;
mozWrap(txtarea, bbtags[butnumber + 1], '');
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
else // Other browsers
{
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
txtarea.focus();
}
}
imageTag = false;
return;
}
else
{
// Open tags
if (is_ie) // IE cursor fix
{
if (imageTag && (bbnumber != 14))
{
// Close image tag before adding another
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[15] + ' ' : bbtags[15];
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.post.addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
}
// Open tag
if (txtarea.createTextRange && document.post.message.caretPos)
{
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? bbtags[bbnumber] + ' ' : bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
txtarea.focus();
return;
}
else
{
txtarea.value += bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
txtarea.focus();
return;
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
// Open tags
if (imageTag && (bbnumber != 14))
{
// Close image tag before adding another
mozWrap(txtarea, bbtags[15], bbtags[bbnumber]);
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.post.addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
}
else
{
// Open tag
mozWrap(txtarea, bbtags[bbnumber], '');
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
return;
}
}
else // Other browsers
{
if (imageTag && (bbnumber != 14))
{
// Close image tag before adding another
txtarea.value += bbtags[15];
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.post.addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
}
else
{
// Open tag
txtarea.value += bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
txtarea.focus();
return;
}
}
}
storeCaret(txtarea);
}
function setbutton(text)
{
var txtarea = document.post.message;
text = '' + text + ' ';
if (is_ie)
{
if (txtarea.createTextRange && txtarea.caretPos)
{
var caretPos = txtarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
txtarea.focus();
}
else
{
txtarea.focus();
txtarea.value += text;
}
}
else if (document.getElementById && !document.all) // Mozilla cursor fix
{
mozWrap(txtarea, text, '');
return;
}
else // Other browsers
{
txtarea.focus();
txtarea.value += text;
}
}
// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
if (selEnd == 1 || selEnd == 2)
selEnd = selLength;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3;
txtarea.blur();
return;
}
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/vie ... 52/fid/130
function storeCaret(textEl) {
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
[/code]
Es wäre nett, wenn Du mal Deinen kompletten Code posten würdest...
M.f.G.
thl1000
thl1000
(ich bin der gast)
der code ist immer noch hier
http://www.c-plusplus.de/forum/posting. ... topic&f=15
mit mehr info meinte ich nicht mehr code,
was funktioniert schon, was noch nicht
du hast doch auf seite 1 des thread gesagt das du schon code gefunden hast der geht, nur das dan der cursor am ende spring.
sehe ich das richtig?
der code ist immer noch hier
http://www.c-plusplus.de/forum/posting. ... topic&f=15
mit mehr info meinte ich nicht mehr code,
was funktioniert schon, was noch nicht
du hast doch auf seite 1 des thread gesagt das du schon code gefunden hast der geht, nur das dan der cursor am ende spring.
sehe ich das richtig?
-
- Mitglied
- Beiträge: 41
- Registriert: 29.12.2001 01:00
- Wohnort: Mülheim a.d. Ruhr
- Kontaktdaten:
RE...
Korrekt...
und bei Deinem Code springt der Cursor an den Anfang des Textes...
Mein Code funzt mit IE einwandfrei, mit Mozilla tritt das Prob auf.
Ich möchte, dass der Cursor, wie beim IE, diekt hinter den eingefügten BBCOde bzw. Smilie spingt.
und bei Deinem Code springt der Cursor an den Anfang des Textes...
Mein Code funzt mit IE einwandfrei, mit Mozilla tritt das Prob auf.
Ich möchte, dass der Cursor, wie beim IE, diekt hinter den eingefügten BBCOde bzw. Smilie spingt.
M.f.G.
thl1000
thl1000
dann probier mal ob die funktion setCaretToPos bei dir funktioniert, fürs erste vielleicht mit festen werden wir 3 oder so
Code: Alles auswählen
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function setSelectionRange(input, selectionStart, selectionEnd)
{
if (input.setSelectionRange)
{
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange)
{
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
}
function setCaretToPos (input, pos)
{
setSelectionRange(input, pos, pos);
}