Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

45 lines
1.0KB

  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. resetTypingSpeed <- function(inputId, session = getDefaultReactiveDomain()) {
  21. session$sendInputMessage("typing", TRUE)
  22. }
  23. ui <- fluidPage(
  24. # textAreaInput("typing", "Type here..."),
  25. typingSpeedInput("typing", "Type here..."),
  26. actionButton("reset", "Reset"),
  27. verbatimTextOutput("debug")
  28. )
  29. server <- function(input, output, session) {
  30. output$debug <- renderPrint({
  31. str(list(typing = input$typing, typing_reset = input$typing_reset))
  32. })
  33. observeEvent(input$reset, {
  34. resetTypingSpeed("typing")
  35. })
  36. }
  37. shinyApp(ui, server)