/tennis

Primary LanguageCSS

tennis-player

Classes

TennisPlayer

Class representing a tennis player.

Statistics

Class representing a player's overall statistics.

Ranking

Class representing a player's ranking

Functions

initializePlayer()Player

Initializes player. If data in local storage exists, retrieves them. If not, dummy data are shown to the user.

displayPlayerInfo()

Creates table with player's basic info

displayPlayerStatistics()

Creates tables with player's statistics (service & return records)

displayPlayerRanking()

Create table with player's ranking (by year)

createSection(headerStr, categoryIconSrc, categoryIconAltTxt)Element

Creates a section, along with its header and icon.

createTable(keyValObj, tableId, header)Array

Creates a new table based on a key-value object (populates its data).

createRankingTable(tableId, header)Array

Creates a new table (ranking) based on given a table id & a subcategory header.

insertRankingRow()

Inserts a new row at the end of the ranking table.

getBase64Image(img)string

Given a img element, creates a 2d canvas & draws a base64 image.

loadMainTitle()

Loads the main title (H1). If it is previous saved, retrieves it from local storage. Else, shows 'Enter Name Here'.

keepNavBar()

Add the sticky class to the navigation bar when you reach its scroll position. Remove 'sticky' when you leave the scroll position.

addSortingEventListeners()

Add event listeners for all columns, according to their class & id (word before the '-th')

sortTable(id, n)

Sorts a table with the given ID, by clicked column. This will be triggered only when user clicks on a column.

addVisibilityEventListeners()

Adds event listeners that refer to column's visibility. This function is triggered when the user clicks the 'eye' button.

loadRankingChart()

Loads the ranking chart (disposes potential old ones first)

addEventListenerToMainTitle()

Adds all the proper events listeners to H1 (title of page)

saveDataToLocalStorage(element)

Given an element, saves its data to local storage properly.

saveRankingToLocalStorage()

Saves ranking table data to local storage properly.

setAutomaticCalculations()

Sets a number of automatic calculations that need to be done. This function is triggered when user changes specific data from a stats table.

addEventListenersToTds()

Adds event listeners to tds (row cells). This function is triggered once at the begining (on load) & every time a users adds rows to ranking table.

addEventListenersToSocialMedia()

Adds event listeners to social media icons in order to make their links editable by the user.

TennisPlayer

Class representing a tennis player.

Kind: global class

new TennisPlayer(name, birthday, birthplace, citizenship, height, outfitter)

Creates a tennis player instance

Param Type Description
name string Player's complete name
birthday string Player's birthday (MM/DD/YYYY)
birthplace string Player's birthplace (country name)
citizenship string Player's citizenship (country name)
height number Player's height (in meters)
outfitter string Player's outfitter (Brand's complete name)

tennisPlayer.toString()

Returns a string representation of the player's instance

Kind: instance method of TennisPlayer

tennisPlayer.toKeyValuePair() ⇒ Map

Creates a Map object with player's basic info.

Kind: instance method of TennisPlayer
Returns: Map - a Map object

Statistics

Class representing a player's overall statistics.

Kind: global class

new Statistics()

Creates a statistics instance

statistics.setComplementaryServiceFields()

Set complementary fields (for autocompletion) for service records.

Kind: instance method of Statistics

statistics.setComplementaryReturnFields()

Set complementary fields (for autocompletion) for return records.

Kind: instance method of Statistics

statistics.initializeSinglesService()

Initialize data for singles service records.

Kind: instance method of Statistics

statistics.initializeSinglesReturn()

Initialize data for return records.

Kind: instance method of Statistics

Ranking

Class representing a player's ranking

Kind: global class

new Ranking(high, end, low)

Creates a ranking instance

Param Type Description
high array Array with the highest rankings (per year).
end array Array with the final rankings (per year).
low array Array with the lowest rankings (per year).

initializePlayer() ⇒ Player

Initializes player. If data in local storage exists, retrieves them. If not, dummy data are shown to the user.

Kind: global function
Returns: Player - New player instance.

displayPlayerInfo()

Creates table with player's basic info

Kind: global function

displayPlayerStatistics()

Creates tables with player's statistics (service & return records)

Kind: global function

displayPlayerRanking()

Create table with player's ranking (by year)

Kind: global function

createSection(headerStr, categoryIconSrc, categoryIconAltTxt) ⇒ Element

Creates a section, along with its header and icon.

Kind: global function
Returns: Element - Section's element

Param Type Description
headerStr string The header's string
categoryIconSrc string Icon's src
categoryIconAltTxt string Icon's alternative text

createTable(keyValObj, tableId, header) ⇒ Array

Creates a new table based on a key-value object (populates its data).

Kind: global function
Returns: Array - Containing table & header's division

Param Type Description
keyValObj string The key-value object
tableId Element Table's id
header Element Subcategory header

createRankingTable(tableId, header) ⇒ Array

Creates a new table (ranking) based on given a table id & a subcategory header.

Kind: global function
Returns: Array - Containing table & header's division

Param Type Description
tableId string Ranking table id
header Element Subcategory header

insertRankingRow()

Inserts a new row at the end of the ranking table.

Kind: global function

getBase64Image(img) ⇒ string

Given a img element, creates a 2d canvas & draws a base64 image.

Kind: global function
Returns: string - the url of the created image

Param Type Description
img Element An image element

loadMainTitle()

Loads the main title (H1). If it is previous saved, retrieves it from local storage. Else, shows 'Enter Name Here'.

Kind: global function

keepNavBar()

Add the sticky class to the navigation bar when you reach its scroll position. Remove 'sticky' when you leave the scroll position.

Kind: global function

addSortingEventListeners()

Add event listeners for all columns, according to their class & id (word before the '-th')

Kind: global function

sortTable(id, n)

Sorts a table with the given ID, by clicked column. This will be triggered only when user clicks on a column.

Kind: global function

Param Type Description
id string The id of the table's element
n int The column number that will be sorted

addVisibilityEventListeners()

Adds event listeners that refer to column's visibility. This function is triggered when the user clicks the 'eye' button.

Kind: global function

loadRankingChart()

Loads the ranking chart (disposes potential old ones first)

Kind: global function

addEventListenerToMainTitle()

Adds all the proper events listeners to H1 (title of page)

Kind: global function

saveDataToLocalStorage(element)

Given an element, saves its data to local storage properly.

Kind: global function

Param Type Description
element Element A HTML element

saveRankingToLocalStorage()

Saves ranking table data to local storage properly.

Kind: global function

setAutomaticCalculations()

Sets a number of automatic calculations that need to be done. This function is triggered when user changes specific data from a stats table.

Kind: global function

addEventListenersToTds()

Adds event listeners to tds (row cells). This function is triggered once at the begining (on load) & every time a users adds rows to ranking table.

Kind: global function

addEventListenersToSocialMedia()

Adds event listeners to social media icons in order to make their links editable by the user.

Kind: global function