Jump to content

MediaWiki:Common.js

From Transight Wiki
Revision as of 09:08, 10 September 2025 by Editor (talk | contribs)

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.

$(document).ready(function() {
  $('input#searchInput').attr('placeholder', 'Search for Transight Wiki');
});

// Open all external links in a new tab
$(document).ready(function () {
    $("a.external").attr("target", "_blank");
});

mw.loader.using('mediawiki.util', function () {
    // Force small text
    document.documentElement.classList.remove('vector-feature-custom-font-size-standard', 'vector-feature-custom-font-size-large');
    document.documentElement.classList.add('vector-feature-custom-font-size-small');

    // Force wide layout
    document.documentElement.classList.remove('vector-feature-limited-width');
    document.documentElement.classList.add('vector-feature-wide-width');
});



/* === Transight site-wide footer (robust body-append) === */
mw.loader.using(['mediawiki.util']).then(function () {

  function injectTsFooter() {
    if (document.getElementById('ts-footer')) return; // avoid duplicates

    var html = '\
<div id="ts-footer" class="ts-footer">\
  <div class="ts-footer__container">\
    <nav class="ts-footer__sitemap">\
      <ul class="ts-footer__col">\
        <li class="ts-footer__title">USE CASES</li>\
        <li><a href="https://transight.com/solutions/fleet-management/">Fleet Telematics</a></li>\
        <li><a href="https://transight.com/solutions/remote-management-system/">Remote Monitoring System</a></li>\
        <li><a href="https://transight.com/solutions/automation/">Automation</a></li>\
        <li><a href="https://transight.com/solutions/asset-tracking/">Asset Tracking</a></li>\
        <li><a href="https://transight.com/transforming-battery-management-for-ev/">Advanced EV Telematics</a></li>\
      </ul>\
      <ul class="ts-footer__col">\
        <li class="ts-footer__title">PRODUCTS</li>\
        <li><a href="/wiki/Trackers">Trackers</a></li>\
        <li><a href="/wiki/Accessories">Accessories</a></li>\
        <li><a href="https://transight.com/products/cloud-iot-platform/">Cloud IoT Solutions</a></li>\
      </ul>\
      <ul class="ts-footer__col">\
        <li class="ts-footer__title">SUPPORT</li>\
        <li><a href="https://transight.com/client-support/">Product Support</a></li>\
        <li><a href="/wiki/WIKI_KNOWLEDGE_BASE">Wiki Knowledge Base</a></li>\
        <li><a href="/wiki/RMA_Guidelines">Warranty & Repair</a></li>\
      </ul>\
      <ul class="ts-footer__col">\
        <li class="ts-footer__title">ABOUT US</li>\
        <li><a href="https://transight.com/about/">Mission, Vision</a></li>\
        <li><a href="/wiki/Career">Career</a></li>\
        <li><a href="https://transight.com/contact/">Contacts</a></li>\
      </ul>\
    </nav>\
    <div class="ts-footer__bottom">\
      <p class="ts-footer__legal">© 2024, Transight | <a href="/wiki/Privacy">Privacy</a> | <a href="/wiki/Cookies">Cookies</a> | <a href="/wiki/Policies">All Policies</a></p>\
      <p class="ts-footer__social"><a href="https://facebook.com">Facebook</a> <a href="https://www.linkedin.com/company/transight/">LinkedIn</a> <a href="https://x.com/transight_iot?s=21">X</a> <a href="https://youtube.com/@transightsystems">YouTube</a> <a href="https://www.instagram.com/transightsystems/">Instagram</a></p>\
    </div>\
  </div>\
</div>';

    // Always append at the very end of <body> so no page element can constrain width
    document.body.insertAdjacentHTML('beforeend', html);

    // Hide any built-in wiki footers
    document.querySelectorAll('footer.mw-footer, .mw-footer, #mw-footer, .mw-footer-container')
      .forEach(function (el) { el.style.display = 'none'; });
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', injectTsFooter);
  } else {
    injectTsFooter();
  }
});



/* === Inject floating "Go to our web" button (robust) === */
mw.loader.using(['mediawiki.util']).then(function () {
  if (document.getElementById('ts-webfab')) return;

  var url = 'https://transight.com/';

  var html = ''
    + '<div id="ts-webfab" class="ts-webfab">'
    + '  <a class="ts-webfab__btn" href="' + url + '" target="_blank" rel="noopener" aria-label="Go to our website"></a>'
    + '  <a class="ts-webfab__bubble" href="' + url + '" target="_blank" rel="noopener"><span>Go to our web</span></a>'
    + '</div>';

  document.body.insertAdjacentHTML('beforeend', html);
});

// Add notification container with custom image
$(document).ready(function() {
  $("body").append(`
    <div id="pushPopNotification">
      <img src="/images/0/01/01.jpg" alt="Device" />
      <div class="text">
        <strong>New Device Launched!</strong><br>
        Click <a href="/wiki/Devices">here</a> to explore.
      </div>
    </div>
  `);

  // Show after 2 seconds
  setTimeout(function() {
    $("#pushPopNotification").css("right", "20px");

    // Hide after 5 seconds
    setTimeout(function() {
      $("#pushPopNotification").css("right", "-350px");
    }, 5000);

  }, 2000);
});