Advertise Here

Author Topic: [Code] Custom BBC  (Read 1857 times)

0 Members and 1 Guest are viewing this topic.

Offline Celebrus

  • SMF For Free Hero
  • *
  • Posts: 941
    • View Profile
    • Vikhyat Korrapati

  • Total Badges: 16
    Badges: (View All)
    Topic Starter Combination Level 3 Level 2 Level 1
[Code] Custom BBC
« on: February 02, 2008, 05:09:19 am »
I thought I'd use plain old javascript for once. This doesn't even have a small piece of jQuery, and I am proud of that.

Preview

First the code. Put in headers:
Code: [Select]
<script>
function custombbc(BBC,HTML,CLOSING_BBC,CLOSING_HTML) {
//Created by Omikron 9861
b = document.getElementsByTagName("div");
var cbbc = new Array;
for(x=0;x<b.length;x++) {
if(b[x].className=="post" && b[x].innerHTML.match(BBC+"(.*)+"+CLOSING_BBC)) {
b[x].innerHTML = b[x].innerHTML.replace(BBC+RegExp.$1+CLOSING_BBC,HTML+RegExp.$1+CLOSING_HTML);
};};}
</script>
Leave that exactly as it is, there is nothing to edit there.




Then, in your footers:
Quote
<script>
custombbc('BBC','HTML','CLOSING BBC','CLOSING HTML');
</script>
You have to edit out the red part.
Replace these:
'BBC' :=====> 'The BBC the user has to enter, LIKE [XYZ]'
'HTML' :====> 'THE HTML TO REPLACE THE BBC ENTERED ABOVE WITH'
'CLOSING BBC' :=> 'THE CLOSING BBC, LIKE [/XYZ]'
'CLOSING HTML' :=> 'CLOSE ALL THE HTML TAGS THAT WERE OPENED IN THE HTML SECTION BEFORE THIS'

To add more custom BBC, add more of these lines in the footer code just before the </script> tag:
Quote
custombbc('BBC','HTML','CLOSING BBC','CLOSING HTML');

Note that it is not compulsory to use only HTML. In the preview, it replaces normal words with other normal words.

KNOWN LIMITATIONS:
If you use more than one BBC in a single post, the script stops responding.

 

Related Topics

  Subject / Started by Replies Last post
35 Replies
13981 Views
Last post November 30, 2009, 03:20:28 pm
by simply sibyl
6 Replies
2932 Views
Last post October 26, 2007, 09:56:15 pm
by trevix
3 Replies
1693 Views
Last post May 19, 2008, 08:45:44 pm
by Celebrus