-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
557 lines (479 loc) · 26.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
<html>
<head>
<title>Fantasy Football Trade Evaluator</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.6.2/chosen.min.css">
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<style type="text/css">
.jumbotron {
margin-top: 2em;
}
.updates {
font-size: 14px;
}
.title {
background: #ccc;
font-weight: bold;
}
.first-group {
padding-left: 0;
padding-right: 30px;
}
.italic {
font-style: italic;
}
.hover-card {
display: none;
width: 20rem;
position: absolute;
left: 50px;
}
.headshot {
width: 70px;
height: 82px;
margin-right: 20px;
background: url('images/headshot-placeholder.jpg');
}
.headshot img {
width: 100%;
}
.val {
font-weight: bold;
}
.val.up {
color: green;
}
.val.same {
color: blue;
}
.val.down {
color: red;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<script src="js/jquery.tabletojson.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.6.2/chosen.jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.hoverintent/1.9.0/jquery.hoverIntent.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
<h1>Fantasy Football Trade Evaluator</h1>
<hr class="my-4">
This Fantasy Football Trade Evaluator tool uses the trade values from CBS Sports' Dave Richard.<br />
You can find his latest articles and rankings <a href="http://www.cbssports.com/writers/dave-richard/">here</a>.</p>
</div>
<p></p><em><strong>Weekly Update:</strong> Updated values after Week 6 of the 2020 season</em></p>
<h5>Changelog:</h5>
<p class="updates">
<em><strong>v2.0:</strong> Add player info cards, hover over players in table to see difference between this week and last week's trade value</em><br />
<em><strong>v1.8:</strong> Add replacement level players for each position, which have values one less than the lowest rated player for that position</em><br />
<em><strong>v1.5:</strong> Add half PPR option (average of Standard and PPR values)</em></p>
</div>
</div>
<form id="tradeEvaluator">
<div class="row">
<div class="col-lg-6">
<h3>My Team</h3>
<div class="form-group">
<label class="form-control-label" for="player1team1">Player 1</label>
<select class="form-control player-name team1" id="player1team1">
<option value="">Select a player...</option>
</select>
</div>
<div class="form-group">
<label class="form-control-label" for="player2team1">Player 2</label>
<select class="form-control player-name team1" id="player2team1">
<option value="">Select a player...</option>
</select>
</div>
<div class="form-group">
<label class="form-control-label" for="player3team1">Player 3</label>
<select class="form-control player-name team1" id="player3team1">
<option value="">Select a player...</option>
</select>
</div>
<div class="form-group">
<label class="form-control-label" for="player4team1">Player 4</label>
<select class="form-control player-name team1" id="player4team1">
<option value="">Select a player...</option>
</select>
</div>
</div>
<div class="col-lg-6">
<h3>Other Team</h3>
<div class="form-group">
<label class="form-control-label" for="player1team2">Player 1</label>
<select class="form-control player-name team1" id="player1team2">
<option value="" selected>Select a player...</option>
</select>
</div>
<div class="form-group">
<label class="form-control-label" for="player2team2">Player 2</label>
<select class="form-control player-name team1" id="player2team2">
<option value="">Select a player...</option>
</select>
</div>
<div class="form-group">
<label class="form-control-label" for="player3team2">Player 3</label>
<select class="form-control player-name team1" id="player3team2">
<option value="">Select a player...</option>
</select>
</div>
<div class="form-group">
<label class="form-control-label" for="player4team2">Player 4</label>
<select class="form-control player-name team1" id="player4team2">
<option value="">Select a player...</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="scoringSystem">Scoring System</label> <br/>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class ="form-check-input" type="radio" name="scoringSystem" value="Stnd" checked="checked"> Standard
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class ="form-check-input" type="radio" name="scoringSystem" value="PPR"> PPR
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class ="form-check-input" type="radio" name="scoringSystem" value="Half"> Half PPR
</label>
</div>
</div>
<button type="submit" class="btn btn-primary" >Submit</button> <button type="reset" class="btn btn-default">Clear</button>
</div>
</div>
</form>
<div id="output" class="card">
<div class="card-header">
<h4>Trade Results</h4>
</div>
<div class="card-body">
<div class="row clearfix">
<div class="col-md-6 team1-results">
</div>
<div class="col-md-6 team2-results">
</div>
</div>
<div class="results">
<em>Select your players and hit submit to see your results.</em>
</div>
</div>
</div>
<hr class="my-4" />
<h3>Running Backs</h3>
<table id="runningbacks" class="table table-hover table-bordered" width="100%"><tbody><tr class="title"><td>Player</td><td>Stnd</td><td>PPR</td></tr><tr><td>A. Kamara, NO</td><td>45</td><td>49</td></tr><tr><td>E. Elliott, DAL</td><td>42</td><td>45</td></tr><tr><td>A. Jones, GB</td><td>37</td><td>40</td></tr><tr><td>C. McCaffrey, CAR</td><td>36</td><td>40</td></tr><tr><td>D. Henry, TEN</td><td>35</td><td>35</td></tr><tr><td>D. Cook, MIN</td><td>31</td><td>33</td></tr><tr><td>J. Conner, PIT</td><td>26</td><td>28</td></tr><tr><td>C. Carson, SEA</td><td>25</td><td>28</td></tr><tr><td>J. Jacobs, LV</td><td>25</td><td>27</td></tr><tr><td>J. Taylor, IND</td><td>24</td><td>26</td></tr><tr><td>K. Hunt, CLE</td><td>22</td><td>24</td></tr><tr><td>J. Mixon, CIN</td><td>21</td><td>23</td></tr><tr><td>M. Sanders, PHI</td><td>20</td><td>22</td></tr><tr><td>N. Chubb, CLE</td><td>20</td><td>21</td></tr><tr><td>C. Edwards-Helaire, KC</td><td>20</td><td>21</td></tr><tr><td>J. Robinson, JAC</td><td>17</td><td>18</td></tr><tr><td>R. Jones, TB</td><td>17</td><td>17</td></tr><tr><td>D. Johnson, HOU</td><td>16</td><td>18</td></tr><tr><td>T. Gurley, ATL</td><td>16</td><td>16</td></tr><tr><td>A. Ekeler, LAC</td><td>15</td><td>18</td></tr><tr><td>D. Montgomery, CHI</td><td>15</td><td>17</td></tr><tr><td>M. Gaskin, MIA</td><td>15</td><td>16</td></tr><tr><td>K. Drake, ARI</td><td>15</td><td>15</td></tr><tr><td>M. Gordon, DEN</td><td>14</td><td>15</td></tr><tr><td>R. Mostert, SF</td><td>13</td><td>14</td></tr><tr><td>D. Swift, DET</td><td>11</td><td>13</td></tr><tr><td>M. Davis, CAR</td><td>10</td><td>13</td></tr><tr><td>A. Gibson, WAS</td><td>10</td><td>13</td></tr><tr><td>D. Henderson, LAR</td><td>10</td><td>11</td></tr><tr><td>J. Dobbins, BAL</td><td>9</td><td>10</td></tr><tr><td>D. Singletary, BUF</td><td>9</td><td>10</td></tr><tr><td>C. Akers, LAR</td><td>9</td><td>9</td></tr><tr><td>L. Bell, KC</td><td>8</td><td>9</td></tr><tr><td>M. Ingram, BAL</td><td>8</td><td>8</td></tr><tr><td>J. Jackson, LAC</td><td>8</td><td>8</td></tr><tr><td>A. Mattison, MIN</td><td>7</td><td>8</td></tr><tr><td>D. Freeman, NYG</td><td>7</td><td>8</td></tr><tr><td>P. Lindsay, DEN</td><td>7</td><td>7</td></tr><tr><td>J. Kelley, LAC</td><td>7</td><td>7</td></tr><tr><td>D. Harris, NE</td><td>7</td><td>7</td></tr><tr><td>C. Edmonds, ARI</td><td>6</td><td>8</td></tr><tr><td>B. Scott, PHI</td><td>6</td><td>7</td></tr><tr><td>J. White, NE</td><td>5</td><td>7</td></tr><tr><td>J. McKinnon, SF</td><td>5</td><td>7</td></tr><tr><td>M. Brown, LAR</td><td>5</td><td>6</td></tr><tr><td>T. Pollard, DAL</td><td>5</td><td>5</td></tr><tr><td>L. Murray, NO</td><td>5</td><td>5</td></tr><tr><td>L. Fournette, TB</td><td>5</td><td>5</td></tr></tbody></table>
<h3>Wide Receivers</h3>
<table id="widereceivers" class="table table-bordered table-hover" width="100%"><tbody><tr class="title"><td>Player</td><td>Stnd</td><td>PPR</td></tr><tr><td>D. Hopkins, ARI</td><td>25</td><td>28</td></tr><tr><td>D. Adams, GB</td><td>24</td><td>28</td></tr><tr><td>M. Thomas, NO</td><td>23</td><td>27</td></tr><tr><td>T. Hill, KC</td><td>23</td><td>25</td></tr><tr><td>C. Ridley, ATL</td><td>22</td><td>25</td></tr><tr><td>J. Jones, ATL</td><td>22</td><td>25</td></tr><tr><td>K. Golladay, DET</td><td>22</td><td>24</td></tr><tr><td>DK Metcalf, SEA</td><td>22</td><td>24</td></tr><tr><td>S. Diggs, BUF</td><td>21</td><td>25</td></tr><tr><td>K. Allen, LAC</td><td>21</td><td>25</td></tr><tr><td>A. Robinson, CHI</td><td>21</td><td>25</td></tr><tr><td>A. Thielen, MIN</td><td>20</td><td>23</td></tr><tr><td>T. Lockett, SEA</td><td>20</td><td>23</td></tr><tr><td>R. Woods, LAR</td><td>18</td><td>21</td></tr><tr><td>W. Fuller, HOU</td><td>17</td><td>20</td></tr><tr><td>A.J. Brown, TEN</td><td>17</td><td>20</td></tr><tr><td>T. McLaurin, WAS</td><td>17</td><td>20</td></tr><tr><td>M. Evans, TB</td><td>17</td><td>19</td></tr><tr><td>O. Beckham, CLE</td><td>15</td><td>18</td></tr><tr><td>C. Godwin, TB</td><td>14</td><td>18</td></tr><tr><td>A. Cooper, DAL</td><td>14</td><td>17</td></tr><tr><td>R. Anderson, CAR</td><td>13</td><td>16</td></tr><tr><td>C. Kupp, LAR</td><td>13</td><td>15</td></tr><tr><td>J. Smith-Schuster, PIT</td><td>13</td><td>15</td></tr><tr><td>D.J. Moore, CAR</td><td>12</td><td>16</td></tr><tr><td>J. Jefferson, MIN</td><td>10</td><td>13</td></tr><tr><td>M. Brown, BAL</td><td>10</td><td>12</td></tr><tr><td>T. Higgins, CIN</td><td>10</td><td>12</td></tr><tr><td>C. Lamb, DAL</td><td>10</td><td>12</td></tr><tr><td>D.J. Chark, JAC</td><td>10</td><td>12</td></tr><tr><td>C. Claypool, PIT</td><td>10</td><td>11</td></tr><tr><td>B. Cooks, HOU</td><td>9</td><td>12</td></tr><tr><td>J. Crowder, NYJ</td><td>8</td><td>12</td></tr><tr><td>T. Fulgham, PHI</td><td>8</td><td>11</td></tr><tr><td>C. Kirk, ARI</td><td>8</td><td>10</td></tr><tr><td>T. Boyd, CIN</td><td>8</td><td>10</td></tr><tr><td>D. Parker, MIA</td><td>8</td><td>10</td></tr><tr><td>D. Slayton, NYG</td><td>8</td><td>9</td></tr><tr><td>J. Brown, BUF</td><td>7</td><td>9</td></tr><tr><td>D. Johnson, PIT</td><td>6</td><td>8</td></tr><tr><td>T. Patrick, DEN</td><td>6</td><td>7</td></tr><tr><td>H. Ruggs, LV</td><td>6</td><td>7</td></tr><tr><td>M. Gallup, DAL</td><td>5</td><td>7</td></tr><tr><td>P. Williams, MIA</td><td>5</td><td>6</td></tr><tr><td>J. Edelman, NE</td><td>5</td><td>6</td></tr><tr><td>B. Aiyuk, SF</td><td>5</td><td>5</td></tr><tr><td>D. Samuel, SF</td><td>5</td><td>5</td></tr></tbody></table>
<h3>Tight Ends</h3>
<table id="tightends" class="table table-bordered table-hover" width="100%"><tbody><tr class="title"><td>Player</td><td>Stnd</td><td>PPR</td></tr><tr><td>T. Kelce, KC</td><td>23</td><td>27</td></tr><tr><td>G. Kittle, SF</td><td>20</td><td>23</td></tr><tr><td>M. Andrews, BAL</td><td>18</td><td>20</td></tr><tr><td>D. Waller, LV</td><td>16</td><td>19</td></tr><tr><td>J. Smith, TEN</td><td>14</td><td>16</td></tr><tr><td>H. Henry, LAC</td><td>10</td><td>12</td></tr><tr><td>J. Cook, NO</td><td>8</td><td>10</td></tr><tr><td>N. Fant, DEN</td><td>8</td><td>9</td></tr><tr><td>D. Schultz, DAL</td><td>7</td><td>9</td></tr><tr><td>E. Engram, NYG</td><td>6</td><td>8</td></tr><tr><td>T. Hockenson, DET</td><td>6</td><td>7</td></tr><tr><td>H. Hurst, ATL</td><td>5</td><td>6</td></tr><tr><td>M. Gesicki, MIA</td><td>5</td><td>6</td></tr><tr><td>R. Gronkowski, TB</td><td>5</td><td>6</td></tr><tr><td>R. Tonyan, GB</td><td>5</td><td>5</td></tr><tr><td>I. Smith, MIN</td><td>5</td><td>5</td></tr><tr><td>Z. Ertz, PHI</td><td>5</td><td>5</td></tr></tbody></table>
<h3>Quarterbacks</h3>
<table id="quarterbacks" class="table table-bordered table-hover" width="100%"><tbody><tr class="title"><td>Player</td><td>Stnd</td><td>PPR</td></tr><tr><td>P. Mahomes, KC</td><td>28</td><td>28</td></tr><tr><td>R. Wilson, SEA</td><td>27</td><td>27</td></tr><tr><td>K. Murray, ARI</td><td>23</td><td>23</td></tr><tr><td>D. Watson, HOU</td><td>22</td><td>22</td></tr><tr><td>L. Jackson, BAL</td><td>21</td><td>21</td></tr><tr><td>J. Allen, BUF</td><td>20</td><td>20</td></tr><tr><td>A. Rodgers, GB</td><td>17</td><td>17</td></tr><tr><td>R. Tannehill, TEN</td><td>11</td><td>11</td></tr><tr><td>B. Roethlisberger, PIT</td><td>10</td><td>10</td></tr><tr><td>M. Ryan, ATL</td><td>9</td><td>9</td></tr><tr><td>J. Herbert, LAC</td><td>8</td><td>8</td></tr><tr><td>T. Brady, TB</td><td>8</td><td>8</td></tr><tr><td>J. Goff, LAR</td><td>7</td><td>7</td></tr><tr><td>C. Newton, NE</td><td>6</td><td>6</td></tr><tr><td>D. Brees, NO</td><td>6</td><td>6</td></tr></tbody></table>
<!-- <h3>DSTs</h3>
<table id="dsts" class="table table-bordered table-hover" width="100%"><tbody><tr class="title"><td>Player</td><td>Stnd</td><td>PPR</td></tr><tr class="row1"><td>Bears DST</td><td>7</td><td>7</td></tr><tr class="row1"><td>Jaguars DST</td><td>7</td><td>7</td></tr><tr class="row1"><td>Ravens DST</td><td>7</td><td>7</td></tr><tr class="row1"><td>Rams DST</td><td>7</td><td>7</td></tr></tbody></table> -->
<p class="float-right"><small>Created by <a href="https://twitter.com/p_Red">@p_Red</a> - Web developer and fantasy football fan</small></p>
</div>
<div class="card hover-card">
<div class="card-body">
<div class="player-info clearfix">
<h4 class="card-title">Player Name</h4>
<h6 class="card-subtitle">Position, Team</h6>
</div>
<hr class="my-3" />
<div class="row">
<div class="current-val col">Current:<div class="val">NA</div></div>
<div class="last-wk-val col">Last wk:<div class="val">NA</div></div>
<div class="change col">Change:<div class="val">NA</div></div>
</div>
</div>
</div>
<script>
(function($){$.concat||$.extend({concat:function(b,c){var a=[];for(var x in arguments)if(typeof a=='object')a=a.concat(arguments[x]);return a}});})(jQuery);
// function for adding generic replacement-level players
function addReplacementPlayer(positionGroup, position) {
var lastPlayer = positionGroup[Object.keys(positionGroup).length - 1];
var lastPlayerPPR = Number(lastPlayer.PPR) - 1;
var lastPlayerStnd = Number(lastPlayer.Stnd) - 1;
positionGroup.push(
{ PPR: lastPlayerPPR.toString(), Player: 'Replacement Level ' + position, Stnd: lastPlayerStnd.toString() }
);
}
// convert tables to JSON objects
var runningBacks = $('#runningbacks').tableToJSON();
var wideReceivers = $('#widereceivers').tableToJSON();
var tightEnds = $('#tightends').tableToJSON();
var quarterbacks = $('#quarterbacks').tableToJSON();
// var DSTs = $('#dsts').tableToJSON();
//add replacement level players to JSON objects
addReplacementPlayer(runningBacks, "RB");
addReplacementPlayer(wideReceivers, "WR");
addReplacementPlayer(tightEnds, "TE");
addReplacementPlayer(quarterbacks, "QB");
// addReplacementPlayer(DSTs, "DST");
// combine all JSON objects into one
var fullData = $.concat(runningBacks, wideReceivers, tightEnds, quarterbacks);
// convert JSON to string so I can add it to the weeklyData file
// TODO try to automate this
var weeklyData = [ fullData ];
var weeklyData = JSON.stringify(weeklyData);
console.log(weeklyData);
// regex for removing links: <a href="\/fantasy\/football\/players\/\d{4,}\/\w{2,}-\w{2,}\/">
// build select fields
var $select = $('.player-name');
$.each(fullData,function(i, player)
{
$select.append('<option>' + fullData[i].Player + '</option>');
});
$('.player-name').chosen();
// trade submitted ... calculating values ... beep boop
$('#tradeEvaluator').submit( function() {
// get player names
var p1t1 = $('#player1team1').val();
var p2t1 = $('#player2team1').val();
var p3t1 = $('#player3team1').val();
var p4t1 = $('#player4team1').val();
var p1t2 = $('#player1team2').val();
var p2t2 = $('#player2team2').val();
var p3t2 = $('#player3team2').val();
var p4t2 = $('#player4team2').val();
// get scoring system
var scoringSystem = $('input[name="scoringSystem"]:checked').val();
// function to calculate half PPR values (average of stnd and PPR)
function halfPPR(Player) {
var halfPPRvalue = ((Number(Player[0].Stnd) + Number(Player[0].PPR)) / 2).toFixed();
return Number(halfPPRvalue);
}
// first we need to get the player object
function getPlayerByName(Player) {
return fullData.filter(
function(data) {
return data.Player == Player;
}
);
}
// take player object and calculate their value based on scoring system selected
function calculatePlayerValue(Player) {
var playerObject = getPlayerByName(Player);
if (playerObject != '') {
if (scoringSystem == 'Stnd') {
return Number(playerObject[0].Stnd);
} else if (scoringSystem == 'PPR') {
return Number(playerObject[0].PPR);
} else {
return halfPPR(playerObject);
}
} else {
return 0;
}
}
// add up values for each team and find out the difference
var team1value = calculatePlayerValue(p1t1) + calculatePlayerValue(p2t1) + calculatePlayerValue(p3t1) + calculatePlayerValue(p4t1)
var team2value = calculatePlayerValue(p1t2) + calculatePlayerValue(p2t2) + calculatePlayerValue(p3t2) + calculatePlayerValue(p4t2)
var difference = team2value - team1value;
// provide results and trade dialog
if (difference >= 10) {
$('#output .results').removeClass('alert-warning alert-info alert-danger').addClass('alert alert-success');
$('#output .results').html("This is a <strong>great</strong> deal for you! You are getting " + difference + " points worth of value compared to your trading partner.");
} else if (difference <= 9 && difference >= 5) {
$('#output .results').removeClass('alert-warning alert-info alert-danger').addClass('alert alert-success');
$('#output .results').html("This is a <strong>good</strong> deal for you. You are getting " + difference + " points worth of value compared to your trading partner.");
} else if (difference <= 4 && difference >= 1) {
$('#output .results').removeClass('alert-warning alert-success alert-danger').addClass('alert alert-info');
$('#output .results').html("This is a pretty <strong>fair</strong> deal, though slightly in your favor. You are getting " + difference + " points worth of value compared to your trading partner.");
} else if (difference == 0) {
$('#output .results').removeClass('alert-warning alert-success alert-danger').addClass('alert alert-info');
$('#output .results').html("This is a perfectly <strong>fair</strong> deal. You are getting " + difference + " points worth of value compared to your trading partner.");
} else if (difference <= -1 && difference >= -4) {
$('#output .results').removeClass('alert-success alert-info alert-danger').addClass('alert alert-warning');
$('#output .results').html("This is a pretty <strong>fair</strong> deal, though slightly in the other team's favor. You are getting " + difference + " points worth of value compared to your trading partner.");
} else if (difference <= -5 && difference >= -9) {
$('#output .results').removeClass('alert-warning alert-info alert-success').addClass('alert alert-danger');
$('#output .results').html("This is a <strong>bad</strong> deal for you. You are getting " + difference + " points worth of value compared to your trading partner.");
} else if (difference <= -10) {
$('#output .results').removeClass('alert-warning alert-info alert-success').addClass('alert alert-danger');
$('#output .results').html("This is a <strong>terrible</strong> deal for you! What are you thinking? You are getting " + difference + " points worth of value compared to your trading partner.");
}
$('#output .team1-results').html("<h6>Value of outgoing players: " + team1value + "</h6>")
$('#output .team2-results').html("<h6>Value of received players: " + team2value + "</h6>")
return false;
});
function fullTeamName(teamAbv) {
if (teamAbv == 'ARI') {
return 'Arizona Cardinals';
} else if (teamAbv == 'ATL') {
return 'Atlanta Falcons';
} else if (teamAbv == 'BAL') {
return 'Baltimore Ravens';
} else if (teamAbv == 'BUF') {
return 'Buffalo Bills';
} else if (teamAbv == 'CAR') {
return 'Carolina Panthers';
} else if (teamAbv == 'CHI') {
return 'Chicago Bears';
} else if (teamAbv == 'CIN') {
return 'Cincinatti Bengals';
} else if (teamAbv == 'CLE') {
return 'Cleveland Browns';
} else if (teamAbv == 'DET') {
return 'Detroit Lions';
} else if (teamAbv == 'DEN') {
return 'Denver Broncos';
} else if (teamAbv == 'DAL') {
return 'Dallas Cowboys';
} else if (teamAbv == 'GB') {
return 'Green Bay Packers';
} else if (teamAbv == 'HOU') {
return 'Houston Texans';
} else if (teamAbv == 'IND') {
return 'Indianapolis Colts';
} else if (teamAbv == 'JAC') {
return 'Jacksonville Jaguars';
} else if (teamAbv == 'KC') {
return 'Kansas City Chiefs'
} else if (teamAbv == 'LAC') {
return 'Los Angeles Chargers';
} else if (teamAbv == 'LAR') {
return 'Los Angeles Rams';
} else if (teamAbv == 'MIA') {
return 'Miami Dolphins';
} else if (teamAbv == 'MIN') {
return 'Minnesota Vikings';
} else if (teamAbv == 'NE') {
return 'New England Patriots';
} else if (teamAbv == 'NO') {
return 'New Orleans Saints';
} else if (teamAbv == 'NYG') {
return 'New York Giants';
} else if (teamAbv == 'NYJ') {
return 'New York Jets';
} else if (teamAbv == 'LV') {
return 'Las Vegas Raiders';
} else if (teamAbv == 'PHI') {
return 'Philadelphia Eagles';
} else if (teamAbv == 'PIT') {
return 'Pittsburgh Steelers';
} else if (teamAbv == 'SEA') {
return 'Seattle Seahawks';
} else if (teamAbv == 'SF') {
return 'San Francisco 49ers';
} else if (teamAbv == 'TB') {
return 'Tampa Bay Buccaneers';
} else if (teamAbv == 'TEN') {
return 'Tennessee Titans';
} else if (teamAbv == 'WAS') {
return 'Washington Football Team'
}
}
function positionAbv(position) {
if (position == 'runningbacks') {
return 'RB';
} else if (position == 'widereceivers') {
return 'WR';
} else if (position == 'tightends') {
return 'TE';
} else if (position == 'quarterbacks') {
return 'QB'
} else if (position == 'dsts') {
return 'DST'
}
}
// player hover cards
$('tr:not(tr.title)').hoverIntent( function(ev) {
$('.hover-card').show(100);
$('.hover-card').css({"top": ev.pageY - 170 + "px", "left": ev.pageX + 5 + "px"});
var playerNameFull = $(this).children('td:first-child').text();
// get position
var position = $(this).parents('table').attr('id');
// split player name and team, retrieve position
if (position != 'dsts') {
var length = playerNameFull.length;
var comma = playerNameFull.indexOf(',');
var teamAbv = playerNameFull.slice(comma).slice(2);
var playerName = playerNameFull.slice(0, comma);
}
// break up player name for image
// var removePunc = playerName.replace('.','');
// var lowercaseName = removePunc.toLowerCase();
// var space = lowercaseName.indexOf(' ');
// var lastName = lowercaseName.slice(space).slice(1);
// var firstName = lowercaseName.slice(0, space);
// var beginlastName = lastName.slice(0,5);
// var beginfirstName = firstName.slice(0,2);
// // build url
// var imgSource = 'https://cdn.footballdb.com/headshots/NFL/2019' + beginlastName + beginfirstName;
// // write player info to card
if (position != 'dsts') {
$('.card-title').text(playerName);
$('.card-subtitle').text(positionAbv(position) + ', ' + fullTeamName(teamAbv));
} else {
$('.card-title').text(playerNameFull);
$('.card-subtitle').text('Defense/Special Teams');
}
// retrieve weekly data
// first, get rid of ajax caching
$.ajaxSetup({ cache:false });
// now pull the json data
$.getJSON("js/weeklyData.json", function(json) {
var length = json.length;
var currentWeek = length - 1;
var lastWeek = length - 2;
// get players current trade value
var playerThisWeek = json[currentWeek].filter(
function(data) {
return data.Player == playerNameFull;
}
);
// get players last week trade value
var playerLastWeek = json[lastWeek].filter(
function(data) {
return data.Player == playerNameFull;
}
);
// calculate the difference
if (playerLastWeek.length != 0) {
var difference = playerThisWeek[0].Stnd - playerLastWeek[0].Stnd;
} else {
var difference = playerThisWeek[0].Stnd - 0;
}
// write values to the hover card
$('.current-val').children('.val').text(playerThisWeek[0].Stnd);
if (playerLastWeek.length != 0) {
$('.last-wk-val').children('.val').text(playerLastWeek[0].Stnd);
}
if (difference >= 1) {
$('.change').children('.val').addClass('up').text('+' + difference);
} else if (difference == 0) {
$('.change').children('.val').addClass('same').text(difference);
} else if (difference < 0) {
$('.change').children('.val').addClass('down').text(difference)
}
});
}, function() {
$('.hover-card').hide(100);
// $('.headshot img').attr("src", 'images/headshot-placeholder.jpg');
$('.current-val').children('.val').text('NA');
$('.last-wk-val').children('.val').text('NA');
$('.change').children('.val').removeClass('up same down');
});
// reset everything
$('button[type=reset]').click( function() {
$('#output .col-md-6').html("");
$('#output .results').html("<em>Select your players and hit submit to see your results.</em>").removeClass('alert alert-success alert-danger alert-warning alert-info');
$('.player-name').val("").trigger("chosen:updated");
});
</script>
</body>
</html>