inst/hbcdtlfb/www/R/observe/change_bg_period.R

req(input$calendar_dates)

browser_calendar_dates <- seq(
  input$calendar_dates$start |> as.Date(),
  input$calendar_dates$end |> as.Date(),
  by = 1)

days_date <- c(
  seq(
    dates_study()$P1[1],
    dates_study()$P1[2],
    by = 1
  ),
  seq(
    dates_study()$P2[1],
    dates_study()$P2[2],
    by = 1
  ),
  seq(
    dates_study()$P3[1],
    dates_study()$P3[2],
    by = 1
  ),
  seq(
    dates_study()$P4[1],
    dates_study()$P4[2],
    by = 1
  )
)

js_index_bg <- (which(browser_calendar_dates %in% days_date) - 1) |> 
  paste(collapse = ",")

shinyjs::runjs(
  glue("var x = [{js_index_bg}]; 
    x.map((n,i) => document.querySelectorAll('.tui-full-calendar-weekday-grid-line.tui-full-calendar-near-month-day').item(n).style.backgroundColor = '#c8cfd6');
    ")
)
ucsd-dsm/hbcd-tlfb documentation built on July 10, 2022, 5:46 p.m.