MediaWiki:Guidedtour-tour-twa5.js

// The Wikipedia Adventure Mission 5

( 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: 'twa5',

});

var steps = [{

//1

title: 'We\'re on! ',

description: new gt.WikitextDescription('

link=
SocraTease riddled us with a puzzling question: How do we know if information on Wikipedia is true?

This is a special question--that needs a special place to get a wise answer.

'),

overlay: true,

buttons: [ {

name: 'Check out the Teahouse',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/Teahouse' ) + '?tour=twa5&step=2'

} ],

allowAutomaticOkay: false

}, {

//2

title: 'What\'s this Teahouse place?',

description: new gt.WikitextDescription('

link=
The Teahouse is a social space for asking questions about Wikipedia--and getting simple, clear answers from smart, welcoming helpers--any time you need it.

'),

overlay: false,

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/5/Start' ) + '?tour=twa5&step=1'

} , {

name: 'Drink some Tea',

action:'next',

} ],

allowAutomaticOkay: false,

}, {

//3

title: 'Teahouse = Awesome.',

description: new gt.WikitextDescription('

link=
Asking for help is part of becoming a great editor. There\'s a lot to learn here, and lots of people who will lend you a hand.

'),

overlay: false,

closeOnClickOutside: false,

allowAutomaticOkay: false,

back: true,

buttons: [ {

name: 'Share the riddle with Teahouse',

action: 'next',

} ],

}, {

//4

title: 'Ask away!',

description: new gt.WikitextDescription('
Truth and Wikipedia

"Hi, I\'m new here and trying to learn more about Wikipedia. I was wondering, how do you know that anything on Wikipedia is *true*?"

'),

overlay: false,

closeOnClickOutside: false,

allowAutomaticOkay: false,

back: true,

buttons: [ {

name: 'Post it!',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/Teahouse/1' ) + '?tour=twa5&step=5'

} ],

}, {

//5

title: 'Asking is Awesome',

description: new gt.WikitextDescription('NEW TOOL EARNED: Researcher Badge

File:TWA badge 7.png

Hey, you got a notification that someone replied to your Teahouse question
'),

attachTo: '#content.mw-body',

position: 'topRight',

autoFocus: 'yes',

overlay: false,

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/Teahouse' ) + '?tour=twa5&step=4'

} , {

name: 'Check out the reply',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/Teahouse/2' ) + '?tour=twa5&step=6'

} ],

allowAutomaticOkay: false,

}, {

//6

title: 'This is important',

description: new gt.WikitextDescription('

link=
So, we only write what we can verify in a published source. Not your own experience, original research, or personal opinions. Just published info.

'),

overlay: false,

attachTo: '#content.mw-body',

position: 'bottomRight',

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/Teahouse/1' ) + '?tour=twa5&step=5'

} , {

name: 'Dig into Verifiability*',

onclick: function() { sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/7template2' , mw.util.getUrl( 'Wikipedia:TWA/5/V' ) + '?tour=twa5&step=7', false, false); }

} ],

allowAutomaticOkay: false

}, {

//7

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!',

overlay: false,

closeOnClickOutside: false,

allowAutomaticOkay: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/Teahouse/2' ) + '?tour=twa5&step=6'

} ]

} , {

//8

title: 'You\'ve got Verifi-ability',

description: new gt.WikitextDescription('NEW TOOL EARNED: Verifiability Badge

File:TWA badge 8.png

Let\'s put this new knowledge to use!
'),

overlay: false,

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/5/V' ) + '?tour=twa5&step=7'

} , {

name: 'Check your messages*',

onclick: function() { sendTalkMessage( 'User talk:' + mw.config.get( 'wgUserName' ) + '/TWA', 'Wikipedia:TWA/MyTalk/5' , mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa5&step=9', false, true); }

} ],

allowAutomaticOkay: false

} , {

//9

title: 'Seeking sources',

description: new gt.WikitextDescription('

link=
Let\'s see what GaiaGirl came up with
'),

overlay: false,

attachTo: '#content.mw-body',

position: 'bottom',

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/5/Start' ) + '?tour=twa5&step=8'

} , {

name: 'Head to Earth\'s talk page*',

onclick: function() { sendTalkMessage( 'User talk:' + mw.config.get( 'wgUserName' ) + '/TWA/Earth', 'Wikipedia:TWA/Earth/Talk/1' , mw.util.getUrl( 'Special:MyTalk/TWA/Earth' ) + '?tour=twa5&step=10', true, true); }

} ],

allowAutomaticOkay: false

} , {

//10

title: '3 Sources',

description: new gt.WikitextDescription('

link=
It looks like GaiaGirl gave you some options.

Verifiability tells us we want published reliable sources with a reputation for fact-checking and accuracy. Sources we can rely on.

'),

overlay: false,

attachTo: '#content.mw-body',

position: 'bottom',

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa5&step=9'

} , {

name: 'Which one of these would be best??*',

onclick: function() { sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/8template2' , mw.util.getUrl( 'Wikipedia:TWA/5/RS' ) + '?tour=twa5&step=11', false, false); }

} ],

allowAutomaticOkay: false

}, {

//11

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: '',

action: 'externalLink',

url: mw.util.getUrl( 'Special:MyTalk/TWA/Earth' ) + '?tour=twa5&step=10'

}],

}, {

//12

title: 'You\'re getting pretty reliable yourself',

description: new gt.WikitextDescription('NEW TOOL EARNED: Sourcer Badge

File:TWA badge 9.png

'),

overlay: false,

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/5/RS' ) + '?tour=twa5&step=11'

} , {

name: 'Reply to GaiaGirl*',

onclick: function() { sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/9template2' , mw.util.getUrl( 'Wikipedia:TWA/5/Start' ) + '?tour=twa5&step=13', false, false); }

} ],

allowAutomaticOkay: false

}, {

//13

title: 'What now?',

description: new gt.WikitextDescription('

link=
Now that we have the source, what do we do with it?

First, let\'s leave a note on the talk page telling GaiaGirl86 about our thoughts.

Hmm... what to say?

'),

overlay: false,

closeOnClickOutside: false,

back: true,

buttons: [ {

name: 'Reply to GaiaGirl',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/5/Reply' ) + '?tour=twa5&step=14'

} ],

allowAutomaticOkay: false

} , {

//14

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: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/5/Start' ) + '?tour=twa5&step=13'

}],

}, {

//15

title: 'Reply to GaiaGirl',

description: new gt.WikitextDescription('
Click REPLY so you can leave your reply to GaiaGirl

'),

attachTo: '.ext-discussiontools-init-replylink-buttons',

position: 'top',

overlay: false,

closeOnClickOutside: false,

allowAutomaticOkay: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Wikipedia:TWA/5/Reply' ) + '?tour=twa5&step=14'

}],

hooks: "userjs.replyOpen",

onShow: function() {

$(".ext-discussiontools-init-replylink-reply").click(function(){

setTimeout(function(){

mw.hook("userjs.replyOpen").fire();

}, 200);

});

},

skip:function() {

return $(".ext-discussiontools-ui-replyWidget-bodyWrapper").length > 0;

}

}, {

//16

title: 'Copy your message into the textbox',

description: new gt.WikitextDescription('

link=
Nature Reviews Earth and Environment looks like a solid and relevant source with a good reputation. I think we can rely on it more than the others for this article. Nice research!
'),

overlay: false,

attachTo: '.ext-discussiontools-ui-replyWidget-bodyWrapper',

position: 'top',

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Special:MyTalk/TWA/Earth' ) + '?tour=twa5&step=15'

} , {

name: 'Copied',

action: 'next',

} ],

} , {

//17

title: 'Publish',

description: new gt.WikitextDescription('
Click REPLY to make it live.

'),

attachTo: '.ext-discussiontools-ui-replyWidget-actions',

position: 'top',

autoFocus: 'yes',

overlay: false,

closeOnClickOutside: false,

allowAutomaticOkay: false,

back: true,

skip: gt.isPostEdit

} , {

//18

title: 'Rock on!',

description: new gt.WikitextDescription('NEW TOOL EARNED: Advisor Badge

File:TWA badge 10.png


I took a look at Earth\'s talk page and GaiaGirl added some awesome content. Check it out!'),

overlay: false,

closeOnClickOutside: false,

buttons: [ {

name: '',

action: 'externalLink',

url: mw.util.getUrl( 'Special:MyTalk/TWA/Earth' ) + '?tour=twa5&step=15'

} , {

name: 'Journey deeper*',

onclick: function() { sendTalkMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/10template2' , mw.util.getUrl( 'Wikipedia:TWA/5/End' ) + '?tour=twa5&step=19', false, false); }

} ],

allowAutomaticOkay: false

} , {

//19

title: 'Mission 5 complete!',

description: new gt.WikitextDescription('
File:Northern mountains (short).ogg
Journey on to mission 6...'),

overlay: false,

closeOnClickOutside: false,

buttons: [ {

name: 'Congrats me!',

action: 'end'

} ],

allowAutomaticOkay: false

}];

var stepBuilders = [];

function makeSkip(target, query) {

return function(event) {

if (query(event)) {

return target;

}

};

}

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;

}

for (var j = 0; j < steps.length; j++) {

if (steps[j].hooks) {

stepBuilders[j].listenForMwHooks(steps[j].hooks);

}

if (steps[j].skip) {

stepBuilders[j].transition(makeSkip(stepBuilders[j+1], steps[j].skip));

}

if (j > 0) {

if (steps[j].back) {

stepBuilders[j].back(stepBuilders[j-1]);

}

}

if (j < steps.length - 1) {

stepBuilders[j].next(stepBuilders[j+1]);

}

}

} (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;