MediaWiki:Guidedtour-tour-twa3.js

// The Wikipedia Adventure Mission 3 ( function ( window, document, $, mw, gt ) { //automatic api:edit function to send yourself messages function sendTalkMessage( targetPage, msgPage, linkTo, overwrite, isTalkPost) {	if(!mw.config.get('wgUserName')) { 		alert( "Please login." );  		return;	}    var api = new mw.Api;    api.get( { 'action' : 'query', 'titles' : msgPage+'|'+targetPage, 'prop'  : 'revisions', 'meta'  : 'tokens', 'type'  : 'csrf', 'rvprop' : 'content', 'indexpageids' : 1 } ).done( function (result) { result = result.query; var page = result.pages[result.pageids[1]]; var text = page.revisions[0]['*']; text = text.replaceAll(" ",""); if (result.pageids[0] > 0) { var targetSrc = result.pages[result.pageids[0]]; var srcText = targetSrc.revisions[0]['*']; if (!overwrite) { // Check for duplicate talk messages with only the first 20 characters in case the messages subst into something different if (isTalkPost && srcText.includes(text.substring(0, 20))) { // Don't send duplicate badges/talk posts window.location.href = linkTo; return; } else if (srcText.includes(text)) { // Check for duplicate badges literally window.location.href = linkTo; return; }           	if (isTalkPost) { // Preserve the banner for talk posts text = srcText.replace("  ","") + "\n" + text + "   "; } else { // Otherwise just add for badges text = srcText + "\n" + text; }          }        }        api.post( {            'action' : 'edit',            'title' : targetPage,            'text' : text,            'summary' : 'New Message (simulated automatically as part of The Wikipedia Adventure)',            'token' : result.tokens.csrftoken        } ).done( function  {        	window.location.href = linkTo;        } ); } ); } var tour = new gt.TourBuilder( { name: 'twa3', }); var steps = [{               //1                title: 'Mission 3 begins!',                description: new gt.WikitextDescription(' TWA_guide_right_top.png GaiaGirl is waiting for us at the Earth article. Let\'s go there. '),               overlay: true,                closeOnClickOutside: false,	            buttons: [ {                        name: 'Head to Earth*',                        onclick: function  {  sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/TWA/Earth', 'Wikipedia:TWA/Earth/1', mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=2', true, false); }                } ],                allowAutomaticOkay: false        },  {                //2                title: 'So this is Planet Earth!',                description: new gt.WikitextDescription(' Articles on Wikipedia give an encyclopedic overview of a subject: they tell readers a little bit about everything that\'s important to know. '),               overlay: false,                closeOnClickOutside: false,		        buttons: [ {                        name: ' ← ',                        action: 'externalLink',                        url: mw.util.getUrl( 'Wikipedia:TWA/3/Start' ) + '?tour=twa3&step=1'                          }, {		        	    name: 'Check it out',                        action: 'next',                } ],                allowAutomaticOkay: false        },  {                //3                title: 'See anything that needs fixing?',                description: new gt.WikitextDescription(' TWA_guide_left_top.png I notice a few spelling edits distracting from the information. How many do you see? '),               attachTo: '#content.mw-body',                position: 'bottom',                overlay: false,                closeOnClickOutside: false,                back: true,                buttons: [ {                         name: 'Search for typos',                         action: 'next'                } ],                allowAutomaticOkay: false				        },  {                //4                title: 'Spellcheck.',                description: new gt.WikitextDescription(' Did you find all 5? thurd -- third fore -- four tree -- three aminals -- animals hughmans -- humans'),               attachTo: '#content.mw-body',                position: 'bottom',                overlay: false,                closeOnClickOutside: false,	            allowAutomaticOkay: false,	            back: true,                buttons: [ {                	    name: 'Found them all',                        action: 'next',                } ],

}, {                //5                title: 'Typofixing', description: new gt.WikitextDescription(' Let\'s put your editing skills to the test and fix those up. Click EDIT. '), attachTo: '#ca-edit', position: 'bottom', overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, back: true, buttons: [ ], skip: "vefork", hooks: "ve.activationComplete"

}, {                //6                title: '5 fixes', description: new gt.WikitextDescription(' thurd -- third fore -- four tree -- three aminals -- animals hughmans -- humans. Then click PUBLISH CHANGES when you\'re ready.'), closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=5' }],               overlay: false, attachTo: "#bodyContent", position: 'leftTop', skip: function(transitionEvent) { return transitionEvent.type === gt.TransitionEvent.MW_HOOK && transitionEvent.hookName == "ve.saveDialog.stateChanged"; },               allowAutomaticOkay: false, hooks: "ve.saveDialog.stateChanged" }, {                //7                title: 'Edit summary and Publish', description: new gt.WikitextDescription(' Let them know that you, "Fixed 5 typos". Then click PUBLISH CHANGES again when you\'re ready.'), // Ideally this would be attached to the save dialog itself but since it is still loading when the tour event fires that doesn't work attachTo: "#footer", position:"bottom", autoFocus: 'yes', overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: 'Go back', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?veaction=edit&tour=twa3&step=6' } ],               skip: gt.isPostEdit, }, {               //8                title: 'See boldly!', description: new gt.WikitextDescription('NEW TOOL EARNED: Copyeditor Badge   Wow. Now the whole world can see the improved version of the article you contributed to...pretty cool!  Let\'s make a few more changes.  Let\'s add bold around the first mention of Earth in the first sentence of the article.  This lets readers focus quickly on the main subject of the article. Click EDIT.  '), overlay: false, attachTo: '#ca-edit', position: 'bottom', closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=6&veaction=edit' } ],               // can't use gt.isEditing here because it still thinks we're editing after the previous publish skip: function(transitionEvent) { return transitionEvent.type === gt.TransitionEvent.MW_HOOK && transitionEvent.hookName == "ve.activationComplete"; },

hooks: "ve.activationComplete" }, {               //9                title: 'Add bold!', description: new gt.WikitextDescription(' Just like before, to add bold, highlight the first mention of the word Earth and then click the B on the toolbar.  Then click PUBLISH CHANGES, as before.'), autoFocus: 'yes', overlay: false, attachTo: "#bodyContent", position: 'leftTop', closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=8' }],               skip: function(transitionEvent) { return transitionEvent.type === gt.TransitionEvent.MW_HOOK && transitionEvent.hookName == "ve.saveDialog.stateChanged"; },               hooks: "ve.saveDialog.stateChanged", allowAutomaticOkay: false

}, {               //10                title: 'Edit summary and Publish', description: new gt.WikitextDescription(' Let them know that you, "Added bold" Then PUBLISH CHANGES when you\'re ready.'), attachTo: "#footer", position: "bottom", autoFocus: 'yes', overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=9&veaction=edit' } ],               skip: function(transitionEvent) { // Can't use gt.isPostEdit here since it still things we're postedit from the previous save return transitionEvent.type === gt.TransitionEvent.MW_HOOK && transitionEvent.hookName == "postEdit"; } }, {               //11                title: 'Whew... This is exciting!', description: new gt.WikitextDescription(' You\'re getting the hang of this. You\'re going to do a lot of good here, I can sense it.  Hey you also have a new message...  '), overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=9&veaction=edit' }, {                       name: 'Check your new message*', onclick: function { sendTalkMessage( 'User talk:' + mw.config.get( 'wgUserName' ) + '/TWA', 'Wikipedia:TWA/MyTalk/3a', mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa3&step=12', false, true); } } ], }, {               //12                title: 'New content...', description: new gt.WikitextDescription(' Let\'s see what\'s new  '), attachTo: '#content.mw-body', position: 'bottom', overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=11' }, {                       name: 'Check out the new content*', onclick: function { sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/4template2', mw.util.getUrl( 'Wikipedia:TWA/3/End' ) + '?tour=twa3&step=13', false, false); } } ],               allowAutomaticOkay: false

}, {               //13                title: 'Mission 3 complete!', description: new gt.WikitextDescription(' Journey on to mission 4...'), overlay: false, closeOnClickOutside: false, buttons: [ { name: 'Congrats me!', action: 'end' } ],               allowAutomaticOkay: false }]; var sourceEditorStepOverrides = { 6: {               title: '5 fixes', description: new gt.WikitextDescription(' thurd -- third fore -- four tree -- three aminals -- animals hughmans -- humans'), overlay: false, attachTo: '#wpTextbox1', position: 'bottomRight', closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=5' }, {               	    name: 'Fixed', action: 'next', } ],               allowAutomaticOkay: false }, 7: {               //7                title: 'Edit summary and Publish', description: new gt.WikitextDescription(' Let them know that you, "Fixed 5 typos". Then PUBLISH when you\'re ready.'), attachTo: '#wpSave', position: 'bottomRight', autoFocus: 'yes', overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, back: true, skip: gt.isPostEdit, }, 8: {               title: 'See boldly!', description: new gt.WikitextDescription('NEW TOOL EARNED: Copyeditor Badge   Wow. Now the whole world can see the improved version of the article you contributed to...pretty cool!  Let\'s make a few more changes.  Let\'s add bold around the first mention of Earth in the first sentence of the article.  This lets readers focus quickly on the main subject of the article. Click EDIT.  '), overlay: false, attachTo: '#ca-edit', position: 'bottom', closeOnClickOutside: false, allowAutomaticOkay: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=5&action=edit' } ],               skip: gt.isEditingWithWikitext }, 9: {		       //9                title: 'Add bold!', description: new gt.WikitextDescription(' Just like before, to add bold, highlight the first mention of the word Earth and then click the B on the toolbar.  '), attachTo: '#wpTextbox1', position: 'bottomRight', autoFocus: 'yes', overlay: false, closeOnClickOutside: false, buttons: [ { name: ' ← ', action: 'externalLink', url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa3&step=8src' }, {	           	    name: 'Bolded', action: 'next', } ],               allowAutomaticOkay: false }, 10: {		       //10                title: 'Edit summary, and Publish', description: new gt.WikitextDescription(' Let them know that you, "Added bold" Then PUBLISH when you\'re ready.'), attachTo: '#wpSave', position: 'bottomRight', autoFocus: 'yes', overlay: false, closeOnClickOutside: false, allowAutomaticOkay: false, back: true, buttons: [], skip: gt.isPostEdit } }; var stepBuilders = []; var sStepBuilders = []; function makeSkip(target, query) { return function(event) { if (query(event)) { return target; }	}; } function makeVeSkip(target1, target2) { return function { if (gt.isEditingWithVisualEditor) { return target1; } else if (gt.isEditingWithWikitext) { return target2; } 	}; } for (var i = 0; i < steps.length; i++) { var step = steps[i]; step.allowAutomaticNext = false; step.name = (i+1).toString; var stepBuilder; if (i == 0) { stepBuilder = tour.firstStep(step); } else { stepBuilder = tour.step(step); }

stepBuilders[i] = stepBuilder; if (sourceEditorStepOverrides[i]) { var sStep = sourceEditorStepOverrides[i]; sStep.allowAutomaticNext = false; sStep.name = i.toString+"src"; sStepBuilders[i-1] = tour.step(sStep); } } for (var j = 0; j < steps.length; j++) { if (steps[j].hooks) { stepBuilders[j].listenForMwHooks(steps[j].hooks); }	if (steps[j].skip) { if (steps[j].skip == "vefork") { stepBuilders[j].transition(makeVeSkip(stepBuilders[j+1], sStepBuilders[j+1])); } else { stepBuilders[j].transition(makeSkip(stepBuilders[j+1], steps[j].skip)); }	}	if (sourceEditorStepOverrides[j] && sourceEditorStepOverrides[j].skip) { sStepBuilders[j-1].transition(makeSkip(sStepBuilders[j] || stepBuilders[j], sourceEditorStepOverrides[j].skip)); }	if (j > 0) { if (steps[j].back) { stepBuilders[j].back(stepBuilders[j-1]); }		if (sStepBuilders[j-1] && sStepBuilders[j-2] && sourceEditorStepOverrides[j].back) { sStepBuilders[j-1].back(sStepBuilders[j-2]); }	}	if (j < steps.length - 1) { stepBuilders[j].next(stepBuilders[j+1]); if (sStepBuilders[j] && sStepBuilders[j+1]) { sStepBuilders[j].next(sStepBuilders[j+1]); }	} } } (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;