MediaWiki:Guidedtour-tour-einfuhrung.js

From Wikipedia

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/*
 * Guided Tour named "Einführung"
 */
 
 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;
		} );
	} );
}
 
( function ( window, document, $, mw, gt ) {

	var pageName = mw.config.get( 'wgGuidedTourHelpGuiderUrl' ),
		tour;

	tour = new gt.TourBuilder( {
 	name: 'einfuhrung',
 	shouldLog: true
 	} );

tour.firstStep( {
	name: 'welcome',
	title: 'Welcome to a Talk page!',
    description: 'Wikipedia:GT Test 01',
    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',
	    										'Wikipedia:GT Test 02',
	    										mw.util.getUrl( 'Special:MyTalk/talk_page_tutorial' ) + '?tour=einfuhrung&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: 'Wikipedia:GT_Test_03',
	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',
	    										'Wikipedia:GT_Test_04',
	    										mw.util.getUrl( 'Special:MyTalk/talk_page_tutorial' ) + '?tour=einfuhrung&step=secondMessage');
							}
    } ],
    overlay: false,
    closeOnClickOutside: false,
    allowAutomaticOkay: false,
    allowAutomaticNext: false,
} )
	.next( 'secondMessage' );

tour.step( {
	name: 'secondMessage',
	title: 'Now it\'s a conversation.',
    description: 'Wikipedia:GT_Test_05',
	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: 'Wikipedia:GT_Test_06',
	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: 'Wikipedia:GT_Test_07',
	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: 'Wikipedia:GT Test 08',
	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: 'Wikipedia:GT Test 09',
    onShow: gt.getPageAsDescription,
	buttons: [ {
        name: 'Try it again.',
        action: 'externalLink',
        url: mw.util.getUrl( 'Special:MyTalk/talk_page_tutorial' ) + '?tour=einfuhrung&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 ) );