MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After saving, 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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */
// Change the top-left logo from navigating to the wiki home page to go to the trial signup page.
$("#p-logo a").attr("href", "https://www.qresearchsoftware.com/").attr("title", "Download a trial of Q");
//
// Hide the "Content:" part of category pages headings.
// The way we organise our wiki is to have category pages as the main
// page on the topic with an overview; not just a listing of all pages
// in the category.
//
var firstHeading = $('#firstHeading span');
if (firstHeading.length === 1) {
var text = firstHeading.text();
var cat_length = 'Category:'.length;
if (text.substr(0, cat_length) === 'Category:') {
firstHeading.text(text.substr(cat_length, text.length - cat_length));
}
}
//
// Use JavaScript to turn a soft redirect into a hard redirect,
// without using MediaWiki's #REDIRECT feature (which prevents inclusion
// of those pages which REDIRECT to the included page, because it is
// an overview).
//
// This is primarily used for the auto-generated pages of JavaScript
// snippets.
//
var softredirect = $('#softredirect a');
if (softredirect.length && window.location.search.indexOf('redirect=no') === -1) {
window.location = softredirect.attr('href');
}
//
// Apply tooltips to the category tree sidebar, because in CSS we trim the
// text using ellipsis.
//
$('a.CategoryTreeLabel').each(function () { $(this).attr('title', $(this).text()); });
//
// Append extra text above the feedback widget so users don't leave specific questions
// in page feedbacks expecting a direct reply.
// The feedback widget is lazy loaded, so wait until it appears
//
var waitForFeedbackWidget = function () {
var widget = $('#mw-articlefeedbackv5 .articleFeedbackv5-title-wrap');
if (widget.length) {
$('#mw-articlefeedbackv5 .articleFeedbackv5-title-wrap').after($('<div style="clear: left; font-size: 1.2em;">Leave feedback about this page. If you have a specific question, <a href="mailto:support@q-researchsoftware.com?subject=Wiki Question">email Q support directly</a>.</div>'));
} else {
setTimeout(waitForFeedbackWidget, 500);
}
};
setTimeout(waitForFeedbackWidget, 500);
// Removed this to prompt authors to clean up their script formatting the hard way,
// and because this had glitches when working with the syntax highlighting script (geshi).
////
//// Make tab stops 4 characters wide (Q's coding standard) instead of 8 (hardwired into
//// browsers like IE).
////
//$('pre.mw-geshi').each(function() {
// this.innerHTML = this.innerHTML.replace(/\t/g, ' ');
//});
//
// Add toggles to code tags to allow you to show and hide the code tag.
// Collapse the code tag by default.
//
$('#Code, #JavaScript').parent().nextAll('.mw-highlight.mw-content-ltr').before('<p class="code_collapser" style="cursor: pointer">▼ Hide Code</p>');
$('.code_collapser').click(function() {
// The next item is the div and its first child is the pre code block
$(this).next().children().first().slideToggle();
if ( $(this).text() == '▶ Show Code') {
$(this).text('▼ Hide Code');
} else {
$(this).text('▶ Show Code');
}
})
$('.code_collapser').click();