### JavaScript Document Ready Handler and Page Routing Source: https://github.com/turanar/stellaris-tech-tree/blob/master/index.html Executes code once the DOM is fully loaded. It checks for URL search parameters to determine if a specific route should be loaded immediately, enabling direct linking to specific tech tree versions. It also initializes a global `window.routes` array, defining a list of available Stellaris tech tree versions with their names, routes, and titles for navigation. ```javascript $(document).ready(function(){ if (window.location.search) { const page = window.routes.find(r => r.route === window.location.search.slice(1)); if (page) { load_page(page.route, page.title); } } }); window.routes = [ { name: 'Orion 3.6.0', route: 'orion-3.6.0', title: 'Stellaris 3.6.0 (Orion)' }, { name: 'Fornax 3.5.3', route: 'vanilla', title: 'Stellaris 3.5.3 (Fornax)' }, { name: 'Cepheus 3.4.3', route: 'cepheus-3.4.3', title: 'Stellaris 3.4.3 (Cepheus)' }, { name: 'Herbert 3.2.2', route: 'herbert-3.2.2', title: 'Stellaris 3.2.2 (Herbert)' }, { name: 'Lem 3.1.1', route: 'lem-3.1.1', title: 'Stellaris 3.1.1 (Lem)' }, { name: 'Stellaris 3.0.1', route: 'dick-3.0.1', title: 'Stellaris 3.0.1 (Dick)' }, { name: 'Stellaris 2.7.1', route: 'wells-2.7.1', title: 'Stellaris 2.7.1 (Wells)' }, { name: 'Stellaris 2.6.0', route: 'verne-2.6.0', title: 'Stellaris 2.6.0 (Verne)' }, { name: 'Stellaris 2.5.0', route: 'shelley-2.5.0', title: 'Stellaris 2.5.0 (Shelley)' }, { name: 'Stellaris 2.3.3', route: 'wolfe-2.3.3', title: 'Stellaris 2.3.3 (Wolfe)' }, { name: 'Stellaris 2.3.0', route: 'wolfe-2.3.0', title: 'Stellaris 2.3.0 (Wolfe)' } ]; ``` -------------------------------- ### Initialize Dynamic Stellaris Version Navigation Source: https://github.com/turanar/stellaris-tech-tree/blob/master/index.html This JavaScript code defines an array of Stellaris game versions, each with a display name, internal route, and page title. Upon document readiness, it dynamically generates navigation list items from this array. Clicking on a list item triggers the `load_page` function, passing the associated route and title to load the respective content. ```javascript const routes = [ { name: 'Stellaris 2.2.7', route: 'leguin-2.2.7', title: 'Stellaris 2.2.7 (Leguin)' }, { name: 'Stellaris 2.2.4', route: 'leguin-2.2.4', title: 'Stellaris 2.2.4 (Leguin)' }, { name: 'Stellaris 2.2.3', route: 'leguin-2.2.3', title: 'Stellaris 2.2.3 (Leguin)' }, { name: 'Stellaris 2.2.0', route: 'leguin-2.2.0', title: 'Stellaris 2.2.0 (Leguin)' } ]; $(document).ready(function(){ routes.forEach(page => { const ele = $("
{{:name}}
{{if tier < 1}} {{:category}} - Starting {{else}} {{:category}} - Tier {{:tier}} {{/if}}
{{if tier > 0}} Cost: {{:cost}}, Weight: {{:base_weight}} {{/if}}
{{if is_gestalt === true}}
![]()
{{/if}}
{{if is_gestalt === false}}
![]()
{{/if}}
{{if is_machine_empire === true}}
![]()
{{/if}}
{{if is_machine_empire === false}}
![]()
{{if is_drive_assimilator === true}}
![]()
{{/if}}
{{if is_rogue_servitor === true}}
![]()
{{/if}}
{{/if}}
{{if is_hive_empire === true}}
![]()
{{/if}}
{{if is_hive_empire === false}}
![]()
{{/if}}
{{if is_megacorp === true}}
![]()
{{/if}}
{{if is_megacorp === false}}
![]()
{{/if}}
{{:weight_modifiers.join('
')}}{{:potential.join('
')}}
{{/for}}