Seite 2 von 2

Verfasst: 14.05.2007 09:22
von 4seven
Danke für den Ansatz, Tompom

Aber diese Lösung, wie ich oben schon anschnitt, greift bei einer, mit der BBcodeBox gemoddeten posting_body.tpl nicht, da die zu aktualisierenden Codeteile schlicht nicht (mehr) vorhanden sind.

Anyway, nachdem ich mir eine weitere Nacht um die Ohren geschlagen habe, hab ich nun die Lösung im Netz gefunden und etwas modifiziert, da die Lösung für die BBcodeBox auf einer älteren Version aufsetzte und nicht mehr relevant war.

Hier erstmal noch eine alternative Lösung für ein Standard PHPBB (ohne BBCodeBox)
als Ansatz, falls der normale Code des Firefox-Snippets
http://www.phpbb.de/viewtopic.php?t=131422
bei dem ein oder anderen nicht greifen sollte:

Code: Alles auswählen

##############################################################
## MOD Title: Accurate BBCode Insertion Mod
## MOD Version: 1.0.1
## MOD Author: Lord Z
## MOD Description: This mod will insert BBCode accuratly into a post, (at the caret position) instead of putting it at the bottom.
##############################################################
#
#-----[ OPEN ]------------------------------------------
#

templates/subSilver/posting_body.tpl

#
#-----[ FIND ]------------------------------------------
#
function emoticon(text) {

#
#-----[ BEFORE, ADD ]------------------------------------------
#

function bbplace(text) {
    var txtarea = document.post.message;
    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 if (txtarea.selectionStart || txtarea.selectionStart == '0') {
        var startPos = txtarea.selectionStart;
        var endPos = txtarea.selectionEnd;
        txtarea.value = txtarea.value.substring(0, startPos)
                      + text
                      + txtarea.value.substring(endPos, txtarea.value.length);
        txtarea.focus();
        txtarea.selectionStart = startPos + text.length;
        txtarea.selectionEnd = startPos + text.length;
    } else {
        txtarea.value  += text;
        txtarea.focus();
    }
}

#
#-----[ FIND ]------------------------------------------
#
# This is in the function emoticon(text)

    } else {
            txtarea.value  += text;
            txtarea.focus();

#
#-----[ REPLACE WITH ]------------------------------------------
#

    } else {
            bbplace(text);
            txtarea.focus();
           
#
#-----[ FIND ]------------------------------------------
#
      while (bbcode[bblast]) {
            butnumber = arraypop(bbcode) - 1;
            txtarea.value += bbtags[butnumber + 1];

#
#-----[ REPLACE WITH ]------------------------------------------
#

      while (bbcode[bblast]) {
            butnumber = arraypop(bbcode) - 1;
            bbplace(bbtags[butnumber + 1]);

#
#-----[ FIND ]------------------------------------------
#
      if (imageTag && (bbnumber != 14)) {      // Close image tag before adding another
         txtarea.value += bbtags[15];

#
#-----[ REPLACE WITH ]------------------------------------------
#

      if (imageTag && (bbnumber != 14)) {      // Close image tag before adding another
         bbplace(bbtags[15]);

#
#-----[ FIND ]------------------------------------------
#
      // Open tag
      txtarea.value += bbtags[bbnumber];

#
#-----[ REPLACE WITH ]------------------------------------------
#
      // Open tag
      bbplace(bbtags[bbnumber]);

#
#----[ FIND  ]------------------------------------------
#

   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];

#
#----[ REPLACE BY ]------------------------------------------
#

   if (donotinsert) {      // Close all open tags up to the one just clicked & default button names
         while (bbcode[bblast]) {
               butnumber = arraypop(bbcode) - 1;
               bbplace(bbtags[butnumber + 1]);

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#

Und hier der Fix für die BBCodeBox (getestet mit BBCode Box v5.1.0):

Code: Alles auswählen

#
#-----[ OPEN ]------------------------------------------
#

bbcode_box/add_bbcode.js + bbcode_box/bbcode_box.js

#
# >>>>    Note: All changes make in both files <<<<<
# >>>> Wichtig: Alle Änderungen in beiden Dateien machen <<<<
#

#
#-----[ FIND ]------------------------------------------
#
function BBCplain() {

#
#-----[ BEFORE, ADD ]------------------------------------------
#
function bbplace(text) {
    var txtarea = document.post.message;
    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 if (txtarea.selectionStart || txtarea.selectionStart == '0') {
        var startPos = txtarea.selectionStart;
        var endPos = txtarea.selectionEnd;
        txtarea.value = txtarea.value.substring(0, startPos)
                      + text
                      + txtarea.value.substring(endPos, txtarea.value.length);
        txtarea.focus();
        txtarea.selectionStart = startPos + text.length;
        txtarea.selectionEnd = startPos + text.length;
    } else {
        txtarea.value  += text;
        txtarea.focus();
    }
}

#
#-----[ FIND ALL ]------------------------------------------
#
document.post.message.value+=ToAdd;

#
#-----[ REPLACE ALL WITH ]-------------------------------------
#

bbplace(ToAdd);

#
#-----[ FIND ALL ]--------------------------------------------------
#

txtarea.value += bbopen + bbclose;

#
#-----[ REPLACE ALL WITH ]------------------------------------------
#

bbplace(bbopen + bbclose);

#
#-----[ FIND ALL ]--------------------------------------------------
#

document.post.message.value += text;

#
#-----[ REPLACE ALL WITH ]------------------------------------------
#

bbplace(text);

#
#-----[ THATS IT ]---------------------------------------------
#
*

Verfasst: 14.05.2007 14:01
von Tompom
Hallo,

na ja bei mir hat es funktioniert und da dachte ich mir, wenn ein blindes Hühnchen mal durch Zufall ein Korn findet dann sollte er es posten, könnte ja sein das es bei jemand anderem auch funzt :lol:

Verfasst: 14.05.2007 22:55
von 4seven
Hallo Tompom,

naaa, das war schon klasse mit dem Tip, weil der Standard Firefox-Fix bei einem, nicht mit der BBCodeBox gemoddeten Forum, ja (meistens) hilft. Da er aber nicht immer hilft, hab ich noch ne Alternativlösung gepostet.

Dem Threadersteller war aber der BBCodeBox-Firefox-Fix wichtig.

Vielleicht könnte man auch den Titel des Threads ändern, weil, wie ich weiß, schlagen sich ne Menge Leute damit rum und ich mußte selbst Wochen suchen, Code probieren und umstellen, um die Lösung zu finden. Noch dazu ist das Support-Forum und damit der Autor der BBCodeBox im Augenblick Off.

lg