Skip to content

Commit

Permalink
lets now user actively set cookie (seems to be EU-law) solves #364
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaSeep committed Nov 12, 2024
1 parent 841d6c8 commit 4e4bc75
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions program/shinyApp/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ server <- function(input,output,session){
<div style='font-size: 18px; margin-top: 10px;'>
<p><i class='fas fa-question-circle'></i> Need help? Press the blue button</p>
<p><i class='fas fa-rocket'></i> Want to start directly? Click 'Next'.</p>
<div style='font-size: 14px; color: #777; margin-top: 15px;'>
<p><input type='checkbox' id='set_cookie_checkbox'> Do not show next time (sets a cookie)</p>
</div>
</div>
</div>
")
)$
)$
step(
el = "tabsetPanel1",
title = "Welcome to cOmicsArt!",
Expand All @@ -117,14 +120,13 @@ server <- function(input,output,session){
observe({
shinyjs::runjs("
if (!checkHasBeenBeforeCookie()) {
setCookie('hasBeenBefore', 'true', 30);
Shiny.setInputValue('first_visit', true);
} else {
Shiny.setInputValue('first_visit', false);
}
")
})

# If it is the user's first visit, start the guide
observeEvent(input$first_visit, {
if (input$first_visit) {
Expand Down
12 changes: 12 additions & 0 deletions program/shinyApp/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ ui <- shiny::fluidPage(
function checkHasBeenBeforeCookie() {
return getCookie('hasBeenBefore') === 'true';
}
// Listen for changes on the checkbox and set the cookie if checked
document.addEventListener('click', function(event) {
if (event.target && event.target.id === 'set_cookie_checkbox') {
const isChecked = document.getElementById('set_cookie_checkbox').checked;
if (isChecked) {
setCookie('hasBeenBefore', 'true', 30);
} else {
deleteCookie('hasBeenBefore');
}
}
});
"))
),
##########
Expand Down

0 comments on commit 4e4bc75

Please sign in to comment.