מדיה ויקי:AlertProtected.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
/*
For protected pages:
Automatically show an icon at the top of the page according to protection level.
Based on Hebrew Wikipedia's script from //he.wikipedia.org/wiki/מדיה_ויקי:Common.js
*/
$.when( mw.loader.using( 'mediawiki.util' ), $.ready ).then( function () {
var protectionLevel = mw.config.get( 'wgRestrictionEdit' ) || mw.config.get( 'wgRestrictionCreate' ),
checkedAction = mw.config.get( 'wgArticleId' ) ? 'edit' : 'create',
uiLanguage = mw.config.get( 'wgUserLanguage' ),
protectionIcon, protectionTooltip;
if ( protectionLevel && protectionLevel.length && $.inArray( mw.config.get( 'wgAction' ), [ 'view', 'submit' ] ) + 1 && !document.getElementById( 'no-protection-icon' ) ) {
switch ( protectionLevel[ 0 ] ) {
case 'autoconfirmed':
protectionIcon = 'Cadenas-entrouvert-jaune.svg',
protectionTooltip = i18n( 'semi' );
break;
case 'sysop':
protectionIcon = 'Cadenas-ferme-rouge.svg',
protectionTooltip = i18n( 'fully' );
}
new mw.Api().get( {
action: 'parse',
format: 'json',
text: '[[' + 'File:' + protectionIcon + '|23px|link={{ns:project}}:דף מוגן|' +
protectionTooltip + ' {{#ifeq:{{PROTECTIONEXPIRY:' + checkedAction + '}}|infinity||' +
i18n( 'until' ) + ' {{#timel:H:i, j xg Y|{{PROTECTIONEXPIRY:' + checkedAction + '}}|' + uiLanguage + '}}}}]]',
prop: 'text',
title: mw.config.get( 'wgPageName' ),
contentmodel: 'wikitext',
wrapoutputclass: 'protected-icon-wrapper'
} ).then( function ( data ) {
$( function () {
if ( !$( '.mw-indicator' ).length ) {
$( '<span>' )
.attr( { 'id': 'mw-indicator-protected', 'class': 'mw-indicator protected-icon', 'style': 'margin-left: 25px' } )
.html( data.parse.text[ '*' ] )
.appendTo( '.mw-indicators' );
}
else {
$( '<span>' )
.attr( { 'class': 'protected-icon', 'style': 'margin-left: 10px; margin-right: 5px' } )
.html( data.parse.text[ '*' ] )
.appendTo( '.mw-indicator' );
}
} );
mw.util.addCSS( '.protected-icon-wrapper { display: inline-block; }' );
} );
}
function i18n( key ) {
switch ( uiLanguage ) {
case 'he':
switch ( key ) {
case 'semi': return 'דף זה מוגן חלקית';
case 'fully': return 'דף זה מוגן';
case 'until': return 'עד';
}
break;
default:
switch ( key ) {
case 'semi': return 'This page is semi-protected';
case 'fully': return 'This page is protected';
case 'until': return 'until';
}
}
}
} );