Jump to content

MediaWiki:Common.js

From Starship Simulator
Revision as of 16:29, 27 April 2025 by DsRulesAll (talk | contribs) (Adding StarSim links to the footer)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

/* Add StarSim socials links to the wiki footer */
const starsimLinks = [
    {text: 'Website', url: 'https://starshipsimulator.co.uk/', id: 'starsim-link-website'},
    {text: 'Steam', url: 'https://store.steampowered.com/app/1332100/Starship_Simulator/', id: 'starsim-link-steam'},
    {text: 'Ko-fi', url: 'https://ko-fi.com/starshipsimulator', id: 'starsim-link-kofi'},
    {text: 'Kickstarter', url: 'https://www.kickstarter.com/projects/fleetyard/starship-simulator', id: 'starsim-link-kickstarter'},
    {text: 'YouTube', url: 'https://www.youtube.com/@StarshipSimulator', id: 'starsim-link-youtube'},
    {text: 'X (Twitter)', url: 'https://x.com/Starship_sim', id: 'starsim-link-twitter'},
    {text: 'Discord', url: 'https://discord.gg/starshipsimulator', id: 'starsim-link-discord'},
    {text: 'Join Discord', url: 'https://discord.com/invite/eDSQvpgdUX', id: 'starsim-link-joindiscord'},
    {text: 'Facebook', url: 'https://www.facebook.com/Starshipgame', id: 'starsim-link-facebook'},
];

const $starsimFooter = jQuery('<ul id="footer-starsim-links"></ul>');
starsimLinks.forEach(linkObj => {
    const anchor = document.createElement('a');
    anchor.setAttribute('rel', 'nofollow');
    anchor.setAttribute('class', 'external');
    anchor.setAttribute('href', linkObj.url);
    anchor.textContent = linkObj.text;
    
    const li = document.createElement('li');
    li.setAttribute('id', linkObj.id);
    li.appendChild(anchor);

    $starsimFooter.append(li);
});

$starsimFooter.insertBefore(jQuery('#footer-places'));