vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Code Requests & Support :: (Marc) Simple Fix Plz! - View Topic
Topic Rating: *****
Printable View
dog199200
Guest
(Marc) Simple Fix Plz! (7th Feb 09 at 12:36pm UTC)
Resolved
Ok umm can I please get this code fixed:

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. //Spoiler Script
  4. //Written by Dranew
  5. //Do not rip or claim as your own.
  6.  
  7. if(location.href.match(/view_topic/)) {
  8.   var post = get('td','tag');
  9.   var sid = 0;
  10.   for(a=0;a<post.length;a++) {
  11.     if(post[a].className == "post") {
  12.       post[a].innerHTML = post[a].innerHTML.replace(/\[spoiler\]/g, "<div id='spoiler'>").replace(/\[\/spoiler\]/g, "</div>");
  13.     }
  14.   }
  15.   for(b=0;b<post.length;b++) {
  16.     if(post[b].className == "post") {
  17.       var div = post[b].getElementsByTagName('div')
  18.       for(c=0;c<div.length;c++) {
  19.         if(div[c].id == "spoiler") {
  20.           var spoil = div[c].innerHTML
  21.           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>";
  22.           sid++
  23.         }
  24.       }
  25.     }
  26.   }
  27.   function dispSpoil(ID) {
  28.     var spoilText = document.getElementById("s"+ID)
  29.     var spoilLabel = document.getElementById("sl"+ID)
  30.     spoilLabel.innerHTML = (spoilLabel.innerHTML == "Open Spoiler")? 'Close Spoiler' : 'Open Spoiler';
  31.     spoilText.style.display = (spoilText.style.display == "none")? '' : 'none';
  32.   }
  33. }
  34. var icon = 'http://i25.photobucket.com/albums/c51/dog199200/Digimon/spoiltag.png'
  35. var testid = 'Spoiler'
  36.  
  37. function qrbuild(){
  38.     _a = document.createElement('a');
  39.     _a.href = testid;
  40.     _a.onclick = function(){add_ubbc('[spoiler]','[/spoiler]');};
  41.     _a.style.cssText = "cursor: pointer;";
  42.     _a.appendChild(_i);
  43. }
  44. function build(){
  45.     var _i = document.createElement('img');
  46.     _i.src = icon;
  47.     _i.style.border='0';
  48.     _a = document.createElement('a');
  49.     _a.onclick = function(){add_ubbc('[spoiler]','[/spoiler]');};
  50.     _a.style.cssText = "cursor: pointer;";
  51.     _a.appendChild(_i);
  52. }
  53.  
  54. if(get('ubbc_buttons','id')){
  55.     build();
  56.     get('ubbc_buttons','id').firstChild.insertBefore(_a, get('ubbc_buttons','id').firstChild.lastChild);
  57. }
  58. if(get('quick_reply_ubbc','id')){
  59.     qrbuild();
  60.     get('quick_reply_ubbc','id').childNodes[1].appendChild(_a);
  61. }
  62. //-->
  63. </script>
 


It works great and all but I did some moding to it from its original coding and added a UBBC button, well the buttons shows up on the second row of the UBBC buttons when I want it to how in the first row, can you please fix {Smile} i've tried. Anyways here is the part of that code that needs fixed to help clean out the mess of a code above:

Code:
 
  1. var icon = 'http://i25.photobucket.com/albums/c51/dog199200/Digimon/spoiltag.png'
  2. var testid = 'Spoiler'
  3.  
  4. function qrbuild(){
  5.     _a = document.createElement('a');
  6.     _a.href = testid;
  7.     _a.onclick = function(){add_ubbc('[spoiler]','[/spoiler]');};
  8.     _a.style.cssText = "cursor: pointer;";
  9.     _a.appendChild(_i);
  10. }
  11. function build(){
  12.     var _i = document.createElement('img');
  13.     _i.src = icon;
  14.     _i.style.border='0';
  15.     _a = document.createElement('a');
  16.     _a.onclick = function(){add_ubbc('[spoiler]','[/spoiler]');};
  17.     _a.style.cssText = "cursor: pointer;";
  18.     _a.appendChild(_i);
  19. }
  20.  
  21. if(get('ubbc_buttons','id')){
  22.     build();
  23.     get('ubbc_buttons','id').firstChild.insertBefore(_a, get('ubbc_buttons','id').firstChild.lastChild);
  24. }
  25. if(get('quick_reply_ubbc','id')){
  26.     qrbuild();
  27.     get('quick_reply_ubbc','id').childNodes[1].appendChild(_a);
  28. }
 


That all controls the adding of the button and where its place, so on and so forth..

Thanks in advance {Smile}
dog199200
Guest
Re: (Marc) Simple Fix Plz! (8th Feb 09 at 6:22pm UTC)
bump, come on please it should be simple.. i'm just stupid and can't figure it out...
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: (Marc) Simple Fix Plz! (12th Feb 09 at 12:23am UTC)
Try changing:

get('ubbc_buttons','id').firstChild.insertBefore(_a, get('ubbc_buttons','id').firstChild.lastChild);

to:

get('ubbc_buttons','id').firstChild.insertBefore(_a, get('ubbc_buttons','id').firstChild.getElementsByTagName('br')[0]);

{Smile}
dog199200
Guest
Re: (Marc) Simple Fix Plz! (12th Feb 09 at 12:30am UTC)
that worked, thank you wrighty
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: (Marc) Simple Fix Plz! (12th Feb 09 at 12:30am UTC)
Welcome dude! {Smile}
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,012
Status: Offline
Gender: Male
Location: vForums
Age: 34
Joined:  
Reputation: 62%  


pmwww
Re: (Marc) Simple Fix Plz! (12th Feb 09 at 11:07pm UTC)
o_O Wrighty?

You rejoined?

Oh yeah your name is Michael. {Tongue Out} {Cheesy}
 Printable View

All times are GMT+0 :: The current time is 6:18am
Page generated in 0.495 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums