MediaWiki:Guidedtour-tour-CourseWizard.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: 'CourseWizard', shouldLog: true, steps: [ { //1               title: 'Course page wizard', 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' ) + '/course_wizard', 'Project:Training/tour/course_wizard_preload', mw.util.getUrl( 'Special:MyPage/course_wizard' ) + '?tour=CourseWizard&step=2'); } } ],               allowAutomaticOkay: false

}, {               //2                title: 'Course wizard 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 ) ) ;