MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ // Globals at https://www.mediawiki.org/wiki/Manual:Interface/JavaScript

// GOOGLE ANALYTICS (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function{ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date;a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-60945029-2', 'auto'); ga('send', 'pageview'); // END GOOGLE ANALYTICS

// Require a summary on edit pages if (document.getElementById("editform") != null) { $('#editform').submit(function (e) {   var summary = $('#wpSummary');    // https://www.mediawiki.org/wiki/Manual:Namespace#Built-in_namespaces    if (wgPageName.match(/^(User|Talk|Module|.*?_talk):/) || !summary.val.match(/^(\/\*.*?\*\/)?\s*$/)) {        return;    }    summary[0].scrollIntoView;    if (mw.config.get('wgUserLanguage') == "en"){alert("Please enter a summary of the changes you are making in the designated text box.");}    summary.focus;    e.preventDefault; }); }

//Get the number of total views of the website for displaying on the main page $.ajax ("/wiki/Special:Statistics").done (function (response){ $('span.totalnumberofviews').text(($(response).find('#mw-hitcounters-statistics-views-total>.mw-statistics-numbers').text)); });

//Add text around donate button if (mw.config.get('wgUserLanguage') == "en"){ $("li#n-donate").prepend(' Did this page help you? '); $("li#n-donate").append(' Help us grow MEpedia. '); } else { $("li#n-donate").prepend(' '); }

//Set color to specific categories

//For Medical hypotheses category if (mw.config.get('wgCategories').includes ("Medical hypotheses")){ //$(".mw-body-content").css ("background-color","#dae6ff"); //$(".toc").css ("background-color","#dae6ff"); $(".firstHeading").prepend (' This is a Medical hypothesis page ');

// pivot fix $("h1.title").prepend (' This is a Medical hypothesis page '); }

//For Potential treatments category if (mw.config.get('wgCategories').includes ("Potential treatments")){ //$(".mw-body-content").css ("background-color","#f8d6c2"); //$(".toc").css ("background-color","#f8d6c2"); $(".firstHeading").prepend (' This is a Potential treatments page ');

// pivot fix $("h1.title").prepend (' This is a Potential treatments page '); }

//For Potential comorbidities category if (mw.config.get('wgCategories').includes ("Potential comorbidities")){ //$(".mw-body-content").css ("background-color","#f8d6c2"); //$(".toc").css ("background-color","#f8d6c2"); $(".firstHeading").prepend (' This is a Potential comorbidities page ');

// pivot fix $("h1.title").prepend (' This is a Potential comorbidities page '); }

/* Disable default license option on Special:Upload (None Selected) to force a choice. Added by Notjusttired Nov 2019 (should be at _end_ of this page?) $(function {  // avoid javascript error if not on Special:Upload  if (mw.config.get('wgPageName') === "Special:Upload") {    myElement = document.getElementById("wpLicense");    myElement.options[0].disabled = true;    myElement.required = true;  } });