DaveM2430 commited on
Commit
2a3bb8a
·
verified ·
1 Parent(s): 8c87399

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +17 -14
app.R CHANGED
@@ -124,12 +124,19 @@ build_pitcher_table <- function(lb, min_pitches, portal_only) {
124
  '+baseball+twitter" target="_blank">&#x1F426; Search</a>'),
125
  `Board` = paste0('<button class="board-btn" data-pitcher="',
126
  gsub('"', '&quot;', Pitcher),
127
- '" data-name="', gsub('"', '&quot;', Name),
128
- '" data-team="', gsub('"', '&quot;', ifelse(is.na(Team), "", Team)),
129
- '" data-throws="', gsub('"', '&quot;', ifelse(is.na(Throws), "", Throws)),
130
- '" data-height="', gsub('"', '&quot;', ifelse(is.na(Height), "", Height)),
131
- '" data-weight="', gsub('"', '&quot;', ifelse(is.na(Weight), "", Weight)),
132
- '">⭐ Add</button>'),
 
 
 
 
 
 
 
133
  Name = ifelse(HasSinker,
134
  paste0('<span style="background:#cce5ff; padding:2px 6px;',
135
  'border-radius:3px; font-weight:700;">', Name, '</span>'),
@@ -311,12 +318,9 @@ ui <- fluidPage(
311
  // board modal
312
  $(document).on('click', '.board-btn', function() {
313
  var d = $(this).data();
314
- // parse name from HTML span
315
- var nameText = $(this).closest('tr').find('td:first button').text().trim();
316
- var parts = nameText.split(' ');
317
- $('#board_first').val(parts[0] || '');
318
- $('#board_last').val(parts.slice(1).join(' ') || '');
319
- $('#board_school').val(d.team || '');
320
  $('#board_throws').val(d.throws || '');
321
  $('#board_height').val(d.height || '');
322
  $('#board_weight').val(d.weight || '');
@@ -965,12 +969,11 @@ make_color_ramp <- function(values, low, high, flip = FALSE,
965
  Last = d$last,
966
  School = d$school,
967
  Position = d$position,
 
968
  Height = d$height,
969
  Weight = d$weight,
970
- Throws = d$throws,
971
  Notes = d$notes,
972
  `Added By` = d$added_by,
973
- `Date Added` = format(Sys.time(), "%Y-%m-%d %H:%M"),
974
  check.names = FALSE
975
  )
976
 
 
124
  '+baseball+twitter" target="_blank">&#x1F426; Search</a>'),
125
  `Board` = paste0('<button class="board-btn" data-pitcher="',
126
  gsub('"', '&quot;', Pitcher),
127
+ '" data-first="', gsub('"', '&quot;', sapply(Pitcher, function(n) {
128
+ parts <- strsplit(n, ", ")[[1]]
129
+ if (length(parts)==2) trimws(parts[2]) else n
130
+ })),
131
+ '" data-last="', gsub('"', '&quot;', sapply(Pitcher, function(n) {
132
+ parts <- strsplit(n, ", ")[[1]]
133
+ if (length(parts)==2) trimws(parts[1]) else n
134
+ })),
135
+ '" data-team="', gsub('"', '&quot;', ifelse(is.na(Team), "", Team)),
136
+ '" data-throws="', gsub('"', '&quot;', ifelse(is.na(Throws), "", Throws)),
137
+ '" data-height="', gsub('"', '&quot;', ifelse(is.na(Height), "", Height)),
138
+ '" data-weight="', gsub('"', '&quot;', ifelse(is.na(Weight), "", Weight)),
139
+ '">⭐ Add</button>')
140
  Name = ifelse(HasSinker,
141
  paste0('<span style="background:#cce5ff; padding:2px 6px;',
142
  'border-radius:3px; font-weight:700;">', Name, '</span>'),
 
318
  // board modal
319
  $(document).on('click', '.board-btn', function() {
320
  var d = $(this).data();
321
+ $('#board_first').val(d.first || '');
322
+ $('#board_last').val(d.last || '');
323
+ $('#board_school').val(d.team || '');
 
 
 
324
  $('#board_throws').val(d.throws || '');
325
  $('#board_height').val(d.height || '');
326
  $('#board_weight').val(d.weight || '');
 
969
  Last = d$last,
970
  School = d$school,
971
  Position = d$position,
972
+ Hand = d$throws,
973
  Height = d$height,
974
  Weight = d$weight,
 
975
  Notes = d$notes,
976
  `Added By` = d$added_by,
 
977
  check.names = FALSE
978
  )
979