[JS Source code]never HTML UBB Converter

Source: Internet
Author: User
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>
&LT;H1 align= "center" >neverubbconverter of Never modules<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, "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\" >http://www.alixixi.com/web/a/$2 " </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=\" http://www.alixixi.com/web/a/$2\ "]$4[/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" >

<strong>http://blog.csdn.net/BlueDestiny/</strong>

<a href= "http://blog.csdn.net/BlueDestiny/" >blueDestiny</a>
</textarea>

<textarea id= "Divoutputuid" ></textarea>
<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>
<input type= "button" value= "Ubb convert to Html"/>

</TD>
</TR>
</TABLE>

Power by Bluedestiny, Never-online,
<a href= "Http://www.never-online.net" >http://www.never-online.net</a>
</BODY>
</HTML>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.