MediaWiki:Common.js
Материал из Guild Wars 2 wiki
Версия от 18:03, 8 июня 2016; Blood (обсуждение | вклад)
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */ /** additional scripts **/ if (wgIsArticle || window.location.href.indexOf('action=submit') > -1 || wgNamespaceNumber == -1) { importScript('MediaWiki:CollapsibleTables.js'); importScript('MediaWiki:TPprices.js'); importScript('MediaWiki:GameLinks.js'); importScript('MediaWiki:BloodTest.js'); $(function() { autoConvertUTC(); }); } /**** autoConvertUTC (see [[Template:UTC time]]) * by Patrick Westerhoff [poke] */ function autoConvertUTC () { function pad (s) { return (s < 10 ? '0' : '') + s; } [].forEach.call(document.querySelectorAll('.utc-auto-convert'), function(v, i) { var time = v.innerHTML.match(/(\d?\d):(\d\d) UTC/); if (!time) { return; } var date = new Date(); date.setUTCHours(time[1], time[2], 0, 0); if (date.getTimezoneOffset() == 0) { v.title = 'Это ваш часовой пояс'; } else { var offset = (-1 * date.getTimezoneOffset() / 60); var local = pad(date.getHours()) + ':' + pad(date.getMinutes()) + ' UTC' + (offset < 0 ? offset : '+' + offset); v.innerHTML += ' (<span style="cursor: help; border-bottom: 1px dotted silver;" title="Это ваш часовой пояс">' + local + '</span>)'; } }); } /** * Helper script for .hlist class in Common.css * Add pseudo-selector class to last-child list items in IE8 * @source mediawiki.org/wiki/Snippets/Horizontal_lists * @revision 6 (2014-08-23) * @author mediawiki.org/wiki/User:Edokter */ ( function ( mw, $ ) { var profile = $.client.profile(); if ( profile.name === 'msie' && profile.versionNumber === 8 ) { mw.hook( 'wikipage.content' ).add( function ( $content ) { $content.find( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' ) .addClass( 'hlist-last-child' ); } ); } } ( mediaWiki, jQuery ) );