Eisspeedway

User:MarMi wiki/common.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
console.log('common start');

var veAutoLoaded;

mw.hook('ve.activationComplete').add(function () {
	mw.notify('ve.activationComplete');
	var surface = ve.init.target.getSurface();
	if ( surface.getMode() === 'visual' ) {
		//[[:pl:User:Nux/veAutocorrect.js]]
		if (!veAutoLoaded)
		{
			mw.notify('import veAutocorrect');
    		importScript(':pl:User:Nux/veAutocorrect.js');
			veAutoLoaded = true;

			mw.hook('userjs.veNuxAutocorrect').add(function (nac, helpers) {
				mw.notify('userjs.veNuxAutocorrect');
			    const p = helpers.p;
			    const h2 = helpers.h2;
			    const tpl = helpers.tpl;
			
				const date = new Date();
				const my = date.toLocaleString('default', { month: 'long', year: 'numeric' });
			
				// '{p' -> {{Page needed}}
				nac.add({
			    	from: '{p',
			    	to: tpl({target: {href: 'Template:Page needed',wt: 'page needed'},params: {'date': {wt: my}}})
				});
		
				// '=e' -> =el + wypunktowanie
			    nac.add({
				    from: p('=e'),
				    to: [
						h2('External links', true),
						p('*')
					].flat()
				});
	
				// '=n' -> =n + {{Notelist}}
			    nac.add({
				    from: p('=n'),
				    to: [
						h2('Notes', true),	//skipParagraph - bez odstępu po sekcji
						tpl({
							target: {
								href: 'Template:NoteFoot',
								wt: 'noteFoot'
							}
						}, true),	//true=blok - kursor po Uwagi, inaczej kursor przed szablonem (i nie da się wstawiać po nim p)
					].flat()
				});
			
				// '{c' -> {{Clarify}}
				/*nac.add({
			    	from: '{c',
			    	to: tpl({target: {href: 'Template:Clarify',wt: 'clarify'},params: {'date': {wt: ym}}})
				});
				
				// '{du' -> {{Dubious}}
				nac.add({
			    	from: '{du',
			    	to: tpl({target: {href: 'Template:Dubious',wt: 'dubious'},params: {'date': {wt: ym}}})
				});
				
				// '{de' -> {{Dead link}}
				nac.add({
			    	from: '{de',
			    	to: tpl({target: {href: 'Template:Dead link',wt: 'dead link'},params: {'date': {wt: ym}}})
				});
				
				// '{f' -> {{Fact}}
				nac.add({
			    	from: '{f',
			    	to: tpl({target: {href: 'Template:Fact',wt: 'fact'},params: {'date': {wt: ym}}})
				});
				
				// '{w' -> {{When}}
				nac.add({
			    	from: '{w',
			    	to: tpl({target: {href: 'Template:When',wt: 'when'},params: {'date': {wt: ym}}})
				});*/
				
		
				// <nowiki>
				// '{we' -> {{Według kogo}}
				/*nac.add({
			    	from: '{we',
			    	to: tpl({target: {href: 'Szablon:Według kogo',wt: 'według kogo'},params: {'data': {wt: ym}}})
				});
				
				// '{o' -> {{Odn}}
				nac.add({
			    	from: '{o',
			    	to: tpl({target: {href: 'Szablon:Odn',wt: 'odn'}})
				});
				
				// '{n' -> {{Nie w źródle}}
				nac.add({
			    	from: '{n',
			    	to: tpl({target: {href: 'Szablon:Nie w źródle',wt: 'nie w źródle'},params: {'data': {wt: ym}}})
				});
				
				
				// '{l' -> {{Link-interwiki}}
				nac.add({
			    	from: '{l',
			    	to: tpl({target: {href: 'Szablon:Link-interwiki',wt: 'link-interwiki'}})
				});
				
				// '{kt' -> {{Kto}}
				nac.add({
			    	from: '{kt',
			    	to: tpl({target: {href: 'Szablon:Kto',wt: 'kto'},params: {'data': {wt: ym}}})
				});
				
		
				
				// '{f' -> {{fakt}}
				nac.add({
			    	from: '{f',
			    	to: tpl({target: {href: 'Szablon:Fakt',wt: 'fakt'},params: {'data': {wt: ym}}})
				});
				
				// '{c' -> {{Czy to ważne}}
				nac.add({
			    	from: '{c',
			    	to: tpl({target: {href: 'Szablon:Czy to ważne',wt: 'czy to ważne'},params: {'data': {wt: ym}}})
				});
				
				*/
				// </nowiki>
			});
		}
	}
});

//mw.loader.load('https://commons.wikimedia.org/w/index.php?title=User:Jack_who_built_the_house/convenientDiscussions.js&action=raw&ctype=text/javascript');


// initialize the array - only do this once
/*window.extraPopupFilters = [];

// define the function
function popupFilterPowerOf10 (wikiText) {
  if (/10^\d+/.test(wikiText)) return '10&lt;sup&gt;'+/10^(\d+)/.exec(wikiText)[1]+'&lt;sup&gt;';
  else return '';
}
*/
// add the function to the array (you can repeat this for lots of functions)
//extraPopupFilters.push(popupFilterPowerOf10);

// install [[:Wikipedia:User:Cacycle/wikEd]] in-browser text editor
/*(function ()
{
	var script = document.createElement('script');	//Wikipedysta:MarMi_wiki/wikiEd.js
	script.src = 'https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript';
	script.async = true;
	document.getElementsByTagName('head')[0].appendChild(script);
}
) ();
*/
//	var wikEdConfig = {};
//wikEdConfig.languageDefault = 'pl';

// install the English translation for [[en:User:Cacycle/wikEd]]

//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Konradek/wikEd_international_pl.js'
//+ '&action=raw&ctype=text/javascript');

//var wikEdConfig = {};

//wikEdConfig.loadTranslation = false;

console.log('common end');