Thanks to SweetAlert for Bootstrap forked from Tristan Edwards non-Bootstrap SweetAlert. Purpose is to demonstrate how to use @RStudio htmltools
to get interactive javascript in your R workflow/environment.
Last active
August 29, 2015 14:08
-
-
Save timelyportfolio/202be3408080cee0c9da to your computer and use it in GitHub Desktop.
sweetalert javascript in r with @rstudio htmltools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# give yourself some positive feedback in R | |
# as you toil away on some difficult, but worthwhile task | |
# uses javascript sweet-alert https://github.com/t4t5/sweetalert | |
library(htmltools) | |
library(pipeR) | |
tagList( | |
tags$script( | |
' | |
document.addEventListener("DOMContentLoaded", function(event) { | |
swal("Good job! Brilliant!", "You\'re doing worthwhile things.", "success") | |
}); | |
' | |
) | |
) %>>% | |
attachDependencies( | |
htmlDependency( | |
name="sweet-alert" | |
,version="0.2.1" | |
,src=c("href"= | |
"http://timelyportfolio.github.io/sweetalert/lib" | |
) | |
,script = "sweet-alert.min.js" | |
,style = "sweet-alert.css" | |
) | |
) %>>% | |
html_print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<link href="http://timelyportfolio.github.io/sweetalert/lib/sweet-alert.css" rel="stylesheet" /> | |
<script src="http://timelyportfolio.github.io/sweetalert/lib/sweet-alert.min.js"></script> | |
</head> | |
<body> | |
<script> | |
document.addEventListener("DOMContentLoaded", function(event) { | |
swal("Good job! Brilliant!", "You're doing worthwhile things.", "success") | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment