MediaWiki:Gadget-AdvancedSiteNotices.js
mw.loader.using( ['mediawiki.cookie', 'mediawiki.util'] ).done( function () {(function ($, mw) { /** Advanced Site Notices ******** * Allow to custom dynamic site notices * Maintainer: [[:zh:User:PhiLiP]] */ if (typeof(window.customASNInterval) == 'undefined') { window.customASNInterval = 10; } $(function () { $('#mw-dismissable-notice').css('display', 'none'); if (window.closeASNForever || mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') { return; } var ln = $('#siteNotice'); if (!ln.length) { return; } var cname = 'dismissASN1'; var cval = mw.cookie.get(cname); if (cval == '') { cval = 0; } var rev = 0; var toid = null; var tb = $('<table id="asn-dismissable-notice" width="100%" style="background: transparent;"/>'); var ct = $('<div id="advancedSiteNotices" style="height: 60px;"/>'); var sd = $('<a href="#" title="Đóng (mở lại bằng cách xóa cookie dismissASN1 trong trình duyệt)"><img src="//upload.wikimedia.org/wikipedia/commons/f/f9/Closewindow14x14.png" alt="Đóng (mở lại bằng cách xóa cookie dismissASN1 trong trình duyệt)" border="0"></a>'); tb.append($('<tr/>').append($('<td/>').append(ct)).append($('<td style="vertical-align: top;"/>').append(sd))); var nts = null; sd.click(function () { mw.cookie.set(cname, rev, { expires: 30, path: '/' }); clearTimeout(toid); tb.remove(); return false; }); var getAttrs = function (nt) { var only = { sysop: nt.hasClass('only_sysop'), logged: nt.hasClass('only_logged'), anon: nt.hasClass('only_anon'), }; only['usr'] = only['sysop'] || only['logged'] || only['anon']; return only; }; var loadNotices = function (pos) { if (!tb.length) { return; } ct.css('min-height', ct.height() + 'px'); var l = nts.length; var nt = null; var rt = 0; while (!nt || nt.attr('class')) { if (nt) { var only = getAttrs(nt); if (!only['usr'] || (($.inArray('sysop', mw.config.get('wgUserGroups')) != -1) && only['sysop']) || (mw.config.get('wgUserName') && only['logged']) || (!mw.config.get('wgUserName') && only['anon'])) { break; } } pos = pos % l; nt = $(nts[pos++]); rt++; if (rt == l) { return; } } nt = nt.html(); if (ct.html()) { ct.stop().fadeOut(function () { ct.html(nt).fadeIn(); }); } else if (rev == cval) { return; } else { tb.appendTo(ln); ct.html(nt).fadeIn(); } toid = setTimeout(function () { loadNotices(pos) }, window.customASNInterval * 1000); }; $.get(mw.util.wikiScript( 'api' ), { page: 'Template:AdvancedSiteNotices/ajax', prop: 'text', action: 'parse', format: 'json', maxage: 3600, smaxage: 3600 }, function (d) { if(!d || !d.parse || !d.parse.text) return; d = $( '<div />' ).html( d.parse.text['*'] ).find( 'ul.sitents' ); nts = $('li', d); rev = d.data( 'asn-version' ); var l = nts.length; loadNotices(Math.floor(Math.random() * l)); }); });})(jQuery, mediaWiki);} );
🔥 Top keywords: Đài Truyền hình Kỹ thuật số VTCTrang ChínhGiỗ Tổ Hùng VươngTrương Mỹ LanĐặc biệt:Tìm kiếmHùng VươngVương Đình HuệUEFA Champions LeagueKuwaitChiến dịch Điện Biên PhủFacebookĐài Truyền hình Việt NamTrần Cẩm TúĐội tuyển bóng đá quốc gia KuwaitGoogle DịchViệt NamCúp bóng đá U-23 châu ÁCúp bóng đá U-23 châu Á 2024Real Madrid CFBảng xếp hạng bóng đá nam FIFACleopatra VIITô LâmTim CookNguyễn Phú TrọngHồ Chí MinhHai Bà TrưngManchester City F.C.VnExpressChủ tịch nước Cộng hòa xã hội chủ nghĩa Việt NamNguyễn Ngọc ThắngĐền HùngCúp bóng đá trong nhà châu Á 2024Võ Văn ThưởngOne PieceLịch sử Việt NamCuộc đua xe đạp toàn quốc tranh Cúp truyền hình Thành phố Hồ Chí Minh 2024Phạm Minh ChínhTikTokĐinh Tiên Hoàng