Uživatel:Shlomo/common.js: Porovnání verzí

Z Wikislovníku
Skočit na navigaci Skočit na vyhledávání
Smazaný obsah Přidaný obsah
secure
WS:AKÚ
Řádek 50: Řádek 50:
importStylesheetURI('//commons.wikimedia.org/w/index.php?action=raw&ctype=text/css&title=MediaWiki:Gadget-Cat-a-lot.css');
importStylesheetURI('//commons.wikimedia.org/w/index.php?action=raw&ctype=text/css&title=MediaWiki:Gadget-Cat-a-lot.css');
importScriptURI('https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript');
importScriptURI('https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript');

// <nowiki>

/**
* @brief
* Automatické kosmetické úpravy.
*
* @details
* Před uložením stránky provádí následující kosmetické úpravy:
* * nadpisy volně s odřádkováním před a bez odřádkování za
* * volný zápis * a # seznamů
* * dlouhá pomlčka místo krátké nebo spojovníku v proškrtnutých položkách seznamů
* * rozložený zápis prázdné šablony {{Překlady}}
* * správný zápis kategorií
* * formátování víceřádkových šablon
* * odstranění mezer na konci řádku
* * odstranění vícenásobných mezer v textu
* * odstranění vícenásobného odřádkování
*
* @author
* [[meta:User:Danny B.]]
*/

/*global mediaWiki, jQuery */
/*jslint browser: true, plusplus: true, white: true */
/*jshint browser:true, laxbreak:false, plusplus:false, white:false, undef:true, unused:true */

( function ( mw, $ ) {
'use strict';
if ( mw.config.get( 'wgNamespaceNumber' ) || !/^(edit|submit)$/.test( mw.config.get( 'wgAction' ) ) ) {
return;
}
$( document ).ready( function () {
var replacements = [
[
/(^|\n)(==+)([^=]+)(\2) *(?=\n)/g,
function ( $0, $1, $2, $3, $4 ) {
return $1 + '\n' + $2 + ' ' + $.trim( $3 ) + ' ' + $4
}
], [
/\n\{\{\s*[Ss][Uu][Bb][Ss][Tt]\s*:\s*Vzor /g,
'\n\n{{subst:Vzor '
], [
/\n([#\*]+)([^\n]*)/g,
function ( $0, $1, $2 ) {
return '\n' + $1 + ' ' + $.trim( $2 )
}
], [
/# [-–] */g,
'# —'
], [
/# \{\{Překlady *\}\}/g,
'# {{Překlady\n}}'
], [
/\[\[ *Kategorie *:([^\]]+)\]\]/gi,
function ( $0, $1 ) {
return '\n[[Kategorie:' + $.trim( $1 ) + ']]\n';
}
], [
/(\[\[Kategorie:[^\]]+\]\])\n+(?!\[\[[a-z])/g,
'$1\n'
], [
/\n+ *\|([^=\n]+)=(?![^\n\|]*\|\|[^\n]*\n)([^\n]*)(?=\n)/g,
function ( $0, $1, $2 ) {
return '\n | ' + $.trim( $1 ) + ' = ' + $.trim( $2 );
}
], [
/([^=]) +\n/g,
'$1\n'
], [
/([^\n]) +/g,
'$1 '
], [
/\n{3,}/g,
'\n\n'
]
];
$( '#wpSave' ).click( function () {
$( '#wpTextbox1' ).val( function ( index, oldPageText ) {
var newPageText = oldPageText;
$.each( replacements, function ( index, replacement ) {
newPageText = newPageText.replace( replacement[0], replacement[1] );
});
newPageText = $.trim( newPageText ) + '\n';
if ( newPageText !== oldPageText ) {
$( '#wpSummary' ).val( function ( index, summary ) {
var summarySeparator = '';
summary = $.trim( summary );
if ( summary !== '' ) {
summarySeparator = /^\/\*.*\*\/$/.test( summary ) ? ' ' : '; '
}
return summary + summarySeparator + '[[WS:AKÚ]]';
});
}
return newPageText;
});
return true;
});
});
}( mediaWiki, jQuery ) );

Verze z 10. 11. 2015, 19:13

( function ( $ ) {
 
	'use strict';
 
 
	$( document ).ready( function () {
 
		$( 'div.translations span.translation-item' ).each( function ( index ) {
 
			var lang = $( this ).attr( 'lang' );
			var text = $( this ).attr( 'data-iw' );
			if (!text) {
				text = $( this ).text();
				if (lang=='he') {
					text = text
						.replace( /[\u05b0-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7]/g, '' )
						.replace(/\u05f3/g,"'")
						.replace(/\u05f4/g,'"')
				}
			}
 
			$( this )
				.after(
					$( '<span>' )
						.attr({
							class: 'mwg-translation-item-iwlink'
						})
						.append(
							$( '<a>' )
								.attr({
									class: 'extiw',
									href: '//' + lang + '.wiktionary.org/wiki/' + text,
									title: lang + ':' + text
								})
								.text( '(' + lang + ')' )
						)
				)
				.after( ' ' )
 
		});
 
	});
 
 
}( jQuery ) );

window.catALotPrefs = {editpages:  true};
mediaWiki.loader.load('jquery.ui.resizable');
importScriptURI('//commons.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-Cat-a-lot.js');
importStylesheetURI('//commons.wikimedia.org/w/index.php?action=raw&ctype=text/css&title=MediaWiki:Gadget-Cat-a-lot.css');
importScriptURI('https://secure.wikimedia.org/wikipedia/commons/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript');

// <nowiki>

/**
 * @brief
 *  Automatické kosmetické úpravy.
 * 
 * @details
 *  Před uložením stránky provádí následující kosmetické úpravy:
 *  * nadpisy volně s odřádkováním před a bez odřádkování za
 *  * volný zápis * a # seznamů
 *  * dlouhá pomlčka místo krátké nebo spojovníku v proškrtnutých položkách seznamů
 *  * rozložený zápis prázdné šablony {{Překlady}}
 *  * správný zápis kategorií
 *  * formátování víceřádkových šablon
 *  * odstranění mezer na konci řádku
 *  * odstranění vícenásobných mezer v textu
 *  * odstranění vícenásobného odřádkování
 * 
 * @author
 *  [[meta:User:Danny B.]]
 */

/*global mediaWiki, jQuery */
/*jslint browser: true, plusplus: true, white: true */
/*jshint browser:true, laxbreak:false, plusplus:false, white:false, undef:true, unused:true */

( function ( mw, $ ) {
	
	'use strict';
	
	
	if ( mw.config.get( 'wgNamespaceNumber' ) || !/^(edit|submit)$/.test( mw.config.get( 'wgAction' ) ) ) {
		return;
	}
	
	
	$( document ).ready( function () {
		
		var replacements = [
			[
				/(^|\n)(==+)([^=]+)(\2) *(?=\n)/g,
				function ( $0, $1, $2, $3, $4 ) {
					return $1 + '\n' + $2 + ' ' + $.trim( $3 ) + ' ' + $4
				}
			], [
				/\n\{\{\s*[Ss][Uu][Bb][Ss][Tt]\s*:\s*Vzor /g,
				'\n\n{{subst:Vzor '
			], [
				/\n([#\*]+)([^\n]*)/g,
				function ( $0, $1, $2 ) {
					return '\n' + $1 + ' ' + $.trim( $2 )
				}
			], [
				/# [-–] */g,
				'# —'
			], [
				/# \{\{Překlady *\}\}/g,
				'# {{Překlady\n}}'
			], [
				/\[\[ *Kategorie *:([^\]]+)\]\]/gi,
				function ( $0, $1 ) {
					return '\n[[Kategorie:' + $.trim( $1 ) + ']]\n';
				}
			], [
				/(\[\[Kategorie:[^\]]+\]\])\n+(?!\[\[[a-z])/g,
				'$1\n'
			], [
				/\n+ *\|([^=\n]+)=(?![^\n\|]*\|\|[^\n]*\n)([^\n]*)(?=\n)/g,
				function ( $0, $1, $2 ) {
					return '\n  | ' + $.trim( $1 ) + ' = ' + $.trim( $2 );
				}
			], [
				/([^=]) +\n/g,
				'$1\n'
			], [
				/([^\n]) +/g,
				'$1 '
			], [
				/\n{3,}/g,
				'\n\n'
			]
		];
		
		$( '#wpSave' ).click( function () {
			
			$( '#wpTextbox1' ).val( function ( index, oldPageText ) {
				
				var newPageText = oldPageText;
				
				$.each( replacements, function ( index, replacement ) {
					newPageText = newPageText.replace( replacement[0], replacement[1] );
				});
				
				newPageText = $.trim( newPageText ) + '\n';
				
				if ( newPageText !== oldPageText ) {
					$( '#wpSummary' ).val( function ( index, summary ) {
						var summarySeparator = '';
						summary = $.trim( summary );
						if ( summary !== '' ) {
							summarySeparator = /^\/\*.*\*\/$/.test( summary ) ? ' ' : '; '
						}
						return summary + summarySeparator + '[[WS:AKÚ]]';
					});
				}
				
				return newPageText;
				
			});
			
			return true;
			
		});
		
	});
	
}( mediaWiki, jQuery ) );