-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #564 from iocanel/email-me-a-poem-index
Add minimal html UI for email me a peom
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
samples/email-a-poem/src/main/resources/META-INF/resources/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Email me a poem</title> | ||
</head> | ||
<body> | ||
<h3>Email me a poem</h3> | ||
Click on the button to get a poem. | ||
</p> | ||
<div id="status"></div> | ||
</p> | ||
<textarea id="poem" rows="10" cols="50" readonly></textarea> | ||
</p> | ||
<button id="emailMe">Email me a poem</button> | ||
<button id="clear" disabled>Clear</button> | ||
|
||
<script> | ||
document.getElementById('emailMe').addEventListener('click', function() { | ||
fetch('http://localhost:8080/email-me-a-poem') | ||
.then(response => response.text()) | ||
.then(data => { | ||
document.getElementById('poem').value = data; | ||
document.getElementById('clear').disabled = false; | ||
}) | ||
.catch(error => { | ||
document.getElementById('status').textContent = 'Failed! Have you started the mock mail container? '; | ||
}); | ||
}); | ||
|
||
document.getElementById('clear').addEventListener('click', function() { | ||
document.getElementById('poem').value = ''; | ||
this.disabled = true; | ||
}); | ||
</script> | ||
</body> | ||
</html> |