// JavaScript Document function IZ_BBCODE_ACTIVATE(id){ var width; var height; var out = null; var bbcode_element_id = id; var iframe_element_id = id + Math.floor(Math.random()*11) var toolbar = "izbt" + Math.floor(Math.random()*11) width = 300; height = 300; out = '
' out = out + '
' //out = out + '' out = out + ''; out = out + '
' var element = document.getElementById(id+"_IZBBCODE"); element.innerHTML = out; //document.getElementById(bbcode_element_id + '_iframe').contentWindow.document.designMode = "On"; //alert(bbcode_element_id + '_txtarea'); url = 'http://'; url = url +window.location.hostname;; url = url +"/"; url = url +"stor/web/bbcode/bbcode_editor.inc.php"; url = url +"?"; url = url +"type=toolbar"; url = url +"&"; url = url +'elid=' + bbcode_element_id ; // alert(url); IZ_HTTP_SGET(url,toolbar) } function IZ_BBCODE_CONVERTER(text_id){ //var getForm = document.getElementById(form_id); //var getText = ; // alert(text_id); //alert(document.getElementById(text_id + '_txtarea').value); //alert(text_id); var strBBcode = "" + document.getElementById(text_id + '_txtarea').value; //alert(strBBcode); // maybe they put spaces around the = . Remove them strBBcode = strBBcode.replace(/ = /gi, "="); // maybe they put quotes surrounding the value // so look for =" and "> strBBcode = strBBcode.replace(/=\"/gi, "="); //strBBcode = strBBcode.replace(/\">/gi, ">"); // maybe they put single quote surrounding the value // so look for =' and '> strBBcode = strBBcode.replace(/=\'/gi, "="); //strBBcode = strBBcode.replace(/\'>/gi, ">"); strBBcode = strBBcode.replace(/]*value=/gi, "]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ BORDER=[^\'>]*\'/gi, " "); strBBcode = strBBcode.replace(/ TARGET=[^\'\">]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ TARGET=[^\'>]*\'/gi, ""); strBBcode = strBBcode.replace(/ CLASSID=[^\'\">]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ CLASSID=[^\'>]*\'/gi, ""); strBBcode = strBBcode.replace(/ ID=[^\'\">]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ ID=[^\'>]*\'/gi, ""); strBBcode = strBBcode.replace(/ NAME=[^\'\">]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ NAME=[^\'>]*\'/gi, ""); //strBBcode = strBBcode.replace(/ ALIGN=[^\"]*\"/gi, ""); //strBBcode = strBBcode.replace(/ ALIGN=[^\']*\'/gi, ""); //strBBcode = strBBcode.replace(/ ALIGN=[^>]*>/gi, ">"); strBBcode = strBBcode.replace(/ STYLE=[^\'\">]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ STYLE=[^\'>]*\'/gi, ""); strBBcode = strBBcode.replace(/ CLASS=[^\'\">]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ CLASS=[^\'>]*\'/gi, ""); strBBcode = strBBcode.replace(/ ALT=[^\'\">]*[\'\">]/gi, ""); //strBBcode = strBBcode.replace(/ ALT=[^\'>]*\'/gi, ""); strBBcode = strBBcode.replace(/ TITLE=[^\'\">]*[\'\">]/gi, ""); strBBcode = strBBcode.replace(/
/gi, ""); strBBcode = strBBcode.replace(//gi, ""); // added (.*?) 5/30/09 strBBcode = strBBcode.replace(/

/gi, "\r\r"); strBBcode = strBBcode.replace(/

]*>/gi, "\r\r"); strBBcode = strBBcode.replace(//gi, "[code]"); strBBcode = strBBcode.replace(/<\/CODE>/gi, "[/code]"); strBBcode = strBBcode.replace(/

/gi, "[quote]"); strBBcode = strBBcode.replace(/<\/BLOCKQUOTE>/gi, "[/quote]"); strBBcode = strBBcode.replace(/]*>/gi, "[list]"); strBBcode = strBBcode.replace(/<\/UL>/gi, "[/list]"); strBBcode = strBBcode.replace(/]*>/gi, "[list=1]"); strBBcode = strBBcode.replace(/<\/OL>/gi, "[/list]"); strBBcode = strBBcode.replace(/
  • /gi, "[*]"); //strBBcode = strBBcode.replace(//gi, "[/url]"); // *** Jeff!! These two remarked statements are the solution // to make a better converter: // (.*?) = match any character except new line 0 or more times and remember the match // ([\s\S]*?) = match \s any white space char once inclduing \n, \S match any non-white space char, *? any number of times or 0 times //strBBcode = strBBcode.replace(/([\s\S]*?)<\/A>/gi, "[url=$1]$2[\/url]"); strBBcode = strBBcode.replace(//gi, "[img]$1[\/img]"); strBBcode = strBBcode.replace(//gi, "[img]$1[\/img]"); //strBBcode = strBBcode.replace(/]*>/gi, ".jpg[/img]"); //strBBcode = strBBcode.replace(/.gif[^>]*>/gi, ".gif[/img]"); //strBBcode = strBBcode.replace(/.bmp[^>]*>/gi, ".bmp[/img]"); //strBBcode = strBBcode.replace(/.png[^>]*>/gi, ".png[/img]"); strBBcode = strBBcode.replace(//gi, "[b]"); strBBcode = strBBcode.replace(/<\/BIG>/gi, "[/b]"); strBBcode = strBBcode.replace(//gi, "[b]"); strBBcode = strBBcode.replace(/<\/B>/gi, "[/b]"); strBBcode = strBBcode.replace(//gi, "[u]"); strBBcode = strBBcode.replace(/<\/U>/gi, "[/u]"); strBBcode = strBBcode.replace(//gi, "[i]"); strBBcode = strBBcode.replace(/<\/I>/gi, "[/i]"); strBBcode = strBBcode.replace(/]*>/gi, "[code]"); strBBcode = strBBcode.replace(/<\/PRE>/gi, "[/code]"); strBBcode = strBBcode.replace(//gi, "[left]"); strBBcode = strBBcode.replace(/<\/LEFT>/gi, "[/left]"); strBBcode = strBBcode.replace(/
    /gi, "[center]"); strBBcode = strBBcode.replace(/<\/CENTER>/gi, "[/center]"); strBBcode = strBBcode.replace(//gi, "[right]"); strBBcode = strBBcode.replace(/<\/RIGHT>/gi, "[/right]"); strBBcode = strBBcode.replace(//gi, "[b]"); strBBcode = strBBcode.replace(/<\/STRONG>/gi, "[/b]"); strBBcode = strBBcode.replace(/]*>/gi, "\r"); strBBcode = strBBcode.replace(/]*>/gi, " "); strBBcode = strBBcode.replace(/]*>/gi, " "); strBBcode = strBBcode.replace(/<\/TR>/gi, " "); strBBcode = strBBcode.replace(/<\/TD>/gi, " "); strBBcode = strBBcode.replace(/<\/TH>/gi, " "); // font size and color tags strBBcode = strBBcode.replace(/]*>/g, ""); // This will convert all > into ] because we left // some open up top such as removing /g, "]"); strBBcode = strBBcode.replace(/\'>/g, "]"); strBBcode = strBBcode.replace(/\">/g, "]"); strBBcode = strBBcode.replace(/\']/g, "]"); strBBcode = strBBcode.replace(/\"]/g, "]"); document.getElementById(text_id+'_txtarea').value = strBBcode; } /*****************************************/ // Name: Javascript Textarea BBCode Markup Editor // Version: 1.3 // Author: Balakrishnan // Last Modified Date: 25/jan/2009 // License: Free // URL: http://www.corpocrat.com /******************************************/ var textarea; var content; //document.write(""); /* function edToolbar(obj) { document.write("
    "); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write("
    "); //document.write(""); }*/ function IZ_BBCODE_Image(obj) { textarea = document.getElementById(obj); var url = prompt('Enter the Image URL:','http://'); var scrollTop = textarea.scrollTop; var scrollLeft = textarea.scrollLeft; if (url != '' && url != null) { if (document.selection) { textarea.focus(); var sel = document.selection.createRange(); sel.text = '[img]' + url + '[/img]'; } else { var len = textarea.value.length; var start = textarea.selectionStart; var end = textarea.selectionEnd; var sel = textarea.value.substring(start, end); //alert(sel); var rep = '[img]' + url + '[/img]'; textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); textarea.scrollTop = scrollTop; textarea.scrollLeft = scrollLeft; } } } function IZ_BBCODE_URL(obj) { textarea = document.getElementById(obj); var url = prompt('Enter the URL:','http://'); var scrollTop = textarea.scrollTop; var scrollLeft = textarea.scrollLeft; if (url != '' && url != null) { if (document.selection) { textarea.focus(); var sel = document.selection.createRange(); if(sel.text==""){ sel.text = '[url]' + url + '[/url]'; } else { sel.text = '[url=' + url + ']' + sel.text + '[/url]'; } //alert(sel.text); } else { var len = textarea.value.length; var start = textarea.selectionStart; var end = textarea.selectionEnd; var sel = textarea.value.substring(start, end); if(sel==""){ var rep = '[url]' + url + '[/url]'; } else { var rep = '[url=' + url + ']' + sel + '[/url]'; } //alert(sel); textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); textarea.scrollTop = scrollTop; textarea.scrollLeft = scrollLeft; } } } function IZ_BBCODE_AddTags(tag1,tag2,obj) { textarea = document.getElementById(obj); // Code for IE if (document.selection) { //textarea.focus(); var sel = document.selection.createRange(); //alert(sel.text); sel.text = tag1 + sel.text + tag2; } else { // Code for Mozilla Firefox var len = textarea.value.length; var start = textarea.selectionStart; var end = textarea.selectionEnd; var scrollTop = textarea.scrollTop; var scrollLeft = textarea.scrollLeft; var sel = textarea.value.substring(start, end); //alert(sel); var rep = tag1 + sel + tag2; textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); textarea.scrollTop = scrollTop; textarea.scrollLeft = scrollLeft; } } function IZ_BBCODE_List(tag1,tag2,obj){ textarea = document.getElementById(obj); // Code for IE if (document.selection) { //textarea.focus(); var sel = document.selection.createRange(); var list = sel.text.split('\n'); for(i=0;i")); var rep = tag1 + '\n' + list.join("\n") + '\n' +tag2; textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); textarea.scrollTop = scrollTop; textarea.scrollLeft = scrollLeft; } }