MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 333: Line 333:
     $("#ca-ve-edit").clone().attr('id', 'ca-ve-edit-clone').prependTo($('#p-views .mw-portlet-body ul'));
     $("#ca-ve-edit").clone().attr('id', 'ca-ve-edit-clone').prependTo($('#p-views .mw-portlet-body ul'));
     $("#ca-ve-edit").hide();
     $("#ca-ve-edit").hide();
   
});


function highlightRows() {
     var rows_to_highlight = [
     var rows_to_highlight = [
         'Normal',
         'Normal',
Line 342: Line 339:
         'PvE',
         'PvE',
         'PvP'
         'PvP'
     ];
     ]


     rows_to_highlight.forEach(function (rowContent) {
     rows_to_highlight.forEach(function (rowContent) {
Line 348: Line 345:
         rows.each(function () {
         rows.each(function () {
             if ($(this).text() == rowContent) $(this).parent().addClass('tone-4');
             if ($(this).text() == rowContent) $(this).parent().addClass('tone-4');
         });
         })
     });
     })
}
      
 
$(document).ready(function () {
    // Call the function on page load
    highlightRows();
 
    // Watch for new elements added to the page and call the function again
    var observer = new MutationObserver(function (mutationsList) {
        for (var mutation of mutationsList) {
            if (mutation.addedNodes.length > 0) {
                highlightRows();
                break;
            }
        }
    });
     observer.observe(document.body, { childList: true, subtree: true });
});
});