MediaWiki:Guidedtour-tour-BeBoldEducator.js

// Guided Tour for learning wikicode by making a series of edits in a user sandbox, as an interactive interlude in Wikipedia:Training/For_educators ( function ( window, document, $, mw, gt ) { //automatic api:edit function to send yourself messages mw.loader.using( 'mediawiki.Title', function {

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' : 'automatic post as part of the sandbox guided tour', '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: 'BeBoldEducator',        shouldLog: true,        steps: [ {                //1                title: 'Let\'s practice editing.',                description: 'Project:Training/tour/be_bold1',                onShow: gt.getPageAsDescription,                overlay: true,                closeOnClickOutside: false,				buttons: [ {                        name: 'Go to your sandbox',                        onclick: function  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );  return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/be_bold', 'Project:Training/tour/be_bold_preload', mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=2'); }                } ],                allowAutomaticOkay: false        },  {                //2                title: 'Welcome to your sandbox!',                description: 'Project:Training/tour/be_bold2',                onShow: gt.getPageAsDescription,                attachTo: '#content.mw-body',                position: 'bottom',                overlay: false,                closeOnClickOutside: false,				buttons: [ {                        name: ' ← ',                        action: 'externalLink',                        url: mw.util.getUrl( 'Project:Training/For_educators/Getting_started_1' ) + '?tour=BeBoldEducator&step=1'                          } , {						name: 'Okay!',                        action: 'next', } ],               allowAutomaticOkay: false }, {                //3                title: 'Edit button', description: 'Project:Training/tour/be_bold3', attachTo: '#ca-edit', position: 'bottom', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=2' } ],               shouldSkip: function { return gt.hasQuery( { action: 'edit' } ); }       },  {                //4                title: 'Boldness', description: 'Project:Training/tour/be_bold4', onShow: gt.getPageAsDescription, attachTo: '#wpTextbox1', position: 'bottomLeft', overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=3' }, {						name: 'I added the wikicode.', action: 'next', } ],               allowAutomaticOkay: false }, {                //5                title: 'Edit summary, and Save', description: 'Project:Training/tour/be_bold5', attachTo: '#wpSave', position: 'bottom', autoFocus: 'yes', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=4&action=edit' } ],               shouldSkip: function { return gt.isPostEdit; },				buttons: postEditButtons }, {               //6                title: 'Nice work!', description: 'Project:Training/tour/be_bold6', onShow: gt.getPageAsDescription, overlay: false, attachTo: '#ca-edit', position: 'bottom', closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=5&action=edit' } ],               shouldSkip: function { return gt.hasQuery( { action: 'edit' } ); } }, {               //7                title: 'Try adding some wikilinks.', description: 'Project:Training/tour/be_bold7', attachTo: '#wpTextbox1', position: 'bottomLeft', autoFocus: 'yes', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=6' }, {						name: 'I added the wikilink code.', action: 'next', } ],               allowAutomaticOkay: false }, {               //8                title: 'Edit summary, and Save (again)', description: 'Project:Training/tour/be_bold8', attachTo: '#wpSave', position: 'bottom', autoFocus: 'yes', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=7&action=edit' } ],               shouldSkip: function { return gt.isPostEdit; },               buttons: postEditButtons }, {               //9                title: 'You made a link...', description: 'Project:Training/tour/be_bold9', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=8&action=edit' } ],                        shouldSkip: function { return !gt.isPage( mw.Title.newFromText( 'User:' + mw.config.get( 'wgUserName' ) + '/be_bold' ).toString ); } }, {				//10               title: 'Whoops!', description: 'Project:Training/tour/wrong_page', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: 'Try again', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=7&action=edit' }, {						name: 'Skip this exercise', action: 'end', url: mw.util.getUrl( 'Project:Training/For_educators/Continue' ) } ],                       shouldSkip: function { return gt.isPage( 'Emphasis_(typography)' ); } }, {               //11                title: 'Hmm...', description: 'Project:Training/tour/be_bold10', autoFocus: 'yes', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=9' }, {						name: 'Let\'s fix the link.', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=12&action=edit' } ],               allowAutomaticOkay: false }, {               //12                title: 'This time, make it link to boldness', description: 'Project:Training/tour/be_bold11', onShow: gt.getPageAsDescription, attachTo: '#wpTextbox1', position: 'bottomLeft', overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=11' }, {                       name: 'I added the piped link!', action: 'next', } ],               allowAutomaticOkay: false }, {				//13               title: 'Don\'t forget the edit summary!', description: ' ', attachTo: '#wpSave', position: 'bottom', autoFocus: 'yes', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=12&action=edit' } ],               shouldSkip: function { return gt.isPostEdit; },				buttons: postEditButtons }, {					//14               title: 'Okay, try the link now.', description: 'Project:Training/tour/be_bold13', attachTo: '#content.mw-body', position: 'bottom', autoFocus: 'yes', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Bold' ) + '?tour=BeBoldEducator&step=13' } ],                       shouldSkip: function { return gt.isPage( 'Boldness' ); } }, {               //15                title: 'Boldness!', description: 'Project:Training/tour/be_bold14', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=14&action=edit' }, {                       name: 'You\'ve got a message!', onclick: function {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User talk:' + mw.config.get( 'wgUserName' ), 'Project:Training/tour/barnstar', mw.util.getUrl( 'Special:MyTalk' ) + '?tour=BeBoldEducator&step=16'); } } ] }, {               //16                title: 'Your new message is at the bottom of the page.', description: 'Project:Training/tour/be_bold15', onShow: gt.getPageAsDescription, attachTo: '#p-personal', position: 'bottom', overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=BeBoldEducator&step=15' }, {                       name: 'Continue the training.', action: 'externalLink', url: mw.util.getUrl( 'Project:Training/For_educators/Continue' ) + '?tour=BeBoldEducator&step=17' } ],               allowAutomaticOkay: false }, {               //17                title: 'Those are the basics.', description: 'Project:Training/tour/be_bold16', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, buttons: [ { name: 'Congratulations to me!', action: 'end' } ],               allowAutomaticOkay: false }] } ); } ); } (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;