MediaWiki:Guidedtour-tour-outreachtalkpage.js
Appearance
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.
// Guided Tour for learning wikicode by making a series of edits in a user sandbox, as an interactive interlude in https://outreachdashboard.wmflabs.org/training/editing-wikipedia/editing-basics
// Forked from MediaWiki:Guidedtour-tour-outreachtalkpage.js
( 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 sandbox guided tour',
'token' : result.tokens.csrftoken
} ).done( function () {
window.location.href = linkTo;
} );
} );
}
var tour;
tour = new gt.TourBuilder( {
name: 'outreachtalkpage'
} );
tour.firstStep( {
name: 'welcome',
title: 'Welcome to a Talk page!',
description: 'Project:Wiki_Ed/tour/talk_page1',
onShow: gt.getPageAsDescription,
buttons: [ {
name: '<small>←</small>',
action: 'externalLink',
url: 'https://outreachdashboard.wmflabs.org/training/editing-wikipedia/editing-basics/talk-page-tutorial'
}, {
name: 'Okay!',
onclick: function() { if(!mw.config.get('wgUserName')){ alert( "Please login." ); return; }
sendMessage( 'User_talk:' + mw.config.get( 'wgUserName' ) + '/talk_page_tutorial',
'Project:Wiki_Ed/tour/talk_page_preload',
mw.util.getUrl( 'Special:MyTalk/talk_page_tutorial' ) + '?tour=outreachtalkpage&step=firstMessage');
}
} ],
overlay: true,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.next( 'firstMessage' );
tour.step( {
name: 'firstMessage',
title: 'Here\'s how a typical article talk page looks.',
description: 'Project:Wiki_Ed/tour/talk_page2',
attachTo: '#content',
position: 'bottomLeft',
onShow: gt.getPageAsDescription,
buttons: [ {
name: 'Okay!',
onclick: function() { if(!mw.config.get('wgUserName')){ alert( "Please login." ); return; }
sendMessage( 'User_talk:' + mw.config.get( 'wgUserName' ) + '/talk_page_tutorial',
'Project:Wiki_Ed/tour/talk_page_preload_2',
mw.util.getUrl( 'Special:MyTalk/talk_page_tutorial' ) + '?tour=outreachtalkpage&step=secondMessage');
}
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false,
} )
.next( 'secondMessage' );
tour.step( {
name: 'secondMessage',
title: 'Now it\'s a conversation.',
description: 'Project:Wiki_Ed/tour/talk_page3',
attachTo: '#content',
position: 'bottomLeft',
onShow: gt.getPageAsDescription,
buttons: [ {
name: 'Okay!',
onclick: function() { mw.libs.guiders.next(); }
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false,
} )
.next( 'editButton' );
tour.step( {
name: 'editButton',
title: 'Click the \'Edit source\' button',
description: 'Project:Wiki_Ed/tour/talk_page4',
onShow: gt.getPageAsDescription,
attachTo: '#ca-edit',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.transition( function () { if ( gt.isEditing() ) { return 'addReply'; } } )
.next( 'addReply' );
tour.step( {
name: 'addReply',
title: 'Add your own comment',
description: 'Project:Wiki_Ed/tour/talk_page5',
onShow: gt.getPageAsDescription,
attachTo: '#wpTextbox1',
position: 'bottomLeft',
buttons: [ {
name: 'I added my reply.',
onclick: function() { mw.libs.guiders.next(); }
} ],
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.transition( function () { if ( gt.isPostEdit() ) { return 'returnToTraining'; } } )
.next( 'saveReply' );
tour.step( {
name: 'saveReply',
title: 'Add an edit summary, then Save',
description: 'Project:Wiki_Ed/tour/talk_page6',
onShow: gt.getPageAsDescription,
attachTo: '#wpSave',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
.transition( function () { if ( gt.isPostEdit() ) { return 'returnToTraining'; } } )
.next( 'returnToTraining' );
tour.step( {
name: 'returnToTraining',
title: 'That\'s it!',
description: 'Project:Wiki_Ed/tour/talk_page7',
onShow: gt.getPageAsDescription,
buttons: [ {
name: 'Try it again.',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyTalk/talk_page_tutorial' ) + '?tour=outreachtalkpage&step=editButton'
}, {
name: 'Return to training.',
action: 'externalLink',
url: 'https://outreachdashboard.wmflabs.org/training/editing-wikipedia/editing-basics/talk-page-tutorial'
} ],
overlay: true,
closeOnClickOutside: false,
allowAutomaticOkay: false,
allowAutomaticNext: false
} )
} );
} ( window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) );