Advertisement
Guest User

Please don't steal, only compact

a guest
Aug 12th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var max_points = 30
  2. var spent_points = 0
  3. var total_off = 0
  4. var total_def = 0
  5. var total_utl = 0
  6.  
  7. $('document').ready(function() {
  8.     $('table.masteries tr.p0 td:nth-child(1)')
  9.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  10.     $('table.masteries tr.p0 td:nth-child(2)')
  11.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  12.     $('table.masteries tr.p0 td:nth-child(3)')
  13.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  14.     $('table.masteries tr.p0 td:nth-child(4)')
  15.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  16.     $('table.masteries tr.p0 td:nth-child(5)')
  17.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  18.     $('table.masteries tr.p0 td:nth-child(6)')
  19.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  20.     $('table.masteries tr.p0 td:nth-child(7)')
  21.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  22.     $('table.masteries tr.p0 td:nth-child(8)')
  23.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  24.     $('table.masteries tr.p0 td:nth-child(9)')
  25.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  26.     $('table.masteries tr.p0 td:nth-child(10)')
  27.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  28.     $('table.masteries tr.p0 td:nth-child(11)')
  29.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  30.     $('table.masteries tr.p0 td:nth-child(12)')
  31.         .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  32.        
  33.     $('table.masteries tr.p0 td').on('click', function(){
  34.     if(spent_points < max_points) {
  35.         if(!this.i){
  36.             this.i = 0;
  37.         }
  38.         s = $(this).find('p').text()
  39.         current_max = parseInt(s.substr(s.length - 1))
  40.         if (
  41.             $(this).is($(':nth-child(1)'))
  42.             || $(this).is($(':nth-child(2)'))
  43.             || $(this).is($(':nth-child(3)'))
  44.             || $(this).is($(':nth-child(4)'))
  45.         ) {
  46.             if(this.i < current_max) {
  47.                 this.i = this.i+1
  48.                 total_off = total_off + 1
  49.                 spent_points = spent_points + 1
  50.                 $(this).find('span').text(this.i);
  51.                 $('span.offensive').text(total_off);
  52.                 $('span.spent').text(spent_points);
  53.             }
  54.             console.log(this.i);
  55.         } else if (
  56.             $(this).is($(':nth-child(5)'))
  57.             || $(this).is($(':nth-child(6)'))
  58.             || $(this).is($(':nth-child(7)'))
  59.             || $(this).is($(':nth-child(8)'))
  60.         ) {
  61.             if(this.i < current_max) {
  62.                 this.i = this.i+1
  63.                 total_def = total_def + 1
  64.                 spent_points = spent_points + 1
  65.                 $(this).find('span').text(this.i);
  66.                 $('span.defensive').text(total_def);
  67.                 $('span.spent').text(spent_points);
  68.             }
  69.             console.log(this.i);
  70.         } else if (
  71.             $(this).is($(':nth-child(9)'))
  72.             || $(this).is($(':nth-child(10)'))
  73.             || $(this).is($(':nth-child(11)'))
  74.             || $(this).is($(':nth-child(12)'))
  75.         ) {
  76.             if(this.i < current_max) {
  77.                 this.i = this.i+1
  78.                 total_utl = total_utl + 1
  79.                 spent_points = spent_points + 1
  80.                 $(this).find('span').text(this.i);
  81.                 $('span.utility').text(total_utl);
  82.                 $('span.spent').text(spent_points);
  83.             }
  84.             console.log(this.i);
  85.         }
  86.         if(total_off >= 4) {
  87.             $('table.masteries tr.p4 td:nth-child(1)')
  88.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  89.             $('table.masteries tr.p4 td:nth-child(2)')
  90.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  91.             $('table.masteries tr.p4 td:nth-child(3)')
  92.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  93.             $('table.masteries tr.p4 td:nth-child(4)')
  94.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  95.         }
  96.         if(total_def >= 4) {
  97.             $('table.masteries tr.p4 td:nth-child(5)')
  98.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  99.             $('table.masteries tr.p4 td:nth-child(6)')
  100.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  101.             $('table.masteries tr.p4 td:nth-child(8)')
  102.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  103.         }
  104.         if(total_utl >= 4) {
  105.             $('table.masteries tr.p4 td:nth-child(10)')
  106.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  107.             $('table.masteries tr.p4 td:nth-child(11)')
  108.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  109.             $('table.masteries tr.p4 td:nth-child(12)')
  110.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  111.         }
  112.     }});
  113.     $('table.masteries tr.p4 td').on('click', function(){
  114.     if(spent_points < max_points) {
  115.         if(!this.i){
  116.             this.i = 0;
  117.         }
  118.         s = $(this).find('p').text()
  119.         current_max = parseInt(s.substr(s.length - 1))
  120.         if (
  121.             $(this).is($(':nth-child(1)'))
  122.             || $(this).is($(':nth-child(2)'))
  123.             || $(this).is($(':nth-child(3)'))
  124.             || $(this).is($(':nth-child(4)'))
  125.         ) {
  126.             if(this.i < current_max) {
  127.                 this.i = this.i+1
  128.                 total_off = total_off + 1
  129.                 spent_points = spent_points + 1
  130.                 $(this).find('span').text(this.i);
  131.                 $('span.offensive').text(total_off);
  132.                 $('span.spent').text(spent_points);
  133.             }
  134.             console.log(this.i);
  135.         } else if (
  136.             $(this).is($(':nth-child(5)'))
  137.             || $(this).is($(':nth-child(6)'))
  138.             || $(this).is($(':nth-child(7)'))
  139.             || $(this).is($(':nth-child(8)'))
  140.         ) {
  141.             if(this.i < current_max) {
  142.                 this.i = this.i+1
  143.                 total_def = total_def + 1
  144.                 spent_points = spent_points + 1
  145.                 $(this).find('span').text(this.i);
  146.                 $('span.defensive').text(total_def);
  147.                 $('span.spent').text(spent_points);
  148.             }
  149.             console.log(this.i);
  150.         } else if (
  151.             $(this).is($(':nth-child(9)'))
  152.             || $(this).is($(':nth-child(10)'))
  153.             || $(this).is($(':nth-child(11)'))
  154.             || $(this).is($(':nth-child(12)'))
  155.         ) {
  156.             if(this.i < current_max) {
  157.                 this.i = this.i+1
  158.                 total_utl = total_utl + 1
  159.                 spent_points = spent_points + 1
  160.                 $(this).find('span').text(this.i);
  161.                 $('span.utility').text(total_utl);
  162.                 $('span.spent').text(spent_points);
  163.             }
  164.             console.log(this.i);
  165.         }
  166.         if(total_off >= 8) {
  167.             $('table.masteries tr.p8 td:nth-child(1)')
  168.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  169.             $('table.masteries tr.p8 td:nth-child(2)')
  170.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  171.             $('table.masteries tr.p8 td:nth-child(3)')
  172.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  173.             $('table.masteries tr.p8 td:nth-child(4)')
  174.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  175.         }
  176.         if(total_def >= 8) {
  177.             $('table.masteries tr.p8 td:nth-child(5)')
  178.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  179.             $('table.masteries tr.p8 td:nth-child(6)')
  180.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  181.             $('table.masteries tr.p8 td:nth-child(7)')
  182.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  183.             $('table.masteries tr.p8 td:nth-child(8)')
  184.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  185.         }
  186.         if(total_utl >= 8) {
  187.             $('table.masteries tr.p8 td:nth-child(9)')
  188.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  189.             $('table.masteries tr.p8 td:nth-child(10)')
  190.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  191.             $('table.masteries tr.p8 td:nth-child(11)')
  192.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  193.             $('table.masteries tr.p8 td:nth-child(12)')
  194.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  195.         }
  196.     }});
  197.     $('table.masteries tr.p8 td').on('click', function(){
  198.     if(spent_points < max_points) {
  199.         if(!this.i){
  200.             this.i = 0;
  201.         }
  202.         s = $(this).find('p').text()
  203.         current_max = parseInt(s.substr(s.length - 1))
  204.         if (
  205.             $(this).is($(':nth-child(1)'))
  206.             || $(this).is($(':nth-child(2)'))
  207.             || $(this).is($(':nth-child(3)'))
  208.             || $(this).is($(':nth-child(4)'))
  209.         ) {
  210.             if(this.i < current_max) {
  211.                 this.i = this.i+1
  212.                 total_off = total_off + 1
  213.                 spent_points = spent_points + 1
  214.                 $(this).find('span').text(this.i);
  215.                 $('span.offensive').text(total_off);
  216.                 $('span.spent').text(spent_points);
  217.             }
  218.             console.log(this.i);
  219.         } else if (
  220.             $(this).is($(':nth-child(5)'))
  221.             || $(this).is($(':nth-child(6)'))
  222.             || $(this).is($(':nth-child(7)'))
  223.             || $(this).is($(':nth-child(8)'))
  224.         ) {
  225.             if(this.i < current_max) {
  226.                 this.i = this.i+1
  227.                 total_def = total_def + 1
  228.                 spent_points = spent_points + 1
  229.                 $(this).find('span').text(this.i);
  230.                 $('span.defensive').text(total_def);
  231.                 $('span.spent').text(spent_points);
  232.             }
  233.             console.log(this.i);
  234.         } else if (
  235.             $(this).is($(':nth-child(9)'))
  236.             || $(this).is($(':nth-child(10)'))
  237.             || $(this).is($(':nth-child(11)'))
  238.             || $(this).is($(':nth-child(12)'))
  239.         ) {
  240.             if(this.i < current_max) {
  241.                 this.i = this.i+1
  242.                 total_utl = total_utl + 1
  243.                 spent_points = spent_points + 1
  244.                 $(this).find('span').text(this.i);
  245.                 $('span.utility').text(total_utl);
  246.                 $('span.spent').text(spent_points);
  247.             }
  248.             console.log(this.i);
  249.         }
  250.         if(total_off >= 12) {
  251.             $('table.masteries tr.p12 td:nth-child(1)')
  252.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  253.             $('table.masteries tr.p12 td:nth-child(2)')
  254.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  255.             $('table.masteries tr.p12 td:nth-child(3)')
  256.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  257.             $('table.masteries tr.p12 td:nth-child(4)')
  258.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  259.         }
  260.         if(total_def >= 12) {
  261.             $('table.masteries tr.p12 td:nth-child(5)')
  262.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  263.             $('table.masteries tr.p12 td:nth-child(6)')
  264.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  265.             $('table.masteries tr.p12 td:nth-child(7)')
  266.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  267.             $('table.masteries tr.p12 td:nth-child(8)')
  268.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  269.         }
  270.         if(total_utl >= 12) {
  271.             $('table.masteries tr.p12 td:nth-child(9)')
  272.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  273.             $('table.masteries tr.p12 td:nth-child(10)')
  274.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  275.             $('table.masteries tr.p12 td:nth-child(11)')
  276.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  277.             $('table.masteries tr.p12 td:nth-child(12)')
  278.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  279.         }
  280.     }});
  281.     $('table.masteries tr.p12 td').on('click', function(){
  282.     if(spent_points < max_points) {
  283.         if(!this.i){
  284.             this.i = 0;
  285.         }
  286.         s = $(this).find('p').text()
  287.         current_max = parseInt(s.substr(s.length - 1))
  288.         if (
  289.             $(this).is($(':nth-child(1)'))
  290.             || $(this).is($(':nth-child(2)'))
  291.             || $(this).is($(':nth-child(3)'))
  292.             || $(this).is($(':nth-child(4)'))
  293.         ) {
  294.             if(this.i < current_max) {
  295.                 this.i = this.i+1
  296.                 total_off = total_off + 1
  297.                 spent_points = spent_points + 1
  298.                 $(this).find('span').text(this.i);
  299.                 $('span.offensive').text(total_off);
  300.                 $('span.spent').text(spent_points);
  301.             }
  302.             console.log(this.i);
  303.         } else if (
  304.             $(this).is($(':nth-child(5)'))
  305.             || $(this).is($(':nth-child(6)'))
  306.             || $(this).is($(':nth-child(7)'))
  307.             || $(this).is($(':nth-child(8)'))
  308.         ) {
  309.             if(this.i < current_max) {
  310.                 this.i = this.i+1
  311.                 total_def = total_def + 1
  312.                 spent_points = spent_points + 1
  313.                 $(this).find('span').text(this.i);
  314.                 $('span.defensive').text(total_def);
  315.                 $('span.spent').text(spent_points);
  316.             }
  317.             console.log(this.i);
  318.         } else if (
  319.             $(this).is($(':nth-child(9)'))
  320.             || $(this).is($(':nth-child(10)'))
  321.             || $(this).is($(':nth-child(11)'))
  322.             || $(this).is($(':nth-child(12)'))
  323.         ) {
  324.             if(this.i < current_max) {
  325.                 this.i = this.i+1
  326.                 total_utl = total_utl + 1
  327.                 spent_points = spent_points + 1
  328.                 $(this).find('span').text(this.i);
  329.                 $('span.utility').text(total_utl);
  330.                 $('span.spent').text(spent_points);
  331.             }
  332.             console.log(this.i);
  333.         }
  334.         if(total_off >= 16) {
  335.             $('table.masteries tr.p16 td:nth-child(1)')
  336.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  337.             $('table.masteries tr.p16 td:nth-child(2)')
  338.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  339.             $('table.masteries tr.p16 td:nth-child(4)')
  340.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  341.         }
  342.         if(total_def >= 16) {
  343.             $('table.masteries tr.p16 td:nth-child(5)')
  344.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  345.             $('table.masteries tr.p16 td:nth-child(6)')
  346.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  347.             $('table.masteries tr.p16 td:nth-child(7)')
  348.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  349.         }
  350.         if(total_utl >= 16) {
  351.             $('table.masteries tr.p16 td:nth-child(10)')
  352.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  353.             $('table.masteries tr.p16 td:nth-child(11)')
  354.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  355.         }
  356.     }});
  357.     $('table.masteries tr.p16 td').on('click', function(){
  358.     if(spent_points < max_points) {
  359.         if(!this.i){
  360.             this.i = 0;
  361.         }
  362.         s = $(this).find('p').text()
  363.         current_max = parseInt(s.substr(s.length - 1))
  364.         if (
  365.             $(this).is($(':nth-child(1)'))
  366.             || $(this).is($(':nth-child(2)'))
  367.             || $(this).is($(':nth-child(4)'))
  368.         ) {
  369.             if(this.i < current_max) {
  370.                 this.i = this.i+1
  371.                 total_off = total_off + 1
  372.                 spent_points = spent_points + 1
  373.                 $(this).find('span').text(this.i);
  374.                 $('span.offensive').text(total_off);
  375.                 $('span.spent').text(spent_points);
  376.             }
  377.             console.log(this.i);
  378.         } else if (
  379.             $(this).is($(':nth-child(5)'))
  380.             || $(this).is($(':nth-child(6)'))
  381.             || $(this).is($(':nth-child(7)'))
  382.         ) {
  383.             if(this.i < current_max) {
  384.                 this.i = this.i+1
  385.                 total_def = total_def + 1
  386.                 spent_points = spent_points + 1
  387.                 $(this).find('span').text(this.i);
  388.                 $('span.defensive').text(total_def);
  389.                 $('span.spent').text(spent_points);
  390.             }
  391.             console.log(this.i);
  392.         } else if (
  393.             $(this).is($(':nth-child(10)'))
  394.             || $(this).is($(':nth-child(11)'))
  395.         ) {
  396.             if(this.i < current_max) {
  397.                 this.i = this.i+1
  398.                 total_utl = total_utl + 1
  399.                 spent_points = spent_points + 1
  400.                 $(this).find('span').text(this.i);
  401.                 $('span.utility').text(total_utl);
  402.                 $('span.spent').text(spent_points);
  403.             }
  404.             console.log(this.i);
  405.         }
  406.         if(total_off >= 20) {
  407.             $('table.masteries tr.p20 td:nth-child(2)')
  408.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  409.         }
  410.         if(total_def >= 20) {
  411.             $('table.masteries tr.p20 td:nth-child(6)')
  412.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  413.         }
  414.         if(total_utl >= 20) {
  415.             $('table.masteries tr.p20 td:nth-child(10)')
  416.                 .attr("style","background-image:url('./assets/masteries/mastery0.png')");
  417.         }
  418.     }});
  419.     $('table.masteries tr.p20 td').on('click', function(){
  420.     if(spent_points < max_points) {
  421.         if(!this.i){
  422.             this.i = 0;
  423.         }
  424.         s = $(this).find('p').text()
  425.         current_max = parseInt(s.substr(s.length - 1))
  426.         if ($(this).is($(':nth-child(2)'))) {
  427.             if(this.i < current_max) {
  428.                 this.i = this.i+1
  429.                 total_off = total_off + 1
  430.                 spent_points = spent_points + 1
  431.                 $(this).find('span').text(this.i);
  432.                 $('span.offensive').text(total_off);
  433.                 $('span.spent').text(spent_points);
  434.             }
  435.             console.log(this.i);
  436.         } else if ($(this).is($(':nth-child(6)'))) {
  437.             if(this.i < current_max) {
  438.                 this.i = this.i+1
  439.                 total_def = total_def + 1
  440.                 spent_points = spent_points + 1
  441.                 $(this).find('span').text(this.i);
  442.                 $('span.defensive').text(total_def);
  443.                 $('span.spent').text(spent_points);
  444.             }
  445.             console.log(this.i);
  446.         } else if ($(this).is($(':nth-child(10)'))) {
  447.             if(this.i < current_max) {
  448.                 this.i = this.i+1
  449.                 total_utl = total_utl + 1
  450.                 spent_points = spent_points + 1
  451.                 $(this).find('span').text(this.i);
  452.                 $('span.utility').text(total_utl);
  453.                 $('span.spent').text(spent_points);
  454.             }
  455.             console.log(this.i);
  456.         }
  457.     }});   
  458.    
  459. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement