ubbcode.js
上传用户:comthink
上传日期:2021-05-06
资源大小:1280k
文件大小:14k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. var Quote = 0;
  2. var Bold  = 0;
  3. var Italic = 0;
  4. var Underline = 0;
  5. var Code = 0;
  6. var Center = 0;
  7. var Strike = 0;
  8. var Sound = 0;
  9. var Swf = 0;
  10. var Ra = 0;
  11. var Rm = 0;
  12. var Marquee = 0;
  13. var Fly = 0;
  14. var fanzi=0;
  15. var text_enter_url      = "请输入连接网址";
  16. var text_enter_txt      = "请输入连接说明";
  17. var text_enter_image    = "请输入图片网址";
  18. var text_enter_sound    = "请输入声音文件网址";
  19. var text_enter_swf      = "请输入FLASH动画网址";
  20. var text_enter_ra      = "请输入Real音乐网址";
  21. var text_enter_rm      = "请输入Real影片网址";
  22. var text_enter_wmv      = "请输入Media影片网址";
  23. var text_enter_wma      = "请输入Media音乐网址";
  24. var text_enter_mov      = "请输入QuickTime音乐网址";
  25. var text_enter_sw      = "请输入shockwave音乐网址";
  26. var text_enter_email    = "请输入邮件网址";
  27. var error_no_url        = "您必须输入网址";
  28. var error_no_txt        = "您必须连接说明";
  29. var error_no_title      = "您必须输入首页标题";
  30. var error_no_email      = "您必须输入邮件网址";
  31. var error_no_gset       = "必须正确按照各式输入!";
  32. var error_no_gtxt       = "必须输入文字!";
  33. var text_enter_guang1   = "文字的长度、颜色和边界大小";
  34. var text_enter_guang2   = "要产生效果的文字!";
  35. var text_enter_points    = "请输入数值,如:1000 (即限制积分在1000点以下的用户不能浏览该内容!)";
  36. var error_no_points       = "您必须输入数值,如:1000";
  37. var text_enter_money    = "请输入数值,如:1000 (即限制金钱在1000点以下的用户不能浏览该内容!)";
  38. var error_no_moeny       = "您必须输入数值,如:1000";
  39. var text_enter_power    = "请输入数值,如:1000 (即限制威望在1000点以下的用户不能浏览该内容!)";
  40. var error_no_power       = "您必须输入数值,如:1000";
  41. var text_enter_post    = "请输入数值,如:1000 (即限制发表文章在1000点以下的用户不能浏览该内容!)";
  42. var error_no_post       = "您必须输入数值,如:1000";
  43. var text_enter_usercp    = "请输入数值,如:1000 (即限制魅力值在1000点以下的用户不能浏览该内容!)";
  44. var error_no_usercp       = "您必须输入数值,如:1000";
  45. var text_enter_usemoney    = "请输入数值,如:1000 (即只有用户支付了1000点金钱才能浏览该内容!)";
  46. var error_no_usemoney       = "您必须输入数值,如:1000";
  47. function commentWrite(NewCode) {
  48. document.frmAnnounce.Content.value+=NewCode;
  49. document.frmAnnounce.Content.focus();
  50. return;
  51. }
  52. function storeCaret(text) { 
  53. if (text.createTextRange) {
  54. text.caretPos = document.selection.createRange().duplicate();
  55. }
  56.         if(event.ctrlKey && window.event.keyCode==13){i++;if (i>1) {alert('帖子正在发出,请耐心等待!');return false;}this.document.form.submit();}
  57. }
  58. function AddText(text) {
  59. if (document.frmAnnounce.Content.createTextRange && document.frmAnnounce.Content.caretPos) {      
  60. var caretPos = document.frmAnnounce.Content.caretPos;      
  61. caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
  62. text + ' ' : text;
  63. }
  64. else document.frmAnnounce.Content.value += text;
  65. document.frmAnnounce.Content.focus(caretPos);
  66. }
  67. function inputs(str)
  68. {
  69. AddText(str);
  70. }
  71. function Curl() {
  72. var FoundErrors = '';
  73. var enterURL   = prompt(text_enter_url, "http://");
  74. var enterTxT   = prompt(text_enter_txt, enterURL);
  75. if (!enterURL)    {
  76. FoundErrors += "n" + error_no_url;
  77. }
  78. if (!enterTxT)    {
  79. FoundErrors += "n" + error_no_txt;
  80. }
  81. if (FoundErrors)  {
  82. alert("错误!"+FoundErrors);
  83. return;
  84. }
  85. var ToAdd = "[URL="+enterURL+"]"+enterTxT+"[/URL]";
  86. document.frmAnnounce.Content.value+=ToAdd;
  87. document.frmAnnounce.Content.focus();
  88. }
  89. function Cimage() {
  90. var FoundErrors = '';
  91. var enterURL   = prompt(text_enter_image, "http://");
  92. if (!enterURL) {
  93. FoundErrors += "n" + error_no_url;
  94. }
  95. if (FoundErrors) {
  96. alert("错误!"+FoundErrors);
  97. return;
  98. }
  99. var ToAdd = "[IMG]"+enterURL+"[/IMG]";
  100. document.frmAnnounce.Content.value+=ToAdd;
  101. document.frmAnnounce.Content.focus();
  102. }
  103. function Cemail() {
  104. var emailAddress = prompt(text_enter_email,"");
  105. if (!emailAddress) { alert(error_no_email); return; }
  106. var ToAdd = "[EMAIL]"+emailAddress+"[/EMAIL]";
  107. commentWrite(ToAdd);
  108. }
  109. function Ccode() {
  110. if (Code == 0) {
  111. ToAdd = "[CODE]";
  112. document.form.code.value = " 代码*";
  113. Code = 1;
  114. } else {
  115. ToAdd = "[/CODE]";
  116. document.form.code.value = " 代码 ";
  117. Code = 0;
  118. }
  119. commentWrite(ToAdd);
  120. }
  121. function Cquote() {
  122. fontbegin="[QUOTE]";
  123. fontend="[/QUOTE]";
  124. fontchuli();
  125. }
  126. function Cbold() {
  127. fontbegin="[B]";
  128. fontend="[/B]";
  129. fontchuli();
  130. }
  131. function Citalic() {
  132. fontbegin="[I]";
  133. fontend="[/I]";
  134. fontchuli();
  135. }
  136. function Cunder() {
  137. fontbegin="[U]";
  138. fontend="[/U]";
  139. fontchuli();
  140. }
  141. function Ccenter() {
  142. fontbegin="[align=center]";
  143. fontend="[/align]";
  144. fontchuli();
  145. }
  146. function Cstrike() {
  147. fontbegin="[strike]";
  148. fontend="[/strike]";
  149. fontchuli();
  150. }
  151. function point() {
  152. var FoundErrors = '';
  153. var enterpoints  =prompt(text_enter_points,"1000");
  154. if (!enterpoints) {
  155. FoundErrors += "n" + error_no_points;
  156. }
  157. if (FoundErrors) {
  158. alert("错误!"+FoundErrors);
  159. return;
  160. }
  161. var ToAdd = "[Point="+enterpoints+"][/Point]";
  162. document.frmAnnounce.Content.value+=ToAdd;
  163. document.frmAnnounce.Content.focus();
  164. }
  165. function money() {
  166. var FoundErrors = '';
  167. var entermoney  =prompt(text_enter_money,"1000");
  168. if (!entermoney) {
  169. FoundErrors += "n" + error_no_money;
  170. }
  171. if (FoundErrors) {
  172. alert("错误!"+FoundErrors);
  173. return;
  174. }
  175. var ToAdd = "[Money="+entermoney+"][/Money]";
  176. document.frmAnnounce.Content.value+=ToAdd;
  177. document.frmAnnounce.Content.focus();
  178. }
  179. function usemoney() {
  180. var FoundErrors = '';
  181. var entermoney  =prompt(text_enter_usemoney,"1000");
  182. if (!entermoney) {
  183. FoundErrors += "n" + error_no_usemoney;
  184. }
  185. if (FoundErrors) {
  186. alert("错误!"+FoundErrors);
  187. return;
  188. }
  189. var ToAdd = "[UseMoney="+entermoney+"][/UseMoney]";
  190. document.frmAnnounce.Content.value+=ToAdd;
  191. document.frmAnnounce.Content.focus();
  192. }
  193. function usercp() {
  194. var FoundErrors = '';
  195. var enterusercp  =prompt(text_enter_usercp,"1000");
  196. if (!enterusercp) {
  197. FoundErrors += "n" + error_no_usercp;
  198. }
  199. if (FoundErrors) {
  200. alert("错误!"+FoundErrors);
  201. return;
  202. }
  203. var ToAdd = "[UserCP="+enterusercp+"][/UserCP]";
  204. document.frmAnnounce.Content.value+=ToAdd;
  205. document.frmAnnounce.Content.focus();
  206. }
  207. function power() {
  208. var FoundErrors = '';
  209. var enterpower  =prompt(text_enter_power,"1000");
  210. if (!enterpower) {
  211. FoundErrors += "n" + error_no_power;
  212. }
  213. if (FoundErrors) {
  214. alert("错误!"+FoundErrors);
  215. return;
  216. }
  217. var ToAdd = "[Power="+enterpower+"][/Power]";
  218. document.frmAnnounce.Content.value+=ToAdd;
  219. document.frmAnnounce.Content.focus();
  220. }
  221. function article() {
  222. var FoundErrors = '';
  223. var enterpost  =prompt(text_enter_post,"1000");
  224. if (!enterpost) {
  225. FoundErrors += "n" + error_no_post;
  226. }
  227. if (FoundErrors) {
  228. alert("错误!"+FoundErrors);
  229. return;
  230. }
  231. var ToAdd = "[Post="+enterpost+"][/Post]";
  232. document.frmAnnounce.Content.value+=ToAdd;
  233. document.frmAnnounce.Content.focus();
  234. }
  235. function replyview() {
  236. var ToAdd = "[replyview][/replyview]";
  237. document.frmAnnounce.Content.value+=ToAdd;
  238. document.frmAnnounce.Content.focus();
  239. }
  240. function Csound() {
  241. var FoundErrors = '';
  242. var enterURL   = prompt(text_enter_sound, "http://");
  243. if (!enterURL) {
  244. FoundErrors += "n" + error_no_url;
  245. }
  246. if (FoundErrors) {
  247. alert("错误!"+FoundErrors);
  248. return;
  249. }
  250. var ToAdd = "[SOUND]"+enterURL+"[/SOUND]";
  251. document.frmAnnounce.Content.value+=ToAdd;
  252. document.frmAnnounce.Content.focus();
  253. }
  254. helpstat = false;
  255. stprompt = true;
  256. basic = false;
  257. function thelp(swtch){
  258. if (swtch == 1){
  259. basic = false;
  260. stprompt = false;
  261. helpstat = true;
  262. } else if (swtch == 0) {
  263. helpstat = false;
  264. stprompt = false;
  265. basic = true;
  266. } else if (swtch == 2) {
  267. helpstat = false;
  268. basic = false;
  269. stprompt = true;
  270. }
  271. }
  272. function Cswf() {
  273.   if (helpstat){
  274. alert("FlashnFlash 动画.n用法: [flash=宽度, 高度]Flash 文件的地址[/flash]");
  275. } else if (basic) {
  276. AddTxt="[flash=500,350][/flash]";
  277. AddText(AddTxt);
  278. } else {                  
  279. txt2=prompt("flash宽度,高度","500,350"); 
  280. if (txt2!=null) {
  281.                 txt=prompt("Flash 文件的地址","http://");
  282. if (txt!=null) {
  283.                           if (txt2=="") {             
  284. AddTxt="[flash=500,350]"+txt;
  285. AddText(AddTxt);
  286. AddTxt="[/flash]";
  287. AddText(AddTxt);
  288.                } else {
  289.         AddTxt="[flash="+txt2+"]"+txt;
  290. AddText(AddTxt);
  291. AddTxt="[/flash]";
  292. AddText(AddTxt);
  293.  }        
  294.     }  
  295.        }
  296.     }
  297. }
  298. function Crm() {
  299. if (helpstat) {
  300.                alert("realplayn播放realplay文件.n用法: [rm=宽度, 高度]文件地址[/rm]");
  301. } else if (basic) {
  302. AddTxt="[rm=500,350][/rm]";
  303. AddText(AddTxt);
  304. } else { 
  305. txt2=prompt("视频的宽度,高度","500,350"); 
  306. if (txt2!=null) {
  307. txt=prompt("视频文件的地址","请输入");
  308. if (txt!=null) {
  309. if (txt2=="") {
  310. AddTxt="[rm=500,350]"+txt;
  311. AddText(AddTxt);
  312. AddTxt="[/rm]";
  313. AddText(AddTxt);
  314. } else {
  315. AddTxt="[rm="+txt2+"]"+txt;
  316. AddText(AddTxt);
  317. AddTxt="[/rm]";
  318. AddText(AddTxt);
  319. }         
  320. }
  321. }
  322. }
  323. function Cwmv() {
  324. if (helpstat) {
  325.                alert("Media Playern播放Media Player文件.n用法: [mp=宽度, 高度]文件地址[/mp]");
  326. } else if (basic) {
  327. AddTxt="[mp=500,350][/mp]";
  328. AddText(AddTxt);
  329. } else { 
  330. txt2=prompt("视频的宽度,高度","500,350"); 
  331. if (txt2!=null) {
  332. txt=prompt("视频文件的地址","请输入");
  333. if (txt!=null) {
  334. if (txt2=="") {
  335. AddTxt="[mp=500,350]"+txt;
  336. AddText(AddTxt);
  337. AddTxt="[/mp]";
  338. AddText(AddTxt);
  339. } else {
  340. AddTxt="[mp="+txt2+"]"+txt;
  341. AddText(AddTxt);
  342. AddTxt="[/mp]";
  343. AddText(AddTxt);
  344. }         
  345. }
  346. }
  347. }
  348. function Cmov() {
  349. if (helpstat) {
  350.                alert("QuickTimen播放QuickTime文件.n用法: [qt=宽度, 高度]文件地址[/qt]");
  351. } else if (basic) {
  352. AddTxt="[qt=500,350][/qt]";
  353. AddText(AddTxt);
  354. } else { 
  355. txt2=prompt("视频的宽度,高度","500,350"); 
  356. if (txt2!=null) {
  357. txt=prompt("视频文件的地址","请输入");
  358. if (txt!=null) {
  359. if (txt2=="") {
  360. AddTxt="[qt=500,350]"+txt;
  361. AddText(AddTxt);
  362. AddTxt="[/qt]";
  363. AddText(AddTxt);
  364. } else {
  365. AddTxt="[qt="+txt2+"]"+txt;
  366. AddText(AddTxt);
  367. AddTxt="[/qt]";
  368. AddText(AddTxt);
  369. }         
  370. }
  371. }
  372. }
  373. function Cdir() {
  374. if (helpstat) {
  375.                alert("Shockwaven插入Shockwave文件.n用法: [dir=宽度, 高度]文件地址[/dir]");
  376. } else if (basic) {
  377. AddTxt="[dir=500,350][/dir]";
  378. AddText(AddTxt);
  379. } else { 
  380. txt2=prompt("Shockwave文件的宽度,高度","500,350"); 
  381. if (txt2!=null) {
  382. txt=prompt("Shockwave文件的地址","请输入地址");
  383. if (txt!=null) {
  384. if (txt2=="") {
  385. AddTxt="[dir=500,350]"+txt;
  386. AddText(AddTxt);
  387. AddTxt="[/dir]";
  388. AddText(AddTxt);
  389. } else {
  390. AddTxt="[dir="+txt2+"]"+txt;
  391. AddText(AddTxt);
  392. AddTxt="[/dir]";
  393. AddText(AddTxt);
  394. }         
  395. }
  396. }
  397. }
  398. function Cra() {
  399. var FoundErrors = '';
  400. var enterURL   = prompt(text_enter_ra, "http://");
  401. if (!enterURL) {
  402. FoundErrors += "n" + error_no_url;
  403. }
  404. if (FoundErrors) {
  405. alert("错误!"+FoundErrors);
  406. return;
  407. }
  408. var ToAdd = "[RA]"+enterURL+"[/RA]";
  409. document.frmAnnounce.Content.value+=ToAdd;
  410. document.frmAnnounce.Content.focus();
  411. }
  412. function Cfanzi() {
  413. fontbegin="[xray]";
  414. fontend="[/xray]";
  415. fontchuli();
  416. }
  417. function Cwma() {
  418. var FoundErrors = '';
  419. var enterURL   = prompt(text_enter_wma, "http://");
  420. if (!enterURL) {
  421. FoundErrors += "n" + error_no_url;
  422. }
  423. if (FoundErrors) {
  424. alert("错误!"+FoundErrors);
  425. return;
  426. }
  427. var ToAdd = "[wma]"+enterURL+"[/wma]";
  428. document.frmAnnounce.Content.value+=ToAdd;
  429. document.frmAnnounce.Content.focus();
  430. }
  431. function Cmarquee() {
  432. fontbegin="[move]";
  433. fontend="[/move]";
  434. fontchuli();
  435. }
  436. function Cfly() {
  437. fontbegin="[fly]";
  438. fontend="[/fly]";
  439. fontchuli();
  440. }
  441. function paste(text) {
  442. if (opener.document.frmAnnounce.Content.createTextRange && opener.document.frmAnnounce.Content.caretPos) {      
  443. var caretPos = opener.document.frmAnnounce.Content.caretPos;      
  444. caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
  445. text + ' ' : text;
  446. }
  447. else opener.document.frmAnnounce.Content.value += text;
  448. opener.document.frmAnnounce.Content.focus(caretPos);
  449. }
  450. function showsize(size){
  451. fontbegin="[size="+size+"]";
  452. fontend="[/size]";
  453. fontchuli();
  454. }
  455. function showfont(font){
  456. fontbegin="[face="+font+"]";
  457. fontend="[/face]";
  458. fontchuli();
  459. }
  460. function showcolor(color){
  461. fontbegin="[color="+color+"]";
  462. fontend="[/color]";
  463. fontchuli();
  464. }
  465. function fontchuli(){
  466. if ((document.selection)&&(document.selection.type == "Text")) {
  467. var range = document.selection.createRange();
  468. var ch_text=range.text;
  469. range.text = fontbegin + ch_text + fontend;
  470. else {
  471. document.frmAnnounce.Content.value=fontbegin+document.frmAnnounce.Content.value+fontend;
  472. document.frmAnnounce.Content.focus();
  473. }
  474. }
  475. function Cguang() {
  476. var FoundErrors = '';
  477. var enterSET   = prompt(text_enter_guang1, "255,red,2");
  478. var enterTxT   = prompt(text_enter_guang2, "文字");
  479. if (!enterSET)    {
  480. FoundErrors += "n" + error_no_gset;
  481. }
  482. if (!enterTxT)    {
  483. FoundErrors += "n" + error_no_gtxt;
  484. }
  485. if (FoundErrors)  {
  486. alert("错误!"+FoundErrors);
  487. return;
  488. }
  489. var ToAdd = "[glow="+enterSET+"]"+enterTxT+"[/glow]";
  490. document.frmAnnounce.Content.value+=ToAdd;
  491. document.frmAnnounce.Content.focus();
  492. }
  493. function Cying() {
  494. var FoundErrors = '';
  495. var enterSET   = prompt(text_enter_guang1, "255,blue,1");
  496. var enterTxT   = prompt(text_enter_guang2, "文字");
  497. if (!enterSET)    {
  498. FoundErrors += "n" + error_no_gset;
  499. }
  500. if (!enterTxT)    {
  501. FoundErrors += "n" + error_no_gtxt;
  502. }
  503. if (FoundErrors)  {
  504. alert("错误!"+FoundErrors);
  505. return;
  506. }
  507. var ToAdd = "[SHADOW="+enterSET+"]"+enterTxT+"[/SHADOW]";
  508. document.frmAnnounce.Content.value+=ToAdd;
  509. document.frmAnnounce.Content.focus();
  510. }
  511. ie = (document.all)? true:false
  512. if (ie){
  513. function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.frmAnnounce.submit();}}
  514. }
  515. function DoTitle(addTitle) { 
  516. var revisedTitle; 
  517. var currentTitle = document.frmAnnounce.subject.value; 
  518. revisedTitle = currentTitle+addTitle; 
  519. document.frmAnnounce.subject.value=revisedTitle; 
  520. document.frmAnnounce.subject.focus(); 
  521. return; }
  522. function insertsmilie(smilieface){
  523. document.frmAnnounce.Content.value+=smilieface;
  524. }
  525. function gopreview()
  526. {
  527. document.forms[1].title.value=document.forms[0].subject.value;
  528. document.forms[1].body.value=document.forms[0].Content.value;
  529. var popupWin = window.open('preview.asp', 'preview_page', 'scrollbars=yes,width=750,height=450');
  530. document.forms[1].submit()
  531. }