SMF For Free Support Forum
Signup For Free Forum
August 30, 2008, 10:41:00 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to SMF For Free. The best free SMF Host
 
   Home   Help Search Arcade Gallery Login Register  

Pages: [1]
  Print  
Author Topic: [Code] Custom BBC  (Read 287 times)
0 Members and 1 Guest are viewing this topic.
Celebrus
SMF For Free Hero
*
Offline Offline

Posts: 745


Previously known as Omikron


View Profile WWW
« 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:
<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.
Logged



Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
ServerBeach Coupon
Page created in 0.157 seconds with 16 queries.