Termynal Class — fastapi Architecture
Architecture documentation for the Termynal class in termynal.js from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 000471a9_ef7a_d9dc_ef48_af16a8d6655c["Termynal"] 8555ada4_1a29_be4d_5ceb_e03d9e57291a["termynal.js"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|defined in| 8555ada4_1a29_be4d_5ceb_e03d9e57291a 6b7d2aeb_22cc_6860_d344_4483dcb2feb2["constructor()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| 6b7d2aeb_22cc_6860_d344_4483dcb2feb2 ee079ce8_1e97_8b63_3228_fd451f3ef3e0["loadLines()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| ee079ce8_1e97_8b63_3228_fd451f3ef3e0 760e745f_41df_15c2_5b93_4b6ef98e12a2["init()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| 760e745f_41df_15c2_5b93_4b6ef98e12a2 f693669c_751b_13db_a04c_e34d87d400df["start()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| f693669c_751b_13db_a04c_e34d87d400df 3a23ab59_5309_03ee_a500_a744548a0496["generateRestart()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| 3a23ab59_5309_03ee_a500_a744548a0496 e9c71d30_bae4_a1b9_5a44_71a4debe1e61["generateFinish()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| e9c71d30_bae4_a1b9_5a44_71a4debe1e61 7568a8e9_3530_204a_4196_d97364db0ae3["addRestart()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| 7568a8e9_3530_204a_4196_d97364db0ae3 9f684b98_4234_86c4_e6a8_88a2808d9fd7["addFinish()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| 9f684b98_4234_86c4_e6a8_88a2808d9fd7 9e560c91_9f8d_f1bc_98e5_c3e59c987365["type()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| 9e560c91_9f8d_f1bc_98e5_c3e59c987365 c1666950_ab84_7e24_2a36_b1d1a8751b9d["progress()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| c1666950_ab84_7e24_2a36_b1d1a8751b9d b0dad3b4_7046_f9b4_bbde_3ae1dee7acce["_wait()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| b0dad3b4_7046_f9b4_bbde_3ae1dee7acce d8be4d1a_8513_576d_4dde_396e61f6c933["lineDataToElements()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| d8be4d1a_8513_576d_4dde_396e61f6c933 6496b920_f57a_a7ae_61e0_306ad925ef21["_attributes()"] 000471a9_ef7a_d9dc_ef48_af16a8d6655c -->|method| 6496b920_f57a_a7ae_61e0_306ad925ef21
Relationship Graph
Source Code
docs/en/docs/js/termynal.js lines 14–255
class Termynal {
/**
* Construct the widget's settings.
* @param {(string|Node)=} container - Query selector or container element.
* @param {Object=} options - Custom settings.
* @param {string} options.prefix - Prefix to use for data attributes.
* @param {number} options.startDelay - Delay before animation, in ms.
* @param {number} options.typeDelay - Delay between each typed character, in ms.
* @param {number} options.lineDelay - Delay between each line, in ms.
* @param {number} options.progressLength - Number of characters displayed as progress bar.
* @param {string} options.progressChar – Character to use for progress bar, defaults to █.
* @param {number} options.progressPercent - Max percent of progress.
* @param {string} options.cursor – Character to use for cursor, defaults to ▋.
* @param {Object[]} lineData - Dynamically loaded line data objects.
* @param {boolean} options.noInit - Don't initialise the animation.
*/
constructor(container = '#termynal', options = {}) {
this.container = (typeof container === 'string') ? document.querySelector(container) : container;
this.pfx = `data-${options.prefix || 'ty'}`;
this.originalStartDelay = this.startDelay = options.startDelay
|| parseFloat(this.container.getAttribute(`${this.pfx}-startDelay`)) || 600;
this.originalTypeDelay = this.typeDelay = options.typeDelay
|| parseFloat(this.container.getAttribute(`${this.pfx}-typeDelay`)) || 90;
this.originalLineDelay = this.lineDelay = options.lineDelay
|| parseFloat(this.container.getAttribute(`${this.pfx}-lineDelay`)) || 1500;
this.progressLength = options.progressLength
|| parseFloat(this.container.getAttribute(`${this.pfx}-progressLength`)) || 40;
this.progressChar = options.progressChar
|| this.container.getAttribute(`${this.pfx}-progressChar`) || '█';
this.progressPercent = options.progressPercent
|| parseFloat(this.container.getAttribute(`${this.pfx}-progressPercent`)) || 100;
this.cursor = options.cursor
|| this.container.getAttribute(`${this.pfx}-cursor`) || '▋';
this.lineData = this.lineDataToElements(options.lineData || []);
this.loadLines()
if (!options.noInit) this.init()
}
loadLines() {
// Load all the lines and create the container so that the size is fixed
// Otherwise it would be changing and the user viewport would be constantly
// moving as she/he scrolls
const finish = this.generateFinish()
finish.style.visibility = 'hidden'
this.container.appendChild(finish)
// Appends dynamically loaded lines to existing line elements.
this.lines = [...this.container.querySelectorAll(`[${this.pfx}]`)].concat(this.lineData);
for (let line of this.lines) {
line.style.visibility = 'hidden'
this.container.appendChild(line)
}
const restart = this.generateRestart()
restart.style.visibility = 'hidden'
this.container.appendChild(restart)
this.container.setAttribute('data-termynal', '');
}
/**
* Initialise the widget, get lines, clear container and start animation.
*/
init() {
/**
* Calculates width and height of Termynal container.
* If container is empty and lines are dynamically loaded, defaults to browser `auto` or CSS.
*/
const containerStyle = getComputedStyle(this.container);
this.container.style.width = containerStyle.width !== '0px' ?
containerStyle.width : undefined;
this.container.style.minHeight = containerStyle.height !== '0px' ?
containerStyle.height : undefined;
this.container.setAttribute('data-termynal', '');
this.container.innerHTML = '';
for (let line of this.lines) {
line.style.visibility = 'visible'
}
this.start();
}
/**
* Start the animation and rener the lines depending on their data attributes.
Defined In
Source
Frequently Asked Questions
What is the Termynal class?
Termynal is a class in the fastapi codebase, defined in docs/en/docs/js/termynal.js.
Where is Termynal defined?
Termynal is defined in docs/en/docs/js/termynal.js at line 14.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free