### Theme Toggling API Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Toggles the application's dark mode theme and persists the preference to localStorage. This function is called when the user clicks the dark mode button. ```APIDOC ## JavaScript API Reference ### toggleDarkMode() #### Description Toggles the application's dark mode theme and persists the preference to localStorage. This function is called when the user clicks the dark mode button in the bottom-right corner. #### Method `JavaScript Function` #### Parameters None #### Request Example ```javascript toggleDarkMode(); ``` #### Response None (modifies UI and localStorage) #### Response Example None ``` -------------------------------- ### Chart Rendering API Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Renders a dual-axis line chart on the specified canvas element showing historical miner count and hashrate data for a cryptocurrency. ```APIDOC ## JavaScript API Reference ### renderChart(canvas, coin) #### Description Renders a dual-axis line chart on the specified canvas element showing historical miner count and hashrate data for a cryptocurrency. #### Method `JavaScript Function` #### Parameters - **canvas** (HTMLElement) - Required - The canvas element to render the chart on. - **coin** (Object) - Required - An object containing the data for the coin to be charted. Expected properties include `name`, `unit`, `labels`, `miners`, and `hashrate`. #### Request Example ```javascript // Example coin data structure: const coinData = { name: 'Bitcoin', unit: 'EH/s', labels: ['01-20 12:31', '01-20 13:31', '01-20 14:32'], miners: [7584341, 7584342, 7584340], hashrate: [1.00, 1.01, 0.99] }; // Assuming 'coinMap' is populated and 'canvas' is a valid canvas element: const canvas = document.querySelector('.chart-canvas[data-id="Bitcoin"]'); renderChart(canvas, coinMap['Bitcoin']); ``` #### Response None (modifies the provided canvas element) #### Response Example None ``` -------------------------------- ### Reset Filters - JavaScript Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Resets all filter input fields (search, minimum miners, profitability ratio) to their default values. After resetting, it calls applyFilters() to refresh the displayed data, effectively showing all coins. ```javascript // Reset all filters to show all coins resetFilters(); // Equivalent to: // document.getElementById('searchInput').value = ''; // document.getElementById('minersFilter').value = '0'; // document.getElementById('ratioFilter').value = '0'; // applyFilters(); ``` -------------------------------- ### Apply Filters - JavaScript Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Filters the coin list and status table based on user input from search, minimum miner count, and profitability ratio filters. It updates a visible count badge and applies the 'hidden' class to non-matching items. The function checks data attributes for filtering criteria. ```javascript // Apply filters based on current input values applyFilters(); // Filter by coin name or algorithm (case-insensitive) document.getElementById('searchInput').value = 'bitcoin'; applyFilters(); // Filter by minimum miner count document.getElementById('minersFilter').value = '100'; // Miners > 100 applyFilters(); // Filter by profitability ratio document.getElementById('ratioFilter').value = '1.0'; // Ratio > 1.0 (Good) applyFilters(); // The function checks each .filter-item element against: // - data-search attribute (for text matching) // - data-miners attribute (for miner count threshold) // - data-ratio attribute (for profitability ratio threshold) // Items not matching criteria receive 'hidden' class ``` -------------------------------- ### Filtering API Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Filters the coin list and status table based on user-specified criteria including search text, minimum miner count, and minimum profitability ratio. Updates the visible count badge after filtering. ```APIDOC ## JavaScript API Reference ### applyFilters() #### Description Filters the coin list and status table based on user-specified criteria including search text, minimum miner count, and minimum profitability ratio. Updates the visible count badge after filtering. #### Method `JavaScript Function` #### Parameters None #### Request Example ```javascript // Apply filters based on current input values applyFilters(); // Example with specific filter values: document.getElementById('searchInput').value = 'bitcoin'; document.getElementById('minersFilter').value = '100'; // Miners > 100 document.getElementById('ratioFilter').value = '1.0'; // Ratio > 1.0 (Good) applyFilters(); ``` #### Response None (modifies UI) #### Response Example None ### resetFilters() #### Description Resets all filter inputs to their default values and reapplies filters to show all coins. #### Method `JavaScript Function` #### Parameters None #### Request Example ```javascript resetFilters(); ``` #### Response None (modifies UI) #### Response Example None ``` -------------------------------- ### Coin Map Object for Historical Cryptocurrency Data (JavaScript) Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt The global `coinMap` object stores historical data for cryptocurrencies, including units, timestamps, miner counts, and hashrate values. This enables lazy-loaded chart rendering for efficient display of historical trends. ```javascript const coinMap = { 'Bitcoin': { name: 'Bitcoin', unit: 'EH/s', labels: [ '01-20 12:31', '01-20 13:31' ], miners: [ 7584341, 7584342 ], hashrate: [ 1.00, 1.01 ] } }; ``` -------------------------------- ### Render Chart - JavaScript Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Renders a dual-axis line chart on a given canvas element, visualizing historical miner count and hashrate data for a specific cryptocurrency. It uses Chart.js and is typically triggered by an IntersectionObserver for lazy loading. The chart displays miner counts on the left Y-axis and hashrate on the right. ```javascript // Chart data structure for each coin in coinMap const coinData = { name: 'Bitcoin', unit: 'EH/s', labels: ['01-20 12:31', '01-20 13:31', '01-20 14:32', /* ... timestamps */], miners: [7584341, 7584342, 7584340, /* ... miner counts */], hashrate: [1.00, 1.01, 0.99, /* ... hashrate values */] }; // Render chart (called automatically via IntersectionObserver) const canvas = document.querySelector('.chart-canvas[data-id="Bitcoin"]'); renderChart(canvas, coinMap['Bitcoin']); // Chart configuration: // - Left Y-axis (y): Miner count (blue line) // - Right Y-axis (y1): Hashrate in specified unit (red filled area) // - Responsive, no animation, index-based tooltip interaction ``` -------------------------------- ### Table Sorting API Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Sorts the status table by the specified column index. Clicking the same column header toggles between ascending and descending order. ```APIDOC ## JavaScript API Reference ### sortTable(n) #### Description Sorts the status table by the specified column index. Clicking the same column header toggles between ascending and descending order. #### Method `JavaScript Function` #### Parameters - **n** (number) - Required - The 0-based index of the column to sort by. #### Request Example ```javascript // Sort by column index (0-based):sortTable(0); // Sort by Coin name sortTable(1); // Sort by Algorithm sortTable(2); // Sort by Price sortTable(3); // Sort by Miners count sortTable(4); // Sort by Hashrate sortTable(5); // Sort by Emission ($) sortTable(6); // Sort by Native Emission sortTable(7); // Sort by Ratio sortTable(8); // Sort by Update time ``` #### Response None (modifies the UI by reordering table rows) #### Response Example None ``` -------------------------------- ### Sort Table - JavaScript Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Sorts the cryptocurrency status table based on the specified column index. Subsequent clicks on the same column header toggle between ascending and descending order. The function automatically handles both numeric and text sorting. ```javascript // Sort by column index (0-based)sortTable(0); // Sort by Coin namesortTable(1); // Sort by AlgorithmsortTable(2); // Sort by PricesortTable(3); // Sort by Miners countsortTable(4); // Sort by HashratesortTable(5); // Sort by Emission ($)sortTable(6); // Sort by Native EmissionsortTable(7); // Sort by RatiosortTable(8); // Sort by Update time // Sorting behavior: // - First click: ascending order // - Second click: descending order // - Handles both numeric and text sorting automatically ``` -------------------------------- ### Filter Item Data Attributes for Interactive Elements (HTML) Source: https://context7.com/mike454545/hash-rate-number-miners/llms.txt Filterable elements, such as table rows and coin list items, utilize data attributes for filtering purposes. These attributes include search terms, miner counts, ratio, and emission values, facilitating dynamic data manipulation. ```html