国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

UBB 轉換函數演示

2024-04-27 13:53:00
字體:
來源:轉載
供稿:網友

UBB代碼對于經常上論壇的朋友來說是最熟悉不過了。
經典論壇的UBB轉換我覺得是處理的非常好的,研究了一下它的轉換結果[因為沒有源碼:)],做了下面的演示。轉換結果基本上覺得象了。

主要是針對[code][html]這兩個標簽的處理,其他的UBB標簽還是一般的處理方法。

下面是分別用javascript和vbscript實現的演示。自己做論壇的朋友,假如想實現類似經典論壇的運行代碼框可以看看這種轉換。

歡迎大家輸入盡量多格式的UBB進行測試,多多指出錯誤。

javascript:

<style>
.CodeSamp {
PADDING-RIGHT: 0.5em; MARGIN-TOP: 1em; PADDING-LEFT: 0.5em; FONT-SIZE: 8p; MARGIN-BOTTOM: 1em; PADDING-BOTTOM: 0.5em; MARGIN-LEFT: 0pt; PADDING-TOP: 0.5em; FONT-FAMILY: "Courier New"; BACKGROUND-COLOR: #eeeeee;width: 480px;overflow:hidden;border: 1px solid #888888;
}
textarea {
border-width: 1; border-color: #000000;font-size: 12px;FONT-FAMILY: "Tahoma", "MS Shell Dlg";
}
</style>

<TEXTAREA name=phx cols=65 rows=12>
[i][b][color=blue]blue[/color][/b][/i]

[html][color=red]te
st[/color][/html]

[html][code]te
st[/code][/html]

[code][html]te
st[/html][/code]</textarea>
<br><button onclick=show.innerHTML=UBBCode(phx.value,"html")>轉換</button><br>
<div id=show style="border:1 solid skyblue;width=500;font-size: 12px;FONT-FAMILY:
'Tahoma', 'MS Shell Dlg';
"></div>


<script>
strIcons = "1" //答應笑臉轉換
strSmile="1" //同上
ImgName="em"
picurl="pic/"

function UBBCode(content,html){
st=new Date().getTime()
content=content.replace(//[(//)?phx_code/]/ig,"{$1phx_code}");
content=content.replace(//[(//)?phx_html/]/ig,"{$1phx_html}");
content="[phx_code]" content "[/phx_code]";
content=content.replace(/(/[code/]([/s/S] ?)/[//code/])/ig,"[/phx_code]$1[phx_code]");
content=content.replace(//[phx_code/]([/s/S]*?)/[//phx_code/]/ig,function($1,$2){if(html=="html"){return(HTMLCode($2));}else{return(trans($2));}});
content=content.replace(//[code/](/r/n)?([/s/S] ?)/[//code/]/ig,function($1,$2,$3){return("<PRE class=CodeSamp>" DvbbsHtmlAn($3) "</PRE>")});
content=content.replace(//{(//)?phx_code/}/ig,"[$1phx_code]");
content=content.replace(//{(//)?phx_html/}/ig,"[$1phx_html]");
alert('共耗時 ' eval(new Date().getTime()-st) ' ms');
return(content);
}

function HTMLCode(content){
content="[phx_html]" content "[/phx_html]";
content=content.replace(/(/[html/]([/s/S] ?)/[//html/])/ig,"[/phx_html]$1[phx_html]");
content=content.replace(//[phx_html/]([/s/S]*?)/[//phx_html/]/ig,function($1,$2){return(trans($2))});
content=content.replace(//[html/]([/s/S] ?)/[//html/]/ig,function($1,$2){return("<span><TEXTAREA cols=95 rows=12>" hencode($2) "</TEXTAREA><br><INPUT onclick=runCode() type=button value=運行代碼>[Ctrl A 全部選擇 提示:你可先修改部分代碼,再按運行]</span>")});
return(content);

共11頁上一頁123456789下一頁
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 福清市| 济宁市| 汉寿县| 岐山县| 新兴县| 沁源县| 临沭县| 奎屯市| 滨州市| 汕尾市| 炉霍县| 平凉市| 海原县| 金秀| 伊通| 六盘水市| 信丰县| 金门县| 黄骅市| 土默特左旗| 大荔县| 寻乌县| 西城区| 巢湖市| 成都市| 石柱| 木里| 专栏| 泾源县| 崇文区| 佛教| 和顺县| 江源县| 长沙县| 洛川县| 齐河县| 鹰潭市| 岱山县| 南岸区| 友谊县| 武义县|