MediaWiki:Guidedtour-tour-finddpla.js

// FindDPLA Guided Tour for installation and instruction ( function ( window, document, $, mw, gt ) { //automatic api:edit function to send yourself messages function sendMessage( targetPage, msgPage, linkTo ) {	var api = new mw.Api;	api.get( { 'action' : 'query', 'titles' : msgPage, 'prop'  : 'revisions', 'meta'  : 'tokens', 'type'  : 'csrf', 'rvprop' : 'content', 'indexpageids' : 1 } ).done( function (result) { result = result.query; var page = result.pages[result.pageids[0]]; var text = page.revisions[0]['*']; api.post( {			'action' : 'edit',			'title' : targetPage,			'appendtext' : "\n" + text,			'summary' : 'Installing WP:FindDPLA script (API:EDIT) through The Wikipedia Library',			'token' : result.tokens.csrftoken		} ).done( function {			window.location.href = linkTo;		} ); } ); } // Fail gracefully post-save but not postedit var postEditButtons = []; if ( mw.config.get( 'wgAction' ) === 'view' && !gt.isPostEdit ) {       postEditButtons.push( { name: 'Click here to go back and make an edit', onclick: function { window.location.href = new mw.Uri.extend( { action: 'edit' } ).toString; }       } ); } // Fail gracefully post-save but not postedit for visual editor var postEditButtonsVisual = []; if ( mw.config.get( 'wgAction' ) === 'view' && !gt.isPostEdit ) {        postEditButtonsVisual.push( { name: 'Go Back', onclick: function { window.location.href = window.location.href + "&veaction=edit"; }       } ); } gt.defineTour( { name: 'finddpla', shouldLog: true, steps: [ { //1               title: 'Welcome to Wikipedia!', description: ' We built a tool so you can see relevant content from the Digital Public Library of America (DPLA) any time you view a Wikipedia article. (Use an updated version of the Chrome or Firefox browser for now). ',               onShow: gt.parseDescription, overlay: true, closeOnClickOutside: false, buttons: [ { name: 'Install the script', action: 'next', } ],                               allowAutomaticOkay: false }, {                //2                title: 'First create an account or login', description: ' Accounts are free and easy to create. Go for it. ',               onShow: gt.parseDescription, overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=1' }, {               	name: 'Have account, need to login', action: 'externalLink', url: mw.util.getUrl( 'Special:UserLogin' ) + '?tour=finddpla&step=3' }, {               	name: 'Register!', action: 'externalLink', url: mw.util.getUrl( 'Special:UserLogin/signup' ) + '?tour=finddpla&step=3' } ],               allowAutomaticOkay: false, shouldSkip: function { return mw.config.get( 'wgUserId' ) !== null; }

}, {        	    //3                title: 'One click and you\'re done', description: ' This is easy, just click the Install button ', overlay: true, onShow: gt.parseDescription, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=1' }, {                        name: 'Install script*', onclick: function {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/common.js', 'Wikipedia:FindDPLA.js', mw.util.getUrl( 'Haymarket affair' ) + '?tour=finddpla&step=4'); } } ],	               allowAutomaticOkay: false }, {

//4               title: 'Try it out!', description: ' Let\'s see what they have on the... Haymarket affair. Note that since Wikipedia now uses https, you have to approve the script to run. At the article, Click the Shield icon in the url address bar to load the results! (We will fix this soon). ',               onShow: gt.parseDescription, overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=3' }, {                       name: 'I clicked the shield', action: 'next', } ],               allowAutomaticOkay: false }, {

//5		 		title: 'That is it! Go exploring :)',               description: ' Note that DPLA Images have an icon next to them in the results.  The rest are text sources.  You can learn about more neat Wikipedia tricks through The Wikipedia Library. To uninstall this script, search for WP:FindDPLA in the Wikipedia search box.  ',                onShow: gt.parseDescription,                overlay: false,                closeOnClickOutside: true,	            buttons: [ {                        name: ' ← ',                        action: 'externalLink',                        url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=4'                   }, {                	    name: 'That was fun.  Congrats me!',                              action: 'end'                      } ], }]

} ); } (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;