MediaWiki:Common.js: Difference between revisions

An idea by Jeff Lawlor
Created on 2025-04-25
Default dark mode to OS preference
No edit summary
Tags: Manual revert Mobile edit Mobile web edit
 
(5 intermediate revisions by the same user not shown)
Line 10: Line 10:
});
});


// Move infoboxes to the bottom of the article in mobile
$(document).ready(function() {
$(document).ready(function() {
// Remove duplicate About Idea Supreme footer link on desktop. See LocalSettings.php for more details
$('#footer-places-about').remove();
// Move infoboxes to the bottom of the article in mobile
if ($('body').hasClass('skin-minerva')) {
if ($('body').hasClass('skin-minerva')) {
var infoboxes = $('#mf-section-0 .infobox-idea');
var infoboxes = $('.mw-parser-output .infobox-idea');
// Move them to the end of the section
// Move them to the end of the section
$('#mf-section-0').append(infoboxes);
$('.mw-parser-output').append(infoboxes);
}
}
});
});
defaultDarkModeToOs();
function defaultDarkModeToOs() {
    // Name of the cookie
    var cookieName = "IdeaSuprememwclientpreferences";
    // Desired value if not already set
    var cookieValue = "skin-theme-clientpref-os";
    // If the cookie doesn’t exist, create it
    if (!getCookie(cookieName)) {
        // Set cookie to expire in 1 year
        var expires = new Date();
        expires.setFullYear(expires.getFullYear() + 1);
        document.cookie = cookieName + "=" + encodeURIComponent(cookieValue) +
            "; path=/; expires=" + expires.toUTCString();
    }
}
// Helper function to get a cookie by name
function getCookie(name) {
    var match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
    return match ? decodeURIComponent(match[2]) : null;
}