MediaWiki:Common.js: Difference between revisions

Update with code from beta: Remove old GR code; GuidedResearch Main Page variant; Expanded language wiki Main Page maps
(reverting)
(Update with code from beta: Remove old GR code; GuidedResearch Main Page variant; Expanded language wiki Main Page maps)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


// test if we're on the home page
// Initialize Tooltips from Bootstrap
if (/Main_Page/.test(document.location.href)) {
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
    $("#firstHeading").css("textAlign", "center","border", "0");
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
}
  return new bootstrap.Tooltip(tooltipTriggerEl)
});
 
/**
* Display the 'Additional online resources' using jQuery
*/
$(document).ready(function(){
  $("#mw-customcollapsible-Additional_online_resources").css({"display": "block"});
});


/* Add Adobe Launch 2020-11-12  
/* Add Adobe Launch 2020-11-12  
Line 19: Line 28:
     };
     };
     // send it
     // send it
     _satellite.track('page_view', config);
     try {
    _satellite.track('page_view', config);
    } catch (e) {
    // ignore
    }
     console.log("recorded page view for " + config.page_detail);
     console.log("recorded page view for " + config.page_detail);
});
});
Line 284: Line 297:
/* end Accordion button */
/* end Accordion button */


/* This is where the code for inserting the Location Map starts. */
(function() {
      if (document.querySelector('h1#firstHeading').innerHTML === "Guided Research for Online Records") {
        var polyfill = document.createElement('script');
        polyfill.type = 'text/javascript';
        polyfill.async = true;
        polyfill.src = 'https://edge.fscdn.org/assets/components/mapFiles/webcomponentsjs/webcomponents-lite-60405515c49744988a6a24e03dedf15a.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(polyfill, s);
        var locationMap = document.createElement('link');
        locationMap.rel = 'import';
/* CHANGE NEEDED: update URL below every time the location-map.html is changed */
        locationMap.href = 'https://gist.githubusercontent.com/ahancey/a86414a07c7c1466cc36ffb790a0817d/raw/748a662f88adf92729d925ebf5fb1ce26ec0bb38/location-map.html';
      var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(locationMap, s);
        document.querySelector('#mw-content-text p').innerHTML = "<div style='width: 1000px;'><location-map></location-map></div>";
    }
})();
/* code for new landing page */
// test if we're on the home page
if ( /Main_Page/.test(document.location.href) ) {
    $("#firstHeading").css("border", "0", "textAlign", "center");
}


/**
/**
  * Conditional include of Map Menus data structure  
  * Conditional include of Map Menus data structure  
  * and all the Map Menus functionality
  * and all the Map Menus functionality
  * - only for pages with 'Main Page' in the title
  * - only for 'Main Page' landing pages
  */
  */
// test if we're on the home page & on beta
const re = /Hauptseite|Main_Page|P%C3%A1gina_principal|Accueil|Pagina_principale|%E3%83%A1%E3%82%A4%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8|%EB%8C%80%EB%AC%B8|%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0|Huvudsida|%E9%A6%96%E9%A1%B5/;
if ( /Main_Page/.test(document.location.href) ) {
if ( re.test(document.location.href) ) {
// align the Heading
$("#firstHeading").css({"border": "0", "textAlign": "center"});
     // console.log('loading menus data');
     // console.log('loading menus data');
     mw.loader.load('/wiki/en/index.php?title=MediaWiki:MapMenu.js&action=raw&ctype=text/javascript');
    const regr = /GR$/;
    var isGR = regr.test(document.location.href);
    var lang = mw.config.get('wgContentLanguage');
    var variant = 'MapMenu.js';
    if (isGR) {
    variant = 'MapMenu-GR.js';
    }
     mw.loader.load('/wiki/' + lang + '/index.php?title=MediaWiki:' + variant + '&action=raw&ctype=text/javascript');


     /**
     /**
53,890

edits