MediaWiki:Guidedtour-tour-EducatorTrainingComplete.js

// Guided Tour for learning wikicode by making a series of edits in a user sandbox, as an interactive interlude in Wikipedia:Training/For_students ( 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' : 'automatic post as part of the training for educators',			'token' : result.tokens.csrftoken		} ).done( function {			window.location.href = linkTo;		} ); } ); } gt.defineTour( { name: 'EducatorTrainingComplete', shouldLog: true, steps: [ { //1               title: 'Training complete', description: 'Project:Training/tour/educator_training_complete1', onShow: gt.getPageAsDescription, overlay: true, closeOnClickOutside: false, buttons: [ { name: 'Just load the course page template.', onclick: function {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/draft_course_page', 'Project:Training/tour/course_wizard_preload', mw.util.getUrl( 'Special:MyPage/draft_course_page' ) + '?tour=EducatorTrainingComplete&step=3'); } }, {                       name: 'Add my name and load the course page template.', onclick: function {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'Project:Training/For_educators/training_complete', 'Project:Training/tour/educator_training_complete_preload', mw.util.getUrl( 'Wikipedia:Training/For_educators/Training_complete' ) + '?tour=EducatorTrainingComplete&step=2'); }, }],               allowAutomaticOkay: false }, {               //2                title: 'Course page template', description: 'Project:Training/tour/course_wizard1', onShow: gt.getPageAsDescription, overlay: true, closeOnClickOutside: false, buttons: [ { name: 'Start', onclick: function {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/draft_course_page', 'Project:Training/tour/course_wizard_preload', mw.util.getUrl( 'Special:MyPage/draft_course_page' ) + '?tour=EducatorTrainingComplete&step=3'); } } ],               allowAutomaticOkay: false

}, {               //3                title: 'Course page template loaded.', description: 'Project:Training/tour/course_wizard2', onShow: gt.getPageAsDescription, overlay: false, closeOnClickOutside: false, buttons: [ { name: 'Okay', action: 'end' } ],               allowAutomaticOkay: false }] } ); } (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;