MediaWiki:Guidedtour-tour-twa4.js
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// The Wikipedia Adventure Mission 4
( 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("<nowiki/>","");
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("</div></div></div>","") + "\n" + text + "</div></div></div>";
} 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 [[WP:The Wikipedia Adventure|The Wikipedia Adventure]])',
'token' : result.tokens.csrftoken
} ).done( function () {
window.location.href = linkTo;
} );
} );
}
var tour = new gt.TourBuilder( {
name: 'twa4',
});
var steps = [{
//1
title: 'Welcome back! ',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>We left off with a new message from GaiaGirl that she added some content to the article. Let\'s see what\'s new.<br><br>'),
overlay: true,
buttons: [ {
name: 'Get back to Earth?*',
onclick: function() { sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/TWA/Earth', 'Wikipedia:TWA/Earth/2' , mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=2', false, true); }
} ],
allowAutomaticOkay: false
}, {
//2
title: 'What\'s new?',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>An easy way to see what\'s changed since you were last here is to use the article\'s HISTORY.<br><br>The history is like a watchlist of all the activity that happens at a single page.<br><br> Every change that\'s ever been made to an article lives there. Neat, huh?<br><br>'),
attachTo: '#content.mw-body',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/Start' ) + '?tour=twa4&step=1'
} , {
name: 'Become a Wiki-Historian',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/Earth/History/1' ) + '?tour=twa4&step=3'
} ],
allowAutomaticOkay: false,
}, {
//3
title: 'This looks familiar!',
description: new gt.WikitextDescription('<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Each line is a change—the time it was made, how much info was added or taken away, and what happened in the edit summary. This is why edit summaries are so cool!<br><br>'),
attachTo: '#content.mw-body',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=2'
} , {
name: 'Master the tool',
action: 'next'
} ],
}, {
//4
title: 'Compare to the previous version',
description: new gt.WikitextDescription('<br><div align="right">[[File:TWA_guide_left_top.png|link=]]</div>If you wanted to compare a version to the one that came right before it, you could click the prev link in that line. (This page\'s prev links are disabled for galactic safety).<br><br>'),
attachTo: '#content.mw-body',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
back: true,
buttons: [ {
name: 'Another trick',
action: 'next'
} ],
}, {
//5
title: 'Compare between two distant versions',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>You can also compare two distant versions, which sometimes comes in handy, when you\'re tracking changes over a longer period of time.<br><br>'),
overlay: false,
attachTo: '#content.mw-body',
position: 'bottom',
closeOnClickOutside: false,
back: true,
buttons: [ {
name: 'What\'s new?',
action: 'next'
} ],
allowAutomaticOkay: false,
}, {
//6
title: 'Diff, what?',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>We call a comparison between any two versions a DIFF, as in <i>difference</i><br><br>'),
attachTo: '#footer-info-copyright',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
back: true,
buttons: [ {
name: 'See the DIFF of GaiaGirl\'s most recent edit',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/Earth/4/Diff' ) + '?tour=twa4&step=7'
} ],
allowAutomaticOkay: false
} , {
//7
title: 'See what changed',
description: new gt.WikitextDescription('<br>The old version is on the left. The new version is on the right. The changes are highlighted.<br><br>'),
overlay: false,
attachTo: '#content.mw-body',
position: 'bottom',
closeOnClickOutside: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/Earth/History/1' ) + '?tour=twa4&step=6'
} , {
name: 'What do you think?',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=8'
} ],
allowAutomaticOkay: false
} , {
//8
title: 'Well, that\'s pretty biased...',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>Ok, it looks like GaiaGirl added some information that might be biased.<br><br>How do we make choices about how to present information? <br><br>Wikipedia editors rely on an idea called the <b>Neutral Point of View</b>.<br><br>'),
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/Earth/4/Diff' ) + '?tour=twa4&step=7'
} , {
name: 'Get to the [neutral] point',
action: 'next',
} ],
} , {
//9
title: 'NPOV',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>The neutral point of view, also called <b>NPOV</b> for short, is the idea that Wikipedia does not have its own opinions or rely on the opinions of its editors.<br><br>Instead, we summarize what good sources have already written about a subject and do that in a balanced way.<br><br>'),
overlay: true,
closeOnClickOutside: false,
back: true,
buttons: [ {
name: 'Read the policy.',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/Start' ) + '?tour=twa4&step=10'
} ],
allowAutomaticOkay: false
} , {
//10
title: 'Policies are practices we practice',
description: new gt.WikitextDescription('<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Policies describe community practices. There\'s pretty much a policy for every situation you could imagine, but a few are extra important.<br><br>'),
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=9'
}, {
name: 'NPOV policy',
action: 'next',
} ],
}, {
//11
title: 'The NPOV policy',
description: new gt.WikitextDescription('<br><b>Articles must not take sides, but should explain the sides, fairly and without bias. This applies to both what you say and how you say it.</b><br><br>Give this a good, deep brain inhale. Let it soak into your cortexes.<br><br>'),
overlay: false,
closeOnClickOutside: false,
back: true,
buttons: [ {
name: 'Think you got it?',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/NPOV' ) + '?tour=twa4&step=12'
} ],
allowAutomaticOkay: false
} , {
//12
title: 'Challenge yourself BELOW...',
description: 'Hint: you can learn as much from getting it wrong as getting it right. And you can always try again!',
attachTo:'#contentSub',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/Start' ) + '?tour=twa4&step=11'
} ],
} , {
//13
title: 'Rock on!',
description: new gt.WikitextDescription('NEW TOOL EARNED: <b>Neutrality Badge</b><div class="center">[[File:TWA badge 5.png|250px|link=]]</div><br>'),
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/NPOV' ) + '?tour=twa4&step=12'
}, {
name: 'Journey on*',
onclick: function() {sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/5template2' , mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=14', false, false); }
} ],
} , {
//14
title: 'Put NPOV to work',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>Let\'s take another look at those changes to Earth.<br><br>'),
overlay: false,
attachTo: '#content.mw-body',
position: 'bottom',
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/Start' ) + '?tour=twa4&step=13'
} , {
name: 'Do you see any problems?',
action: 'next',
} ],
} , {
//15
title: 'Removing Bias',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div><strong>Earth is the best and coolest planet in the whole galaxy. Earth is a place that\'s perfect for humans to live.</strong><br><br>Those additions are trying to say something relevant but they\'re not balanced. They\'re not neutral. They sound like the writer\'s opinion.<br><br>'),
attachTo: '#content.mw-body',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
back: true,
buttons: [ {
name: 'Say it better',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/Rephrase' ) + '?tour=twa4&step=16'
} ],
} , {
//16
title: 'Challenge yourself BELOW...',
description: 'Hint: you can learn as much from getting it wrong as getting it right. And you can always try again!',
attachTo:'#contentSub',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=15'
} ],
}, {
//17
title: 'Time for a rephrase',
description: new gt.WikitextDescription('<br>Click EDIT to rephrase the text<br><br>'),
attachTo: '#ca-edit',
position: 'bottom',
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/Rephrase' ) + '?tour=twa4&step=16'
}],
skip: "vefork",
hooks: "ve.activationComplete",
}, {
//18
title: 'Fix and replace',
description: new gt.WikitextDescription('<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Copy the neutral text and paste it to replace the biased text:<br><br>Earth is the only planet in the galaxy which is known to support life. Earth has many places that are suitable for humans to live; although, some areas of the planet can be dangerous for humans or uninhabitable.<br><br>Then click PUBLISH CHANGES as before.'),
closeOnClickOutside: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=17'
}],
skip: function(transitionEvent) {
return transitionEvent.type === gt.TransitionEvent.MW_HOOK && transitionEvent.hookName == "ve.saveDialog.stateChanged";
},
allowAutomaticOkay: false,
hooks: "ve.saveDialog.stateChanged"
}, {
//19
title: 'Edit summary and Publish',
description: new gt.WikitextDescription('<br>Let them know that you, "Changed text to be more neutral and unbiased".<br><br>Then PUBLISH 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",
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=18&veaction=edit'
} ],
skip: gt.isPostEdit
}, {
//20
title: 'Helpin\' out!',
description: new gt.WikitextDescription('NEW TOOL EARNED: Collaborator Badge <div class="center">[[File:TWA badge 6.png|250px|link=]]</div><br>'),
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=18&veaction=edit'
} , {
name: 'Keep on helping*',
onclick: function() { sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/6template2' , mw.util.getUrl( 'Wikipedia:TWA/4/Start' ) + '?tour=twa4&step=21', false, false); }
} ],
allowAutomaticOkay: false
}, {
//21
title: 'That was great',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>It\'s important that Wikipedia read like a real encyclopedia and not any editor\'s personal blog.<br><br>We\'re all here to share information in a way that is balanced.<br><br>That process can be challenging, but we are united in the goal of sharing knowledge.<br><br>'),
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=20'
} , {
name: 'All Hail NPOV',
action: 'next',
} ],
} , {
//22
title: 'Ooh, a new message!',
description: new gt.WikitextDescription('<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>Check it out.</br><br>'),
overlay: false,
closeOnClickOutside: false,
allowAutomaticOkay: false,
back: true,
buttons: [ {
name: 'Check your talk page*',
onclick: function() { sendTalkMessage( 'User talk:' + mw.config.get( 'wgUserName' ) + '/TWA', 'Wikipedia:TWA/MyTalk/4' , mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa4&step=23', false, true); }
} ],
} , {
//23
title: 'Interesting question...',
description: new gt.WikitextDescription('<div align="right">[[File:TWA_guide_right_top.png|link=]]</div>What does it mean?'),
overlay: false,
attachTo: '#content.mw-body',
position: 'bottom',
closeOnClickOutside: false,
allowAutomaticOkay: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=22'
} , {
name: 'Pierce the veil of Verifiability',
action: 'externalLink',
url: mw.util.getUrl( 'Wikipedia:TWA/4/End' ) + '?tour=twa4&step=24'
} ],
} , {
//24
title: 'Mission 4 complete!',
description: new gt.WikitextDescription('<br>[[File:02 Taiko2.ogg (short).ogg]]<br><b>Journey on to mission 5...</b>'),
overlay: false,
closeOnClickOutside: false,
buttons: [ {
name: 'Congrats me!',
action: 'end'
} ],
allowAutomaticOkay: false
}];
var sourceEditorStepOverrides = {
18: {
title: 'Fix and replace',
description: new gt.WikitextDescription('<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Copy the neutral text and paste it to replace the biased text:<br><br><b>Earth is the only planet in the galaxy which is known to support life. Earth has many places that are suitable for humans to live; although, some areas of the planet can be dangerous for humans or uninhabitable.</b><br><br>'),
overlay: false,
attachTo: '#wpTextbox1',
position: 'bottomRight',
closeOnClickOutside: false,
buttons: [ {
name: '<big>←</big>',
action: 'externalLink',
url: mw.util.getUrl( 'Special:MyPage/TWA/Earth' ) + '?tour=twa4&step=17'
} , {
name: 'Done',
action: 'next'
} ]
}, 19: {
title: 'Edit summary and Publish',
description: new gt.WikitextDescription('<br>Let them know that you, "Changed text to be more neutral and unbiased".<br><br>Then PUBLISH when you\'re ready.'),
attachTo: '#wpSave',
position: 'bottomRight',
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 ) ) ;