allInputsEmpty

Checks if all input fields in the '#principia-table' are empty.

allInputsEmpty(): boolean
Returns
boolean: True if all input fields are empty, otherwise false.

exportJson

Exports the filtered data from the table to a JSON file.

exportJson()

exportCsv

Exports the filtered data from the table to a CSV file.

exportCsv()

initComplete

Initializes the column search input fields and their event listeners.

initComplete()

Graph

Represents a Graph containing nodes and their relationships.

new Graph()
Instance Members
getNodeByNumber(number)
getNodeById(id)
getChildrenIdsByNumber(number)
getParentIdByNumber(number)
getNodesByProperties(desiredProperties)
getChapterNumbers()
getChapterNodes(chapter)
plot(chapter, startingX, startingY, PAD)

chapterTitle

Updates the chapter title in the minimap based on the given chapter number.

chapterTitle(chapterNumber: string)
Parameters
chapterNumber (string) The chapter number to find the title for.

minimapTemplate

Generates the HTML template for the minimap.

minimapTemplate(): string
Returns
string: The HTML template for the minimap.

Creates a link to the original text for a given chapter number.

createSummaryLink(pmNumber: string)
Parameters
pmNumber (string) The chapter number to create the link for.

insertChapterSvgs

Inserts chapter SVGs into the specified container.

insertChapterSvgs(pmNumber: string, isLeft: boolean)
Parameters
pmNumber (string) The chapter number to insert SVGs for.
isLeft (boolean) Whether to insert SVGs into the left container.

generateAllRows

Generates all rows of chapter SVGs for a given chapter number.

generateAllRows(pmNumber: string)
Parameters
pmNumber (string) The chapter number to generate rows for.

processChapters

Processes the chapters and generates the data needed for the minimap.

processChapters(options: Object): Object
Parameters
options (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.
Returns
Object: The processed chapter data.

miniMap

Generates a minimap for the specified chapters.

miniMap(chapters: Array<string>, svgSelector: string, highlightedNumber: (string | null))
Parameters
chapters (Array<string>) The chapters to generate the minimap for.
svgSelector (string) The CSS selector for the SVG element.
highlightedNumber ((string | null) = null) The chapter number to highlight.

normalMap

Generates the main map visualization.

normalMap()

Map

Draw Class to create a D3 visualization.

new Map(svgSelector: string, data: Object, options: Object)
Parameters
svgSelector (string = 'pm-map') The CSS selector to attach the SVG element to.
data (Object) The data to be visualized.
options (Object = {}) Additional options for customization.

Minimap

Represents a minimap visualization in an SVG element.

new Minimap(svgSelector: string, data: Object, options: Object)
Parameters
svgSelector (string = 'pm-map') The selector for the SVG element.
data (Object) The data to be visualized.
options (Object = {}) Additional options for the visualization.

Node

Represents a Node in a graph, including its properties and relationships.

new Node(id: string, properties: Object)
Parameters
id (string) The unique identifier for the Node.
properties (Object = {}) Additional properties of the Node.
Instance Members
id
properties
proves
provenBy
addProof(node)
addProofFor(node)

getDecimalLength

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.

getDecimalLength(number: string): number
Parameters
number (string) The number as a string from which to determine the length of the decimal part.
Returns
number: The length of the decimal part of the number, or 0 if there is no decimal part.
Example
// 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

getDecimalPart

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.

getDecimalPart(number: string): (string | null)
Parameters
number (string) The number as a string from which to extract the decimal part.
Returns
(string | null): The decimal part of the number, or null if there is no decimal part.
Example
// 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

downloadData

Downloads the provided chapter data as a JSON file.

downloadData(allChapterData: Array<Object>)
Parameters
allChapterData (Array<Object>) An array of chapter data objects to be downloaded.
Throws
  • Error: Throws an error if the browser does not support Blob or URL.createObjectURL.

romanize

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.

romanize(num: number): string
Parameters
num (number) The number to be converted to a Roman numeral. Should be a positive integer.
Returns
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.

getQueryParam

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.

getQueryParam(param: string): (string | null)
Parameters
param (string) The name of the query parameter to retrieve.
Returns
(string | null): The value of the query parameter, or null if the parameter is not present.
Example
// 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

findLabel

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.

findLabel(chapterNumber: string, data: Object, labels: Object): (Object | null)
Parameters
chapterNumber (string) The chapter number to find labels for. If it ends in '.0', the function will try to find a suffix that matches.
data (Object) The data object containing chapter information. It is expected to be structured with nested objects containing properties .
labels (Object) The labels object containing titles for volumes, parts, sections, and chapters.
Returns
(Object | null): An object containing the part, section, and chapter labels if found, otherwise null .
Example
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" }