Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mod4-wp-2023-2024-pokemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Botea, R. (Raul, Student B-TCS)
mod4-wp-2023-2024-pokemon
Commits
98a40e35
Commit
98a40e35
authored
9 months ago
by
Botea, R. (Raul, Student B-TCS)
Browse files
Options
Downloads
Patches
Plain Diff
Issue 1 solved, Trainers.
parent
d1364dc5
Branches
issue#1
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/webapp/js/requests.js
+21
-2
21 additions, 2 deletions
src/main/webapp/js/requests.js
src/main/webapp/pokemonTypes.html
+1
-1
1 addition, 1 deletion
src/main/webapp/pokemonTypes.html
src/main/webapp/trainers.html
+11
-2
11 additions, 2 deletions
src/main/webapp/trainers.html
with
33 additions
and
5 deletions
src/main/webapp/js/requests.js
+
21
−
2
View file @
98a40e35
...
...
@@ -86,7 +86,7 @@ function updateTrainerDetails(trainerId) {
function
trainersTypeToRow
(
trainerTypes
)
{
return
`
<tr id="
${
getRowId
(
trainerTypes
)}
" onclick="updateDetails('
${
trainerTypes
?.
id
?.
trim
()}
')">
<tr id="
${
getRowId
(
trainerTypes
)}
" onclick="update
Trainer
Details('
${
trainerTypes
?.
id
?.
trim
()}
')">
<th scope="row">
${
trainerTypes
.
id
}
</th>
<td>
${
trainerTypes
.
name
}
</td>
<td>#
${
trainerTypes
.
created
}
</td>
...
...
@@ -117,4 +117,23 @@ function createTrainersTypesTable() {
</tbody>
</table>
`
}
\ No newline at end of file
}
function
addNewCharacter
(
charName
,
charId
)
{
fetch
(
`/pokemon/api/trainers/
${
charId
}
`
,
{
method
:
"
PUT
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
},
body
:
JSON
.
stringify
({
name
:
charName
})
// Assuming you want to send the character name in the request body
})
.
then
(
response
=>
{
if
(
!
response
.
ok
)
{
throw
new
Error
(
"
Failed to add new character
"
);
}
// Handle success response here if needed
})
.
catch
(
error
=>
{
console
.
error
(
"
Error:
"
,
error
);
});
}
This diff is collapsed.
Click to expand it.
src/main/webapp/pokemonTypes.html
+
1
−
1
View file @
98a40e35
...
...
@@ -31,7 +31,7 @@
});
</script>
<h1>
T
rainers
</h1>
<h1>
Go to t
rainers
</h1>
<button
onclick=
"window.location.href = 'http://localhost:8080/pokemon/trainers.html'"
>
Go to Pokemon Page
</button>
<h1>
Pokemon Types
</h1>
...
...
This diff is collapsed.
Click to expand it.
src/main/webapp/trainers.html
+
11
−
2
View file @
98a40e35
<!DOCTYPE html>
<html
lang=
"en"
>
<html
lang=
"en"
xmlns:CName=
"http://www.w3.org/1999/xhtml"
>
<head>
<!-- Required meta tags -->
<meta
charset=
"utf-8"
>
...
...
@@ -30,7 +31,7 @@
console
.
error
(
err
);
});
</script>
<h1>
M
ain page
</h1>
<h1>
Go to m
ain page
</h1>
<button
onclick=
"window.location.href = 'http://localhost:8080/pokemon/'"
>
Go to Pokemon Page
</button>
<h1>
Trainers
</h1>
...
...
@@ -42,5 +43,13 @@
</div>
</div>
<h1>
Add a new trainer
</h1>
<form>
<label
for=
"charName"
>
CName:
</label>
<input
type=
"text"
id=
"charName"
name=
"charName"
><br><br>
<label
for=
"charId"
>
ID:
</label>
<input
type=
"text"
id =
"charId"
name=
"charId"
>
<br><br>
<button
onclick=
addNewCharacter(charName,charId)
>
Add the new trainer today, at no cost!
</button>
</form>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment