Skip to content

Instantly share code, notes, and snippets.

View desoga10's full-sized avatar
💥
Aiming for the stars

deji adesoga desoga10

💥
Aiming for the stars
View GitHub Profile
static clearFormField() {
document.getElementById('firstname').value = '';
document.getElementById('lastname').value = '';
document.getElementById('residence').value = '';
document.getElementById('position').value = '';
document.getElementById('country').value = '';
document.getElementById('jersey').value = '';
}
@desoga10
desoga10 / app.js
Created April 10, 2019 01:48
Local Storage Code
//Handles the local storage in the UI
class Storage {
static getPlayers() {
let players;
if (localStorage.getItem('players') === null) {
players = [];
} else {
players = JSON.parse(localStorage.getItem('players'));
}
<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" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous" />
<!-- Form Section -->
<div class=" container mt-4">
<div class="pt-5 form row">
<div class="col-lg-12 card-body">
<form id="player-form">
<div class="form-row">
<div class="form-group col-md-6">
<label for="firstname">First Name</label>
<input type="text" class="form-control" id="firstname" placeholder="First Name" required />
</div>
<!-- Table Section -->
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Residence</th>
<th>Position</th>
<th>Country</th>
@desoga10
desoga10 / index.html
Created April 10, 2019 09:55
Full Code
<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" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous" />
@desoga10
desoga10 / app.js
Created April 10, 2019 10:59
User Interface
//User Interface Class
class Interface {
static displayPlayers() {
const RegisteredPlayers = Storage.getPlayers();
const players = RegisteredPlayers;
players.forEach(player => Interface.addPlayers(player));
}
@desoga10
desoga10 / app.js
Created April 10, 2019 11:04
Add Player
//Register a New Player in User Interface
Interface.addPlayers(player);
@desoga10
desoga10 / app.js
Created April 10, 2019 11:18
Clear Form
static clearFormField() {
document.getElementById('firstname').value = '';
document.getElementById('lastname').value = '';
document.getElementById('residence').value = '';
document.getElementById('position').value = '';
document.getElementById('country').value = '';
document.getElementById('jersey').value = '';
}
@desoga10
desoga10 / app.js
Created April 10, 2019 11:22
Clear Field Method
//Clear Form Field
Interface.clearFormField();