vForums Support > Programming & Coding :: Code Requests & Support :: > Need help with code on mini-profile template

Need help with code on mini-profile template - Posted By Aiken (ionfortuna) on 7th Dec 09 at 7:02pm
The only thing I see is what is in the div by default

Code:
 
  1. <div id="DyouPost">{custom_value_2} Dyou</div>
  2. <script>
  3.  
  4. var Dyou; DyouNum, DyouBox; DyouBox1K; DyouPost;
  5.  
  6. Dyou = {custom_value_2};
  7.  
  8. DyouNum = (Dyou)/10;
  9.  
  10. DyouPost = '<div style="text: #000000;">';
  11.  
  12. DyouBox1K = new Array()
  13.  
  14. var n = -1;
  15.  
  16. if(DyouNum > 1000)
  17. {
  18. DyouPost = '<div style="height: 8px; width: 100px; background-color: #C0C000; float: left; margin: 1px;">10000+ Dyou</div>';
  19. } else {
  20.  
  21. if(DyouNum >= 100)
  22. {
  23. while(DyouNum >= 100)
  24. {
  25.  
  26. DyouBox1K[n++] = '<div style="height: 8px; width: 8px; background-color: #FFFF00; float: left; margin: 1px;">1K</div>';
  27. DyouNum -= 100;
  28.  
  29. }
  30. }
  31.  
  32. DyouBox = '<div style="height: 8px; width: ' + DyouNum + 'px; background-color: #FFFF00; float: left; margin: 1px;">' + DyouNum + ' Dyou</div>';
  33.  
  34. if(DyouBox1K.length > 0)
  35. {
  36. for(i = 0; i <= DyouBox1k.length; i++)
  37. {
  38.  
  39. DyouPost += DyouBox1K[i];
  40.  
  41. }
  42.  
  43. DyouPost += "<br>";
  44.  
  45. }
  46.  
  47. DyouPost += DyouBox;
  48.  
  49. }
  50.  
  51. DyouPost += "</div>
  52.  
  53. document.getElementById("DyouPost") = DyouPost;
  54.  
  55. </script>
  56.  
 



Re: Need help with code on mini-profile template - Posted By Ross (admin) on 7th Dec 09 at 10:46pm
Hi,

Can you post the link to your forum so I can check how that custom field is setup? You can PM it if you prefer {Smile}

Re: Need help with code on mini-profile template - Posted By Aiken (ionfortuna) on 8th Dec 09 at 3:54am
http://xenqarnarp.vforums.co.uk/

Re: Need help with code on mini-profile template - Posted By Ross (admin) on 8th Dec 09 at 6:16pm
Hi,

There were a couple of little errors in the javascript which were stopping it from working. Things like:

DyouBox1K = new Array();

DyouPost += "</div>";

document.getElementById("DyouPost").innerHTML = DyouPost;

I have fixed them on your forum for you {Smile}

Re: Need help with code on mini-profile template - Posted By Aiken (ionfortuna) on 11th Dec 09 at 5:22pm
I see there is a problem with the code, in a thread only the profile on the top seems to be using the code

I written up a alternate code for this using the headers and footers, I just don't know how to use it in the template so that all profiles in a thread will use it

Here is the code for Global Header:

Code:
 
  1. <script>
  2.  
  3. function Dyou(dyou){
  4.  
  5. var Dyou; DyouMil; DyouPost;
  6.  
  7. Dyou = dyou
  8.  
  9. if(DyouNum > 1000000){
  10.  
  11. while(DyouNum > 1000000){
  12. ++DyouMil
  13. DyouNum -= 1000000;
  14.  
  15. DyouPost = '<div style="height: 20px; width: 30px; color: #000000; background-color: #C0C000; float: right; margin: 1px;">' + DyouMil + ' Mil</div>';
  16. DyouPost += '<div style="height: 20px; width: 70px; color: #000000; background-color: #FFFF00; float: right; margin: 1px;">' + Dyou + ' Dyou</div>';
  17.  
  18. } else {
  19.  
  20. DyouPost = '<div style="height: 20px; width: 100px; color: #000000; background-color: #FFFF00; float: right; margin: 1px;">' + Dyou + ' Dyou</div>';
  21.  
  22. }
  23.  
  24. return DyouPost;
  25.  
  26. }
  27.  
  28. </script>
 


This one might work better

Re: Need help with code on mini-profile template - Posted By Ross (admin) on 11th Dec 09 at 10:41pm
Hi,

I've updated your mini-profile template so it writes out the result of that Dyou function (although I had to fix a few errors in it). The most up-to-date Dyou function is now in your Global Header. I was unsure how you were hoping it to display but expect you can tweak it as needed now it is setup {Smile}

Re: Need help with code on mini-profile template - Posted By Aiken (ionfortuna) on 12th Dec 09 at 6:53pm
I still seem to have a slight problem when I change the number in the additional information, when I change it from 185 to 1850000 it displays as 1850

Re: Need help with code on mini-profile template - Posted By Ross (admin) on 13th Dec 09 at 12:59am
Hi,

When a numeric custom field is greater than 1000 it adds commas (eg. 1,850,000). These were confusing the script. I've fixed that now {Smile}

Re: Need help with code on mini-profile template - Posted By Aiken (ionfortuna) on 13th Dec 09 at 6:04pm
I made a modification to my code and because of what you did it works just the way I want it to, I made it so there is a maximum value

Re: Need help with code on mini-profile template - Posted By Aiken (ionfortuna) on 13th Dec 09 at 7:01pm
What is this for?

Code:
 
  1. <br style="clear: both;" />