User:Jberkel/Gadgets/Test.js

Hello, you have come here looking for the meaning of the word User:Jberkel/Gadgets/Test.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Jberkel/Gadgets/Test.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Jberkel/Gadgets/Test.js in singular and plural. Everything you need to know about the word User:Jberkel/Gadgets/Test.js you have here. The definition of the word User:Jberkel/Gadgets/Test.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Jberkel/Gadgets/Test.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
'use strict'; // <nowiki>
mw.log.warn("gadget loading");

function el(tag, child, attr, events) {
	var node = document.createElement(tag);
 
	if (child) {
		if (typeof child !== 'object')
			child = ;
		for (var i = 0; i < child.length; ++i) {
			var ch = child;
			if ((ch === void(null)) || (ch === null))
				continue;
			else if (typeof ch !== 'object')
				ch = document.createTextNode(String(ch));
			node.appendChild(ch);
		}
	}
 
	if (attr) for (var key in attr) {
		node.setAttribute(key, String(attr));
	}
 
	if (events) for (var key in events) {
		node.addEventListener(key, events, false);
	}
 
	return node;
}


var uiQuery, uiTitle,  uiTabs, uiTabLabels, uiForm;
var uiMain = el('div', [
	uiTitle = el('div', [
		el('strong', "TT"),
		el('a', "hide", {
			'href': 'javascript:void(0);',
			'class': 'hide-link'
		}, {
			'click': function () {
				uiMain.style.display = 'none';
			}
		})
	], { 'class': 'title' }),
	uiForm = el('form', [
		el('fieldset', [
			el('legend', "Search for example sentences"),
			uiQuery = el('input', null, {
				'type': 'text',
				'placeholder': "term",
				'class': 'search-terms',
				'value': (function () {
					var m;
					if (.indexOf(mw.config.get('wgNamespaceNumber')) !== -1) // main, Talk, Citations
						return '"' + mw.config.get('wgTitle') + '"';
					if (mw.config.get('wgNamespaceNumber') === 100)
						if (m = /+\/(.*)/.exec(mw.config.get('wgTitle')))
							return m;
					if (mw.config.get('wgCanonicalSpecialPageName') === 'Search')
						return '"' + document.getElementById('searchText').value + '"';
					return '';
				})()
			}),
			el('input', null, {
				'type': 'submit',
				'value': "search"
			})
		])
	], {
		'action': 'javascript:void(0);'
	}, {
		'submit': function () {	
           var query = uiQuery.value;
           console.log("search for "+query);				
                   jQuery.ajax({
						url: 'https://tatoeba.org/eng/sentences/search?query='+query+'&from=por',
						dataType: 'html',
					}).done(function (data) {
						console.log("data");
					});
		}
	}),
	uiTabLabels = el('ul', null, {
		'class': 'tab-labels',
		'style': 'display: none;'
	}),
	uiTabs = el('div', null, {
		'class': 'tabs',
		'style': 'display: none;'
	})
], {
	'class': 'jberkel-tt',
	'style': 'display: none; position: fixed;'
});
jQuery(uiMain).draggable({
	handle: uiTitle
}).resizable({
	alsoResize: uiTabs
});

document.body.appendChild(uiMain);

var link = mw.util.addPortletLink(mw.config.get('skin') === 'vector' ? 'p-views' : 'p-cactions',
	'javascript:void(0);', 'TT', 'p-Jberkel-tt', "TT", '9'
);

link.addEventListener('click', function () {
	uiMain.style.display = '';
	uiQuery.focus();
}, false);