| Conditions | 1 |
| Paths | 2 |
| Total Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | $(function () { |
||
| 2 | $.getJSON( "core/json/variables.json", function( jsondata ) { |
||
| 3 | var pokeimg_suffix=jsondata['system']['pokeimg_suffix']; |
||
| 4 | |||
| 5 | $('.trainerLoader').hide(); |
||
| 6 | var page = 0; |
||
| 7 | var teamSelector=0; //0=all;1=Blue;2=Red;3=Yellow |
||
| 8 | var rankingFilter=0; //0=Level & Gyms; 1=Level; 2=Gyms |
||
| 9 | |||
| 10 | loadTrainers(page,null,null,null,pokeimg_suffix); |
||
| 11 | page++; |
||
| 12 | var win = $(window); |
||
| 13 | win.scroll(function () { |
||
| 14 | // End of the document reached? |
||
| 15 | if ($(document).height() - win.height() == win.scrollTop()) { |
||
| 16 | loadTrainers(page,$('input#name').val(),teamSelector,rankingFilter,pokeimg_suffix); |
||
| 17 | page++; |
||
| 18 | } |
||
| 19 | }); |
||
| 20 | $("#searchTrainer").submit(function ( event ) { |
||
| 21 | page = 0; |
||
| 22 | $('input#name').val()!=''?$('#trainersGraph').hide():$('#trainersGraph').show(); |
||
| 23 | $('#trainersContainer tr:not(.trainersTemplate)').remove(); |
||
| 24 | loadTrainers(page,$('input#name').val(),teamSelector,rankingFilter,pokeimg_suffix); |
||
| 25 | page++; |
||
| 26 | event.preventDefault(); |
||
| 27 | }); |
||
| 28 | $(".teamSelectorItems").click(function ( event ) { |
||
| 29 | switch ($(this).attr("id")) { |
||
| 30 | case "AllTeamsFilter": |
||
| 31 | teamSelector=0; |
||
| 32 | break; |
||
| 33 | case "BlueTeamFilter": |
||
| 34 | teamSelector=1; |
||
| 35 | break; |
||
| 36 | case "RedTeamFilter": |
||
| 37 | teamSelector=2; |
||
| 38 | break; |
||
| 39 | case "YellowFilter": |
||
| 40 | teamSelector=3; |
||
| 41 | break; |
||
| 42 | default: |
||
| 43 | teamSelector=0; |
||
| 44 | } |
||
| 45 | $("#teamSelectorText").html($(this).html()); |
||
| 46 | event.preventDefault(); |
||
| 47 | $("#searchTrainer").submit(); |
||
| 48 | |||
| 49 | }); |
||
| 50 | $(".rankingOrderItems").click(function ( event ) { |
||
| 51 | switch ($(this).attr("id")) { |
||
| 52 | case "levelsFirst": |
||
| 53 | rankingFilter=0; |
||
| 54 | break; |
||
| 55 | case "gymsFirst": |
||
| 56 | rankingFilter=1; |
||
| 57 | break; |
||
| 58 | case "maxCpFirst": |
||
| 59 | rankingFilter=2; |
||
| 60 | break; |
||
| 61 | default: |
||
| 62 | rankingFilter=0; |
||
| 63 | } |
||
| 64 | $("#rankingOrderText").html($(this).html()); |
||
| 65 | event.preventDefault(); |
||
| 66 | $("#searchTrainer").submit(); |
||
| 67 | |||
| 68 | }); |
||
| 69 | |||
| 70 | |||
| 71 | }); |
||
| 72 | }); |
||
| 188 | } |