Generate JavaScript Code for Single Survey Integration
survey_single_js.Rd
Returns the JavaScript code needed to initialize and handle a single survey in a Shiny application. This JavaScript code sets up event handlers for survey completion, manages survey progress persistence through cookies, and enables communication between the survey and Shiny.
Arguments
Integer specifying how many days the survey progress cookie should persist. Defaults to 7 days. The cookie is automatically deleted when the survey is completed.
Value
A character string containing the JavaScript code for survey initialization and management. The code includes functionality for:
Survey progress persistence through cookies
Automatic progress saving on page changes and value updates
Survey completion handling and data transmission to Shiny
Error handling and user feedback
Examples
# Generate JavaScript with default 7-day cookie expiration
js_code <- survey_single_js()
#> Error in survey_single_js(): could not find function "survey_single_js"
# Generate JavaScript with 30-day cookie expiration
js_code <- survey_single_js(cookie_expiration_days = 30)
#> Error in survey_single_js(cookie_expiration_days = 30): could not find function "survey_single_js"