vForums Support > Programming & Coding :: Code Requests & Support :: > Progress bar for posting ranks

Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 26th Apr 10 at 4:58pm
Global Header:
Code:
 
  1. <script>
  2.  
  3. function PostLevel(Posts){
  4.  
  5. if(vf_username != 'guest' && GroupCheck(0)){
  6.  
  7. Posts = parseInt(Posts)
  8. var PPost = ''
  9.  
  10. var PostList = []
  11. PostList[0] = [0,1];
  12. PostList[1] = [1,5];
  13. PostList[2] = [5,250];
  14. PostList[3] = [250,250];
  15.  
  16. for(i = PostList.length; i >= 0; i--){
  17.  
  18. if(Posts > PostsList[i][0]){
  19.  
  20. var PostPer = (Posts/PostList[i][1])*100
  21.  
  22. if(PostPer > 100){
  23. PostPer = 100
  24. }
  25.  
  26. PostPer = (PostPer * 2)-4
  27.  
  28. PPost = '<tr><td class="window2" colspan="2"><div style="width:98px; height:18px; background-color:000;"><div style="float:left; width:' + PostPer + 'px; height:16px; background-color:FF0;"></div></div></td></tr>';
  29.  
  30. document.write(PPost);
  31.  
  32. }
  33.  
  34. }
  35.  
  36. }
  37.  
  38. }
  39.  
  40. </script>
 


Mini-Profile template:
Code:
 
  1. <script>
  2. PostLevel({posts});
  3. </script>
 


It is not being displayed at all

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 5:11pm
Do you have a link to a profile with this on so that I can see the rest of the coding please? {Smile}

Re: Progress bar for posting ranks - Posted By Nick (nickb) on 26th Apr 10 at 6:39pm
Doesn't work for me either.

http://dmtesting.vforums.co.uk/action/view_profile/admin

I put it under the post count table, so it should be directly underneath the post count, but it's not.

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 6:55pm
Darkmage... the reason I asked for a link is because he is using other predefined functions within his coding that you don't have defined. {Smile}

Re: Progress bar for posting ranks - Posted By Nick (nickb) on 26th Apr 10 at 6:56pm
Oh I see. {Tongue Out} Well it still doesn't work on mine. >.<

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 26th Apr 10 at 7:14pm
Here's one: http://tfah.vforums.us/profile/eunie

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 9:03pm
This line:
if(Posts > PostsList[­i][0]){
PostsList is undefined
I think you mean "PostList"


Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 26th Apr 10 at 9:39pm
I fixed that but it still isn't working

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 10:18pm
Change your for loop to:
for(i = PostList.length-1; i >= 0; i--){

Also add a break; statement to the end of your if statement.

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 26th Apr 10 at 10:21pm
I did that, still not showing

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 10:33pm
Unfortunately being a guest I can't test it exactly. Can you remove the first line (and the corresponding closing brace) from your code that sets it so that only guests can see it ... then I can test it further for you ... I have it on my test forum, and it worked fine... :/

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 26th Apr 10 at 10:35pm
I think I might have coded that part wrong O.o

I took it off but the div's in the code aren't there but the tr and td are

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 10:36pm
That could be the bit that's 'causing to not work. Is there any reason that you don't want to show it to the Guests?

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 26th Apr 10 at 10:38pm
That isn't what I was trying to do, my mistake

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 10:52pm
Does it work now?

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 26th Apr 10 at 11:10pm
Only half of the output is working, the tr and td are there but I don't see the 2 div's

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 26th Apr 10 at 11:31pm
The Divs are being outputted... look into your html for the divs. {Smile}

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 27th Apr 10 at 1:11am
Then what is the problem?

Also I want it to work for only regular posting ranks and certain member groups

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 27th Apr 10 at 1:24am
Well why don't you tell me what you want it to do, and I will then code it up for you {Smile}

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 27th Apr 10 at 1:51am
It is a bar that appears below the post count as a progress bar to the next posting rank

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 27th Apr 10 at 3:54am
Global Header:
<script type = 'text/javascript'>
/* Post bar to next rank - Wrighty */
var r = [0, 20, 50, 100, 250, 500];

function postBar(x){
     for(i = r.length-1; i >= 0; i--)
          if(x >= r[i]){
               document.write('<tr><td class="window2" colspan="2"><div style="width:98px; height:18px; background-color:#000;"><div style="float:left; width:' + ((x-r[i])/(r[i+1]-r[i]))*98 + 'px; height:16px; background-color:#FF0;"></div></div></td></tr>');
               break;
          }
}
</script>


Alter the red to be a list of the number of posts for each rank, making sure that they are incrementing {Smile}

In Mini Profile Template:
<script type = 'text/javascript'>
postBar({posts});
</script>


Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 27th Apr 10 at 4:43am
It's not showing up at all

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 27th Apr 10 at 4:51am
I updated my code in my previous post, (the first section only), please recopy.

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 27th Apr 10 at 5:27am
I see a problem with your code, you are missing a pair of braces for the for()

But even fixing that problem it still isn't working

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 27th Apr 10 at 10:26pm
the for doesn't require them. Try adding quotes around the digits .... eg:

"5", "10", "50" etc...

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 27th Apr 10 at 10:36pm
Nope, still not working

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 27th Apr 10 at 10:50pm
The code works flawlessly on my forum (as posted in my last post)... you have this in your headers:

<script>SetDisLink(Guest);</script>

(might be in the Welcome Table Template) .. remove it, as it's returning an errror.

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 27th Apr 10 at 11:12pm
I removed that but the code still isn't working

Re: Progress bar for posting ranks - Posted By Michael (wrighty) on 27th Apr 10 at 11:14pm
Is it at the bottom of your global header?

Re: Progress bar for posting ranks - Posted By Aiken (ionfortuna) on 27th Apr 10 at 11:56pm
Yeah