МедиаУики:Gadget-AdvancedSiteNotices.js: Нұсқалар арасындағы айырмашылық

Content deleted Content added
ш Arystanbek МедиаУики:Scripts.js/AdvancedSiteNotices.js бетін МедиаУики:Gadget-AdvancedSiteNotices.js бетіне жылжытты (айдатқыш қалдырмады): қайтару
Өңдеу түйіні жоқ
1-жол:
mw.loader.using(function ($['jquery.cookie', mw'mediawiki.util'] ) { $.done( function () {
 
(function ($, mw) {
/** Advanced Site Notices ********
* Allow to custom dynamic site notices
Line 5 ⟶ 7:
*/
if (typeof(window.customASNInterval) == 'undefined') {
window.customASNInterval = 1510;
}
$(function () {
$('#mw-dismissable-notice').css('display', 'none');
if (window.closeASNForever || mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') {
return;
Line 19 ⟶ 22:
var cval = $.cookie(cname);
if (cval == '') {
cval = -10;
}
var rev = 0;
Line 26 ⟶ 29:
var tb = $('<table id="asn-dismissable-notice" width="100%" style="background: transparent;"/>');
var ct = $('<div id="advancedSiteNotices" style="word-break: break-word;" class="mw-parser-output"/>');
var sd = $('<a href="#" title="Жабуন">'<img +src="//upload.wikimedia.org/wikipedia/commons/f/f9/Closewindow14x14.png" wgULS('Жабу',alt="Жабуন" 'Жасыру') + 'border="0"></a>');
tb.append($('<tr/>').append($('<td/>').append(ct)).append($('<td/>').append('[').append(sd).append(']')));
var nts = null;
var styles = [];
 
sd.click(function () {
Line 41 ⟶ 43:
});
 
var matchCriteriagetAttrs = function ( nt ) {
var cacheonly = nt.data( 'asn-cache' );{
if ( cache !== undefinedsysop: nt.hasClass('only_sysop') {,
returnlogged: cache;nt.hasClass('only_logged'),
} anon: nt.hasClass('only_anon'),
var criteria = nt.attr( 'data-asn-criteria' );
if ( criteria === undefined ) {
criteria = nt.attr( 'class' ) ? 'false' : 'true';
if ( nt.hasClass('only_sysop') ) {
criteria += '||in_group("sysop")';
}
if ( nt.hasClass('only_logged') ) {
criteria += '||in_group("user")';
}
if ( nt.hasClass('only_anon') ) {
criteria += '||!in_group("user")';
}
if ( nt.hasClass('only_zh_cn') ) {
criteria += '||only_for("zh-cn")';
}
if ( nt.hasClass('only_zh_hk') ) {
criteria += '||only_for("zh-hk")';
}
if ( nt.hasClass('only_zh_sg') ) {
criteria += '||only_for("zh-sg")';
}
if ( nt.hasClass('only_zh_tw') ) {
criteria += '||only_for("zh-tw")';
}
} else {
criteria = decodeURIComponent( criteria.replace(/\+/g, '%20') );
criteria = $.trim( criteria );
}
if ( criteria === '' ) {
criteria = 'true';
}
var testCriteria = function() {
var in_country = function( country ) {
return window.Geo === undefined || Geo.country === country;
}, in_region = function( region ) {
return window.Geo === undefined || Geo.region === region;
}, in_city = function( city ) {
return window.Geo === undefined || Geo.city === city;
}, in_group = function( group ) {
return $.inArray( group, mw.config.get( 'wgUserGroups' ) ) > -1;
}, only_for = function( userlang ) {
return userlang === mw.config.get('wgUserLanguage');
};
// FIXME: This shouldn't be using eval on data entered in wikitext. If that data is malformed it will throw an exception e.g. criteria = "(false))"
try {
return eval( criteria ); } catch ( e ) { return false; }
};
cacheonly['usr'] = testCriteria()only['sysop'] || only['logged'] || only['anon'];
nt.data(return 'asn-cache', cache )only;
return cache;
};
 
Line 103 ⟶ 58:
}
ct.css('min-height', ct.height() + 'px');
tb.css('min-height', tb.height() + 'px');
var l = nts.length;
var nt = null;
var rt = 0;
while (!nt rt++ < l|| nt.attr('class')) {
ntif = $(nt) nts[pos] );{
if ( matchCriteria( 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;
criteria += '||in_group("sysop")' break;
}
}
}pos = pos % l;
ifnt (= nt.hasClass$('only_anon'nts[pos++]) ) {;
}rt++;
if ( criteriart === undefined l) {
} return;
}
pos = (pos + 1) % l;
}
ifnt ( rt >= l nt.html() {;
if (ct.html()) return;{
} ct.stop().fadeOut(function () {
if ( typeof nt.data( 'asn-style' ) == 'string' ct.html(nt) {.fadeIn();
var styles = [] });
var style = mw.util.addCSS( decodeURIComponent( nt.data( 'asn-style' ).replace(/\+/g, '%20') ) );
nt.data( 'asn-style', null );
nt.data( 'asn-style-id', styles.length );
style.disabled = true;
styles.push( style );
}
if ( typeof nt.data( 'asn-html' ) == 'string' ) {
nt.data( 'asn-html-raw', decodeURIComponent( nt.data( 'asn-html' ).replace(/\+/g, '%20') ) );
nt.data( 'asn-html', null );
}
var styleId = nt.data( 'asn-style-id' );
nt = nt.data( 'asn-html-raw' ) || nt.html();
var cthtml = ct.html();
if ( cthtml ) {
if ( cthtml !== nt ) {
ct.stop().fadeOut(function () {
$.each( styles, function() {
this.disabled = true;
} );
if ( styles[styleId] ) {
styles[styleId].disabled = false;
}
ct.html(nt).fadeIn();
});
}
} else if (rev == cval) {
return;
} else {
$.cookie( cname, null );
tb.appendTo(ln);
if ( styles[styleId] ) {
styles[styleId].disabled = false;
}
ct.html(nt).fadeIn();
}
toid = setTimeout(function () {
loadNotices( (pos + 1) % l );
}, window.customASNInterval * 1000);
};
Line 160 ⟶ 93:
$.get(mw.util.wikiScript( 'api' ), {
page: 'Template:AdvancedSiteNotices/ajax',
variant: mw.config.get('wgUserVariant'),
prop: 'text',
action: 'parse',
Line 167 ⟶ 99:
smaxage: 3600
}, function (d) {
if(!d || !d.parse || !d.parse.text || !d.parse.text['*']) return;
d = $( '<div />' ).html( d.parse.text['*'] ).find( 'ul.sitents' );
nts = $('li', d);
Line 175 ⟶ 107:
});
});
}); })(jQuery, mediaWiki);
 
} );