Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\server.js"
}
]
}
39 changes: 39 additions & 0 deletions dist/APIManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//This is the class that will manage all your APIs

class APIManager {

constructor() {
this.renderer = new Renderer()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the renderer shouldn't be created and used here. this class should only manage the API calls, while the main.js file should be the one that using both APIManager and the Renderer classes

}

getPlayers()
{
let input = $('#team-input').val()
input = input.toLowerCase()
if(input != "")
{
$.ajax({
type:"GET",
url: `/team/${input}`,
success: (ref) => {
if (ref.length > 0)
{
for(let player of ref)
{
//requesting image
player.image = `https://nba-players.herokuapp.com/players/${player.lastName}/${player.firstName}`
}
this.renderer.renderPlayers(ref)
}
}

});
}
else
{
alert("Insert team name")
}

}

}
15 changes: 15 additions & 0 deletions dist/Renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Renderer
{
constructor()
{
this.template = $('#team-template').html()
this.templateScript = Handlebars.compile(this.template)
}

renderPlayers(data)
{
$('.team-container').empty()
const html = this.templateScript({data})
$('.team-container').append(html)
}
}
40 changes: 40 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My Roster</title>
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>

<body>

<script id="team-template" type="text/x-handlebars-template">
{{#each data}}
<div class="player-info">
<div class="name">{{firstName}} {{lastName}}</div>
<div class="jersey">{{jersey}}</div>
<img class="image" src={{image}} onerror= "this.src = `https://www.pngkey.com/png/detail/968-9682817_nba-logo.png`;this.className=`errorimage`">
<div class="pos">{{pos}}</div>
</div>
{{/each}}
</script>

<div id="new-roster">
<input type="text" id="team-input" placeholder="Enter team name">
<button onclick=fetchRoster()>Get Roster</button>
</div>

<div id="container">
<div class="team-container">
</div>
</div>
<script src="./jquery/dist/jquery.js"></script>
<script src="./handlebars/dist/handlebars.js"></script>
<script src="renderer.js"></script>
<script src="APIManager.js"></script>
<script src="main.js"></script>

</body>

</html>
7 changes: 7 additions & 0 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const api = new APIManager()

const fetchRoster = function()
{
api.getPlayers()
}

73 changes: 73 additions & 0 deletions dist/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
body{
font-family: 'PT Sans', sans-serif;
font-size: large;
}

#new-roster{
display: grid;
margin-bottom: 1vmax;
height: 2vmax;
grid-template-columns: 5fr 2fr;

}
#team_input{
font-size: 150%;
text-size-adjust: 30px;
}
button{
justify-self: center;
padding-left: 5%;
padding-right: 5%;
margin-right: 50%;
border: cornsilk transparent solid 3px;
border-radius: 30px;
opacity: 0.8;
font-size: large;

}

.team-container{
display: grid;
grid-gap: 1vmax;
grid-template-columns: repeat(4, 1fr);
}

.player-info{
display: grid;
background-color: #1D428A;;
grid-template-columns: none;
border-radius: 15px;
padding: 1vmax;
margin-left: 1vmax;
border-color: #98002E;
box-shadow: 5px 5px 5px #98002E;
}
.name{
justify-self:center;
}
.jersey
{
justify-self:center;
margin-bottom: 2px;
}
.pos{
justify-self: center;
align-content:center;
margin-top: 10px;
}
.image
{
justify-self:center;
outline: 3px solid white;
opacity: 0.9;
border-radius: 2px;
}
.errorimage
{
justify-self:center;
height: 12vmax;
width: 18 vmax;
outline: 3px solid black;
opacity: 0.9;
border-radius: 2px;
}
Loading