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
!127
Issue#1
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue#1
s3190285/mod4-wp-2023-2024-pokemon:issue#1
into
main
Overview
0
Commits
2
Pipelines
0
Changes
2
Open
Ruginosu, M.I. (Ioana, Student B-BIT)
requested to merge
s3190285/mod4-wp-2023-2024-pokemon:issue#1
into
main
10 months ago
Overview
0
Commits
2
Pipelines
0
Changes
2
Expand
0
0
Merge request reports
Viewing commit
68e432df
Prev
Next
Show latest version
2 files
+
107
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
68e432df
issue 1
· 68e432df
Ruginosu, M.I. (Ioana, Student B-BIT)
authored
10 months ago
src/main/webapp/js/trainers.js
0 → 100644
+
63
−
0
Options
let
pokemonTypes
=
{};
let
tableParentId
=
'
table
'
;
let
detailsParentId
=
'
details
'
;
function
getRowId
(
resource
)
{
return
`
${
resource
.
id
}
_row`
}
function
updateDetails
(
pokemonTypeId
)
{
const
pt
=
pokemonTypes
?.
data
?.
find
(
item
=>
item
.
id
===
pokemonTypeId
);
const
parent
=
document
.
getElementById
(
detailsParentId
);
parent
.
innerHTML
=
`
<div class="card" id="
${
pt
.
id
}
_card">
<img src="
${
pt
.
imgUrl
}
" class="card-img-top" alt="
${
pt
.
classification
}
">
<div class="card-body">
<h5 class="card-title">
${
pt
.
name
}
#
${
pt
.
pokedexNumber
}
</h5>
<p class="card-text">
Japanese name:
${
pt
.
japaneseName
}
</br>
Classification:
${
pt
.
classification
}
</br>
Abilities:
${
pt
.
abilities
?.
join
(
"
,
"
)
||
"
none
"
}
</br>
Type:
${
pt
.
primaryType
}${
pt
.
secondaryType
?
"
,
"
+
pt
.
secondaryType
:
""
}
</p>
</div>
</div>
`
}
function
pokemonTypeToRow
(
pokemonType
)
{
return
`
<tr id="
${
getRowId
(
pokemonType
)}
" onclick="updateDetails('
${
pokemonType
?.
id
?.
trim
()}
')">
<th scope="row">
${
pokemonType
.
id
}
</th>
<td>
${
pokemonType
.
name
}
</td>
<td>#
${
pokemonType
.
pokedexNumber
}
</td>
<td>
${
pokemonType
.
primaryType
}
</td>
<td>
${
pokemonType
.
secondaryType
||
'
-
'
}
</td>
</tr>
`
}
function
createPokemonTypesTable
()
{
const
tableParent
=
document
.
getElementById
(
tableParentId
);
tableParent
.
innerHTML
=
`
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Pokedex Number</th>
<th scope="col">Primary Type</th>
<th scope="col">Secondary Type</th>
</tr>
</thead>
<tbody>
${
pokemonTypes
.
data
.
map
(
resource
=>
`
${
pokemonTypeToRow
(
resource
)}
`
).
join
(
"
\n
"
)
||
"
no data
"
}
</tbody>
</table>
`
}
\ No newline at end of file
Loading