forked from myskam7/Project-Uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathowEx.html
More file actions
240 lines (164 loc) · 6.93 KB
/
Copy pathowEx.html
File metadata and controls
240 lines (164 loc) · 6.93 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Challenge Round</title>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js'></script>
<script src="https://d3js.org/d3.v4.min.js"></script>
<link rel="stylesheet" href=" https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin="anonymous">
</head>
<body>
<style>
.paper{
border: 1px solid red;
}
a:hover{
text-decoration: none;
}
</style>
</head>
<body>
<div class="container" >
<div class="jumbotron">
<div class="chart"></div>
<h1> </h1>
<i class="fa fa-newspaper-o" aria-hidden="true"></i>
<nav class="navbar navbar-light bg-faded">
<form class="form-inline">
<input class="form-control mr-sm-2" id="input" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
</div>
<div class="paper1">
<div id="grid"></div>
<div id="details"></div>
</div>
</div>
<script>
$(document).ready(function(){
// Input name into search bar to search for id
const cors = "https://cors-bcs.herokuapp.com/";
var queryURL = cors + 'https://overwatch-api.net/api/v1/hero';
$.ajax({
url: queryURL,
method: 'GET',
}).done(function(result){
var characters = result.data
//console.log(characters);
for(var i = 0; i < characters.length; i++){
var d = $("<button>")
d.addClass("btn btn-outline-success my-2 my-sm-0")
d.data("url", characters[i].url)
d.data("data-toggle", "modal")
d.data("data-target", "#exampleModal")
d.html(characters[i].name + ": " + characters[i].id)
$("#grid").append(d);
}
$(document).on("click", "button", function(){
var click = $(this).data().url;
$.ajax({
url: click,
method: 'GET',
}).done(function(result){
// var selectedName = $(this).data("name");
// var selectedAffiliation = $(this).data("affiliation")
// var selectedDescription = $(this).data("description")
// var selectedDifficulty = $(this).data("difficulty")
// var selectedHealth = $(this).data("health")
// var selectedArmour = $(this).data("armour")
// var selectedBaseOfOperations = $(this).data("base_of_operations")
// var selectedUrl = $(this).data("url")
$("#details").empty();
var details = $("<div>");
details.addClass("hero-details")
var heroName = $("<h3>")
heroName.addClass("hero-name")
heroName.html(result.name)
var heroInfo = $("<div>")
heroInfo.addClass("hero-info")
var heroAffiliation = $("<div>")
heroAffiliation.addClass("hero-Affiliation")
heroAffiliation.html(result.affiliation);
var heroDifficulty = $("<span>")
heroDifficulty.addClass("hero-difficulty")
heroDifficulty.html(result.difficulty)
var heroOperations = $("<div>")
heroOperations.addClass("hero-operations")
heroOperations.html(result.base_of_operations);
var heroDescription = $("<p>")
heroDescription.addClass("hero-description")
heroDescription.html(result.description)
$(heroInfo).append(heroAffiliation, heroDifficulty, heroDescription, heroOperations)
var heroStats = $("<div>")
heroStats.addClass("hero-stats")
heroStats.html("Hero Stats")
var heroHealth = $("<span>")
heroHealth.addClass("hero-health")
heroHealth.html(result.health)
var heroArmour = $("<span>")
heroArmour.addClass("hero-armour")
heroArmour.html(result.armour)
var Abilities = $("<span>")
heroArmour.addClass("abilities")
heroArmour.html(result.abilities)
$(heroStats).append(heroHealth, heroArmour)
$(details).append(heroName, heroInfo, heroStats, Abilities)
$("#details").append(details)
console.log('result', result);
})
});
});
// function displayInfo(){
// var modal = $("<div>");
// modal.addClass("modal fade");
// modal.attr("id", "myModal");
// modal.attr("tabindex", "-1");
// modal.attr("role", "dialog");
// modal.attr("aria-labelledby","exampleModalLabel")
// modal.attr("aria-hidden", "true")
// var modalDialog = $("<div>")
// modalDialog.addClass("modal-dialog")
// modalDialog.attr("role", "document")
// var modalContent = $("<div>")
// modalContent.addClass("modal-content")
// $(modal).append(modalDialog, modalContent)
// var modalHeader = $("<div>")
// modalHeader.addClass("modal-header")
// var modalTitle = $("<h3>")
// modalTitle.addClass("modal-title")
// modalTitle.html(selectedName)
// var closeModal = $("<button>")
// closeModal.addClass("close")
// closeModal.data("data-dismiss", "modal")
// closeModal.attr("aria-label", "Close")
// var closeSpan = $("<span>");
// closeSpan.attr("aria-hidden", "true")
// closeSpan.html("×")
// $(closeModal).append(closeSpan)
// $(modalHeader).append(modalTitle, closeModal)
// $(modalContent).append(modalHeader);
// var modalBody = $("<div>");
// modalBody.addClass('modal-body');
// modalBody.html(selectedAffiliation);
// var modalFooter = $("<div>");
// modalFooter.addClass("modal-footer");
// modalFooter.html(selectedName)
// $(modal).append(modalBody, modalFooter);
// }
});
// $(".btn btn-outline-success my-2 my-sm-0").on("click", function(event){
// event.preventDefault();
// console.log("You clicked on " + this.data.id);
// });
// $(".btn btn-outline-success my-2 my-sm-0").on("click", function(event){
// event.preventDefault();
// console.log("You clicked on " + this.data.id);
// });
</script>
</body>
</html>