From 0f889fc155d3a96c03898b3810c030292f57061c Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Mon, 26 May 2025 20:33:26 +0200 Subject: [PATCH 1/2] Add new input value returned after pausing shinyTimer. --- DESCRIPTION | 2 +- NEWS.md | 3 ++- inst/examples/shinymobile_timer_up.R | 6 +++++- inst/www/timer.js | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 04cd148..347be82 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: shinyTimer Title: Customizable Timer for 'shiny' Applications -Version: 0.1.0.9001 +Version: 0.1.0.9002 Authors@R: person("Maciej", "Banas", email = "banasmaciek@gmail.com", role = c("aut", "cre")) Description: Provides a customizable timer widget for 'shiny' applications. Key diff --git a/NEWS.md b/NEWS.md index b394f18..2122bc7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # shinyTimer (development version) -* Renamed `background` parameter to `frame` to better reflect its purpose. Added `fill` parameter to pass colors to the background of the `shinyTimer` ([#60](https://github.com/maciekbanas/shinyTimer/issues/60)). +* Added new feedback value (text content of the timer) returned after pausing `shinyTimer` (#63). +* Renamed `background` parameter to `frame` to better reflect its purpose. Added `fill` parameter to pass colors to the background of the `shinyTimer` (#60). # shinyTimer 0.1.0 diff --git a/inst/examples/shinymobile_timer_up.R b/inst/examples/shinymobile_timer_up.R index 2686db7..e2fd93c 100644 --- a/inst/examples/shinymobile_timer_up.R +++ b/inst/examples/shinymobile_timer_up.R @@ -39,7 +39,8 @@ ui <- shinyMobile::f7Page( ) |> htmltools::tagAppendAttributes( style="font-size:20px;" - ) + ), + shiny::textOutput("shinytimer_content_output") ) ) @@ -55,6 +56,9 @@ server <- function(input, output, session) { shiny::observeEvent(input$resume_timer, { resetTimer("shiny_timer") }) + output$shinytimer_content_output <- shiny::renderText({ + input$shinytimer_content + }) } shinyApp(ui, server) diff --git a/inst/www/timer.js b/inst/www/timer.js index 09d732c..b022fe1 100644 --- a/inst/www/timer.js +++ b/inst/www/timer.js @@ -63,7 +63,10 @@ Shiny.addCustomMessageHandler('countUp', function(message) { }); Shiny.addCustomMessageHandler('pauseTimer', function(message) { + const { inputId, start } = message; clearInterval(timerInterval); + const timerElement = document.getElementById(inputId); + Shiny.setInputValue("shinytimer_content", timerElement.textContent) }); Shiny.addCustomMessageHandler('resetTimer', function(message) { From 91fe51487c7113092601ffe06c26b70ecf4d94e1 Mon Sep 17 00:00:00 2001 From: Maciej Banas Date: Mon, 26 May 2025 20:37:18 +0200 Subject: [PATCH 2/2] Update NEWS. --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 2122bc7..ce2d871 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # shinyTimer (development version) -* Added new feedback value (text content of the timer) returned after pausing `shinyTimer` (#63). +* Added new feedback value (text content of the timer) returned after pausing `shinyTimer` (#63). It can be accessed via `input$shinytimer_content`. * Renamed `background` parameter to `frame` to better reflect its purpose. Added `fill` parameter to pass colors to the background of the `shinyTimer` (#60). # shinyTimer 0.1.0