-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerator.html
68 lines (63 loc) · 1.68 KB
/
generator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<html>
<head>
<title>Lasers and Feelings Generator</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(function() {
$.ajax("http://127.0.0.1:5000/Text")
.done(function(text) {
$("#openingSpiel").html(text.opening);
$("#numberOfHeroes").html(text.numberOfHeroes);
});
$("body").on("submit", "form", function(e) {
e.preventDefault();
$("#output").hide();
$.ajax("http://127.0.0.1:5000/Generate", {
'method': "POST",
contentType: "application/json",
'data': JSON.stringify({
'numberOfHeroes': $("#inputNumberOfHeroes").val()
})
}).done(function(result) {
$("#heroes").html(result.heroes);
$("#ship").html(result.ship);
$("#threat").html(result.threat);
$("#output").fadeIn();
});
});
});
</script>
<style>
.dataBlock {
margin-top: 25px;
}
h4 {
margin-bottom: 5px;
}
</style>
</head>
<body>
<form>
<div id="openingSpiel"></div>
<div class="dataBlock">
<span id="numberOfHeroes"></span>
<input id="inputNumberOfHeroes" type="number" min="0" max="7" />
<button type="submit">Go!</button>
</div>
<div id="output" style="display:none">
<div class="dataBlock">
<h4>Heroes</h4>
<div id="heroes"></div>
</div>
<div class="dataBlock">
<h4>The Raptor</h4>
<div id="ship"></div>
</div>
<div class="dataBlock">
<h4>The Mission</h4>
<div id="threat"></div>
</div>
</div>
</form>
</body>
</html>