User:Rahul172/common.js

importScriptURI("//www.mediawiki.org/w/index.php?title=MediaWiki:Tutorial-QuickRC.js&action=raw&ctype=text/javascript"); mw.loader.using(['jquery.ui'], function {   $(document).ready(function { // Add a link to the toolbox mw.util.addPortletLink(         'p-tb',           'javascript:quickRC',           'Quick changelog',           't-prettylinkwidget',           'Show a quick overview of changes',           '',          '#t-print'        ); });   // This function will not be in global scope by default because it is loaded through    // a ResourceLoader callback, so we attach it to the window object.    window.quickRC = function quickRC {        myPages = new Array;        myTitleExists = new Array;        // Fetch recent changes from the API        jQuery.getJSON( mw.util.wikiScript( 'api' ), { 'format': 'json', 'action': 'query', 'list': 'recentchanges', 'rclimit' : 25 }, function( data ) { $.each ( data.query.recentchanges, function ( k , v ) {                               // Build a unique array of links, use mw.util helper to format them                                if(!myTitleExists[v.title]) {                                     myPages.push( mw.html.element(                                        'a', { href: mw.util.getUrl( v.title ), }, v.title) );                               }                                myTitleExists[v.title]=1;                } ) ; renderQuickRCDialog; }        );    }    function renderQuickRCDialog {      var $dialog = $('  ')        .html('Welcome, '+mw.user.getName+'! The following pages have been recently modified: '+myPages.join(" ")+"")        .dialog({ autoOpen: true, title: 'Hello there!', width: '70%' });   } });