User:Dixtosa/link to GED.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

$(() => {
	const pageName = mw.config.values.wgPageName;
	if ($("h2 span.mw-headline#Georgian").length > 0 || $("h2 span.mw-headline#Old_Georgian").length > 0 || mw.config.values.wgRelevantArticleId == 0)
	{
		addToRightVectorTabs("ena.ge", get_ena_ge());
		addToRightVectorTabs("translate.ge", get_translate_ge());
	}
	else if ($("h2 span.mw-headline#English").length > 0)
		addToRightVectorTabs("translate.ge", get_translate_ge());
	
	function addToRightVectorTabs(title, link) {
		let description = "გადადი ამ საიტზე და შეამოწმე ეს ტერმინი";
		mw.util.addPortletLink('p-views', link, title, 'ca-' + title.replace(".", "-"), description, null, "#ca-view");
	}
	function get_translate_ge() {
		const base = "http://translate.ge/word/";
		return base + pageName;
	}
	function get_ena_ge() {
		const base = "http://ena.ge/explanatory-online?ls=";
		const phpobj = 'a:2:{s:12:"word_metauri";s:' + 3 * pageName.length + ':"' + pageName + '";s:11:"word_statia";s:0:"";}';
		const php_base64 = btoa(unescape(encodeURIComponent(phpobj)));
		return base + php_base64;
	}
});