Seite 1 von 1

BBCode Erweiterungen

Verfasst: 10.04.2005 20:20
von citymuenchen
Hallo,

ich habe von einem Spezl ein Script bekommen, welches eurem BBCode nachgeahmt ist.

Das Script wäre genau das, was ich seit ewigen Zeiten gesucht habe. Aber leider bräuchte ich ein paar Änderungen bzw. Zusätze, die ich (ohne Kenntnisse von JavaScript) nicht selbst umsetzen kann.

Ich wäre euch sehr dankbar, wenn ihr mir dabei helfen könntet!

Also, zunächst ist mir wichtig, dass ich weitere 5 Buttons dort erzeugen kann, die man mit eigenen Codes, welche in einer MySql-Tabelle hinterlegt sind, einfügen lassen könnte.

Die 5 Codeschnipsel stehen aus der Datenbank ausgelesen zur Verfügung. Man kann sie mit print_f anzeigen lassen.

Ich bräuchte also nur weitere 5 Buttons, mit A, B, C, D und E, die beim Klick das Einfügen von 5 Texten auslösen.

Hier das derzeitige Script:

Code: Alles auswählen

<script language="JavaScript" type="text/javascript">
// Startvariablen setzen
var imageTag=false;
var theSelection=false;
// Browsercheck
var clientPC=navigator.userAgent.toLowerCase();
var clientVer = parseInt(navigator.appVersion);
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);
// Hilfezeile
a_help="Alle offenen BBCodes schließen";
b_help="Text in fett: [b]Text[/b] (alt+b)";
c_help="Code anzeigen: [code]Code
(alt+c)";
d_help="Textbox A einfügen";
f_help="Schriftgröße: [size=x-small]Kleiner Text[/size]";
i_help="Text in kursiv: Text (alt+i)";
l_help="Liste:
  • Text
(alt+l)";
o_help="Geordnete Liste:
  • Text
(alt+o)";
p_help="Bild einfügen: [img]http://URL_des_Bildes[/img] (alt+p)";
q_help="Zitat: [quote]Text[/quote] (alt+q)";
s_help="Schriftfarbe: Text Tipp: Du kannst ebenfalls color=#FF0000 benutzen";
u_help="Unterstrichener Text: Text (alt+u)";
w_help="URL einfügen: http://URL oder URL Text (alt+w)";
// BBCode Tags einlesen
bbcode=new Array();
bbtags=new Array('<b>','</b>','<i>','</i>','<u>','</u>','<quote>','</quote>','<code>','</code>','<list>','</list>','<list=>','</list>','<img>','</img>','<url>','</url>');
imageTag=false;
// Funktion Hilfetexte anzeigen
function helpline(help) {
document.post.helpbox.value=eval(help+"_help");
}
// Funktion Ermittlung der Position
function getarraysize(thearray) {
for (i=0;i<thearray.length;i++) {
if ((thearray=="undefined") || (thearray=="") || (thearray==null))
return i;
}
return thearray.length;
}
function arraypush(thearray,value) {
thearray[getarraysize(thearray)]=value;
}
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="Du musst zu deinem Beitrag einen Text eingeben.";
}
if (formErrors) {
alert(formErrors);
return false;
} else {
bbstyle(-1);
return true;
}
}
function bbfontstyle(bbopen, bbclose) {
var txtarea=document.post.message;
if ((clientVer>=4) && is_ie && is_win) {
theSelection=document.selection.createRange().text;
if (!theSelection) {
txtarea.value+=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
{
txtarea.value+=bbopen+bbclose;
txtarea.focus();
}
storeCaret(txtarea);
}
function bbstyle(bbnumber) {
var txtarea=document.post.message;
txtarea.focus();
donotinsert=false;
theSelection=false;
bblast=0;
// Alle Tags schließen
if (bbnumber==-1) {
while (bbcode[0]) {
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))+'"');
}
// Alle Tags geschlossen inkl. Image-Tags
imageTag=false;
txtarea.focus();
return;
}
if ((clientVer>=4) && is_ie && is_win)
{
theSelection=document.selection.createRange().text;
if (theSelection) {
// Einfügen von Tags in markierte Bereiche
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;
}
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]) {
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))+'"');
imageTag=false;
}
txtarea.focus();
return;
} else {
if (imageTag && (bbnumber!=14)) { // Close image tag before adding another
txtarea.value+=bbtags[15];
lastValue=arraypop(bbcode)-1;
document.post.addbbcode14.value="Img";
imageTag=false;
}
txtarea.value+=bbtags[bbnumber];
if ((bbnumber==14) && (imageTag==false)) imageTag=1;
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value+="*"');
txtarea.focus();
return;
}
storeCaret(txtarea);
}
</script>
[/code]

Die Buttonfelder bekomme ich hin...

Aber wo muss ich was einfügen?

Gruß, und schon mal DANKE!
Hans

Verfasst: 10.04.2005 21:55
von shwepsi
das ist nicht nachgeahmt, das ist das orginal, also schaue dir einfach den mod dafür an
und schaue was da an der posting.php geändert wird
anstelle der {irgendwas} musst du nur den gewünschten Text einfügen wie 'Text zentriert anzeigen' und so

Sorry, aber das wusste ich nicht!

Verfasst: 10.04.2005 22:30
von citymuenchen
Hallo,

muss mich entschuldigen, aber das wusste ich nicht!

Darf ich den Code trotzdem verwenden? Er ist nämlich - meiner Meinung nach - genial!

Gruß
Hans

Verfasst: 11.04.2005 20:38
von shwepsi
ja, darfst du, ich weiss nur nicht ob da ein kleiner Vermerk wegen phpBB reinmuss ... muss sicher nicht, aber sollte
also nutze ihn einfach so