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: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */ // Scripts to use when viewing articles /* if (mw.config.get('wgIsArticle') || window.location.href.indexOf('action=submit') > -1 || mw.config.get('wgNamespaceNumber') == -1) { mw.loader.load( '/index.php?title=MediaWiki:CollapsibleTables.js&action=raw&ctype=text/javascript' ); } */ window.addEventListener("load", function(){ var positionAdDivs= function () { console.log('version 2.6') var viewport_height = $(window).height() console.log('viewport_height', viewport_height) var fixed = $("#IL_INSEARCH"); var fixed_position = $("#IL_INSEARCH").offset().top; var fixed_height = $("#IL_INSEARCH").height(); var toCross_position = $("#taboola-below-article-thumbnails").offset().top; var toCross_height = $("#taboola-below-article-thumbnails").height(); /* console.log('fixed_position', fixed_position) console.log('fixed_height', fixed_height) console.log('toCross_position', toCross_position) console.log('toCross_height', toCross_height) */ if (fixed_position + fixed_height < toCross_position) { console.log('fixed_position', fixed_position) } else if (fixed_position > toCross_position + toCross_height) { console.log('remove displaynone class') console.log('fixed_position', fixed_position) console.log('fixed_height', fixed_height) console.log('toCross_position', toCross_position) console.log('toCross_height', toCross_height) fixed.removeClass('displaynone'); } else { var fixed_classes = fixed.attr('class') if (fixed_classes.includes('displaynone')){ console.log('already has displaynone class!', 'fixed_position', fixed_position) } else { console.log('add displaynone class!') console.log('fixed_position', fixed_position) console.log('fixed_height', fixed_height) console.log('toCross_position', toCross_position) console.log('toCross_height', toCross_height) fixed.addClass('displaynone'); } } /* if (fixed_position + fixed_height < toCross_position) { var fixed_classes = fixed.attr('class') console.log('fixed_classes', fixed_classes) if (fixed_classes.includes('displaynone')){ console.log('remove displaynone class!') fixed.removeClass('displaynone') } else { console.log('already removed displaynone class') } } else { var fixed_classes = fixed.attr('class') console.log('fixed_classes', fixed_classes) if (fixed_classes.includes('displaynone')){ console.log('already has displaynone class') } else { console.log('add displaynone class!') fixed.addClass('displaynone') } } */ }; // if fixed_position is Not found, do nothing if (!$("#IL_INSEARCH").offset()){ // otherwise start the interval } else { setInterval(positionAdDivs, 200); } });