Page 1 of 1

how to make your own bbcodes?

Posted: Tue Feb 28, 2012 1:50 am
by Ark
Hello everyone wanted to ask if anyone got any experience with bbcodes. Where exactly do you download the source? And besides that how can you make like your own bbcode: for example like if you're sending a message to another player in the game and in your message you put [player] arigato23 [/player]

And when the other player recieves that message their html would be <a href="('arigato's profile.php')">arigato23</a>

yeah I know I would have to query if the player exists and all that, but how to know when it's surrounded by the [player][/player] ...

Oh also how like what would be the javascript(if that's the one) to do when you highlight a section of a text and then press the B button for example and then it puts the [ b][/b] around that highlighted text.

regards to everyone! :D

Re: how to make your own bbcodes?

Posted: Tue Feb 28, 2012 9:34 am
by Chris

Re: how to make your own bbcodes?

Posted: Wed Feb 29, 2012 12:30 am
by Jackolantern
Cool! Very concise code, too. I had wondered before how to do this, but I am not a whiz with regular expressions.

Re: how to make your own bbcodes?

Posted: Wed Feb 29, 2012 12:33 am
by Ark
Yeah Thanks Chris, i´d also figured out the javascript part. As it's not in that link ill post the js function here:

Code: Select all

function SelectedText(){
    var t = '';
    if(window.getSelection){
            t = window.getSelection();
    }else if(document.getSelection){
            t = document.getSelection();
    }else if(document.selection){
            t = document.selection.createRange().text;
    }
    return t;
}