// CSS then switches flex-flow: column → row, limits tierlist to 80% width, // and limits toggleable-container to max-width: 25% set_layout(LAYOUT_HORIZONTAL); // Removes class "vertical" — reverts to default stacked layout ``` -------------------------------- ### Add Tier Row with add_row() Source: https://context7.com/silverweed/tiers/llms.txt Inserts a new tier row DOM element at a specified index with a given name. Automatically assigns a color and sets up drag-and-drop functionality. Use to dynamically expand the tier list. ```javascript const newRow = add_row(0, 'GOD TIER'); // newRow is a
appended to .tierlist at index 0 // Header is colored #ff6666 (first TIER_COLORS entry) // Row now accepts image drops and shows +/- management buttons on hover // Add an empty tier at the end const lastIndex = tierlist_div.children.length; add_row(lastIndex, ''); ``` -------------------------------- ### add_row(index, name) Source: https://context7.com/silverweed/tiers/llms.txt Inserts a new tier row into the tier list at a specified index with a given name. It automatically assigns a color and sets up drag-and-drop functionality. ```APIDOC ## add_row(index, name) ### Description Creates a full tier row DOM element (header span, items span, +/- row-management buttons) and inserts it into the tier list at the specified zero-based index. Returns the created `
` element. Automatically assigns a color from `TIER_COLORS` and sets up drag-and-drop acceptance on the new row. ### Parameters * **index** (number) - Required - The zero-based index at which to insert the new row. * **name** (string) - Required - The name to display for the new tier row. ### Returns * (`HTMLDivElement`) - The newly created tier row `
` element. ### Example ```javascript // Add a new tier labeled "GOD TIER" at position 0 (top of the list) const newRow = add_row(0, 'GOD TIER'); // Add an empty tier at the end const lastIndex = tierlist_div.children.length; add_row(lastIndex, ''); ``` ``` -------------------------------- ### Load Tier List with load_tierlist() Source: https://context7.com/silverweed/tiers/llms.txt Restores a tier list from a parsed JSON object. Reconstructs the DOM, including title, rows, colors, images, and the untiered pool. This function is typically used after importing a saved tier list file. ```javascript // Triggered by the Import file input document.getElementById('import-input').addEventListener('input', (evt) => { let file = evt.target.files[0]; let reader = new FileReader(); reader.addEventListener('load', (load_evt) => { let parsed = JSON.parse(load_evt.target.result); if (!parsed) { alert("Failed to parse data"); return; } hard_reset_list(); // wipe current state load_tierlist(parsed); // rebuild from JSON }); reader.readAsText(file); }); // Manual programmatic usage: const data = { title: "Loaded List", rows: [ { name: "S", color: "#ff6666", imgs: ["data:image/png;base64,..."] }, { name: "F", color: "#f45bed", imgs: [] } ], untiered: ["data:image/jpeg;base64,..."] }; hard_reset_list(); load_tierlist(data); ``` -------------------------------- ### Recalculate Tier Header Colors Source: https://context7.com/silverweed/tiers/llms.txt Assigns colors from the TIER_COLORS palette to row headers. If idx is provided, only that row is updated; if omitted, all rows are recolored in sequence. Also syncs the hidden input type="color" picker value stored in each header. ```javascript const TIER_COLORS = [ '#ff6666', // S — red '#f0a731', // A — orange '#f4d95b', // B — yellow '#66ff66', // C — green '#58c8f4', // D — light blue '#5b76f4', // E — blue '#f45bed', // F — pink ]; ``` ```javascript // Recolor all rows (e.g., after loading a list without stored colors) recompute_header_colors(); ``` ```javascript // Recolor only the newly inserted row at index 2 add_row(2, 'NEW'); recompute_header_colors(2); ``` -------------------------------- ### Remove Tier Row with rm_row() Source: https://context7.com/silverweed/tiers/llms.txt Removes a tier row by its zero-based index. Images within the row are moved to the untiered pool before removal. This function is typically triggered by the row's delete button, with a confirmation prompt for non-empty rows. ```javascript // Remove the second row (index 1); its images return to the untiered pool rm_row(1); // Triggered by the "-" button on each row: btn_rm.addEventListener('click', (evt) => { let rows = Array.from(tierlist_div.querySelectorAll('.row')); if (rows.length < 2) return; // always keep at least one row let idx = rows.indexOf(evt.target.parentNode.parentNode); if (rows[idx].querySelectorAll('img').length === 0 || confirm(`Remove tier ${rows[idx].querySelector('.header label').innerText}?`)) { rm_row(idx); } }); ``` -------------------------------- ### rm_row(idx) Source: https://context7.com/silverweed/tiers/llms.txt Removes a tier row from the tier list by its index. Images within the row are moved to the untiered pool before removal. ```APIDOC ## rm_row(idx) ### Description Removes the row at the given zero-based index from the tier list. Any images inside the row are first moved back to the untiered pool via `reset_row()`, so no images are lost. ### Parameters * **idx** (number) - Required - The zero-based index of the row to remove. ### Example ```javascript // Remove the second row (index 1); its images return to the untiered pool rm_row(1); // Triggered by the "-" button on each row: btn_rm.addEventListener('click', (evt) => { let rows = Array.from(tierlist_div.querySelectorAll('.row')); if (rows.length < 2) return; // always keep at least one row let idx = rows.indexOf(evt.target.parentNode.parentNode); if (rows[idx].querySelectorAll('img').length === 0 || confirm(`Remove tier ${rows[idx].querySelector('.header label').innerText}?`)) { rm_row(idx); } }); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.