Checks if all input fields in the '#principia-table' are empty.
boolean
:
True if all input fields are empty, otherwise false.
Exports the filtered data from the table to a JSON file.
Exports the filtered data from the table to a CSV file.
Initializes the column search input fields and their event listeners.
Represents a Graph containing nodes and their relationships.
Fetches the nodes associated with a specific chapter, ensuring that there's a node for every primary decimalPart value from 0 to 9. Missing nodes are represented as placeholders.
(string)
: The type of the node. In this context, it's always "node".
Array<Object>
:
An array of node objects associated with the chapter, sorted by their 'number' property.
// Assuming the instance has a nodes property populated as:
// {
// node1: { properties: { chapter: '1', number: '1.0' } },
// node2: { properties: { chapter: '1', number: '1.1' } },
// ... other nodes
// }
getChapterNodes(1);
// Output: Array of nodes for chapter 1, with placeholders for missing primary decimalPart values.
Plots nodes for a specified chapter on a 2D space. Nodes are positioned based on their 'number' property's decimalPart length.
Nodes with:
(number
= 0
)
The initial x-coordinate for plotting.
(number
= 0
)
The initial y-coordinate for plotting.
(number
= 50
)
The padding between nodes.
[Array<Object>, number]
:
A tuple where the first element is the array of plotted node objects and the second is the maximum x-coordinate value among the nodes.
// Given nodes with properties {chapter: '1', number: '1.x'} etc.
plot(1, 0, 0);
// Output: Array of plotted nodes for chapter 1 and the maximum x-coordinate value.
Updates the chapter title in the minimap based on the given chapter number.
(string)
The chapter number to find the title for.
Generates the HTML template for the minimap.
string
:
The HTML template for the minimap.
Creates a link to the original text for a given chapter number.
(string)
The chapter number to create the link for.
Inserts chapter SVGs into the specified container.
Generates all rows of chapter SVGs for a given chapter number.
(string)
The chapter number to generate rows for.
Processes the chapters and generates the data needed for the minimap.
(Object
= {}
)
Options for processing the chapters.
Name | Description |
---|---|
options.chapterNumbers Array<string>
(default null )
|
The specific chapters to process. |
options.GAP number
(default 200 )
|
The gap between chapters. |
options.PAD number
(default 50 )
|
The padding between nodes in a chapter. |
options.x number
(default 0 )
|
The starting x-coordinate. |
Object
:
The processed chapter data.
Generates a minimap for the specified chapters.
Generates the main map visualization.
Draw Class to create a D3 visualization.
Represents a minimap visualization in an SVG element.
Represents a Node in a graph, including its properties and relationships.
(string)
The unique identifier for the Node.
(Object
= {}
)
Additional properties of the Node.
Retrieves the length of the decimal part of a given number represented as a string.
This function splits the number by the decimal point and returns the length of the decimal part if it exists.
If the number does not have a decimal part, it returns 0
.
(string)
The number as a string from which to determine the length of the decimal part.
number
:
The length of the decimal part of the number, or
0
if there is no decimal part.
// Example with a decimal part
const length = getDecimalLength('123.456')
console.log(length) // Outputs: 3
// Example without a decimal part
const length = getDecimalLength('123')
console.log(length) // Outputs: 0
Retrieves the decimal part of a given number represented as a string.
This function splits the number by the decimal point and returns the decimal part if it exists.
If the number does not have a decimal part, it returns null
.
(string)
The number as a string from which to extract the decimal part.
(string | null)
:
The decimal part of the number, or
null
if there is no decimal part.
// Example with a decimal part
const decimal = getDecimalPart('123.456')
console.log(decimal) // Outputs: '456'
// Example without a decimal part
const decimal = getDecimalPart('123')
console.log(decimal) // Outputs: null
Downloads the provided chapter data as a JSON file.
Converts a given number to its Roman numeral representation.
Roman numerals are created by combining symbols and adding values. This function handles numbers up to 3999 (inclusive). For numbers outside this range, an 'Appendix' string is returned. The Roman numeral system uses seven symbols: I, V, X, L, C, D, and M.
(number)
The number to be converted to a Roman numeral. Should be a positive integer.
string
:
The Roman numeral representation of the given number. Returns 'Appendix' for non-numeric inputs or numbers outside the range of standard Roman numeral representation.
Retrieves the value of a specified query parameter from the URL.
This function parses the current page's URL and extracts the value of the given query parameter.
If the parameter is not found, it returns null
.
(string)
The name of the query parameter to retrieve.
(string | null)
:
The value of the query parameter, or
null
if the parameter is not present.
// Assuming the URL is: http://example.com/?foo=bar
const value = getQueryParam('foo')
console.log(value) // Outputs: 'bar'
// Assuming the URL is: http://example.com/?foo=bar
const value = getQueryParam('baz')
console.log(value) // Outputs: null
Finds the labels for a given chapter number from the provided data and labels.
This function attempts to locate the correct labels for a chapter by its number. If the chapter number ends with '.0', it increments the suffix until it finds a match or exceeds a limit. Once found, it retrieves the corresponding labels from the provided labels object.
(string)
The chapter number to find labels for. If it ends in '.0', the function will try to find a suffix that matches.
(Object)
The data object containing chapter information. It is expected to be structured with nested objects containing
properties
.
(Object)
The labels object containing titles for volumes, parts, sections, and chapters.
(Object | null)
:
An object containing the part, section, and chapter labels if found, otherwise
null
.
const chapterNumber = '1.0'
const data = {
volume1: [{ properties: { number: '1.1', volume: 1, part: 1, section: 1, chapter: 1 } }]
}
const labels = {
default: {
"Volume I": {
"Part I": {
title: "Part 1 Title",
sections: {
1: {
title: "Section 1 Title",
chapters: {
1: { title: "Chapter 1 Title" }
}
}
}
}
}
}
}
const result = findLabel(chapterNumber, data, labels)
console.log(result) // Outputs: { "part-label": "Part 1 Title", "sect-label": "Section 1 Title", "chap-label": "Chapter 1 Title" }