Kullanıcı:Yusuf 506/LocalLiveClock.js

Vikipedi, özgür ansiklopedi
Not: Sayfayı kaydettikten sonra değişiklikleri görebilmek için tarayıcınızın önbelleğinizi temizlemeniz gerekir. Google Chrome, Firefox, Microsoft Edge ve Safari: ⇧ Shift tuşuna basılı tutun ve Yeniden Yükle araç çubuğu düğmesine tıklayın. Ayrıntılar ve diğer tarayıcılara yönelik yönergeler için Vikipedi:Önbelleğinizi atlayın sayfasını inceleyin.
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hedonil/XTools/XTools.js&action=raw&ctype=text/javascript');
/*global jQuery, mediaWiki */
(function( $, mw ) {
	'use strict';

	var PrintDialog = {
		install: function () {
			$( '#t-print a' )
				.click( function ( e ) {
					PrintDialog.open();
					e.preventDefault();
				} )
				.text( 'Sayfayı yazdır' );
		},

		open: function () {
			var response,
				$dialog,
				dlgButtons = {};
			dlgButtons.Print = function () {
				$.each( PrintDialog.questions, function ( i, v ) {
					response = $( '#PrintOption' + i ).val();
					if ( v.type === 'checkbox' ) {
						response = $( '#PrintOption' + i ).prop( 'checked' );
					}
					PrintDialog[v.returnvalue] = response;
				} );
				PrintDialog.changePrintCSS();
				PrintDialog.otherEnhancements();
				$(this).dialog( 'close' );
				window.print();
				if( !$.browser.opera ) {
					/* Reload the page to fix the overridden stylesheets */
					window.location = window.location;
				}
			};
			dlgButtons.Cancel = function () {
				$(this).dialog( 'close' );
			};
			$dialog = $( '<div></div>' )
				.html( '<div id="PrintDialogContainer"></div>' )
				.dialog( {
					width: 600,
					modal: true,
					title: 'Sayfayı yazdır',
					draggable: true,
					dialogClass: 'wikiEditor-toolbar-dialog',
					close: function () {
							$(this).dialog( 'destroy' );
							$(this).remove();
					},
					buttons: dlgButtons
				} );
			$.each( PrintDialog.questions, function ( i, v ) {
				 if( v.type === 'checkbox' &&
				 		( v.returnvalue !== 'enhanced' || mw.config.get( 'wgUserName' ) === 'TheDJ' ) )
				 {
					$( '#PrintDialogContainer' ).append( '<input type="checkbox" id="PrintOption' + i + '" ' + (v.checked ? 'checked' : '') + '>' + '<label for="PrintOption' + i + '">' + v.label + '</label><br>' );
				 }
			} );
		}, /* end open */

		changePrintCSS: function () {
			/* Here we:
				 - disable stylesheets that are print specific
				 - make screen specific stylesheets also enabled for print medium
				 - remove print specific stylerules
				 - make screen specific stylerules also enabled for print medium
			*/
			var printStyle = '';
			if( this.enhanced === undefined ) {
 				var i, j, k,
 					rule,
				 	hasPrint,
				 	hasScreen,
				 	rules,
					stylesheet,
					disabled,
				 	stylesheets = document.styleSheets;

				for( i = 0; i < stylesheets.length; i++ ) {
					stylesheet = stylesheets[i];
					disabled = false;
					if( !stylesheet.media ) {
						continue;
					}
					if( stylesheet.media.mediaText && stylesheet.media.mediaText.indexOf( 'print' ) !== -1 ) {
						if(stylesheet.media.mediaText.indexOf( 'screen' ) === -1 ) {
							stylesheet.disabled = true;
						}
					} else if( stylesheet.media.mediaText && stylesheet.media.mediaText.indexOf( 'screen' ) !== -1) {
						if( stylesheet.media.mediaText.indexOf( 'print' ) === -1 ) {
							try {
								stylesheet.media.appendMedium( 'print' );
							} catch( e ) {
								stylesheet.media.mediaText += ',print';
							}
						}
					}

					/* now test individual stylesheet rules */
					try {
						rules = stylesheet.cssRules || stylesheet.rules;
					} catch( e ) {
						/* Cross domain issue. */
						mw.log.warn( 'Not possible to correct stylesheet due to cross origin restrictions.' );
						continue;
					}
					stylesheet.compatdelete = stylesheet.deleteRule || stylesheet.removeRule;
					for( j = 0; rules && j < rules.length; j++ ) {
						rule = rules[j];
						hasPrint = false;
						hasScreen = false;
						if( rule.type === 4 && rule.media ) {
							for( k = 0; k < rule.media.length; k++ ) {
								if( rule.media[k] === 'print' ) {
									hasPrint = true;
								} else if (rule.media[k] === 'screen' ) {
									hasScreen = true;
								}
							}
						} else {
							continue;
						}
						if( hasPrint && !hasScreen ) {
							stylesheet.compatdelete( j );
							j--;
						} else if ( hasScreen && !hasPrint ) {
							stylesheet.media.appendMedium( 'print' );
						}
					}
				}
			}
			/* Add css to hide images */
			if( this.noimages ) {
				printStyle += 'img, .thumb {display:none;}\n';
			}
			/* Add css to hide references markers and the references lists */
			if( this.norefs ) {
				printStyle += '.mw-headline[id="References"], ol.references, .reference {display:none;}\n';
			}
			if( this.notoc ) {
				printStyle += '#toc, .toc {display:none;}\n';
			}
			if( this.nobackground ) {
				printStyle += '* {background:none !important;}\n';
			}
			if( this.blacktext ) {
				printStyle += '* {color:black !important;}\n';
			}

			if ( printStyle ) {
				$( 'head' ).append( '<style type="text/css" media="print">' + printStyle + '</style>' );
			}
		},

		/* Rewrite the "retrieved from" url to be readable */
		otherEnhancements: function () {
			var link = $( 'div.printfooter a' );
			link.text( decodeURI( link.text() ) );
		},

		questions: [
			{
				label: "Arayüz öğelerini gizle ",
				type: "checkbox",
				checked: true,
				returnvalue: 'enhanced'
			},
			{
				label: 'Resimleri gizle',
				type: 'checkbox',
				checked: false,
				returnvalue: 'noimages'
			},
			{
				label: 'Referansları gizle',
				type: 'checkbox',
				checked: false,
				returnvalue: 'norefs'
			},
			{
				label: 'İçindekiler tablosunu gizle',
				type: 'checkbox',
				checked: false,
				returnvalue: 'notoc'
			},
			{
				label: 'Arka planları kaldır',
				type: 'checkbox',
				checked: false,
				returnvalue: 'nobackground'
			},
			{
				label: 'Tüm metni siyah olmaya zorla',
				type: 'checkbox',
				checked: true,
				returnvalue: 'blacktext'
			}
		]
	};

	if ( mw.config.get( 'wgNamespaceNumber' ) >= 0 ) {
		$( PrintDialog.install );
		var $stylesheets = $('link[rel="stylesheet"]');
		if ( mw.config.get( 'wgUserName' ) === 'TheDJ' && 'crossOrigin' in $stylesheets.get(0) ) {
			$stylesheets.each( function( index, Element ) {
				Element.crossOrigin = 'anonymous';				
			} );
		}
	}
} ) ( jQuery, mediaWiki );
/**
 * Add "Purge" content action link.
 *
 * Dependencies: mediawiki.util, mediawiki.api
 *
 * @source https://www.mediawiki.org/wiki/Snippets/Purge_action
 * @revision 2016-05-22
 */
$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api']), $.ready).then(function () {
	if ( $( '#ca-purge' ).length || !mw.config.get( 'wgIsArticle' ) ) return;
	var node = mw.util.addPortletLink(
		'p-cactions',
		mw.util.getUrl( null, { action: 'purge' } ),
		'Önbelleği temizle',
		'ca-purge',
		'Bu sayfanın sunucu önbelleğini temizleyin'
	);
	$(node).on( 'click', function (e) {
		new mw.Api().post( { action: 'purge', titles: mw.config.get( 'wgPageName' ) } ).then(function () {
			location.reload();
		}, function () {
			mw.notify( 'Önbellek temizlenemedi', { type: 'error' } );
		});
		e.preventDefault();
	});
});
/*
 * dependencies=mediawiki.jqueryMsg,mediawiki.user
 */
location.search.indexOf( 'printable=yes' ) === -1 && mw.config.get( 'wgPageContentModel' ) !== 'wikibase-item' && mw.loader.using( [ 'mediawiki.jqueryMsg', 'mediawiki.user' ] ).done( function () {
	var translate = {
		'tr': {
			notfound: "Vikiveri öğesi bulunamadı.",
			intro: "Vikiveri: ",
			nolabel: "(Etiket bulunmadı)",
			nodescription: "Açıklama bulunmadı",
			aliases: "{{PLURAL:$1|Alias|Aliases}}: ",
			noaliases: "Yok"
		},
			};
	var namespace = mw.config.get( 'wgNamespaceNumber' ),
		lang = mw.config.get( 'wgContentLanguage' ),
		page = ( namespace -= ( namespace > 0 && namespace % 2 ) ) === 0 ? mw.config.get( 'wgTitle' ) : mw.config.get( 'wgFormattedNamespaces' )[ namespace ] + ':' + mw.config.get( 'wgTitle' );

	namespace !== 2 && namespace !== -1 && $.ajax( {
		url: '//www.wikidata.org/w/api.php',
		data: {
			'format': 'json',
			'action': 'wbgetentities',
			'sites': mw.config.get( 'wgDBname' ),
			'titles': page,
			'props': 'info|labels|descriptions|aliases',
			'languages': lang,
			'maxage': mw.user.isAnon() ? 900 : 30,
			'smaxage': mw.user.isAnon() ? 900 : 30,
			'maxlag': 1
		},
		dataType: 'jsonp',
		cache: true
	} )
	.done( function ( data ) {
		if ( data.success ) {
			$( function () {
				var $d = $( '<div>' ).addClass( 'WDI-box' ),
					userLang = mw.config.get( 'wgUserLanguage' ),
					m = Object.prototype.hasOwnProperty.call( translate, userLang ) ? translate[ userLang ] : translate.en;
				mw.messages.set( 'WDI-aliases', m.aliases );
				$.each( data.entities, function ( entity, item ) {
					if ( entity == -1 ) {
						$d.append( $( '<a>' ).attr( 'href',
							'//www.wikidata.org/wiki/Special:CreateItem?site=' +
							mw.config.get( 'wgDBname' ) +
							'&page=' + encodeURIComponent( page ) +
							'&label=' + encodeURIComponent( page )
						).text( m.notfound ) );
					} else {
						var label = item.labels[ lang ] && item.labels[ lang ].value,
							description = item.descriptions[ lang ] && item.descriptions[ lang ].value,
							aliases = $.map( item.aliases[ lang ] || [], function ( alias ) {
								return alias.value;
							} );
						if ( window.WDIlimitaliases && WDIlimitaliases < aliases.length ){
							for( ; WDIlimitaliases < aliases.length; aliases.pop() ) ;
							aliases.push( '...' );
						}
						$d.append(
							$( '<a>' )
								.attr( 'href', '//www.wikidata.org/wiki/' + item.title )
								.text( m.intro + ( label || m.nolabel ) ),
							' (',
							$( '<a>' )
								.attr( 'href', '//www.wikidata.org/wiki/' + item.title )
								.text( item.title ),
							')',
							$( '<span>' ).text( ', ' ),
							$( '<i>' )
								.text( description || m.nodescription )
								.addClass( description ? 'WDI-desc' : 'WDI-desc WDI-nodesc' ),
							$( '<br>' ),
							$( '<span>' ).text( mw.msg( 'WDI-aliases', aliases.length ) + ( aliases.join( ', ' ) || m.noaliases ) )
						);
					}
				} );
				$d.appendTo( '#contentSub' );
			} );
		}
	} );
} );
$(function () {
    var title = wgTitle;

    mw.util.addPortletLink('p-tb', '/wiki/Special:PrefixIndex/' + mw.config.get('wgPageName'),
                   'Alt sayfalar', 't-subpages');

});