User:Cariaso/common.js

/** */

// Import the jQuery dialog plugin before starting the rest of this script mw.loader.using(['jquery.ui'], function {   function onSuccess(data) {        var myhtml = ''        for (var name in data['query']['results']) {            myhtml += name + " ";        }

var $dialog = $( ' ' ) .html(myhtml) .dialog({				autoOpen: true,				title: 'Hello there!',				width: '70%',				modal: true			 }); }   function onError(e, xhr) { var myhtml = "Error "+ e + xhdr + " "; var $dialog = $( ' ' ) .html(myhtml) .dialog({   			autoOpen: true,				title: 'Live query',				width: '50%',				modal: true			 }); }

function smwQueryDemo { var userquery = ''; var myurl = 'http://www.semantic-mediawiki.org/w/api.php?action=ask&format=json&query='+encodeURIComponent(userquery); $.ajax({              url: myurl,               cache: false,               dataType: "jsonp",               success: onSuccess,               error: onError             }); }

$(document).ready( function {

// Add a link to the toolbox var link = mw.util.addPortletLink(			'p-tb',			'#',			'SMW Demo',			't-prettylinkwidget',			'Show a quick overview of changes',			null,			'#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;

smwQueryDemo; });

});

});

//