Skip to content

Instantly share code, notes, and snippets.

@birm
Last active May 22, 2017 17:41
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 birm/46db0a1929f90497222e742116813bb7 to your computer and use it in GitHub Desktop.
Save birm/46db0a1929f90497222e742116813bb7 to your computer and use it in GitHub Desktop.
JNLP Form Independent Page
<html>
<style>
.spinner {
width: 20px;
height: 20px;
position: relative;
margin: 15px;
}
.double-bounce1,
.double-bounce2 {
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #333;
opacity: 0.6;
position: absolute;
top: 0;
left: 0;
-webkit-animation: sk-bounce 2.0s infinite ease-in-out;
animation: sk-bounce 2.0s infinite ease-in-out;
}
.double-bounce2 {
-webkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
@-webkit-keyframes sk-bounce {
0%, 100% {
-webkit-transform: scale(0.0)
}
50% {
-webkit-transform: scale(1.0)
}
}
@keyframes sk-bounce {
0%, 100% {
transform: scale(0.0);
-webkit-transform: scale(0.0);
}
50% {
transform: scale(1.0);
-webkit-transform: scale(1.0);
}
}
</style>
<script type="text/javascript">
function open_btn() {
document.getElementById("jnlpform").setAttribute("style", "display:block;");
}
function submit_btn() {
document.getElementById("spinner").setAttribute("style", "display:block;");
var list = document.getElementById('shared_list_name').value;
// get the file, call back on finish...
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:3001/api/createJNLP", true);
xhr.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
console.log(xhr.responseText)
var link = JSON.parse(xhr.responseText).jnlp;
// handle error
if (link) {
document.getElementById("spinner").setAttribute("style",
"display:none;");
document.getElementById("downloadbtn").innerHTML = "<a href='" +
link + "'><input type='button '>Download</input></a>";
} else {
document.getElementById("downloadbtn").innerHTML = "ERROR";
}
}
}
xhr.send('shared_list_name=list');
}
</script>
<div id="all">
<button onClick='open_btn()'>Get a JNLP</button>
<div id="jnlpform" style="display:none;">
<input type="text" name="shared_list_name" id="shared_list_name"></input>
<button onClick="submit_btn()">Create</button>
<div className="spinner" id="spinner" style="display:none;">
<div className="double-bounce1" />
<div className="double-bounce2" />
</div>
<div id="downloadbtn">
</div>
</div>
</div>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment