Skip to content

Instantly share code, notes, and snippets.

@McClellandLegge
Forked from withr/server.R
Created May 19, 2016 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McClellandLegge/6a054593de5c3237c02f7936b8f2bc96 to your computer and use it in GitHub Desktop.
Save McClellandLegge/6a054593de5c3237c02f7936b8f2bc96 to your computer and use it in GitHub Desktop.
"Calculation In Process..." busy indictor
shinyServer(function(input, output) {
output$obs <- renderUI({
sliderInput("obs", "Number of observations:",
min = 10000, max = 90000,
value = 50000, step = 10000)
})
output$distPlot <- renderPlot({
if (!is.null(input$obs)) {
dist <- NULL
for (i in 1:input$obs) {
dist <- c(dist, rnorm(1))
}
hist(dist, breaks = 100)
}
})
})
shinyUI(bootstrapPage(
# Add custom CSS & Javascript;
tagList(
tags$head(
tags$link(rel="stylesheet", type="text/css",href="style.css"),
tags$script(type="text/javascript", src = "busy.js")
)
),
div(class = "busy",
p("Calculation in progress.."),
img(src="http://imageshack.us/a/img827/4092/ajaxloaderq.gif")
),
div(class = "span4", uiOutput("obs")),
div(class = "span8", plotOutput("distPlot"))
))
setInterval(function(){
if ($('html').attr('class')=='shiny-busy') {
setTimeout(function() {
if ($('html').attr('class')=='shiny-busy') {
$('div.busy').show()
}
}, 1000)
} else {
$('div.busy').hide()
}
}, 100)
div.busy {
position:absolute;
top: 40%;
left: 50%;
margin-top: -100px;
margin-left: -50px;
display:none;
background: rgba(230, 230, 230, .8);
text-align: center;
padding-top: 20px;
padding-left: 30px;
padding-bottom: 40px;
padding-right: 30px;
border-radius: 5px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment