MediaWiki:Guidedtour-tour-sandbox.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// Guided Tour for making sandbox edits, to be launched by a button in the training that takes you straight to your sandbox in edit mode
( function ( window, document, $, mw, gt ) {
//automatic api:edit function to send yourself messages
sendMessage = function( targetPage, msgPage, linkTo ) {
var api = new mw.Api();
api.get( {
'action' : 'query',
'titles' : msgPage,
'prop' : 'revisions|info',
'intoken' : 'edit',
'rvprop' : 'content',
'indexpageids' : 1
}, {
'ok' : 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' : page.edittoken
},
{
'ok' : 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: 'sandbox',
shouldLog: true,
steps: [ {
//1
title: 'Let\'s practice editing.',
description: 'Project:Training/tour/sandbox1',
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/sandbox-preload' , mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=2'); }
} ],
allowAutomaticOkay: false
}, {
//2
title: 'Welcome to your sandbox!',
description: 'Project:Training/tour/sandbox2',
onShow: gt.getPageAsDescription,
attachTo: '#content.mw-body',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Project:Training/For_students/Getting_started_1' ) + '?tour=sandbox&step=1'
} , {
name: 'Okay!',
action: 'next',
} ],
allowAutomaticOkay: false
}, {
//3
title: 'Edit button',
description: 'Project:Training/tour/sandbox3',
attachTo: '#ca-edit',
position: 'bottom',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=2'
} ],
shouldSkip: function() {
return gt.hasQuery( { action: 'edit' } );
}
}, {
//4
title: 'Boldness',
description: 'Project:Training/tour/sandbox4',
onShow: gt.getPageAsDescription,
attachTo: '#wpTextbox1',
position: 'bottomLeft',
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=3'
} , {
name: 'I added the wikicode.',
action: 'next',
} ],
allowAutomaticOkay: false
}, {
//5
title: 'Edit summary, and Save',
description: 'Project:Training/tour/sandbox5',
attachTo: '#wpSave',
position: 'bottom',
autoFocus: 'yes',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=4&action=edit'
} ],
shouldSkip: function() {
return gt.isPostEdit();
},
buttons: postEditButtons
} , {
//6
title: 'Nice work!',
description: 'Project:Training/tour/sandbox6',
onShow: gt.getPageAsDescription,
overlay: false,
attachTo: '#ca-edit',
position: 'bottom',
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=5&action=edit'
} ],
shouldSkip: function() {
return gt.hasQuery( { action: 'edit' } );
}
} , {
//7
title: 'Try adding some wikilinks.',
description: 'Project:Training/tour/sandbox7',
attachTo: '#wpTextbox1',
position: 'bottomLeft',
autoFocus: 'yes',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=6'
} , {
name: 'I added the wikilink code.',
action: 'next',
} ],
allowAutomaticOkay: false
} , {
//8
title: 'Edit summary, and Save (again)',
description: 'Project:Training/tour/sandbox8',
attachTo: '#wpSave',
position: 'bottom',
autoFocus: 'yes',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=7&action=edit'
} ],
shouldSkip: function() {
return gt.isPostEdit();
},
buttons: postEditButtons
} , {
//9
title: 'You made a link...',
description: 'Project:Training/tour/sandbox9',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=8&action=edit'
} ],
shouldSkip: function() {
return gt.isPage( 'Emphasis_(typography)' );
}
} , {
//10
title: 'Hmm...',
description: 'Project:Training/tour/sandbox10',
autoFocus: 'yes',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=9'
} , {
name: 'Let\'s fix the link.',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=11&action=edit'
} ],
allowAutomaticOkay: false
} , {
//11
title: 'This time, make it link to [[boldness]]',
description: 'Project:Training/tour/sandbox11',
onShow: gt.getPageAsDescription,
attachTo: '#wpTextbox1',
position: 'bottomLeft',
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=10'
} , {
name: 'I added the piped link!',
action: 'next',
} ],
allowAutomaticOkay: false
} , {
//12
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: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=11&action=edit'
} ],
shouldSkip: function() {
return gt.isPostEdit();
},
buttons: postEditButtons
} , {
//13
title: 'Okay, try the link now.',
description: 'Project:Training/tour/sandbox12',
attachTo: '#content.mw-body',
position: 'bottom',
autoFocus: 'yes',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Bold' ) + '?tour=sandbox&step=12'
} ],
shouldSkip: function() {
return gt.isPage( 'Boldness' );
}
} , {
//14
title: 'Boldness!',
description: 'Project:Training/tour/sandbox13',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=13&action=edit'
} , {
name: 'You\'ve earned a Barnstar!',
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:Random' ) + '?tour=sandbox&step=15'); }
} ],
allowAutomaticOkay: false
} , {
//15
title: 'Your barnstar is at the bottom of the page.',
description: 'Project:Training/tour/sandbox14',
onShow: gt.getPageAsDescription,
attachTo: '#p-personal',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/be_bold' ) + '?tour=sandbox&step=14'
} , {
name: 'Continue the training.',
action: 'externalLink',
url: mw.util.getUrl( 'Project:Training/For_students/Continue' ) + '?tour=sandbox&step=16'
} ],
allowAutomaticOkay: false
} , {
//16
title: 'Those are the basics.',
description: 'Project:Training/tour/sandbox15',
onShow: gt.getPageAsDescription,
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: 'Congrats me!',
action: 'end'
} ],
allowAutomaticOkay: false
}]
} );
} (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;