js|ubb
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> neverUbbConverter Of never Modules - http://www.never-online.net </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="never-online, blueDestiny">
<META NAME="Keywords" CONTENT="never-online, blueDestiny">
<META NAME="Description" CONTENT="http://www.never-online.net">
<STYLE>
<!--
body, pre, td
{
font-size: 0.8em;
font-family: verdana;
}
h1
{
font-size: 1.8em;
}
.copyright
{
text-align: center;
font-size: 0.8em;
font-weight: normal;
}
textarea
{
width: 100%;
height: 200px;
}
-->
</STYLE>
</HEAD>
<h1 align="center">neverUbbConverter Of never Modules</h1>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
//<![CDATA[
/* ---------------------------------------------
// never UBB namespace and config
------------------------------------------------*/
var App = new Object();
App.neverUbbConverter =
{
_ubbuid : "ubbuid",
_ubbValue : null,
getElById : document.getElementById || document.all,
// ----------------------------------------
ubb2Html : function(val)
{
val = val.replace(/\[img]([^\[\]]*)\[\/img\]/ig, "<img src=\"$1\"/>");
val = val.replace(/\[b\]([^\[\]]*)\[\/b\]/ig, "<b>$1</b>");
val = val.replace(/\[strong\]([^\[\]]*)\[\/strong\]/ig, "<strong>$1</strong>");
val = val.replace(/\[i\]([^\[\]]*)\[\/i\]/ig, "<i>$1</i>");
val = val.replace(/\[a href=\"?([^ \'\"\[\]]*)\"?\]([^\[\]]*)\[\/a\]/ig, "<a href=\"$1\" target=\"_blank\">/Upload\20100705\Re_201007051044532851.jpg</a>");
return val;
},
html2Ubb : function(val)
{
val = val.replace(/\< *img (.+ )*src=["|']?([^ ="']*)["|']?( .+)*\/?\>/ig, ""); // img
val = val.replace(/<(\/?)b>/ig, "[$1b]"); // b
val = val.replace(/<(\/?)strong>/ig, "[$1strong]"); // strong
val = val.replace(/<(\/?)i>/ig, "[$1i]"); // i
val = val.replace(/<a (.+ )*href=\"?([^ \"\']*)\"?( .+)*>([^<>]*)< *\/a *>/ig, "[a href=\"/Upload\20100705\Re_201007051044532851.jpg\"]$4[/a]");// a
return val;
},
getElValue : function (val)
{
var u = this.getElById(val);
var a = u.tagName;
if (a=="INPUT" || a=="TEXTAREA") {return u.value;} else {return u.innerHTML};
},
setElValue : function (val1, val2)
{
var u = this.getElById(val1);
var a = u.tagName;
if (a=="INPUT" || a=="TEXTAREA") {u.value = val2;} else {u.innerHTML = val2};
}
};
/* ---------------------------------------------
// never UBB converter API
------------------------------------------------*/
App.neverUbbConverter.convert = function (convertType)
{
var type = (convertType) ? convertType : 1;
var retval = "";
var elValue = this.getElValue(this._ubbuid);
if (type == 1) { retval = App.neverUbbConverter.html2Ubb(elValue); }
else { retval = App.neverUbbConverter.ubb2Html(elValue); }
this._ubbValue = retval;
return retval;
};
App.neverUbbConverter.output = function (uid)
{
this.setElValue(uid, this._ubbValue);
};
App.neverUbbConverter.setUbbuid = function (uid)
{
this._ubbuid = uid;
};
/* ---------------------------------------------
// never UBB converter Demo
------------------------------------------------*/
function HandleHtml2Ubb()
{
App.neverUbbConverter.setUbbuid("divUbbUid");
App.neverUbbConverter.convert(1); // Html to ubb
App.neverUbbConverter.output("divoutputUid");
};
function HandleUbb2Html()
{
App.neverUbbConverter.setUbbuid("tx3");
App.neverUbbConverter.convert(2); // ubb to Html
App.neverUbbConverter.output("tx4");
};
// util.addEvent(window, 'load', HandleOnload);
//]]>
</SCRIPT>
<BODY>
<TABLE>
<TR>
<TD width="50%">
<textarea id="divUbbUid">
<img src="http://file.wbgxw.com/UpLoad\20100705\Re_201007051044538539.gif"/>
<strong>http://blog.csdn.net/BlueDestiny/</strong>
<img src="http://www.pushad.com/Info/im_BlueDestiny_never-online.jpg" border="0"/>
<a href="http://blog.csdn.net/BlueDestiny/">blueDestiny</a>
</textarea>
<textarea id="divoutputUid"></textarea>
<hr>
<input type="button" value="Html convert to ubb" />
</TD>
<TD width="50%">
<textarea id="tx3">
[strong]/XrssFile/2006-6/28/20066281542554.jpg[/img]
[a href="http://blog.csdn.net/BlueDestiny/"]blueDestiny[/a]
</textarea>
<textarea id="tx4"></textarea>
<hr>
<input type="button" value="Ubb convert to Html" />
</TD>
</TR>
</TABLE>
<h4 class="copyright">
Power By BlueDestiny, never-online,
<a href="http://www.never-online.net">http://www.never-online.net</a>
</h4>
</BODY>
</HTML>