หมายเหตุ: หลังเผยแพร่ คุณอาจต้องล้างแคชเว็บเบราว์เซอร์ของคุณเพื่อดูการเปลี่ยนแปลง

  • ไฟร์ฟอกซ์ / ซาฟารี: กด Shift ค้างขณะคลิก Reload หรือกด Ctrl-F5 หรือ Ctrl-R (⌘-R บนแมค)
  • กูเกิล โครม: กด Ctrl-Shift-R (⌘-Shift-R บนแมค)
  • อินเทอร์เน็ตเอกซ์พลอเรอร์ และ Edge: กด Ctrl ค้างขณะคลิก Refresh หรือกด Ctrl-F5
  • โอเปร่า: กด Ctrl-F5
var pageName = mw.config.get('wgPageName');
var pageTitle = mw.config.get('wgTitle');
var indexUrl = mw.util.wikiScript('index');
var apiUrl = mw.util.wikiScript('api');
function get_part_of_speech(link)
{
	// Acceleration can be added to inflection tables too.
	// This tells the search script to skip headers with these names.
	var skipheaders = ["รูปแบบอื่น", "คำตรงข้าม", "การผันรูป", "การผันรูป", "ลูกคำ", 
		"inflection", "การกลายรูป", "คำที่เกี่ยวข้อง", "การผันรูป", "คำแปลภาษาอื่น", "usage notes"];
	var node = link;
	
	while (node)
	{
		if (node.nodeType == 1 && node.nodeName.match(/^[hH][3456]$/))
		{
			var header = $(node).find(".mw-headline").text().replace(/^[1-9.]* /, "").toLowerCase();
			
			if (skipheaders.indexOf(header) == -1)
				return header;
		}
		
		node = node.previousSibling || node.parentNode;
	}
	
	throw new Error("This entry seems to be formatted incorrectly. Does it have a language and part-of-speech header?");
}
function get_language_name(link)
{
	var node = link;
	
	while (node)
	{
		if (node.nodeType == 1)
		{
			if (node.nodeName.match(/^[hH]2$/))
				return $(node).find(".mw-headline").text().replace(/^[1-9.]* /, "");
			else if (node.className == "languageContainer")  // TabbedLanguages support
				return node.id.replace(/container$/, "");
		}
		
		node = node.previousSibling || node.parentNode;
	}
	
	throw new Error("This entry seems to be formatted incorrectly. Does it have a language and part-of-speech header?");
}


$(document).ready(function() {
// Finnish
$('.lang-fi').each(function() {
	var word = $(this);
	var formhead = $(this).text().slice(0,2);
	var regfromh = new RegExp(formhead, 'g');
	var fform = $(this).text().replace(regfromh, '??' + formhead).slice(2);
	var form,form2,form3,fform2,fform3;
	if (fform.includes('??') === true) {
		form = fform.substring(0, fform.indexOf('??'));
		fform2 = fform.substring(fform.indexOf('??')).slice(2);
		if (fform2.includes('??') === true) {
			form2 = fform2.substring(0, fform2.indexOf('??'));
			form3 = fform2.substring(fform2.indexOf('??')).slice(2);
		} else {
			form2 = fform2;
		}
	} else {
		form = fform;
	}
	var clas = $(this).attr('class').slice(8,-16);
	var infl = {
		'plural-nominative':'nom|p',
		'singular-genitive':'gen|s',
		'plural-genitive':'gen|p',
		'singular-partitive':'par|s',
		'plural-partitive':'par|p',
		'singular-inessive':'ine|s',
		'plural-inessive':'ine|p',
		'singular-elative':'ela|s',
		'plural-elative':'ela|p',
		'singular-illative':'ill|s',
		'plural-illative':'ill|p',
		'singular-adessive':'ade|s',
		'plural-adessive':'ade|p',
		'singular-ablative':'abl|s',
		'plural-ablative':'abl|p',
		'singular-allative':'all|s',
		'plural-allative':'all|p',
		'singular-essive':'ess|s',
		'plural-essive':'ess|p',
		'singular-translative':'tra|s',
		'plural-translative':'tra|p',
		'plural-instructive':'ins|p',
		'plural-comitative':'com|p', 
		'singular-abessive':'abe|s',
		'plural-abessive':'abe|p'
	};
	var button = $('<button>สร้าง</button>').click(function() {
		$(this).fadeOut();
		word.fadeOut();
		var exporttext = '== ภาษาฟินแลนด์ ==\n\n=== การออกเสียง ===\n{{fi-pronunciation}}\n\n=== คำนาม ===\n{{head|fi|รูปผันคำนาม}}\n\n# {{inflection of|' + pageName + '||' + infl[clas] + '|lang=fi}}';
		$.post(apiUrl, {
			'action': 'edit',
			'title': form,
			'summary': 'สร้างคำผันจาก [[' + pageName + ']] (โดยใช้ [[ผู้ใช้:ZilentFyld/autocreat.js|Autocreat]])',
			'createonly': '1',
			'appendtext': exporttext,
			'token': mw.user.tokens.get('editToken'),
			'format': 'xml'
		}, function () {
			mw.util.jsMessage('สร้างหน้า ' + form + ' เรียบร้อยแล้ว');
			word.fadeIn()
		});
		if (typeof form2 !== 'undefined')  {
			$.post(apiUrl, {
				'action': 'edit',
				'title': form2,
				'summary': 'สร้างคำผันจาก [[' + pageName + ']] (โดยใช้ [[ผู้ใช้:ZilentFyld/autocreat.js|Autocreat]])',
				'createonly': '1',
				'appendtext': exporttext,
				'token': mw.user.tokens.get('editToken'),
				'format': 'xml'
			}, function () {
				mw.util.jsMessage('สร้างหน้า ' + form + ' เรียบร้อยแล้ว');
				word.fadeIn()
			});
		}
		if (typeof form3 !== 'undefined')  {
			$.post(apiUrl, {
				'action': 'edit',
				'title': form3,
				'summary': 'สร้างคำผันจาก [[' + pageName + ']] (โดยใช้ [[ผู้ใช้:ZilentFyld/autocreat.js|Autocreat]])',
				'createonly': '1',
				'appendtext': exporttext,
				'token': mw.user.tokens.get('editToken'),
				'format': 'xml'
			}, function () {
				mw.util.jsMessage('สร้างหน้า ' + form + ' เรียบร้อยแล้ว');
			word.fadeIn()
			});
		}
	});
	$(this).after(button);
});

// Swedish
$('.lang-sv').each(function() {
	var word = $(this);
	var form = $(this).text();
	var clas = $(this).attr('class').slice(8,-16);
	var infl = {
		'sv-indf-nom-sg':'nom|s|indf',
		'sv-defn-nom-sg':'nom|s|defn',
		'sv-indf-nom-pl':'nom|p|indf',
		'sv-defn-nom-pl':'nom|p|defn',
		'sv-indf-gen-sg':'gen|s|indf',
		'sv-defn-gen-sg':'gen|s|defn',
		'sv-indf-gen-pl':'gen|p|indf',
		'sv-defn-gen-pl':'gen|p|defn'
	};
	var button = $('<button>สร้าง</button>').click(function() {
		$(this).fadeOut();
		word.fadeOut();
		var exporttext = '== ภาษาสวีเดน ==\n\n=== คำนาม ===\n{{head|sv|รูปผันคำนาม}}\n\n# {{inflection of|' + pageName + '||' + infl[clas] + '|lang=sv}}';
		$.post(apiUrl, {
			'action': 'edit',
			'title': form,
			'summary': 'สร้างคำผันจาก [[' + pageName + ']] (โดยใช้ [[ผู้ใช้:ZilentFyld/autocreat.js|Autocreat]])',
			'createonly': '1',
			'appendtext': exporttext,
			'token': mw.user.tokens.get('editToken'),
			'format': 'xml'
		}, function () {
			mw.util.jsMessage('สร้างหน้า ' + form + ' เรียบร้อยแล้ว');
			word.fadeIn();
		});
	});
	$(this).after(button);
});
// English (Noun)
$('.lang-en').each(function() {
	var word = $(this);
	var form = $(this).text();
	var clas = $(this).attr('class').slice(21,-8)
	var infl = {
		'plural':'plural of', 'third-person-singular' : 'en-third-person singular of', 'present-participle' : 'present participle of',
		'simple-past-and-participle' : 'en-past of'
	};
	var pos = {
		'plural':'นาม','third-person-singular': 'กริยา', 'present-participle' : 'กริยา', 'simple-past-and-participle' : 'กริยา'
	};
	var button = $('<button>' + clas + '</button>').click(function() {
		$(this).fadeOut();
		word.fadeOut();
		var exporttext = '== ภาษาอังกฤษ ==\n\n=== คำ' + pos[clas] + ' ===\n{{head|en|รูปผันคำ' + pos[clas] + '}}\n\n# {{' + infl[clas] + '|' + pageName + '|lang=en}}';
		$.post(apiUrl, {
			'action': 'edit',
			'title': form,
			'summary': 'สร้างคำผันจาก [[' + pageName + ']] (โดยใช้ [[ผู้ใช้:ZilentFyld/autocreat.js|Autocreat]])',
			'createonly': '1',
			'appendtext': exporttext,
			'token': mw.user.tokens.get('editToken'),
			'format': 'xml'
		}, function () {
			mw.util.jsMessage('สร้างหน้า ' + form + ' เรียบร้อยแล้ว');
			word.fadeIn();
		});
	});
	$(this).after(button);
});
});