MediaWiki:ResponsivePrivateList/code.js

//@author-Dorumin // The actual thing that calculates the height and stuff var calcRail = function { var nodes = [].slice.call(document.querySelectorAll('#Rail > *:not(#WikiChatList)')); var height = 0; nodes.forEach(function(el) {      height = height + (el.scrollHeight - 1);    }); if (height > window.innerHeight / 2) height = window.innerHeight / 2; document.getElementById('WikiChatList').style.height = (document.getElementById('Rail').offsetHeight - height - 70) + 'px'; }; // Bind function to window resize $(window).resize(calcRail); // select the target node var targets = [].slice.call(document.querySelectorAll('#PrivateChatList, #WikiChatList')); // create an observer instance var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type == 'attributes' && mutation.attributeName == 'style') return; calcRail; }); }); // configuration of the observer: var config = { attributes: true, childList: true, characterData: true, subtree: true }; // pass in the target node, as well as the observer options targets.forEach(function(target) {   observer.observe(target, config); }); // execute all that observer stuff when the window loads $(function {   mw.util.addCSS('#PrivateChatList {max-height: 40vh !important; overflow-y: auto;} #WikiChatList {overflow-y: auto; max-height: 666vh;} #Rail {overflow: hidden !important;}');    calcRail;    var interval = setInterval(calcRail, 200);    // clear the interval after the window is fully loaded    setTimeout(function { clearInterval(interval); }, 15000); });