MediaWiki:Common.js: Difference between revisions

From Bemar leit
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
// Breyta &printable=yes í &action=render í öllum hlekkjum á síðunni
// Hluti 1: Grípa smellinn dýnamískt
mw.hook('wikipage.content').add(function ($content) {
$(document).ready(function() {
     $content.find('a[href*="printable=yes"]').each(function () {
     $('body').on('click', 'a', function(e) {
         var $link = $(this);
         var href = $(this).attr('href');
        var href = $link.attr('href');
         if (href && href.indexOf('printable=yes') !== -1) {
          
            e.preventDefault();
        // Skipta út printable=yes fyrir action=render
            var newHref = href.replace('printable=yes', 'action=render');
        var newHref = href.replace('printable=yes', 'action=render');
            window.location.href = newHref;
        $link.attr('href', newHref);
        }
     });
     });
});
});
// Hluti 2: Ef notandinn lendir samt á printable síðu, áframsenda strax
if (window.location.href.indexOf('printable=yes') !== -1) {
    window.location.href = window.location.href.replace('printable=yes', 'action=render');
}

Latest revision as of 06:07, 20 October 2026

// Hluti 1: Grípa smellinn dýnamískt
$(document).ready(function() {
    $('body').on('click', 'a', function(e) {
        var href = $(this).attr('href');
        if (href && href.indexOf('printable=yes') !== -1) {
            e.preventDefault();
            var newHref = href.replace('printable=yes', 'action=render');
            window.location.href = newHref;
        }
    });
});

// Hluti 2: Ef notandinn lendir samt á printable síðu, áframsenda strax
if (window.location.href.indexOf('printable=yes') !== -1) {
    window.location.href = window.location.href.replace('printable=yes', 'action=render');
}