MediaWiki:Guidedtour-tour-finddpla.js
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// 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 [[WP:The Wikipedia Library|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: '<br>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).<br><br>',
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: '<br>Accounts are free and easy to create. Go for it.<br><br>',
onShow: gt.parseDescription,
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
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: '<br>This is easy, just click the Install button<br><br>',
overlay: true,
onShow: gt.parseDescription,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
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: '<br>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.<br><br>At the article, Click the <b>Shield</b> icon in the url address bar to load the results! (We will fix this soon).<br><br>',
onShow: gt.parseDescription,
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
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: '<br>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 [[WP:TWL|The Wikipedia Library]].<br>To uninstall this script, search for <b>WP:FindDPLA</b> in the Wikipedia search box.<br><br>',
onShow: gt.parseDescription,
overlay: false,
closeOnClickOutside: true,
buttons: [ {
name: '<small>←</small>',
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 ) ) ;