|
1
|
|
|
/** global: trainerName */ |
|
2
|
|
|
|
|
3
|
|
|
$(function () { |
|
4
|
|
|
|
|
5
|
|
|
$.getJSON( "core/json/variables.json", function( jsondata ) { |
|
6
|
|
|
var pokeimg_suffix=jsondata['system']['pokeimg_suffix']; |
|
7
|
|
|
var iv_numbers=jsondata['system']['iv_numbers']; |
|
8
|
|
|
|
|
9
|
|
|
$('.trainerLoader').hide(); |
|
10
|
|
|
var page = 0; |
|
11
|
|
|
var teamSelector=0; //0=all;1=Blue;2=Red;3=Yellow |
|
12
|
|
|
var rankingFilter=0; //0=Level & Gyms; 1=Level; 2=Gyms |
|
13
|
|
|
|
|
14
|
|
|
$('input#name').filter(':visible').val(trainerName); |
|
15
|
|
|
loadTrainers(page,$('input#name').filter(':visible').val(),null,null,pokeimg_suffix,true,iv_numbers); |
|
16
|
|
|
|
|
17
|
|
|
page++; |
|
18
|
|
|
$('#loadMoreButton').click(function () { |
|
19
|
|
|
|
|
20
|
|
|
loadTrainers(page,$('input#name').filter(':visible').val(),teamSelector,rankingFilter,pokeimg_suffix,true,iv_numbers); |
|
21
|
|
|
page++; |
|
22
|
|
|
}); |
|
23
|
|
|
$("#searchTrainer").submit(function ( event ) { |
|
24
|
|
|
page = 0; |
|
25
|
|
|
$('input#name').filter(':visible').val()!=''?$('#trainersGraph').hide():$('#trainersGraph').show(); |
|
26
|
|
|
$('#trainersContainer tr:not(.trainersTemplate)').remove(); |
|
27
|
|
|
loadTrainers(page,$('input#name').filter(':visible').val(),teamSelector,rankingFilter,pokeimg_suffix,true,iv_numbers); |
|
28
|
|
|
page++; |
|
29
|
|
|
event.preventDefault(); |
|
30
|
|
|
}); |
|
31
|
|
|
$(".teamSelectorItems").click(function ( event ) { |
|
32
|
|
|
switch ($(this).attr("id")) { |
|
33
|
|
|
case "AllTeamsFilter": |
|
34
|
|
|
teamSelector=0; |
|
35
|
|
|
break; |
|
36
|
|
|
case "BlueTeamFilter": |
|
37
|
|
|
teamSelector=1; |
|
38
|
|
|
break; |
|
39
|
|
|
case "RedTeamFilter": |
|
40
|
|
|
teamSelector=2; |
|
41
|
|
|
break; |
|
42
|
|
|
case "YellowFilter": |
|
43
|
|
|
teamSelector=3; |
|
44
|
|
|
break; |
|
45
|
|
|
default: |
|
46
|
|
|
teamSelector=0; |
|
47
|
|
|
} |
|
48
|
|
|
$("#teamSelectorText").html($(this).html()); |
|
49
|
|
|
event.preventDefault(); |
|
50
|
|
|
$("#searchTrainer").submit(); |
|
51
|
|
|
|
|
52
|
|
|
}); |
|
53
|
|
|
$(".rankingOrderItems").click(function ( event ) { |
|
54
|
|
|
switch ($(this).attr("id")) { |
|
55
|
|
|
case "levelsFirst": |
|
56
|
|
|
rankingFilter=0; |
|
57
|
|
|
break; |
|
58
|
|
|
case "gymsFirst": |
|
59
|
|
|
rankingFilter=1; |
|
60
|
|
|
break; |
|
61
|
|
|
case "maxCpFirst": |
|
62
|
|
|
rankingFilter=2; |
|
63
|
|
|
break; |
|
64
|
|
|
default: |
|
65
|
|
|
rankingFilter=0; |
|
66
|
|
|
} |
|
67
|
|
|
$("#rankingOrderText").html($(this).html()); |
|
68
|
|
|
event.preventDefault(); |
|
69
|
|
|
$("#searchTrainer").submit(); |
|
70
|
|
|
|
|
71
|
|
|
}); |
|
72
|
|
|
window.onpopstate = function() { |
|
73
|
|
|
if (window.history.state && "Trainer" === window.history.state.page) { |
|
74
|
|
|
$('#trainersContainer').empty(); |
|
75
|
|
|
$('input#name').filter(':visible').val(window.history.state.name); |
|
76
|
|
|
loadTrainers(0,$('input#name').filter(':visible').val(),teamSelector,rankingFilter,pokeimg_suffix,false,iv_numbers); |
|
77
|
|
|
} |
|
78
|
|
|
else{ |
|
79
|
|
|
window.history.back(); |
|
80
|
|
|
} |
|
81
|
|
|
}; |
|
82
|
|
|
|
|
83
|
|
|
}); |
|
84
|
|
|
}); |
|
85
|
|
|
|
|
86
|
|
|
function loadTrainers(page,name,teamSelector,rankingFilter,pokeimg_suffix,stayOnPage,iv_numbers) { |
|
87
|
|
|
$('.trainerLoader').show(); |
|
88
|
|
|
|
|
89
|
|
|
if (stayOnPage) { |
|
90
|
|
|
// build a state for this name |
|
91
|
|
|
var state = {name: name, page: 'Trainer'}; |
|
92
|
|
|
window.history.pushState(state,'Trainer',"trainer?name="+name); |
|
93
|
|
|
} |
|
94
|
|
|
var trainerIndex = 0+(page*10); |
|
95
|
|
|
$.ajax({ |
|
96
|
|
|
'async': true, |
|
97
|
|
|
'type': "GET", |
|
98
|
|
|
'global': false, |
|
99
|
|
|
'dataType': 'json', |
|
100
|
|
|
'url': "core/process/aru.php", |
|
101
|
|
|
'data': { |
|
102
|
|
|
'request': "", |
|
103
|
|
|
'target': 'arrange_url', |
|
104
|
|
|
'method': 'method_target', |
|
105
|
|
|
'type' : 'trainer', |
|
106
|
|
|
'page' : page, |
|
107
|
|
|
'name' : name, |
|
108
|
|
|
'team' : teamSelector, |
|
109
|
|
|
'ranking' :rankingFilter |
|
110
|
|
|
} |
|
111
|
|
|
}).done(function (data) { |
|
112
|
|
|
var internalIndex = 0; |
|
113
|
|
|
$.each(data.trainers, function (trainerName, trainer) { |
|
114
|
|
|
trainerIndex++; |
|
115
|
|
|
internalIndex++ |
|
116
|
|
|
printTrainer(trainer, trainerIndex,pokeimg_suffix,iv_numbers, data.locale); |
|
117
|
|
|
}); |
|
118
|
|
|
if(internalIndex < 10){ |
|
119
|
|
|
$('#loadMoreButton').hide(); |
|
120
|
|
|
} |
|
121
|
|
|
else{ |
|
122
|
|
|
$('#loadMoreButton').removeClass('hidden'); |
|
123
|
|
|
$('#loadMoreButton').show(); |
|
124
|
|
|
} |
|
125
|
|
|
$('.trainerLoader').hide(); |
|
126
|
|
|
}); |
|
127
|
|
|
}; |
|
128
|
|
|
|
|
129
|
|
|
|
|
130
|
|
|
|
|
131
|
|
|
function printTrainer(trainer, trainerIndex,pokeimg_suffix,iv_numbers, locale) { |
|
132
|
|
|
var trainersInfos = $('<tr>',{id: 'trainerInfos_'+trainer.name}).css('border-bottom','2px solid '+(trainer.team=="3"?"#ffbe08":trainer.team=="2"?"#ff7676":"#00aaff")); |
|
133
|
|
|
trainersInfos.append($('<td>',{id : 'trainerIndex_'+trainer.name, text : trainerIndex})); |
|
134
|
|
|
trainersInfos.append($('<td>',{id : 'trainerRank_'+trainer.name, text : trainer.rank})); |
|
135
|
|
|
trainersInfos.append($('<td>',{id : 'trainerName_'+trainer.name}).append($('<a>',{href: 'trainer?name='+trainer.name, text: trainer.name})).click( |
|
136
|
|
|
function (e) { |
|
137
|
|
|
e.preventDefault(); |
|
138
|
|
|
$('input#name').filter(':visible').val(trainer.name); |
|
139
|
|
|
$("#searchTrainer").submit(); |
|
140
|
|
|
$('#trainerName_'+trainer.name).off('click'); |
|
141
|
|
|
} |
|
142
|
|
|
)); |
|
143
|
|
|
trainersInfos.append($('<td>',{id : 'trainerLevel_'+trainer.name, text : trainer.level})); |
|
144
|
|
|
trainersInfos.append($('<td>',{id : 'trainerGyms_'+trainer.name, text : trainer.gyms})); |
|
145
|
|
|
trainersInfos.append($('<td>',{id : 'trainerLastSeen_'+trainer.name, text : trainer.last_seen})); |
|
146
|
|
|
$('#trainersContainer').append(trainersInfos); |
|
147
|
|
|
var trainersPokemonsRow = $('<tr>',{id: 'trainerPokemons_'+trainer.name}); |
|
148
|
|
|
var trainersPokemons = $('<td>',{colspan : 6}); |
|
149
|
|
|
var trainersPokemonsContainer = $('<div>',{class : ""}); |
|
150
|
|
|
for (var pokeIndex = 0; pokeIndex<trainer.pokemons.length; pokeIndex++) { |
|
151
|
|
|
var pokemon = trainer.pokemons[pokeIndex]; |
|
152
|
|
|
trainersPokemonsContainer.append(printPokemon(pokemon,pokeimg_suffix,iv_numbers, locale)); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
trainersPokemons.append(trainersPokemonsContainer); |
|
156
|
|
|
trainersPokemonsRow.append(trainersPokemons); |
|
157
|
|
|
$('#trainersContainer').append(trainersPokemonsRow); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
function printPokemon(pokemon,pokeimg_suffix,iv_numbers,locale){ |
|
161
|
|
|
var trainerPokemon = $('<div>',{id : 'trainerPokemon_'+pokemon.pokemon_uid, class: "col-md-1 col-xs-4 pokemon-single", style: "text-align: center" }); |
|
162
|
|
|
var gymClass = ""; |
|
163
|
|
|
if ((pokemon.gym_id===null)) { |
|
164
|
|
|
gymClass = "unseen"; |
|
165
|
|
|
} |
|
166
|
|
|
trainerPokemon.append( |
|
167
|
|
|
$('<a>', |
|
168
|
|
|
{href : 'pokemon/'+pokemon.pokemon_id} |
|
169
|
|
|
).append($('<img />', |
|
170
|
|
|
{ src : 'core/pokemons/'+pokemon.pokemon_id+pokeimg_suffix, |
|
171
|
|
|
'class' : 'img-responsive '+gymClass |
|
172
|
|
|
}) |
|
173
|
|
|
) |
|
174
|
|
|
); |
|
175
|
|
|
trainerPokemon.append($('<p>',{class : 'pkmn-name'}).append(pokemon.cp)); |
|
176
|
|
|
var progressBar |
|
177
|
|
|
if (iv_numbers) { |
|
178
|
|
|
progressBar = $('<div>',{class : 'progress'}).css({'height': '15px','margin-bottom': '0'}); |
|
179
|
|
|
progressBar.append( |
|
180
|
|
|
$('<div>', |
|
181
|
|
|
{ |
|
182
|
|
|
title: locale.ivAttack+' :'+pokemon.iv_attack, |
|
183
|
|
|
class: 'progress-bar progress-bar-danger' , |
|
184
|
|
|
role : 'progressbar', |
|
185
|
|
|
text : pokemon.iv_attack, |
|
186
|
|
|
'aria-valuenow' : pokemon.iv_attack, |
|
187
|
|
|
'aria-valuemin' : 0, |
|
188
|
|
|
'aria-valuemax' : 45 |
|
189
|
|
|
}).css({'width':(100/3) + '%','line-height': '16px'})) |
|
190
|
|
|
progressBar.append( |
|
191
|
|
|
$('<div>', |
|
192
|
|
|
{ |
|
193
|
|
|
title: locale.ivDefense+' :'+pokemon.iv_defense, |
|
194
|
|
|
class: 'progress-bar progress-bar-info' , |
|
195
|
|
|
role : 'progressbar', |
|
196
|
|
|
text : pokemon.iv_defense, |
|
197
|
|
|
'aria-valuenow': pokemon.iv_defense, |
|
198
|
|
|
'aria-valuemin' : 0, |
|
199
|
|
|
'aria-valuemax' : 45 |
|
200
|
|
|
}).css({'width':(100/3) + '%','line-height': '16px'})) |
|
201
|
|
|
progressBar.append( |
|
202
|
|
|
$('<div>', |
|
203
|
|
|
{ |
|
204
|
|
|
title: locale.ivStamina+' :'+pokemon.iv_stamina, |
|
205
|
|
|
class: 'progress-bar progress-bar-success' , |
|
206
|
|
|
role : 'progressbar', |
|
207
|
|
|
text : pokemon.iv_stamina, |
|
208
|
|
|
'aria-valuenow' :pokemon.iv_stamina, |
|
209
|
|
|
'aria-valuemin' : 0, |
|
210
|
|
|
'aria-valuemax' : 45 |
|
211
|
|
|
}).css({'width':(100/3) + '%','line-height': '16px'})) |
|
212
|
|
|
} else { |
|
213
|
|
|
progressBar = $('<div>',{class : 'progress'}).css({'height': '6px','margin-bottom': '0'}); |
|
214
|
|
|
progressBar.append( |
|
215
|
|
|
$('<div>', |
|
216
|
|
|
{ |
|
217
|
|
|
title: locale.ivAttack+' :'+pokemon.iv_attack, |
|
218
|
|
|
class: 'progress-bar progress-bar-danger' , |
|
219
|
|
|
role : 'progressbar', |
|
220
|
|
|
'aria-valuenow' : pokemon.iv_attack, |
|
221
|
|
|
'aria-valuemin' : 0, |
|
222
|
|
|
'aria-valuemax' : 45 |
|
223
|
|
|
}).css('width',((100/45)*pokemon.iv_attack ) + '%')) |
|
224
|
|
|
progressBar.append( |
|
225
|
|
|
$('<div>', |
|
226
|
|
|
{ |
|
227
|
|
|
title: locale.ivDefense+' :'+pokemon.iv_defense, |
|
228
|
|
|
class: 'progress-bar progress-bar-info' , |
|
229
|
|
|
role : 'progressbar', |
|
230
|
|
|
'aria-valuenow': pokemon.iv_defense, |
|
231
|
|
|
'aria-valuemin' : 0, |
|
232
|
|
|
'aria-valuemax' : 45 |
|
233
|
|
|
}).css('width',((100/45)*pokemon.iv_defense ) + '%')) |
|
234
|
|
|
progressBar.append( |
|
235
|
|
|
$('<div>', |
|
236
|
|
|
{ |
|
237
|
|
|
title: locale.ivStamina+' :'+pokemon.iv_stamina, |
|
238
|
|
|
class: 'progress-bar progress-bar-success' , |
|
239
|
|
|
role : 'progressbar', |
|
240
|
|
|
'aria-valuenow' :pokemon.iv_stamina, |
|
241
|
|
|
'aria-valuemin' : 0, |
|
242
|
|
|
'aria-valuemax' : 45 |
|
243
|
|
|
}).css('width',((100/45)*pokemon.iv_stamina ) + '%')) |
|
244
|
|
|
} |
|
245
|
|
|
trainerPokemon.append(progressBar); |
|
246
|
|
|
|
|
247
|
|
|
var cpm_arr={1:.09399999678134918,1.5:.1351374313235283,2:.16639786958694458,2.5:.1926509141921997,3:.21573247015476227,3.5:.23657265305519104,4:.2557200491428375,4.5:.27353037893772125,5:.29024988412857056,5.5:.3060573786497116,6:.3210875988006592,6.5:.33544503152370453,7:.3492126762866974,7.5:.362457737326622,8:.37523558735847473,8.5:.38759241108516856,9:.39956727623939514,9.5:.4111935495172506,10:.4225000143051148,10.5:.4329264134104144,11:.443107545375824,11.5:.4530599538719858,12:.46279838681221,12.5:.4723360780626535,13:.4816849529743195,13.5:.4908558102324605,14:.4998584389686584,14.5:.5087017565965652,15:.517393946647644,15.5:.5259425118565559,16:.5343543291091919,16.5:.5426357612013817,17:.5507926940917969,17.5:.5588305993005633,18:.5667545199394226,18.5:.574569147080183,19:.5822789072990417,19.5:.5898879119195044,20:.5974000096321106,20.5:.6048236563801765,21:.6121572852134705,21.5:.6194041110575199,22:.6265671253204346,22.5:.633649181574583,23:.6406529545783997,23.5:.6475809663534164,24:.654435634613037,24.5:.6612192690372467,25:.667934000492096,25.5:.6745819002389908,26:.6811649203300476,26.5:.6876849085092545,27:.6941436529159546,27.5:.7005428969860077,28:.7068842053413391,28.5:.7131690979003906,29:.719399094581604,29.5:.7255756109952927,30:.7317000031471252,30.5:.7347410172224045,31:.7377694845199585,31.5:.740785576403141,32:.7437894344329834,32.5:.7467812150716782,33:.74976104,33.5:.752729104,34:.75568551,34.5:.75863037,35:.76156384,35.5:.76448607,36:.76739717,36.5:.77029727,37:.7731865,37.5:.77606494,38:.77893275,38.5:.78179006,39:.78463697,39.5:.78747358,40:.79030001,40.5:.7931164}; |
|
248
|
|
|
|
|
249
|
|
|
// assume some super high level |
|
250
|
|
|
pokemon_level = 50; |
|
|
|
|
|
|
251
|
|
|
$.each(cpm_arr, function(lvl, cpm) { |
|
252
|
|
|
if (pokemon.cp_multiplier <= cpm) { |
|
253
|
|
|
pokemon_level = pokemon_level > lvl ? lvl : pokemon_level; |
|
|
|
|
|
|
254
|
|
|
} |
|
255
|
|
|
}); |
|
256
|
|
|
|
|
257
|
|
|
pokemon_level = Number(pokemon_level) + Number(pokemon.num_upgrades)/2; |
|
258
|
|
|
pokemon_level = pokemon_level.toString(); |
|
259
|
|
|
|
|
260
|
|
|
trainerPokemon.append($('<small>').append("L" + " " + pokemon_level)); |
|
261
|
|
|
trainerPokemon.append($('<br>').append()); |
|
262
|
|
|
|
|
263
|
|
|
if (pokemon.last_scanned === '0') { |
|
264
|
|
|
trainerPokemon.append($('<small>',{text: locale.today})); |
|
265
|
|
|
} |
|
266
|
|
|
else if (pokemon.last_scanned === '1') { |
|
267
|
|
|
trainerPokemon.append($('<small>',{text: pokemon.last_scanned + " " + locale.day})); |
|
268
|
|
|
} |
|
269
|
|
|
else { |
|
270
|
|
|
trainerPokemon.append($('<small>',{text: pokemon.last_scanned + " " + locale.days})); |
|
271
|
|
|
} |
|
272
|
|
|
return trainerPokemon; |
|
273
|
|
|
} |
|
274
|
|
|
|