vForums Support :: Programming & Coding :: Code Requests & Support :: Custom UBBC - Simple Version - View Topic
 |  |
| Aiken Full Member
  
![[Avatar]](http://uploads.virtualforums.co.uk/forums/support/me-yat.jpeg) Posts: 330 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 20 Joined:
pmskypemsnyahooxfire | | Custom UBBC - Simple Version (4th Mar 10 at 12:43pm EST) | |  Code: - <script>
-
- function CustomUBBC(code){
-
- code = code.replace(/\[anime\](.+?)\[\/anime\]/gi,'<center>' + RegExp.$1 + '</center>');
-
- document.write(code);
-
- }
-
- CustomUBBC('[anime]Naruto[/anime]');
-
- </script>
The way it is right now is to just try to get the replacement to work, right now when I use this code it displays as http at the location it is used at
Later I want 2 functions: The first will be used for posts as [anime]Anime Title[/anime] and any other Custom UBBC I want, The second will directly refer to the 2nd function in the global h/f where I want it to display
Note: The <center></center> in the replacement code is just for testing, it will be different later when it is working and I figure out how I want it, I just want to figure out the core of the function first | |
vF forums: Perfect World RP BLEACH Universe - Under Construction / Testing Phase Xen Qarna RP - Stage I Vyren Entar Battle Network RP - Under Construction / Maintenance Mode Enabled the Final Anime Hideout |
| Broken Senior Member
   
![[Avatar]](http://i25.photobucket.com/albums/c51/dog199200/Dont%20removm/brokenavi.png) Lost Resolve Posts: 1,741 Status: Offline Gender: Male Age: 18 Joined:
pmskypemsnyahooaim | | Re: Custom UBBC - Simple Version (4th Mar 10 at 1:24pm EST) | | | yo be 100% honestly, after ross redid the system a while back, i don't think it can actually be added onto anymore, i always got an error of some kind when i tried, BUT maybe michael or marc can help you out, i'm just saying i'm not sure if its 100% possible anymore | |
If you fall I’ll catch, if you love I’ll love, And so it goes, my dear, don’t be scared, you’ll be safe, This I swear. If you only love me back.
 |
| Aiken Full Member
  
![[Avatar]](http://uploads.virtualforums.co.uk/forums/support/me-yat.jpeg) Posts: 330 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 20 Joined:
pmskypemsnyahooxfire | | Broken Senior Member
   
![[Avatar]](http://i25.photobucket.com/albums/c51/dog199200/Dont%20removm/brokenavi.png) Lost Resolve Posts: 1,741 Status: Offline Gender: Male Age: 18 Joined:
pmskypemsnyahooaim | | Re: Custom UBBC - Simple Version (4th Mar 10 at 7:34pm EST) | | umm ok give me a second, if your going to do it like that, that I have a code for you to look at and i'm sure you can figure it out from there
This is a modified version of the spoiler script, i added in a few things, and at the bottom is the code to add a button. I'm sure you can see how it is done and get a better idea on how to revise your script. I'd rewrite your code to make it work, but as we both know my JS sucks, i dont use it enough.
 Code: - <script type="text/javascript">
- <!--
- //Spoiler Script
- //Written by Dranew
- //Do not rip or claim as your own.
-
- if(location.href.match(/view_topic/)) {
- var post = get('td','tag');
- var sid = 0;
- for(a=0;a<post.length;a++) {
- if(post[a].className == "post") {
- post[a].innerHTML = post[a].innerHTML.replace(/\[spoiler\]/g, "<div id='spoiler'>").replace(/\[\/spoiler\]/g, "</div>");
- }
- }
- for(b=0;b<post.length;b++) {
- if(post[b].className == "post") {
- var div = post[b].getElementsByTagName('div')
- for(c=0;c<div.length;c++) {
- if(div[c].id == "spoiler") {
- var spoil = div[c].innerHTML
- div[c].innerHTML = "<center><span class='header' style='width: 498px; height: 20px;'></span><span class='head' style='width: 496px;'><center><a href='javascript:dispSpoil("+sid+")' id='sl"+sid+"'>Open Spoiler</a></center></span><span class=' window1 text' style='display: none; width: 496px;' id='s"+sid+"'>"+spoil+"</span><span class='base' style='width: 498px; height: 20px;'></span></center>";
- sid++
- }
- }
- }
- }
- function dispSpoil(ID) {
- var spoilText = document.getElementById("s"+ID)
- var spoilLabel = document.getElementById("sl"+ID)
- spoilLabel.innerHTML = (spoilLabel.innerHTML == "Open Spoiler")? 'Close Spoiler' : 'Open Spoiler';
- spoilText.style.display = (spoilText.style.display == "none")? '' : 'none';
- }
- }
- var icon = 'http://i25.photobucket.com/albums/c51/dog199200/Digimon/spoiltag.png'
- var testid = 'Spoiler'
-
- function qrbuild(){
- _a = document.createElement('a');
- _a.href = testid;
- _a.onclick = function(){add_ubbc('[spoiler]','[/spoiler]');};
- _a.style.cssText = "cursor: pointer;";
- _a.appendChild(_i);
- }
- function build(){
- var _i = document.createElement('img');
- _i.src = icon;
- _i.style.border='0';
- _a = document.createElement('a');
- _a.onclick = function(){add_ubbc('[spoiler]','[/spoiler]');};
- _a.style.cssText = "cursor: pointer;";
- _a.appendChild(_i);
- }
-
- if(get('ubbc_buttons','id')){
- build();
- get('ubbc_buttons','id').firstChild.insertBefore(_a, get('ubbc_buttons','id').firstChild.getElementsByTagName('br')[0]);
- }
- if(get('quick_reply_ubbc','id')){
- qrbuild();
- get('quick_reply_ubbc','id').childNodes[1].appendChild(_a);
- }
- //-->
- </script>
Keep in mind the input system did work before ross change the messaging system, so with that said if separating out the functions to work with the templating system, it should work.
edit: actually i think something like this would be closer to what you wan't:
 Code: - <script>
- function CustomUBBC(anime){
- _a = document.createElement('a');
- _a.onclick = function(){add_ubbc('[anime]','[/anime]');};
- _a.style.cssText = "cursor: pointer;";
- }
-
- CustomUBBC(anime);
-
- }
- </script>
That should just create the function, you'd have to edit it yourself and make a few adjustments. | |
If you fall I’ll catch, if you love I’ll love, And so it goes, my dear, don’t be scared, you’ll be safe, This I swear. If you only love me back.
 |
| Aiken Full Member
  
![[Avatar]](http://uploads.virtualforums.co.uk/forums/support/me-yat.jpeg) Posts: 330 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 20 Joined:
pmskypemsnyahooxfire | | |
 |  |
|