Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup #92

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
#' @import shiny
#' @import shinyjs
app_server <- function(input, output,session) {
show_popup = FALSE
observe({
if (is.null(session$userData$app_open_count)) {
session$userData$app_open_count <- shiny::reactiveVal(0)

#Calculate whether should create the pop-up, by using the date/time as a random number proxy
# Get the current time
current_time <- Sys.time()
# Format the time as a continuous string
formatted_time <- format(current_time, "%Y%m%d%H%M%S")
# Convert the string to a numeric value
numeric_time <- as.numeric(formatted_time)
if ((numeric_time %% 3) == 0) { #modulus two seems to make it show up less than 50% of time?
show_popup = TRUE
}

}

if (show_popup) {
# Show a non-aggressive pop-up notification using shinyjs
shinyjs::runjs("
const div = document.createElement('div');
div.innerHTML = 'Please support tenzing &#x1F60A; <br>Donate <a href=\"https://opencollective.com/tenzing\" target=\"_blank\">here</a>!';
div.style.position = 'fixed';
div.style.top = '75%';
div.style.left = '16%';
div.style.padding = '10px';
div.style.background = 'lightblue';
div.style.border = '1px solid gray';
div.style.borderRadius = '5px';
div.style.zIndex = 9999;
document.body.appendChild(div);

// Remove the notification after 60 seconds
setTimeout(function() { div.remove(); }, 60000);
")
}
})

# Read in the contributors_table
## Save the read data as a reactive object
read_out <- mod_read_spreadsheet_server("read_spreadsheet")
Expand Down
1 change: 1 addition & 0 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ golem_add_external_resources <- function(){
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/components/prism-yaml.min.js"),
tags$link(rel = "stylesheet", type = "text/css",
href = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.4/themes/prism.min.css"),
shinyjs::useShinyjs(), #To create pop-up, in app_server.R
# Matomo analytics
# includeHTML(app_sys("app/www/usage_tracker.html"))
HTML("<script>
Expand Down
2 changes: 1 addition & 1 deletion app.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Launch the ShinyApp (Do not remove this comment)
11# Launch the ShinyApp (Do not remove this comment)
# To deploy, run: rsconnect::deployApp()
# Or use the blue button on top of this file

Expand Down
Loading