You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 satır
896B

  1. library(shiny)
  2. options(scipen = 1e3)
  3. typingSpeedInput <- function(inputId, label, placeholder = NULL) {
  4. .label <- label
  5. htmltools::withTags(
  6. div(
  7. class = "form-group typing-speed",
  8. label(class = "control-label", `for` = inputId, .label),
  9. textarea(id = inputId, class = "form-control", placeholder = placeholder),
  10. htmltools::htmlDependency(
  11. name = "typingSpeed",
  12. version = "0.0.1",
  13. src = ".",
  14. script = "typing.js",
  15. all_files = FALSE
  16. )
  17. )
  18. )
  19. }
  20. ui <- fluidPage(
  21. # textAreaInput("typing", "Type here..."),
  22. typingSpeedInput("typing", "Type here..."),
  23. actionButton("reset", "Reset"),
  24. verbatimTextOutput("debug")
  25. )
  26. server <- function(input, output, session) {
  27. output$debug <- renderPrint(input$typing)
  28. observeEvent(input$reset, {
  29. session$sendInputMessage("typing", TRUE)
  30. })
  31. }
  32. shinyApp(ui, server)