User:DannyS712 test/rating.js

mw.loader.using( 'mediawiki.util', function {    $(document).ready( function  { var link = mw.util.addPortletLink( 'p-cactions', '#', 'Get rating', 'ca-getRating', 'Get rating'); $( link ).click( function ( event ) {           event.preventDefault;            getRating;        } ); } ); } ); function getRating { return new Promise((resolve) => {		var page = 'NASA|Alain Prost|Sébastien Ogier';		var request = {	       action: 'query',	        titles: page,	        prop: 'categories',	        clcategories: 'Category:Good articles|Category:Featured articles',	        format: 'json',		    formatversion: 2		};		$.get( mw.config.get( 'wgScriptPath' ) + '/api.php', request, function( response ) { console.log( response ); if ( response && response.query && response.query.pages ) { console.log( response.query.pages ); resolve( response.query.pages ); }			resolve ( false ); } );	} ); }