Home > Software engineering >  How to add js API in shiny?
How to add js API in shiny?

Time:12-08

I want to add the GazeCloudAPI.js in my app to capture online Eye-Tracking. I think this API is insteresting. I have add the js code in the shiny but nothing happened. Is there any way to use this API in shiny?

shinyApp(
  ui = basicPage( 
    HTML('<button type="button" id="b1" >Travel time</button>'),
## GazeCloudAPI.js ##
    tags$script('<script src=”https://api.gazerecorder.com/GazeCloudAPI.js” ></script>'),
    tags$script('GazeCloudAPI.StartEyeTracking()')
  ),
  
  server = function(input, output, session) {
    observeEvent(input$b1, {
      print(paste("This will only be printed once; all",
                  "subsequent button clicks won't do anything"))
    }, once = TRUE) 
  }

)

Here is the github of this API. https://github.com/szydej/GazeCloud

CodePudding user response:

Try this. Remove the script tags and set the src parameter to your url. Also you inadvertently had curly quotes which aren't recognizable by R as quotes.

tags$script(src="https://api.gazerecorder.com/GazeCloudAPI.js")

CodePudding user response:

Have you tried doing this through the shiny javascript library? Try adding library(shinyjs) and useShinyjs() within your ui

  • Related