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
Morais Fonseca, Claudenir (UT-EEMCS)
mod4-wp-2023-2024-pokemon
Merge requests
!124
Assignment3
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Assignment3
s3259633/mod4-wp-2023-2024-pokemon:Assignment3
into
main
Overview
0
Commits
3
Pipelines
1
Changes
2
Open
Liebeton, J.C. (Joost, Student B-BIT)
requested to merge
s3259633/mod4-wp-2023-2024-pokemon:Assignment3
into
main
10 months ago
Overview
0
Commits
3
Pipelines
1
Changes
2
Expand
0
0
Merge request reports
Viewing commit
5b7775a9
Prev
Next
Show latest version
2 files
+
30
−
16
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
5b7775a9
solution to exercise 2
· 5b7775a9
Joost080
authored
10 months ago
src/main/webapp/js/requests.js
+
25
−
16
Options
@@ -111,20 +111,29 @@ function createPokemonTypesTable() {
</tbody>
</table>
`
}
function
submitForm
()
{
let
name
=
document
.
getElementById
(
"
name
"
).
value
;
let
trainer
=
{
name
:
name
,
created
:
new
Date
().
toISOString
(),
id
:
Math
.
random
*
100
,
lastUpDate
:
new
Date
().
toISOString
(),
profileUrl
:
"
https://www.google.com
"
};
fetch
(
'
/pokemon/api/trainers
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
(
trainer
)
})
.
then
(
res
=>
res
.
json
())
.
then
(
data
=>
{
console
.
log
(
data
);
trainers
.
push
(
data
);
createTrainerTable
();
})
.
catch
(
err
=>
{
console
.
error
(
`unable to create trainer:
${
err
.
status
}
`
);
console
.
error
(
err
);
});
}
// function addTrainer() {
// // Retrieve trainer details from the form
// var trainerName = document.getElementById("trainerName").value;
// var trainerID = document.getElementById("trainerID").value;
//
// // Create a new row in the table with the trainer details
// var newRow = "<tr><td>" + trainerName + "</td><td>" + trainerID + "</td></tr>";
// document.getElementById("tableDiv").innerHTML += newRow;
//
// // Clear the form fields
// document.getElementById("trainerName").value = "";
// document.getElementById("trainerID").value = "";
//
// // Close the modal
// $('#addTrainerModal').modal('hide');
// }
\ No newline at end of file
Loading