new Generator(htmlContent)
Represents the logic of the genarate controller view
Parameters:
| Name | Type | Description |
|---|---|---|
htmlContent | HTMLElement | The HTML template of the generator view |
- Source
Example
const generator = new Generator(htmlTemplate);Members
btnConverter :HTMLElement
Type:
- HTMLElement
- Source
htmlContent :HTMLElement
Type:
- HTMLElement
- Source
outputOption :HTMLElement
Type:
- HTMLElement
- Source
outputPlace :HTMLElement
Type:
- HTMLElement
- Source
Methods
convertJsonToCsv() → {void}
Convert the JSON text into an array of properties and items
- Source
Fires:
Returns:
- Type:
- void
copyIntoClipboard() → {void}
Copy into the clipboard the csv text result
- Source
Fires:
Returns:
- Type:
- void
init() → {void}
Init the Generator and add some lsiteners
- Source
Returns:
- Type:
- void
renderCells(data) → {String}
Render the cells of the table of the csv information
Parameters:
| Name | Type | Description |
|---|---|---|
data | Array.<String> | The data of each cell |
- Source
Returns:
Each cell in a HTML div but all in one and single string
- Type:
- String
renderOutput(properties, items) → {void}
Render the information input in the arrays into a csv format, it coould be in a table way or just the csv text format
Parameters:
| Name | Type | Description |
|---|---|---|
properties | Array.<String> | List of properties of the json file |
items | Array.<Array.<String>> | List of the values of each item according to the properties list |
- Source
Returns:
- Type:
- void
renderRows(data) → {String}
Render the rows of the table of the csv information
Parameters:
| Name | Type | Description |
|---|---|---|
data | Array.<Array.<String>> | The data of each row |
- Source
Returns:
Each row in a HTML div but all in one and single string
- Type:
- String
renderTable(headerData, contentData) → {HTMLElement}
Render the table of the csv information
Parameters:
| Name | Type | Description |
|---|---|---|
headerData | Array.<String> | The array of teh properties |
contentData | Array.<Array.<String>> | The array of array of the items |
- Source
Returns:
The table representation of the csv data
- Type:
- HTMLElement