User:Schloe06/common.js

messages = { 'en': { 'quickchanges-title': 'Hello there!', 'quickchanges-greeting': 'Welcome, $1!', 'quickchanges-intro': 'The following pages have been recently modified:', 'quickchanges-link': 'Find related content', 'quickchanges-tooltip': 'Get recommendations of images and references on the fly' } };

mw.messages.set(messages['en']); var lang = mw.config.get('wgUserLanguage'); if (lang && lang != 'en' && lang in messages) { mw.messages.set(messages[lang]); }

// Import the jQuery dialog plugin before starting the rest of this script mw.loader.using(['jquery.ui.dialog'], function {

var autoQuery = function(e) { if (e.keyCode == 13) { console.log('trigger'); var text = this.value; var paragraphs = { language:'en', paragraphs:[{ id:1, content:text, headline:'' }]           };            console.log(paragraphs); var xhr = $.ajax({               url: 'https://eexcess.joanneum.at/eexcess-privacy-proxy-issuer-1.0-SNAPSHOT/issuer/recognizeEntity',                data: JSON.stringify(paragraphs),                type: 'POST',                contentType: 'application/json',                dataType: 'json',                timeout:5000            }); xhr.done(function(response) {           	console.log(response);            }); }	};

$(document).ready( function {

// Add a link to the toolbox var link = mw.util.addPortletLink(			'p-tb',			'#',			mw.message('quickchanges-link').plain,			't-prettylinkwidget',			mw.message('quickchanges-tooltip').plain,			'/',			'#t-whatlinkshere'		);

// Create a jQuery object for this link so that we get // to use jQuery awesomeness like .click for binding functions to events // and methods like e.preventDefault; $(link).click( function( e ) {			// Avoid the browser going to '#'			e.preventDefault;

// Initiate quickRC! //quickRC; console.log('test'); $('#wpTextbox1').bind('keyup',autoQuery); });

});

});