Skip to content

Commit

Permalink
Added a timer on the plots page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonathan Wagaye authored and Yonathan Wagaye committed Nov 4, 2024
1 parent a76754b commit 0006f2d
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions tabs/plots.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,52 @@
library(plotly)

timer_js <- "
let startTime = new Date().getTime();
function updateTimer() {
let now = new Date().getTime();
let elapsed = now - startTime;
let seconds = Math.floor((elapsed / 1000) % 60);
let minutes = Math.floor((elapsed / (1000 * 60)) % 60);
let hours = Math.floor((elapsed / (1000 * 60 * 60)) % 24);
document.getElementById('timer').innerHTML =
(hours < 10 ? '0' + hours : hours) + ':' +
(minutes < 10 ? '0' + minutes : minutes) + ':' +
(seconds < 10 ? '0' + seconds : seconds);
// Check every second
setTimeout(updateTimer, 1000);
}
document.addEventListener('DOMContentLoaded', (event) => {
updateTimer();
});
"

plotsTab <- tabPanel(
'Plots',
tags$head(tags$style(type="text/css",
"body.disconnected {
background-color: inherit;
opacity: 1;
}"
)),
tags$head(
tags$style(type="text/css", "
#timer {
position: absolute;
top: 10px;
right: 10px;
margin-right: 10px;
font-size: 16px;
font-weight: bold;
color: #FFFFFF;
background-color: rgba(0, 0, 0, 0.7);
padding: 5px;
border-radius: 5px;
z-index: 9999;
}
body.disconnected {
background-color: inherit;
opacity: 1;
}
"),
tags$script(HTML(timer_js))
),
div(id = "timer", "00:00:00"),
radioButtons(
"fileType",
"Select download file type:",
Expand Down

0 comments on commit 0006f2d

Please sign in to comment.