大哥大姐们好!谁能给小弟讲讲UBB代码吗?怎么生成UBB代码再写入数据库,再怎么又从数据库中读出来呢,我也想像此编程论坛中多功能编辑器那样,太完美了!!
~~~~~~~~~~~~~~~在此先谢~??
下面的是UBB.JS 主要是脚本做的 // ----------------------------------------- // UBB Codes // -----------------------------------------
function insertText(str) { var oContent = findObj('con'); if (oContent) { if (document.all) { insertAtCaret(oContent, str); } else { oContent.value += str; } oContent.focus(); } }insertCode
function insertAtCaret(textEl, text) { if (textEl.createTextRange && textEl.caretPos) { var caretPos = textEl.caretPos; caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text; } else if (textEl) { textEl.value += text; } else { textEl.value = text; } CountStrByte(this.form.con,this.form.used,this.form.remain) }
function findObj(theObj, theDoc){ var i, foundObj; if(!theDoc) theDoc = document; if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj]; for (i=0; !foundObj && i < theDoc.forms.length; i++) foundObj = theDoc.forms[i][theObj]; if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
return foundObj; }
function insertCode(code, option){ var promptTitle; var promptValue; var codeBegin; var codeClose; var text; var text1; var Url = false; switch (code){ case 'B': promptTitle = promptValue = "粗体文字"; codeBegin = ""; codeClose = ""; break; case 'I': promptTitle = promptValue = "斜体文字"; codeBegin = ""; codeClose = ""; break; case 'U': promptTitle = promptValue = "下划线文字"; codeBegin = ""; codeClose = ""; break; case 'IMG': promptTitle = "图象地址"; promptValue = "http://"; codeBegin = "[img]"; codeClose = "[/img]"; break; case 'URL': promptTitle = "超级链接"; promptValue = "http://"; codeBegin = "[url]"; codeClose = "[/url]"; Url = true; break; case 'EMAIL': promptTitle = "电子邮件"; promptValue = "@"; codeBegin = "[email]"; codeClose = "[/email]"; break; case 'FLY': promptTitle = promptValue = "飞行文字"; codeBegin = "[fly]"; codeClose = "[/fly]"; break; case 'MOVE': promptTitle = promptValue = "滚动文字"; codeBegin = "[move]"; codeClose = "[/move]"; break; case 'SHADOW': promptTitle = "阴影文字 (参数: shadow=颜色,方向,阴影大小)"; promptValue = "阴影文字"; codeBegin = "[shadow=green,45,2]"; codeClose = "[/shadow]"; break; case 'FONT' : promptTitle = "字体 (" +option+ ")"; promptValue = option; codeBegin = ""; codeClose = ""; break; case 'COLOR' : promptTitle = "字体颜色 (" +option+ ")"; promptValue = "颜色字"; codeBegin = "[color=" +option+ "]"; codeClose = "[/color]"; break; default: text = code; } if(text){ insertText(text); }else if(code && option!='false'){ if(Url){ txt1=prompt("链接文本显示:\n如果不想使用, 可以为空, 将只显示超级链接地址. ",""); if (txt1!=null) { txt=prompt(promptTitle + ": ",promptValue); if (txt!=null) { if (txt1 != "") { codeBegin="[url="+txt+"]"; txt = txt1; } insertText(codeBegin + txt + codeClose); } } }else{ txt = prompt(promptTitle + ": ", promptValue); if (txt != null) { insertText(codeBegin + txt + codeClose); } } } }