Seite 1 von 1

bbcodes umschließen markierte texte nicht mehr

Verfasst: 03.08.2005 02:37
von AK87
standardmäßig ist es ja so, dass wenn man einen text markiert und dann einen bbcode-button wie drückt, wird der text von [url] und umschlossen. das funktioniert bei mir nun leider nicht mehr, hab zusätzlich den spoiler und center bbcode eingebaut, könnte also daran liegen!

hier mal eventl betroffene dateien als txt:

bbcode.php
bbcode.tpl
posting_body.tpl
posting.php

Vielen dank vorweg!

Verfasst: 04.08.2005 04:58
von AK87
*schieb*

Verfasst: 06.08.2005 14:34
von AK87
*schieb* :cry:

Verfasst: 06.08.2005 16:06
von Yepppaa!!
ich bin mal so frei und schiebe mit, denn ich hab' nach dem einbau der gleichen hacks ähnliche probleme :D

http://www.phpbb.de/viewtopic.php?t=94686

Verfasst: 08.08.2005 12:33
von AK87
immer noch kein versuch? :cry:

Verfasst: 08.08.2005 14:21
von SD582
Hi

Das Thema interessiert mich. ich werde mich heute Abend damit auseinandersetzen.

Gruß
Franz

Verfasst: 08.08.2005 20:10
von SD582
Hi

Also das Problem dürfte mit dem verwendeten Style zusammenhängen.
Ich habe deine posting_body.tpl mit dreien von meinen verglichen.
Die Java-Script Funktionen die für das Einfügen von BBCodes zuständig sind, sind sehr unterschiedlich.

Ich habe weiters dann festgestellt, daß bei mir der von dir genannte Vorgang mit subSilver und Cobalt2 funktioniert. Mit Chronicles funktioniert es nicht.

Chronicles hat genau die selben JS-Funktionen wie sie in deiner posting_body.tpl zu finden sind.

Das größte Problem dabei dürfte dieser Abschnitt sein:
subSilver-posting_body.tpl-function bbstyle()

Code: Alles auswählen

	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;
	}
Chronicles-posting_body.tpl-function bbstyle()

Code: Alles auswählen

	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];
		document.post.message.focus();
		theSelection = '';
		return;
	}

und dann fehlt noch die Funktion mozWrap()

Code: Alles auswählen

// 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;
	return;
}

Und wie durch diesen Vergleich vermutet, funktioniert die Sache im InternetExplorer auch mit dem Style Chronicles einwandfrei - was nach Durchsicht des Codes ja klar ist.

Es fehlt also in deinem Fall, genauso wie bei Chronicles, die Unterstützung für den Firefox (Mozzilla).

Kannst du das so nachvollziehen und bestätigen?

Gruß
Franz

Verfasst: 08.08.2005 21:07
von SD582
So - und jetzt zum Abschluss

Ich hab mir das noch genauer angesehen und sage jetzt:

Suche in der posting_body.tpl nach der ersten Zeile im folgenden Code.
Ab hier schmeißt du alles raus bis zur letzten Zeile im folgenden Code - also die Zeile suchen und bis hier alles rausschmeißen und durch den Code ersetzen.

Achte darauf, daß die erste und letzte Zeile nicht doppelt vorkommt und auch nicht fehlt.

Code: Alles auswählen

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 (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.value  += text;
		txtarea.focus();
	}
}

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;

	if (bbnumber == -1) { // Close all open tags & default button names
		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)) + '"');
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		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[i] == 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 { // Open tags
	
		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;
		}
		
		// 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);
}

// 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;
	return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

//-->
</script>

<!-- BEGIN privmsg_extensions -->
Alles klar?

Gruß
Franz

Verfasst: 09.08.2005 00:24
von AK87
Hab alles gemacht und es klappt auch!!

Tut mir leid, dass ich dir vorhin nicht drauf antworten konnte :oops: :oops:

aber meine eltern hatten silberhochzeit ;)

VIELEN DANK!!