MediaWiki:Guidedtour-tour-wikiedtalkpage2.js

// Guided Tour for learning wikicode by making a series of edits in a user sandbox, as an interactive interlude in https://dashboard.wikiedu.org/training/students/how-to-edit ( 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|info',		'meta' : 'tokens',		'rvprop' : 'content',		'rvslots' : 'main',		'indexpageids' : 1	} ).done( function (result) {		result = result.query;		var page = result.pages[result.pageids[0]];		var text = page.revisions[0].slots.main['*'];		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: 'wikiedtalkpage2' } );

tour.firstStep( {	name: 'welcome',	title: 'Welcome to a Talk page!',   description: 'Project:Wiki_Ed/tour/talk_page1',    onShow: gt.getPageAsDescription,	buttons: [ {        name: ' ← ',        action: 'externalLink',        url: 'https://dashboard.wikiedu.org/training/students/how-to-edit/talk-page-tutorial-v2'            }, {	    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=wikiedtalkpage2&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=wikiedtalkpage2&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 Publish',   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=wikiedtalkpage2&step=editButton'    }, {	    name: 'Return to training.',        action: 'externalLink',        url: 'https://dashboard.wikiedu.org/training/students/how-to-edit/talk-page-tutorial-v2'            } ],    overlay: true,	closeOnClickOutside: false,    allowAutomaticOkay: false,    allowAutomaticNext: false } )

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