vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Code Requests & Support :: Mini-Profile code (modification) - View Topic
Topic Rating: *****
Printable View
Aiken
Full Member
***

[Avatar]

Posts: 333
Status: Offline
Gender: Male
Location: In a very lonely place, the domain of despair
Age: 34
Joined:  
Reputation: 12%  


pmtwitterskypemsnyahooxfire
Mini-Profile code (modification) (16th Jan 10 at 5:15am UTC)
Resolved - Needs fixed
Was (worked):
Code:
 
  1. <script type="text/javascript">
  2.  
  3. function Token(Tokens){
  4.  
  5. var Tokens = parseInt(Tokens.replace(/[^0-9]/gi, ''));
  6.  
  7. var TokenPost = '';
  8. var TokenMod = 0;
  9.  
  10. if(Tokens >= 10000){
  11.  
  12. TokenMod = parseInt(Tokens/10000);
  13.  
  14. TokenPost += '<img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token_Platinum.gif"> ' + TokenMod + ' Platinum Token';
  15.  
  16. if(TokenMod != 1){
  17. TokenPost += 's';
  18. }
  19.  
  20. } else if(Tokens >= 500){
  21.  
  22. TokenMod = parseInt(Tokens/500);
  23.  
  24. TokenPost = '<img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token_Gold.gif"> ' + TokenMod + ' Gold Token';
  25.  
  26. if(TokenMod != 1){
  27. TokenPost += 's';
  28. }
  29.  
  30. TokenPost += '<br>';
  31.  
  32. } else if(Tokens >= 20){
  33.  
  34. TokenMod = parseInt(Tokens/20);
  35.  
  36. TokenPost = '<img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token_Silver.gif"> ' + TokenMod + ' Silver Token';
  37.  
  38. if(TokenMod != 1){
  39. TokenPost += 's';
  40. }
  41.  
  42. } else {
  43.  
  44. TokenMod = Tokens
  45.  
  46. TokenPost = '<img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token.gif"> ' +  TokenMod + ' Copper Token';
  47.  
  48. if(TokenMod != 1){
  49. TokenPost += 's';
  50. }
  51.  
  52. }
  53.  
  54. return TokenPost;
  55.  
  56. }
  57.  
  58. </script>
 


Now (doesn't work):
Code:
 
  1. <script type="text/javascript">
  2.  
  3. function Token(Tokens){
  4.  
  5. var Tokens = parseInt(Tokens.replace(/[^0-9]/gi, ''));
  6.  
  7. var TokenPost = '';
  8. var TokenMod = 0;
  9. var TokenMod20 = 0;
  10. var TokenMod500 = 0;
  11. var TokenMod2500 = 0;
  12.  
  13. while(Tokens >= 2500){
  14. Tokens -= 2500;
  15. ++TokenMod2500
  16. }
  17.  
  18. TokenPost += '<img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token_Platinum.gif"> ' + TokenMod2500 + ' Platinum Token';
  19.  
  20. if(TokenMod2500 != 1){
  21. TokenPost += 's';
  22. }
  23.  
  24. while(Tokens >= 500){
  25. Tokens -= 500;
  26. ++TokenMod500
  27. }
  28.  
  29. TokenPost += '<br><img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token_Gold.gif"> ' + TokenMod500 + ' Gold Token';
  30.  
  31. if(TokenMod500 != 1){
  32. TokenPost += 's';
  33. }
  34.  
  35. while(Tokens >= 20){
  36. Tokens -= 20;
  37. ++TokenMod20
  38. }
  39.  
  40. TokenPost += '<br><img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token_Silver.gif"> ' + TokenMod20 + ' Silver Token';
  41.  
  42. if(TokenMod20 != 1){
  43. TokenPost += 's';
  44. }
  45.  
  46. TokenMod = Tokens;
  47.  
  48. TokenPost += '<br><img src="http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/TFAH_Token.gif"> ' +  TokenMod + ' Copper Token';
  49.  
  50. if(TokenMod != 1){
  51. TokenPost += 's';
  52. }
  53.  
  54. return TokenPost;
  55.  
  56. }
  57.  
  58. </script>
 


The new version won't display anything

Displays the currency Tokens as Copper Tokens, Silver Tokens, Gold Tokens, and Platinum Tokens

Working version just shows the amount of the highest available type
New version supposed to show all types and their amount
I want to only show types of the highest available type and below

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
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Mini-Profile code (modification) (16th Jan 10 at 11:48pm UTC)
<script type="text/javascript">
function Token(Tokens){
     var numbers = [
          ["http://i266.photobucket.com/albums/ii280/Ryuzaki_Master/"], //Root Image Directory
          ["Platinum", "2500", "TFAH_Token_Platinum.gif"],
          ["Gold", "500", "TFAH_Token_Gold.gif"],
          ["Silver", "20", "TFAH_Token_Silver.gif"],
          ["Copper", "1", "TFAH_Token.gif"]
     ];
     var out = '';
     for(i = 1; i < numbers.length; i++){
          var temp = 0;
          while(Tokens >= numbers[i][1]){
               Tokens -= numbers[i][1];
               temp++;
          }
          out += '<img src = "' + numbers[0] + numbers[i][2] + '" />' + temp + ' ' + numbers[i][0] + ' Token' + (temp != 1? 's' : '') + '<br />';
     }
     return out;
}

document.write(Token(3021));
document.write('<br />' + Token(1234));
</script>


{Smile}

Try that. I've included the
document.write
at the bottom for you.
Aiken
Full Member
***

[Avatar]

Posts: 333
Status: Offline
Gender: Male
Location: In a very lonely place, the domain of despair
Age: 34
Joined:  
Reputation: 12%  


pmtwitterskypemsnyahooxfire
Re: Mini-Profile code (modification) (17th Jan 10 at 12:18am UTC)
After a small modification to your code it worked, you forgot to add:

Code:
 
  1. var Tokens = parseInt(Tokens.replace(/[^0-9]/gi, ''));
 


at the top of the function

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
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Mini-Profile code (modification) (17th Jan 10 at 12:20am UTC)
That isn't needed! {Wink}
Aiken
Full Member
***

[Avatar]

Posts: 333
Status: Offline
Gender: Male
Location: In a very lonely place, the domain of despair
Age: 34
Joined:  
Reputation: 12%  


pmtwitterskypemsnyahooxfire
Re: Mini-Profile code (modification) (17th Jan 10 at 1:03am UTC)
Actually, it is needed for me.
With out it on my profile 55 Tokens displayed as 1 Platinum Token but now it is 2 Silver Tokens and 15 Copper Tokens

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
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Mini-Profile code (modification) (17th Jan 10 at 1:08am UTC)
Ok {Smile}
 Printable View

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