vForums Support :: Programming & Coding :: Code Requests & Support :: (Marc) Simple Fix Plz! - View Topic
| |
| dog199200 Guest | (Marc) Simple Fix Plz! (7th Feb 09 at 12:36pm UTC) Resolved | | Ok umm can I please get this code fixed:
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.lastChild);
- }
- if(get('quick_reply_ubbc','id')){
- qrbuild();
- get('quick_reply_ubbc','id').childNodes[1].appendChild(_a);
- }
- //-->
- </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 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: - 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.lastChild);
- }
- if(get('quick_reply_ubbc','id')){
- qrbuild();
- get('quick_reply_ubbc','id').childNodes[1].appendChild(_a);
- }
That all controls the adding of the button and where its place, so on and so forth..
Thanks in advance | |
| 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
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | 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]);
| |
| dog199200 Guest | Re: (Marc) Simple Fix Plz! (12th Feb 09 at 12:30am UTC) | | that worked, thank you wrighty | |
| Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: (Marc) Simple Fix Plz! (12th Feb 09 at 12:30am UTC) | | Welcome dude! | |
| Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: (Marc) Simple Fix Plz! (12th Feb 09 at 11:07pm UTC) | | o_O Wrighty?
You rejoined?
Oh yeah your name is Michael. | |
| |
| |
|