BBCodes mit Abfrage immer am Ende des Textfeldes :(
Hallo Leute.
Ich habe schon lange das Problem bei meiner 1.6.1, dass wenn ich zum Beispiel einen Link einbauen möchte mit Linktext geht ja erst das Fenster auf zum Eingeben des Textes und danach zum Eingeben der URL. Wenn ich dann aber auf OK klicke schmeißt er mir den BBCode ans Ende des Textfeldes. Das ist sehr lästig wenn man in einem sehr langen Bericht zwischendrin einen Link setzten will. Dann muss ich erst ganz nach unten scrollen, den Code ausschneiden und diesen dann an der richtigen Position wieder einbauen.
Wie kann ich das machen, dass auch das mit der URL dort eingefügt wird, wo der Cursor ist?
Meine mycode.js
Hier klicken für weitere Informationen
Mein BBCode-Tag
Ideen?
gruß
Ich habe schon lange das Problem bei meiner 1.6.1, dass wenn ich zum Beispiel einen Link einbauen möchte mit Linktext geht ja erst das Fenster auf zum Eingeben des Textes und danach zum Eingeben der URL. Wenn ich dann aber auf OK klicke schmeißt er mir den BBCode ans Ende des Textfeldes. Das ist sehr lästig wenn man in einem sehr langen Bericht zwischendrin einen Link setzten will. Dann muss ich erst ganz nach unten scrollen, den Code ausschneiden und diesen dann an der richtigen Position wieder einbauen.
Wie kann ich das machen, dass auch das mit der URL dort eingefügt wird, wo der Cursor ist?
Meine mycode.js
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
// Start - BB-Codes in das Textfeld schreiben by http://www.kit-extreme.de und http://www.kit-spiele.de
function insertBBCode(aTag, eTag) {
var input = document.myform.content;
input.focus();
// Position des Textfeldes merken
var scroll = {'x': input.scrollLeft, 'y': input.scrollTop};
/* für Internet Explorer */
if(typeof document.selection != 'undefined') {
/* Einfügen des Formatierungscodes */
var range = document.selection.createRange();
var insText = range.text;
range.text = aTag + insText + eTag;
/* Anpassen der Cursorposition */
range = document.selection.createRange();
if (insText.length == 0) {
range.move('character', -eTag.length);
} else {
range.moveStart('character', aTag.length + insText.length + eTag.length);
}
range.select();
}
/* für neuere auf Gecko basierende Browser */
else if(typeof input.selectionStart != 'undefined')
{
/* Einfügen des Formatierungscodes */
var start = input.selectionStart;
var end = input.selectionEnd;
var insText = input.value.substring(start, end);
input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
/* Anpassen der Cursorposition */
var pos;
if (insText.length == 0) {
pos = start + aTag.length;
} else {
pos = start + aTag.length + insText.length + eTag.length;
}
input.selectionStart = pos;
input.selectionEnd = pos;
}
/* für die übrigen Browser */
else
{
/* Abfrage der Einfügeposition */
var pos;
var re = new RegExp('^[0-9]{0,3}$');
while(!re.test(pos)) {
pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
}
if(pos > input.value.length) {
pos = input.value.length;
}
/* Einfügen des Formatierungscodes */
var insText = prompt("Bitte gib den zu formatierenden Text ein:");
input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
}
// Textfeld wieder an die gespeicherte Position setzen
input.scrollLeft = scroll.x;
input.scrollTop = scroll.y;
}
// Ende - BB-Codes in das Textfeld schreiben by http://www.kit-extreme.de und http://www.kit-spiele.de
// *** Text bei der Eingabeaufforderung ***********
standard = "Geben Sie bitte den gewünschten Text ein:";
texteingabe = "Geben Sie bitte Ihren Text ein - ";
linkname = "Geben Sie bitte den Linknamen an (optional).";
linkadresse = "Geben Sie bitte die vollständige Adresse des Links an.";
videonummer = "Geben Sie bitte die Nummer aus dem Videolink ein - Zentriert sich selbst:";
emailname = "Geben Sie bitte die Email Adresse ein.";
listentyp = "Für eine numerierte Liste geben Sie eine '1' an. Für eine alphabetische ein 'a'.\nFür eine einfache Punktliste drücken Sie ok.";
listenwerte = "Geben Sie bitte die Listenpunkte ein und drücken Sie anschliessend ok.\nAlternativ können Sie 'Abbrechen' wählen, um die Liste direkt fertigzustellen.";
highlightmsg = "Alles markiert und in die Zwischenablage kopiert.";
searchfailed = "Die Suche lieferte kein Ergebnis.";
admincss = "<link rel='stylesheet' href='style.css' type='text/css'>";
flashlenght = "Geben Sie bitte die Maße in Pixel an (optional).\nAngabe in: Breite,Höhe Bsp.: 300,100";
flashadresse = "Geben Sie bitte die vollständige Adresse (URL) des Flashfilmes an.";
//**** Für Einzelzeichen *****
function singler(text) {
var txtarea = document.myform.content;
var caretPos = txtarea.caretPos;
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();
}
}
//**** Pop-Fenster **********
function helpwindow(w,h,e) {
window.open("include.php?path=misc/help.php&explain="+e,"helpwindow","toolbar=yes,scrollbars=yes,resizable=yes,location=yes,directories=yes,status=yes,menubar=yes,width="+w+",height="+h);
}
//**** Passwortgenerator für PHPKit by saarradio.de ****
function passwort(w,h) {
window.open("popup.php?path=login/passwort.php&window_w_size="+w+"&window_h_size="+h,"passwort","toolbar=no,scrollbars=no,resizable=no,width="+w+",height="+h);
}
//**** Passwortgenerator für PHPKit by saarradio.de ****
//**** Foreninfo Start ****
function foreninfo(w,h) {
window.open("popup.php?path=misc/foreninfo.php&window_w_size="+w+"&window_h_size="+h,"foreninfo","toolbar=no,scrollbars=no,resizable=no,width="+w+",height="+h);
}
//**** Foreninfo ende ****
function smiliewindow(w,h) {
window.open("popup.php?path=misc/smiliewindow.php&window_w_size="+w+"&window_h_size="+h,"smilies","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function windowsmilie(w,h,opt) {
window.open("popup.php?path=smilies&window_w_size="+w+"&window_h_size="+h+"&option="+opt,"smilies","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function morelinkswindow(w,h,opt) {
window.open("popup.php?path=morelinks&window_w_size="+w+"&window_h_size="+h+"&option="+opt,"morelinks","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function readfilewindow(w,h,opt) {
window.open("popup.php?path=readfile&window_w_size="+w+"&window_h_size="+h+"&option="+opt,"readfile","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function finduserID(w,h,opt) {
window.open("popup.php?path=finduser&window_w_size="+w+"&window_h_size="+h+"&option="+opt,"finduser","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function downloadwindow(w,h,opt) {
window.open("popup.php?path=download&window_w_size="+w+"&window_h_size="+h+"&option="+opt,"download","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function attachment(w,h) {
window.open("popup.php?path=script/attachment.php","attachment","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function previewWindow(w,h) {
window.open("../popup.php?path=admin/popup/preview.php&window_w_size="+w+"&window_h_size="+h,"preview","toolbar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}
function previewTemplate() {
var inf=document.edittemplate.template_value.value + admincss;
popupwindow=window.open(", ","popup","toolbar=no,status=no,scrollbars=yes,resizable=yes");
popupwindow.document.write("" + inf + "");
}
//******** Wahl modus *******
function modus(mymode) {
document.cookie = "mycodemode="+0+"; path=/; expires=Wed, 1 Jan 2020 00:00:00 GMT;";
}
function mymode(myform) {
if (myform.mode[0]) return true;
else return false;
}
function mystatus(myvalue) {
document.myform.status.value = eval(myvalue+"_text");
}
function setfocus(myform) {
myform.content.focus();
}
var textmarkiert = "";
auswahltext = "";
//********* Textauswahl ******
function myselection(doit) {
textmarkiert = (document.all) ? document.selection.createRange().text : document.getSelection();
if (doit.createTextRange) doit.caretPos = document.selection.createRange().duplicate();
return true;
}
function mytextadd(textneu,myform) {
if (myform.content.createTextRange && myform.content.caretPos) {
var caretPos = myform.content.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? textneu + ' ' : textneu;
} else myform.content.value+=textneu
auswahltext = "";
setfocus(myform);
}
function mycode(myform,mycode,fensterausgabe) {
setfocus(myform);
if ((mymode(myform)) || (mycode=="IMG")) {
if (textmarkiert) var direkttext=textmarkiert;
else var direkttext=fensterausgabe;
inserttext = prompt(standard+"\n["+mycode+"]Ihr Text[/"+mycode+"]",direkttext);
if ((inserttext != null) && (inserttext != "")) {
auswahltext = "["+mycode+"]"+inserttext+"[/"+mycode+"]";
mytextadd(auswahltext,myform);
}
}
else {
untersagt = false;
for (i = 0; i < bbtags.length; i++) {
if (bbtags == mycode) untersagt = true;
}
if (!untersagt) {
myform.content.value += "["+mycode+"]";
arraypush(bbtags,mycode);
}
}
setfocus(myform);
}
/**************************************** HIDDEN_HACK Anfang ****************************************/
function hidden(myform,mytype,wert) {
if (textmarkiert) { var direkttext=textmarkiert; } else { var direkttext=""; }
linktext = prompt(standard,direkttext);
var fensterausgabe;
if (mytype == "hiddenstatus") {
ausgabe = "Bitte den status angeben ab wann man diesen Text lesn darf.\nBsp.: (user, member, mod oder admin).";
ausgabeinhalt = "";
}
if (mytype == "hiddencounter") {
ausgabe = "Ab wie viele Tage soll diese Nachricht sichtbar werden?\nMaximal " + wert + " Tage möglich";
ausgabeinhalt = "";
}
if (mytype == "hiddenpost") {
ausgabe = "Ab wie viele Posts darf man diesen Text sehen?\nMaximal " + wert + " Posts möglich";
ausgabeinhalt = "";
}
if (mytype == "hiddenid") {
ausgabe = "Bitte die Userid`s mit Komma eintragen. Bsp.: 1,44,678,543,678";
ausgabeinhalt = "";
}
if (mytype == "hiddenpw") {
ausgabe = "Bitte ein Passwort hier eingeben";
ausgabeinhalt = "";
}
linkurl = prompt(ausgabe,ausgabeinhalt);
if ((linkurl != null) && (linkurl != "")) {
if ((linktext != null) && (linktext != "")) {
auswahltext = "["+mytype+"="+linkurl+"]"+linktext+"[/"+mytype+"] ";
mytextadd(auswahltext,myform);
}
}
}
/**************************************** HIDDEN_HACK ****************************************/
//**** Link und email***********
//--- Video BB Codes Anfang ----
function myvideos(myform,mycode,fensterausgabe) {
setfocus(myform);
if ((mymode(myform)) || (mycode=="IMG")) {
if (textmarkiert) var direkttext=textmarkiert;
else var direkttext=fensterausgabe;
inserttext = prompt(videonummer+"\n["+mycode+"]..Videonummer..[/"+mycode+"]",direkttext);
if ((inserttext != null) && (inserttext != "")) {
auswahltext = "["+mycode+"]"+inserttext+"[/"+mycode+"]";
mytextadd(auswahltext,myform);
}
}
else {
untersagt = false;
for (i = 0; i < bbtags.length; i++) {
if (bbtags[i] == mycode) untersagt = true;
}
if (!untersagt) {
myform.content.value += "["+mycode+"]";
arraypush(bbtags,mycode);
}
}
setfocus(myform);
}
// --- Video BB Codes Ende ----
function speciallink(myform,mytype) {
if (textmarkiert) { var direkttext=textmarkiert; } else { var direkttext=""; }
linktext = prompt(linkname,direkttext);
var fensterausgabe;
if (mytype == "URL") {
ausgabe = linkadresse;
ausgabeinhalt = "http://";
}
else {
ausgabe = emailname;
ausgabeinhalt = "";
}
linkurl = prompt(ausgabe,ausgabeinhalt);
if ((linkurl != null) && (linkurl != "")) {
if ((linktext != null) && (linktext != "")) {
auswahltext = "["+mytype+"="+linkurl+"]"+linktext+"[/"+mytype+"] ";
mytextadd(auswahltext,myform);
}
else{
auswahltext = "["+mytype+"]"+linkurl+"[/"+mytype+"] ";
mytextadd(auswahltext,myform);
}
}
}
//**** Flash ***********
function myflashcode(myform,mytype,fensterausgabe) {
if (textmarkiert) var direkttext=textmarkiert;
else var direkttext=fensterausgabe;
url = prompt(flashadresse,direkttext);
lenght = prompt(flashlenght,'');
if (mytype == "FLASH") {
if ((url != null) && (url != "")) {
if ((lenght != null) && (lenght != "")) {
auswahltext = "["+mytype+"="+lenght+"]"+url+"[/"+mytype+"] ";
mytextadd(auswahltext,myform);
} else{
auswahltext = "["+mytype+"]"+url+"[/"+mytype+"] ";
mytextadd(auswahltext,myform);
}
}
}
}
// ***** liste **************
function createlist(myform) {
listtype = prompt(listentyp, "");
if ((listtype == "a") || (listtype == "1")) {
mylist = "[list="+listtype+"]\n";
listend = "[/list="+listtype+"] ";
}
else {
mylist = "[list]\n";
listend = "[/list] ";
}
listentry = "initial";
while ((listentry != "") && (listentry != null)) {
listentry = prompt(listenwerte, "");
if ((listentry != "") && (listentry != null))
mylist = mylist+"[*]"+listentry+"\n";
}
auswahltext = mylist+listend;
mytextadd(auswahltext,myform);
}
var NS4=(document.layers);
var IE4=(document.all);
var win=window;
var n=0;
function highlightSearch(str) {
var txt, i, found;
if (str == '') return false;
if (NS4) {
if (!win.find(str)) while(win.find(str, false, true)) n++;
else n++;
if (n == 0) alert(searchfailed);
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart('character', 1);
txt.moveEnd('textedit');
}
if (found) {
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {n = 0; findit(str);}
else alert(searchfailed);
}
}
return false;
}
function HighlightAndCopy() {
var tempval=eval("document.edittemplate.template_value")
tempval.focus()
tempval.select()
if (document.all){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status=highlightmsg
setTimeout("window.status=''",1800)
}
}
function checkall(status,theelement) {
for (i=0;i<document.myform.length;i++) {if(document.myform.elements[i].name=="" + theelement + "[]") document.myform.elements[i].checked=status;}
}
function selectUser() {
if(document.finduser.User.options[document.finduser.User.selectedIndex].value != -1) {
opener.document.myform.im_receiver.value = document.finduser.User.options[document.finduser.User.selectedIndex].value; opener.myform.im_receiver.focus();
}
}
function selectBuddy() {
if(document.finduser.Buddy.options[document.finduser.Buddy.selectedIndex].value != -1) {
opener.document.myform.im_receiver.value = document.finduser.Buddy.options[document.finduser.Buddy.selectedIndex].value;
opener.myform.im_receiver.focus();
}
}
|
Mein BBCode-Tag
|
|
Quellcode |
1 |
<td><a href="javascript:;" onclick="speciallink(document.myform,'URL')" onFocus="blur();"><img src="../images/bbcode/office2007/url2.gif" alt="Einen Link mit Text einfügen" title="Einen Link mit Text einfügen" width="25" height="24" onmouseover="this.src='../images/bbcode/office2007/url_over2.gif'" onmouseout="this.src='../images/bbcode/office2007/url2.gif'" border="0" /></a></td> |
Ideen?
gruß
Ähnliche Themen
-
Aktuelle Version [1.6.5] »-
1.6.5 "Newsflash" Bug
(21. November 2009, 11:38)
-
alte Versionen [1.6.03|1.6.1|1.6.4] »-
Flash BB CODE
(29. Dezember 2007, 13:22)
-
Web | Allgemein »-
Smilies nicht ans ende der Seite
(29. November 2008, 20:03)
-
Plauderecke »-
WBB BBcodes
(11. Oktober 2008, 07:38)
-
alte Versionen [1.6.03|1.6.1|1.6.4] »-
htmentilities in php
(4. Januar 2008, 20:45)


