User:Resutant edition/API-Demo.js

/*

TASK - 3 --Made a Button by which a User can see the past Page viewers--

$(document).ready(function {   mw.loader.using(["oojs-ui-core", "oojs-ui-widgets", "mw.Api"]).done(function { (new mw.Api).get({           action: 'query',            titles: mw.config.get('wgPageName'),            indexpageids: true,            prop: 'pageviews'

}).then(function(response) { var yesterday = new Date; yesterday.setDate(new Date.getDate - 1); var popUp = new OO.ui.PopupButtonWidget({               popup: {                    $content: $(' Yesterdays views: ' + response.query.pages[response.query.pageids[0]].pageviews[yesterday.toISOString.split('T')[0]] + ' ')                },                label: "Yesterday's pageviews"            }); console.log(popUp); $('.firstHeading').after(popUp.$element); })   }); });