Advertisement
Guest User

Love AB Extension

a guest
Aug 29th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calc() {
  2.  
  3. first = document.loveform.name1.value.toUpperCase();
  4. firstlength = document.loveform.name1.value.length;
  5. second = document.loveform.name2.value.toUpperCase();
  6. secondlength = document.loveform.name2.value.length;
  7. var LoveCount=0;
  8.  
  9. for (Count=0; Count < firstlength; Count++) {
  10. letter1=first.substring(Count,Count+1);
  11. if (letter1=='L') LoveCount+=2;
  12. if (letter1=='O') LoveCount+=2;
  13. if (letter1=='V') LoveCount+=2;
  14. if (letter1=='E') LoveCount+=2;
  15. if (letter1=='Y') LoveCount+=3;
  16. if (letter1=='O') LoveCount+=1;
  17. if (letter1=='U') LoveCount+=3;
  18. }
  19.  
  20. for (Count=0; Count < secondlength; Count++) {
  21. letter2=second.substring(Count,Count+1);
  22. if (letter2=='L') LoveCount+=2;
  23. if (letter2=='O') LoveCount+=2;
  24. if (letter2=='V') LoveCount+=2;
  25. if (letter2=='E') LoveCount+=2;
  26. if (letter2=='Y') LoveCount+=3;
  27. if (letter2=='O') LoveCount+=1;
  28. if (letter2=='U') LoveCount+=3;
  29. }
  30.  
  31. amount=0;
  32. if (LoveCount> 0) amount= 5-((firstlength+secondlength)/2)
  33. if (LoveCount> 2) amount= 10-((firstlength+secondlength)/2)
  34. if (LoveCount> 4) amount= 20-((firstlength+secondlength)/2)
  35. if (LoveCount> 6) amount= 30-((firstlength+secondlength)/2)
  36. if (LoveCount> 8) amount= 40-((firstlength+secondlength)/2)
  37. if (LoveCount>10) amount= 50-((firstlength+secondlength)/2)
  38. if (LoveCount>12) amount= 60-((firstlength+secondlength)/2)
  39. if (LoveCount>14) amount= 70-((firstlength+secondlength)/2)
  40. if (LoveCount>16) amount= 80-((firstlength+secondlength)/2)
  41. if (LoveCount>18) amount= 90-((firstlength+secondlength)/2)
  42. if (LoveCount>20) amount=100-((firstlength+secondlength)/2)
  43. if (LoveCount>22) amount=110-((firstlength+secondlength)/2)
  44.  
  45. if (firstlength==0 || secondlength==0) amount= "Err";
  46. if (amount < 0) amount= 0;
  47. if (amount >99) amount=99;
  48.  
  49. document.loveform.output.value=amount+"%";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement