var theSelection = false; 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_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); var is_mac = (clientPC.indexOf("mac")!=-1); hr_help = "Ein Horizontaler Seperator"; b_help = "Text in fett: [b]Text[/b]"; i_help = "Text in kursiv: [i]Text[/i]"; u_help = "Unterstrichener Text: [u]Text[/u]"; q_help = "Zitat: [quote]Text[/quote]"; c_help = "Code anzeigen: [code]Code[/code]"; l_help = "Liste: [list]Text[/list]"; o_help = "Geordnete Liste: [list=]Text[/list]"; p_help = "Bild einfügen: [img]http://URL_des_Bildes[/img]"; y_help = "Bild einfügen: [imgm]imgid[/imgm]"; w_help = "URL einfügen: [url]http://URL[/url] oder [url=http://url]URL Text[/url]"; a_help = "Alle offenen BBCodes schließen"; s_help = "Schriftfarbe: [color=red]Text[/color]"; f_help = "Schriftgröße: [size=10]Kleiner Text[/size]"; sc_help = "Smilie Creator: [schild=1]Text[/schild] Erstellt einen Smilie mit Schild"; sb_help = "Font color: [COLOR=#000000]text[/COLOR]"; e_help = "Text höher stellen (a²+b²=c²): [sup]Texte[/sup]"; r_help = "Text tiefer stellen: [sub]Texte[/sub]"; z_help = "Zentriert Text&Images: [center]Text[/center]"; ri_help = "Rechtsbündig Text&Images: [right]Text[/right]"; tab_help = "Tabelle [table]Text1A[col]Text2A[row]Text1B[col]Text2B[/table]"; row_help = "Neue Zeile in Tabelle"; col_help = "Nächste Zelle in Tabelle"; var Quote = 0; var Bold = 0; var Italic = 0; var Underline = 0; var Code = 0; var Super = 0; var Sub = 0; var Center = 0; var Right = 0; var FloatL = 0; var FloatR = 0; var Table = 0; function helpline(help) { document.post.helpbox.value = eval(help + "_help"); document.post.helpbox.readOnly = "true"; } function checkForm() { formErrors = false; if (document.post.edittext.value.length < 2) { formErrors = "You must enter a message when posting"; } if (formErrors) { alert(formErrors); return false; } else { //formObj.preview.disabled = true; //formObj.submit.disabled = true; return true; } } function emoticon(text) { text = ' ' + text + ' '; PostWrite(text); } function bbfontstyle(bbopen, bbclose) { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (!theSelection) { // document.post.edittext.value += bbopen + bbclose; // document.post.edittext.focus(); var ToAdd = bbopen + bbclose; PostWrite(ToAdd); return; } document.selection.createRange().text = bbopen + theSelection + bbclose; document.post.edittext.focus(); return; } else { // document.post.edittext.value += bbopen + bbclose; // document.post.edittext.focus(); var ToAdd = bbopen + bbclose; PostWrite(ToAdd); return; } storeCaret(document.post.edittext); } function storeCaret(textEl) { if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); } function PostWrite(text) { if (document.post.edittext.createTextRange && document.post.edittext.caretPos) { var caretPos = document.post.edittext.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text; } else document.post.edittext.value += text; document.post.edittext.focus(caretPos) } function BBCcode() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[code]" + theSelection + "[/code]"; document.post.edittext.focus(); return; } } if (Code == 0) { ToAdd = "[code]"; document.post.code.value = "Code*"; Code = 1; } else { ToAdd = "[/code]"; document.post.code.value = "Code"; Code = 0; } PostWrite(ToAdd); } function BBCquote() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[quote]" + theSelection + "[/quote]"; document.post.edittext.focus(); return; } } if (Quote == 0) { ToAdd = "[quote]"; document.post.quote.value = "Quote*"; Quote = 1; } else { ToAdd = "[/quote]"; document.post.quote.value = "Quote"; Quote = 0; } PostWrite(ToAdd); } function BBCcenter() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[center]" + theSelection + "[/center]"; document.post.edittext.focus(); return; } } if (Center == 0) { ToAdd = "[center]"; document.post.center.value = "CENTER*"; Center = 1; } else { ToAdd = "[/center]"; document.post.center.value = "CENTER"; Center = 0; } PostWrite(ToAdd); } function BBCright() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[right]" + theSelection + "[/right]"; document.post.edittext.focus(); return; } } if (Right == 0) { ToAdd = "[right]"; document.post.right.value = "RIGHT*"; Right = 1; } else { ToAdd = "[/right]"; document.post.right.value = "RIGHT"; Right = 0; } PostWrite(ToAdd); } function BBCbold() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[b]" + theSelection + "[/b]"; document.post.edittext.focus(); return; } } if (Bold == 0) { ToAdd = "[b]"; document.post.bold.value = "B*"; Bold = 1; } else { ToAdd = "[/b]"; document.post.bold.value = "B"; Bold = 0; } PostWrite(ToAdd); } function BBCitalic() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[i]" + theSelection + "[/i]"; document.post.edittext.focus(); return; } } if (Italic == 0) { ToAdd = "[i]"; document.post.italic.value = "i*"; Italic = 1; } else { ToAdd = "[/i]"; document.post.italic.value = "i"; Italic = 0; } PostWrite(ToAdd); } function BBCunder() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[u]" + theSelection + "[/u]"; document.post.edittext.focus(); return; } } if (Underline == 0) { ToAdd = "[u]"; document.post.under.value = "U*"; Underline = 1; } else { ToAdd = "[/u]"; document.post.under.value = "U"; Underline = 0; } PostWrite(ToAdd); } function BBCfloatl() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[fl]" + theSelection + "[/fl]"; document.post.edittext.focus(); return; } } if (FloatL == 0) { ToAdd = "[fl]"; document.post.floatl.value = "FL*"; FloatL = 1; } else { ToAdd = "[/fl]"; document.post.floatl.value = "FL"; FloatL = 0; } PostWrite(ToAdd); } function BBCfloatr() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[fr]" + theSelection + "[/fr]"; document.post.edittext.focus(); return; } } if (FloatR == 0) { ToAdd = "[fr]"; document.post.floatr.value = "FR*"; FloatR = 1; } else { ToAdd = "[/fr]"; document.post.floatr.value = "FR"; FloatR = 0; } PostWrite(ToAdd); } function BBCtable() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[table]" + theSelection + "[/table]"; document.post.edittext.focus(); return; } } if (Table == 0) { ToAdd = "[table]"; document.post.table.value = "Table*"; document.post.row.visibility="show"; document.post.col.visibility="show"; Table = 1; } else { ToAdd = "[/table]"; document.post.table.value = "Table"; document.post.row.visibility="hide"; document.post.col.visibility="hide"; Table = 0; } PostWrite(ToAdd); } function BBCcol() { ToAdd = "[col]"; PostWrite(ToAdd); } function BBCrow() { ToAdd = "[row]"; PostWrite(ToAdd); } function BBChr() { ToAdd = "[hr]"; PostWrite(ToAdd); } function BBCurl() { var FoundErrors = ''; var enterURL = prompt("Enter your URL", "http://"); var enterTITLE = prompt("Enter the webpage title", "Webpage Title"); if (!enterURL) { FoundErrors += " You have not entered the URL yet!"; } if (!enterTITLE) { FoundErrors += " You have not entered the title yet!"; } if (FoundErrors) { alert("Error!"+FoundErrors); return; } var ToAdd = "[url="+enterURL+"]"+enterTITLE+"[/url]"; //document.post.edittext.value+=ToAdd; //document.post.edittext.focus(); PostWrite(ToAdd); } function BBCimg() { var FoundErrors = ''; var enterURL = prompt("Enter your image URL","http://"); if (!enterURL) { FoundErrors += " You have not entered the URL yet!"; } if (FoundErrors) { alert("Error!"+FoundErrors); return; } var ToAdd = "[img]"+enterURL+"[/img]"; //document.post.edittext.value+=ToAdd; //document.post.edittext.focus(); PostWrite(ToAdd); } function BBCsuper() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[sup]" + theSelection + "[/sup]"; document.post.edittext.focus(); return; } } if (Super == 0) { ToAdd = "[sup]"; document.post.sup.value = "SUP*"; Super = 1; } else { ToAdd = "[/sup]"; document.post.sup.value = "SUP"; Super = 0; } PostWrite(ToAdd); } function BBCsub() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "[sub]" + theSelection + "[/sub]"; document.post.edittext.focus(); return; } } if (Sub == 0) { ToAdd = "[sub]"; document.post.sub.value = "SUB*"; Sub = 1; } else { ToAdd = "[/sub]"; document.post.sub.value = "SUB"; Sub = 0; } PostWrite(ToAdd); } // ------------------------------------------------------------------- // swapOptions(select_object,option1,option2) // Swap positions of two options in a select list // ------------------------------------------------------------------- function swapOptions(obj,i,j) { var o = obj.options; var i_selected = o[i].selected; var j_selected = o[j].selected; var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected); var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected); o[i] = temp2; o[j] = temp; o[i].selected = j_selected; o[j].selected = i_selected; } // ------------------------------------------------------------------- // moveOptionUp(select_object) // Move selected option in a select list up one // ------------------------------------------------------------------- function moveOptionUp(obj) { for (i=0; i=0; i--) { if (obj.options[i].selected) { if (i != (obj.options.length-1) && ! obj.options[i+1].selected) { swapOptions(obj,i,i+1); obj.options[i+1].selected = true; } } } } // ------------------------------------------------------------------- // removeSelectedOptions(select_object) // Remove all selected options from a list // (Thanks to Gene Ninestein) // ------------------------------------------------------------------- function moveOptionBottom(obj) { for (i=obj.options.length-1; i>=0; i--) { if (obj.options[i].selected) { if (i != (obj.options.length-1) && ! obj.options[i+1].selected) { swapOptions(obj,i,i+1); obj.options[i+1].selected = true; } } } } function moveOptionTop(obj) { //laenge ermitteln //+ obj.editdir.updownlist.length + //auf 0 setzen if(obj.editdir.updownlist.selectedIndex == 2) obj.editdir.updownlist.selectedIndex = 0; }